java.awt.image.BufferedImage#setAccelerationPriority()源码实例Demo

下面列出了java.awt.image.BufferedImage#setAccelerationPriority() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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;
}
 
源代码2 项目: jdk8u-jdk   文件: UnmanagedDrawImagePerformance.java
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;
}
 
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;
}
 
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;
}
 
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;
}
 
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;
}
 
源代码7 项目: TencentKona-8   文件: ImageTests.java
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;
}
 
源代码8 项目: jdk8u-dev-jdk   文件: DrawImage.java
/**
 * 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;
}
 
源代码9 项目: openjdk-jdk8u   文件: ImageTests.java
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;
}
 
源代码10 项目: openjdk-jdk9   文件: ImageTests.java
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;
}
 
源代码11 项目: jdk8u60   文件: ImageTests.java
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;
}
 
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;
}
 
源代码13 项目: jdk8u60   文件: IncorrectAlphaConversionBicubic.java
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;
}
 
源代码14 项目: jdk8u-dev-jdk   文件: SourceClippingBlitTest.java
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;
}
 
源代码15 项目: jdk8u_jdk   文件: SourceClippingBlitTest.java
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;
}
 
源代码16 项目: jdk8u-jdk   文件: ImageRepresentation.java
/**
 * 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;
}
 
源代码17 项目: jdk8u-dev-jdk   文件: ImageRepresentation.java
/**
 * 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;
}
 
源代码18 项目: openjdk-jdk9   文件: ImageRepresentation.java
/**
 * 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;
}
 
源代码19 项目: openjdk-jdk8u-backup   文件: ImageRepresentation.java
/**
 * 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;
}
 
源代码20 项目: openjdk-jdk8u   文件: ImageRepresentation.java
/**
 * 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;
}