Java Code Examples for java.awt.image.BufferedImage#setAccelerationPriority()

The following examples show how to use java.awt.image.BufferedImage#setAccelerationPriority() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnmanagedDrawImagePerformance.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static BufferedImage makeUnmanagedBI(final int type) {
    final BufferedImage img = new BufferedImage(SIZE, SIZE, type);
    final DataBuffer db = img.getRaster().getDataBuffer();
    if (db instanceof DataBufferInt) {
        ((DataBufferInt) db).getData();
    } else if (db instanceof DataBufferShort) {
        ((DataBufferShort) db).getData();
    } else if (db instanceof DataBufferByte) {
        ((DataBufferByte) db).getData();
    } else {
        try {
            img.setAccelerationPriority(0.0f);
        } catch (final Throwable ignored) {
        }
    }
    return img;
}
 
Example 2
Source File: IncorrectAlphaConversionBicubic.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static BufferedImage makeUnmanagedBI(GraphicsConfiguration gc,
                                             int type) {
    BufferedImage img = gc.createCompatibleImage(SIZE, SIZE, type);
    Graphics2D g2d = img.createGraphics();
    g2d.setColor(RGB);
    g2d.fillRect(0, 0, SIZE, SIZE);
    g2d.dispose();
    final DataBuffer db = img.getRaster().getDataBuffer();
    if (db instanceof DataBufferInt) {
        ((DataBufferInt) db).getData();
    } else if (db instanceof DataBufferShort) {
        ((DataBufferShort) db).getData();
    } else if (db instanceof DataBufferByte) {
        ((DataBufferByte) db).getData();
    } else {
        try {
            img.setAccelerationPriority(0.0f);
        } catch (final Throwable ignored) {
        }
    }
    return img;
}
 
Example 3
Source File: IncorrectAlphaConversionBicubic.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static BufferedImage makeUnmanagedBI(GraphicsConfiguration gc,
                                             int type) {
    BufferedImage img = gc.createCompatibleImage(SIZE, SIZE, type);
    Graphics2D g2d = img.createGraphics();
    g2d.setColor(RGB);
    g2d.fillRect(0, 0, SIZE, SIZE);
    g2d.dispose();
    final DataBuffer db = img.getRaster().getDataBuffer();
    if (db instanceof DataBufferInt) {
        ((DataBufferInt) db).getData();
    } else if (db instanceof DataBufferShort) {
        ((DataBufferShort) db).getData();
    } else if (db instanceof DataBufferByte) {
        ((DataBufferByte) db).getData();
    } else {
        try {
            img.setAccelerationPriority(0.0f);
        } catch (final Throwable ignored) {
        }
    }
    return img;
}
 
Example 4
Source File: ImageTests.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public Image makeImage(TestEnvironment env, int w, int h) {
    BufferedImage img = new BufferedImage(w, h, type);
    if (unmanaged) {
        DataBuffer db = img.getRaster().getDataBuffer();
        if (db instanceof DataBufferInt) {
            ((DataBufferInt)db).getData();
        } else if (db instanceof DataBufferShort) {
            ((DataBufferShort)db).getData();
        } else if (db instanceof DataBufferByte) {
            ((DataBufferByte)db).getData();
        } else {
            try {
                img.setAccelerationPriority(0.0f);
            } catch (Throwable e) {}
        }
    }
    return img;
}
 
Example 5
Source File: ImageTests.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public Image makeImage(TestEnvironment env, int w, int h) {
    BufferedImage img = new BufferedImage(w, h, type);
    if (unmanaged) {
        DataBuffer db = img.getRaster().getDataBuffer();
        if (db instanceof DataBufferInt) {
            ((DataBufferInt)db).getData();
        } else if (db instanceof DataBufferShort) {
            ((DataBufferShort)db).getData();
        } else if (db instanceof DataBufferByte) {
            ((DataBufferByte)db).getData();
        } else {
            try {
                img.setAccelerationPriority(0.0f);
            } catch (Throwable e) {}
        }
    }
    return img;
}
 
Example 6
Source File: ImageTests.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public Image makeImage(TestEnvironment env, int w, int h) {
    BufferedImage img = new BufferedImage(w, h, type);
    if (unmanaged) {
        DataBuffer db = img.getRaster().getDataBuffer();
        if (db instanceof DataBufferInt) {
            ((DataBufferInt)db).getData();
        } else if (db instanceof DataBufferShort) {
            ((DataBufferShort)db).getData();
        } else if (db instanceof DataBufferByte) {
            ((DataBufferByte)db).getData();
        } else {
            try {
                img.setAccelerationPriority(0.0f);
            } catch (Throwable e) {}
        }
    }
    return img;
}
 
Example 7
Source File: DrawImage.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a non-accelerated BufferedImage of the requested type with the
 * indicated subimage of the original image located at 0,0 in the new image.
 * If a bgColor is supplied, composite the original image over that color
 * with a SrcOver operation, otherwise make a SrcNoEa copy.
 * <p>
 * Returned BufferedImage is not accelerated for two reasons:
 * <ul>
 * <li> Types of the image and surface are predefined, because these types
 *      correspond to the TransformHelpers, which we know we have. And
 *      acceleration can change the type of the surface
 * <li> Image will be used only once and acceleration caching wouldn't help
 * </ul>
 */
BufferedImage makeBufferedImage(Image img, Color bgColor, int type,
                                int sx1, int sy1, int sx2, int sy2)
{
    final int width = sx2 - sx1;
    final int height = sy2 - sy1;
    final BufferedImage bimg = new BufferedImage(width, height, type);
    final SunGraphics2D g2d = (SunGraphics2D) bimg.createGraphics();
    g2d.setComposite(AlphaComposite.Src);
    bimg.setAccelerationPriority(0);
    if (bgColor != null) {
        g2d.setColor(bgColor);
        g2d.fillRect(0, 0, width, height);
        g2d.setComposite(AlphaComposite.SrcOver);
    }
    g2d.copyImage(img, 0, 0, sx1, sy1, width, height, null, null);
    g2d.dispose();
    return bimg;
}
 
Example 8
Source File: ImageTests.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Image makeImage(TestEnvironment env, int w, int h) {
    BufferedImage img = new BufferedImage(w, h, type);
    if (unmanaged) {
        DataBuffer db = img.getRaster().getDataBuffer();
        if (db instanceof DataBufferInt) {
            ((DataBufferInt)db).getData();
        } else if (db instanceof DataBufferShort) {
            ((DataBufferShort)db).getData();
        } else if (db instanceof DataBufferByte) {
            ((DataBufferByte)db).getData();
        } else {
            try {
                img.setAccelerationPriority(0.0f);
            } catch (Throwable e) {}
        }
    }
    return img;
}
 
Example 9
Source File: IncorrectUnmanagedImageSourceOffset.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static BufferedImage makeUnmanagedBI(final int type) {
    final BufferedImage bi = new BufferedImage(511, 255, type);
    final DataBuffer db = bi.getRaster().getDataBuffer();
    if (db instanceof DataBufferInt) {
        ((DataBufferInt) db).getData();
    } else if (db instanceof DataBufferShort) {
        ((DataBufferShort) db).getData();
    } else if (db instanceof DataBufferByte) {
        ((DataBufferByte) db).getData();
    } else {
        try {
            bi.setAccelerationPriority(0.0f);
        } catch (final Throwable ignored) {
        }
    }
    return bi;
}
 
Example 10
Source File: IncorrectClipXorModeSW2Surface.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static BufferedImage getBufferedImage(int sw) {
    final BufferedImage bi = new BufferedImage(sw, sw, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2d = bi.createGraphics();
    g2d.setColor(Color.RED);
    g2d.fillRect(0, 0, sw, sw);
    g2d.dispose();

    final DataBuffer db = bi.getRaster().getDataBuffer();
    if (db instanceof DataBufferInt) {
        ((DataBufferInt) db).getData();
    } else if (db instanceof DataBufferShort) {
        ((DataBufferShort) db).getData();
    } else if (db instanceof DataBufferByte) {
        ((DataBufferByte) db).getData();
    } else {
        try {
            bi.setAccelerationPriority(0.0f);
        } catch (final Throwable ignored) {
        }
    }
    return bi;
}
 
Example 11
Source File: UnmanagedDrawImagePerformance.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static BufferedImage makeUnmanagedBI(final int type) {
    final BufferedImage img = new BufferedImage(SIZE, SIZE, type);
    final DataBuffer db = img.getRaster().getDataBuffer();
    if (db instanceof DataBufferInt) {
        ((DataBufferInt) db).getData();
    } else if (db instanceof DataBufferShort) {
        ((DataBufferShort) db).getData();
    } else if (db instanceof DataBufferByte) {
        ((DataBufferByte) db).getData();
    } else {
        try {
            img.setAccelerationPriority(0.0f);
        } catch (final Throwable ignored) {
        }
    }
    return img;
}
 
Example 12
Source File: IncorrectAlphaConversionBicubic.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static BufferedImage makeUnmanagedBI(GraphicsConfiguration gc,
                                             int type) {
    BufferedImage img = gc.createCompatibleImage(SIZE, SIZE, type);
    Graphics2D g2d = img.createGraphics();
    g2d.setColor(RGB);
    g2d.fillRect(0, 0, SIZE, SIZE);
    g2d.dispose();
    final DataBuffer db = img.getRaster().getDataBuffer();
    if (db instanceof DataBufferInt) {
        ((DataBufferInt) db).getData();
    } else if (db instanceof DataBufferShort) {
        ((DataBufferShort) db).getData();
    } else if (db instanceof DataBufferByte) {
        ((DataBufferByte) db).getData();
    } else {
        try {
            img.setAccelerationPriority(0.0f);
        } catch (final Throwable ignored) {
        }
    }
    return img;
}
 
Example 13
Source File: IncorrectUnmanagedImageSourceOffset.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static BufferedImage makeUnmanagedBI(final int type) {
    final BufferedImage bi = new BufferedImage(511, 255, type);
    final DataBuffer db = bi.getRaster().getDataBuffer();
    if (db instanceof DataBufferInt) {
        ((DataBufferInt) db).getData();
    } else if (db instanceof DataBufferShort) {
        ((DataBufferShort) db).getData();
    } else if (db instanceof DataBufferByte) {
        ((DataBufferByte) db).getData();
    } else {
        try {
            bi.setAccelerationPriority(0.0f);
        } catch (final Throwable ignored) {
        }
    }
    return bi;
}
 
Example 14
Source File: SourceClippingBlitTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static Image getBufferedImage(GraphicsConfiguration gc,
                              int w, int h, int type, boolean acceleratable)
{
    BufferedImage image = new BufferedImage(w, h, type);
    if (!acceleratable) {
        image.setAccelerationPriority(0.0f);
    }
    initImage(gc, image);
    return image;
}
 
Example 15
Source File: ImageRepresentation.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the BufferedImage that will be used as the representation of
 * the pixel data.  Subclasses can override this method to return
 * platform specific subclasses of BufferedImage that may or may not be
 * accelerated.
 *
 * It is subclass' responsibility to propagate acceleration priority
 * to the newly created image.
 */
protected BufferedImage createImage(ColorModel cm,
                                    WritableRaster raster,
                                    boolean isRasterPremultiplied,
                                    Hashtable properties)
{
    BufferedImage bi =
        new BufferedImage(cm, raster, isRasterPremultiplied, null);
    bi.setAccelerationPriority(image.getAccelerationPriority());
    return bi;
}
 
Example 16
Source File: ImageRepresentation.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the BufferedImage that will be used as the representation of
 * the pixel data.  Subclasses can override this method to return
 * platform specific subclasses of BufferedImage that may or may not be
 * accelerated.
 *
 * It is subclass' responsibility to propagate acceleration priority
 * to the newly created image.
 */
protected BufferedImage createImage(ColorModel cm,
                                    WritableRaster raster,
                                    boolean isRasterPremultiplied,
                                    Hashtable properties)
{
    BufferedImage bi =
        new BufferedImage(cm, raster, isRasterPremultiplied, null);
    bi.setAccelerationPriority(image.getAccelerationPriority());
    return bi;
}
 
Example 17
Source File: ImageRepresentation.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the BufferedImage that will be used as the representation of
 * the pixel data.  Subclasses can override this method to return
 * platform specific subclasses of BufferedImage that may or may not be
 * accelerated.
 *
 * It is subclass' responsibility to propagate acceleration priority
 * to the newly created image.
 */
protected BufferedImage createImage(ColorModel cm,
                                    WritableRaster raster,
                                    boolean isRasterPremultiplied,
                                    Hashtable<?,?> properties)
{
    BufferedImage bi =
        new BufferedImage(cm, raster, isRasterPremultiplied, null);
    bi.setAccelerationPriority(image.getAccelerationPriority());
    return bi;
}
 
Example 18
Source File: ImageRepresentation.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the BufferedImage that will be used as the representation of
 * the pixel data.  Subclasses can override this method to return
 * platform specific subclasses of BufferedImage that may or may not be
 * accelerated.
 *
 * It is subclass' responsibility to propagate acceleration priority
 * to the newly created image.
 */
protected BufferedImage createImage(ColorModel cm,
                                    WritableRaster raster,
                                    boolean isRasterPremultiplied,
                                    Hashtable properties)
{
    BufferedImage bi =
        new BufferedImage(cm, raster, isRasterPremultiplied, null);
    bi.setAccelerationPriority(image.getAccelerationPriority());
    return bi;
}
 
Example 19
Source File: ImageRepresentation.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the BufferedImage that will be used as the representation of
 * the pixel data.  Subclasses can override this method to return
 * platform specific subclasses of BufferedImage that may or may not be
 * accelerated.
 *
 * It is subclass' responsibility to propagate acceleration priority
 * to the newly created image.
 */
protected BufferedImage createImage(ColorModel cm,
                                    WritableRaster raster,
                                    boolean isRasterPremultiplied,
                                    Hashtable properties)
{
    BufferedImage bi =
        new BufferedImage(cm, raster, isRasterPremultiplied, null);
    bi.setAccelerationPriority(image.getAccelerationPriority());
    return bi;
}
 
Example 20
Source File: SourceClippingBlitTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static Image getBufferedImage(GraphicsConfiguration gc,
                              int w, int h, int type, boolean acceleratable)
{
    BufferedImage image = new BufferedImage(w, h, type);
    if (!acceleratable) {
        image.setAccelerationPriority(0.0f);
    }
    initImage(gc, image);
    return image;
}