Search in sources :

Example 51 with VolatileImage

use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.

the class StrikeDisposalCrashTest method renderText.

private static void renderText(Frame frame, Font f1) {
    VolatileImage vi = frame.createVolatileImage(256, 32);
    vi.validate(frame.getGraphicsConfiguration());
    Graphics2D g = vi.createGraphics();
    g.setFont(f1);
    g.drawString(text, 0, vi.getHeight() / 2);
    g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g.drawString(text, 0, vi.getHeight() / 2);
    g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
    g.drawString(text, 0, vi.getHeight() / 2);
    Toolkit.getDefaultToolkit().sync();
}
Also used : VolatileImage(java.awt.image.VolatileImage) Graphics2D(java.awt.Graphics2D)

Example 52 with VolatileImage

use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.

the class MutableColorTest method main.

public static void main(String[] args) {
    GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    bmImage = gc.createCompatibleImage(64, 64, Transparency.BITMASK);
    argbImage = gc.createCompatibleImage(64, 64, Transparency.TRANSLUCENT);
    if (gc.getColorModel().getPixelSize() > 8) {
        VolatileImage vi = gc.createCompatibleVolatileImage(64, 64, Transparency.OPAQUE);
        do {
            if (vi.validate(gc) == VolatileImage.IMAGE_INCOMPATIBLE) {
                vi = gc.createCompatibleVolatileImage(64, 64, Transparency.OPAQUE);
                vi.validate(gc);
            }
            int color = testImage(vi, false, false);
            testResult("vi_noclip_notx", vi.getSnapshot(), color);
            color = testImage(vi, true, true);
            testResult("vi_clip_tx", vi.getSnapshot(), color);
            color = testImage(vi, true, false);
            testResult("vi_clip_notx", vi.getSnapshot(), color);
            color = testImage(vi, false, true);
            testResult("vi_noclip_tx", vi.getSnapshot(), color);
        } while (vi.contentsLost());
    }
    BufferedImage bi = new BufferedImage(64, 64, BufferedImage.TYPE_INT_RGB);
    int color = testImage(bi, false, false);
    testResult("bi_noclip_notx", bi, color);
    color = testImage(bi, true, true);
    testResult("bi_clip_tx", bi, color);
    color = testImage(bi, true, false);
    testResult("bi_clip_notx", bi, color);
    color = testImage(bi, false, true);
    testResult("bi_noclip_tx", bi, color);
    System.err.println("Test passed.");
}
Also used : VolatileImage(java.awt.image.VolatileImage) BufferedImage(java.awt.image.BufferedImage) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Aggregations

VolatileImage (java.awt.image.VolatileImage)52 GraphicsConfiguration (java.awt.GraphicsConfiguration)30 BufferedImage (java.awt.image.BufferedImage)28 Graphics2D (java.awt.Graphics2D)24 GraphicsEnvironment (java.awt.GraphicsEnvironment)21 Graphics (java.awt.Graphics)6 AffineTransform (java.awt.geom.AffineTransform)6 Rectangle (java.awt.Rectangle)5 File (java.io.File)5 GraphicsDevice (java.awt.GraphicsDevice)3 Shape (java.awt.Shape)3 IOException (java.io.IOException)3 DestSurfaceProvider (sun.java2d.DestSurfaceProvider)3 Surface (sun.java2d.Surface)3 AWTException (java.awt.AWTException)2 Font (java.awt.Font)2 GradientPaint (java.awt.GradientPaint)2 Image (java.awt.Image)2 ImageCapabilities (java.awt.ImageCapabilities)2 Point (java.awt.Point)2