Search in sources :

Example 41 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.

the class OpaqueImageToSurfaceBlitTest method main.

public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    VolatileImage vi = gc.createCompatibleVolatileImage(16, 16);
    vi.validate(gc);
    BufferedImage bi = new BufferedImage(2, 2, BufferedImage.TYPE_INT_RGB);
    int[] data = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData();
    data[0] = 0x0000007f;
    data[1] = 0x0000007f;
    data[2] = 0xff00007f;
    data[3] = 0xff00007f;
    Graphics2D g = vi.createGraphics();
    g.setComposite(AlphaComposite.SrcOver.derive(0.999f));
    g.drawImage(bi, 0, 0, null);
    bi = vi.getSnapshot();
    if (bi.getRGB(0, 0) != bi.getRGB(1, 1)) {
        throw new RuntimeException("Test FAILED: color at 0x0 =" + Integer.toHexString(bi.getRGB(0, 0)) + " differs from 1x1 =" + Integer.toHexString(bi.getRGB(1, 1)));
    }
    System.out.println("Test PASSED.");
}
Also used : GraphicsDevice(java.awt.GraphicsDevice) VolatileImage(java.awt.image.VolatileImage) DataBufferInt(java.awt.image.DataBufferInt) GraphicsEnvironment(java.awt.GraphicsEnvironment) BufferedImage(java.awt.image.BufferedImage) GraphicsConfiguration(java.awt.GraphicsConfiguration) Graphics2D(java.awt.Graphics2D)

Example 42 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.

the class InfiniteValidationLoopTest method runTest.

private void runTest(Graphics g) {
    int status = IMAGE_OK;
    int count1 = 0;
    do {
        GraphicsConfiguration gc = getGraphicsConfiguration();
        int count2 = 0;
        while (vi == null || (status = vi.validate(gc)) != IMAGE_OK) {
            if (++count2 > LOOP_THRESHOLD) {
                System.err.println("Infinite loop detected: count2=" + count2);
                failed = true;
                return;
            }
            if (vi == null || status == IMAGE_INCOMPATIBLE) {
                if (vi != null) {
                    vi.flush();
                    vi = null;
                }
                vi = gc.createCompatibleVolatileImage(100, 100);
                continue;
            }
            if (status == IMAGE_RESTORED) {
                Graphics gg = vi.getGraphics();
                gg.setColor(Color.green);
                gg.fillRect(0, 0, vi.getWidth(), vi.getHeight());
                break;
            }
        }
        g.drawImage(vi, getInsets().left, getInsets().top, null);
        if (++count1 > LOOP_THRESHOLD) {
            System.err.println("Infinite loop detected: count1=" + count1);
            failed = true;
            return;
        }
    } while (vi.contentsLost());
}
Also used : Graphics(java.awt.Graphics) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 43 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.

the class NonOpaqueDestLCDAATest method initImages.

private void initImages(int w, int h) {
    if (images == null) {
        images = new Image[6];
        GraphicsConfiguration gc = getGraphicsConfiguration();
        for (int i = OPAQUE; i <= TRANSLUCENT; i++) {
            VolatileImage vi = gc.createCompatibleVolatileImage(w, h / images.length, i);
            images[i - 1] = vi;
            vi.validate(gc);
            String s = "LCD AA Text rendered to " + tr[i - 1] + " HW destination";
            render(vi, i, s);
            s = "LCD AA Text rendered to " + tr[i - 1] + " SW destination";
            images[i - 1 + 3] = gc.createCompatibleImage(w, h / images.length, i);
            render(images[i - 1 + 3], i, s);
        }
    }
}
Also used : VolatileImage(java.awt.image.VolatileImage) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 44 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.

the class TransformedPaintTest method runTest.

private void runTest() {
    GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    if (gc.getColorModel().getPixelSize() < 16) {
        System.out.println("8-bit desktop depth found, test passed");
        return;
    }
    VolatileImage vi = gc.createCompatibleVolatileImage(R_WIDTH, R_HEIGHT);
    BufferedImage bi = null;
    do {
        vi.validate(gc);
        Graphics2D g = vi.createGraphics();
        render(g, vi.getWidth(), vi.getHeight());
        bi = vi.getSnapshot();
    } while (vi.contentsLost());
    checkBI(bi);
    System.out.println("Test PASSED.");
}
Also used : VolatileImage(java.awt.image.VolatileImage) BufferedImage(java.awt.image.BufferedImage) GraphicsConfiguration(java.awt.GraphicsConfiguration) Graphics2D(java.awt.Graphics2D)

Example 45 with GraphicsConfiguration

use of java.awt.GraphicsConfiguration in project vft-capture by videofirst.

the class DefaultInfoService method initConfigInfo.

private ConfigInfo initConfigInfo() {
    GraphicsConfiguration graphicsConfiguration = getGraphicsConfiguration();
    Rectangle rect = graphicsConfiguration.getBounds();
    ConfigInfo systemInfo = ConfigInfo.builder().started(LocalDateTime.now()).categories(vftConfig.getCategories()).storage(vftConfig.getStorage()).upload(vftConfig.getUpload()).display(DisplayInfo.builder().x(rect.x).y(rect.y).width(rect.width).height(rect.height).build()).environment(getEnvironmentFromJavaSystemProps()).build();
    return systemInfo;
}
Also used : Rectangle(java.awt.Rectangle) ConfigInfo(co.videofirst.vft.capture.model.info.ConfigInfo) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Aggregations

GraphicsConfiguration (java.awt.GraphicsConfiguration)136 GraphicsEnvironment (java.awt.GraphicsEnvironment)55 BufferedImage (java.awt.image.BufferedImage)46 Rectangle (java.awt.Rectangle)44 GraphicsDevice (java.awt.GraphicsDevice)38 Graphics2D (java.awt.Graphics2D)34 VolatileImage (java.awt.image.VolatileImage)31 Point (java.awt.Point)30 Dimension (java.awt.Dimension)21 Insets (java.awt.Insets)17 File (java.io.File)16 Graphics (java.awt.Graphics)13 IOException (java.io.IOException)13 Frame (java.awt.Frame)11 JFrame (javax.swing.JFrame)8 HeadlessException (java.awt.HeadlessException)7 Window (java.awt.Window)7 ImageIcon (javax.swing.ImageIcon)7 Color (java.awt.Color)6 AffineTransform (java.awt.geom.AffineTransform)6