當前位置: 首頁>>代碼示例>>Java>>正文


Java GraphicsConfiguration.createCompatibleVolatileImage方法代碼示例

本文整理匯總了Java中java.awt.GraphicsConfiguration.createCompatibleVolatileImage方法的典型用法代碼示例。如果您正苦於以下問題:Java GraphicsConfiguration.createCompatibleVolatileImage方法的具體用法?Java GraphicsConfiguration.createCompatibleVolatileImage怎麽用?Java GraphicsConfiguration.createCompatibleVolatileImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.GraphicsConfiguration的用法示例。


在下文中一共展示了GraphicsConfiguration.createCompatibleVolatileImage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBackBuffer

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
@Override
protected Image getBackBuffer(boolean clear) {
    int w = window.getWidth();
    int h = window.getHeight();
    GraphicsConfiguration gc = peer.getGraphicsConfiguration();

    if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
        viBB.validate(gc) == IMAGE_INCOMPATIBLE)
    {
        flush();

        if (gc instanceof AccelGraphicsConfig) {
            AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
            viBB = agc.createCompatibleVolatileImage(w, h,
                                                     TRANSLUCENT,
                                                     RT_PLAIN);
        }
        if (viBB == null) {
            viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
        }
        viBB.validate(gc);
    }

    return clear ? clearImage(viBB) : viBB;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:26,代碼來源:TranslucentWindowPainter.java

示例2: initImages

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
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);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:NonOpaqueDestLCDAATest.java

示例3: main

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
public static void main(String[] args) {

        boolean iaeThrown = false;
        GraphicsEnvironment ge = GraphicsEnvironment.
                                      getLocalGraphicsEnvironment();
        GraphicsConfiguration gc = ge.getDefaultScreenDevice().
                                           getDefaultConfiguration();
        try {
            VolatileImage volatileImage = gc.createCompatibleVolatileImage(0, 0);
        } catch (IllegalArgumentException iae) {
            iaeThrown = true;
        }
        if (!iaeThrown) {
            throw new RuntimeException ("IllegalArgumentException not thrown " +
                                        "for createCompatibleVolatileImage(0,0)");
        }
    }
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:18,代碼來源:VolatileImageBug.java

示例4: initVI

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
private static void initVI(GraphicsConfiguration gc) {
    int res;
    if (destVI == null) {
        res = VolatileImage.IMAGE_INCOMPATIBLE;
    } else {
        res = destVI.validate(gc);
    }
    if (res == VolatileImage.IMAGE_INCOMPATIBLE) {
        if (destVI != null) destVI.flush();
        destVI = gc.createCompatibleVolatileImage(IMAGE_SIZE, IMAGE_SIZE);
        destVI.validate(gc);
        res = VolatileImage.IMAGE_RESTORED;
    }
    if (res == VolatileImage.IMAGE_RESTORED) {
        Graphics vig = destVI.getGraphics();
        vig.setColor(Color.red);
        vig.fillRect(0, 0, destVI.getWidth(), destVI.getHeight());
        vig.dispose();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:AcceleratedScaleTest.java

示例5: main

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
public static void main(final String[] args) {
    GraphicsConfiguration gc =
            GraphicsEnvironment.getLocalGraphicsEnvironment()
                    .getDefaultScreenDevice().getDefaultConfiguration();
    VolatileImage vi = gc.createCompatibleVolatileImage(S, S, BITMASK);
    BufferedImage ci = gc.createCompatibleImage(S, S, BITMASK);

    int attempt = 0;
    do {
        if (++attempt > 10) {
            throw new RuntimeException("Too many attempts: " + attempt);
        }
        vi.validate(gc);
        test(vi, ci, gc);
    } while (vi.contentsLost());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:BitmaskVolatileImage.java

示例6: runTest

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
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());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:33,代碼來源:InfiniteValidationLoopTest.java

示例7: test

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
private void test() {
    GraphicsConfiguration gc =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice().getDefaultConfiguration();
    if (gc.getColorModel().getPixelSize() < 16) {
        System.out.println("<16 bit depth detected, test passed");
        return;
    }

    VolatileImage vi =
        gc.createCompatibleVolatileImage(250, 4*120, Transparency.OPAQUE);
    BufferedImage res;
    do {
        vi.validate(gc);
        Graphics2D g2d = vi.createGraphics();
        g2d.setColor(Color.white);
        g2d.fillRect(0, 0, vi.getWidth(), vi.getHeight());

        render(g2d);

        res = vi.getSnapshot();
    } while (vi.contentsLost());

    for (int y = 0; y < bi.getHeight(); y++) {
        for (int x = 0; x < bi.getWidth(); x++) {
            if (res.getRGB(x, y) == Color.black.getRGB()) {
                System.err.printf("Test FAILED: found black at %d,%d\n",
                                  x, y);
                try {
                    String fileName = "AccelPaintsTest.png";
                    ImageIO.write(res, "png", new File(fileName));
                    System.err.println("Dumped rendering to " + fileName);
                } catch (IOException e) {}
                throw new RuntimeException("Test FAILED: found black");
            }
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:39,代碼來源:AccelPaintsTest.java

示例8: createImage

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
@Override
protected Image createImage(Component c, int w, int h, GraphicsConfiguration config) {
	if (config == null) {
		return new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR);
	}
	return config.createCompatibleVolatileImage(w, h);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:8,代碼來源:MenuSeparatorPainter.java

示例9: getVolatileImage

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
private static VolatileImage getVolatileImage(GraphicsConfiguration gc,
                                              int size) {
    VolatileImage vi = gc.createCompatibleVolatileImage(size, size);
    Graphics2D g2d = vi.createGraphics();
    g2d.setColor(Color.GREEN);
    g2d.fillRect(0, 0, size, size);
    return vi;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:IncorrectClipSurface2SW.java

示例10: test

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
private static void test(final BufferedImage bi) throws IOException {
    GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    GraphicsConfiguration gc = ge.getDefaultScreenDevice()
                                 .getDefaultConfiguration();
    VolatileImage vi = gc.createCompatibleVolatileImage(500, 200,
                                                        TRANSLUCENT);
    BufferedImage gold = gc.createCompatibleImage(500, 200, TRANSLUCENT);
    // draw to compatible Image
    draw(bi, gold);
    // draw to volatile image
    int attempt = 0;
    BufferedImage snapshot;
    while (true) {
        if (++attempt > 10) {
            throw new RuntimeException("Too many attempts: " + attempt);
        }
        vi.validate(gc);
        if (vi.validate(gc) != VolatileImage.IMAGE_OK) {
            continue;
        }
        draw(bi, vi);
        snapshot = vi.getSnapshot();
        if (vi.contentsLost()) {
            continue;
        }
        break;
    }
    // validate images
    for (int x = 0; x < gold.getWidth(); ++x) {
        for (int y = 0; y < gold.getHeight(); ++y) {
            if (gold.getRGB(x, y) != snapshot.getRGB(x, y)) {
                ImageIO.write(gold, "png", new File("gold.png"));
                ImageIO.write(snapshot, "png", new File("bi.png"));
                throw new RuntimeException("Test failed.");
            }
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:40,代碼來源:IncorrectUnmanagedImageRotatedClip.java

示例11: testVolatileImage

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
private static void testVolatileImage(GraphicsConfiguration cfg,
        boolean accelerated)
{
    VolatileImage dst = null;
    try {
        dst = cfg.createCompatibleVolatileImage(640, 480,
            new ImageCapabilities(accelerated));
    } catch (AWTException e) {
        System.out.println("Unable to create volatile image, skip the test.");
        return;
    }
    renderToVolatileImage(dst);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:CustomCompositeTest.java

示例12: main

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    GraphicsConfiguration gc = ge.getDefaultScreenDevice()
                                 .getDefaultConfiguration();
    VolatileImage vi = gc.createCompatibleVolatileImage(100, 100);

    Graphics2D g2d = vi.createGraphics();
    g2d.scale(2, 2);
    BufferedImage img = new BufferedImage(50, 50,
                                          BufferedImage.TYPE_INT_ARGB);

    g2d.drawImage(img, 10, 25, Color.blue, null);
    g2d.dispose();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:DrawCachedImageAndTransform.java

示例13: testGC

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
private static void testGC(GraphicsConfiguration gc) {
    if (!(gc instanceof AccelGraphicsConfig)) {
        System.out.println("Test passed: no hw accelerated configs found.");
        return;
    }
    System.out.println("AccelGraphicsConfig exists, testing.");
    AccelGraphicsConfig agc = (AccelGraphicsConfig) gc;
    printAGC(agc);

    testContext(agc);

    VolatileImage vi = gc.createCompatibleVolatileImage(10, 10);
    vi.validate(gc);
    if (vi instanceof DestSurfaceProvider) {
        System.out.println("Passed: VI is DestSurfaceProvider");
        Surface s = ((DestSurfaceProvider) vi).getDestSurface();
        if (s instanceof AccelSurface) {
            System.out.println("Passed: Obtained Accel Surface");
            printSurface((AccelSurface) s);
        }
        Graphics g = vi.getGraphics();
        if (g instanceof DestSurfaceProvider) {
            System.out.println("Passed: VI graphics is " +
                               "DestSurfaceProvider");
            printSurface(((DestSurfaceProvider) g).getDestSurface());
        }
    } else {
        System.out.println("VI is not DestSurfaceProvider");
    }
    testVICreation(agc, CAPS_RT_TEXTURE_ALPHA, TRANSLUCENT, RT_TEXTURE);
    testVICreation(agc, CAPS_RT_TEXTURE_OPAQUE, OPAQUE, RT_TEXTURE);
    testVICreation(agc, CAPS_RT_PLAIN_ALPHA, TRANSLUCENT, RT_PLAIN);
    testVICreation(agc, agc.getContextCapabilities().getCaps(), OPAQUE,
                   TEXTURE);
    testForNPEDuringCreation(agc);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:37,代碼來源:RSLAPITest.java

示例14: getVImage

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
static VolatileImage getVImage(GraphicsConfiguration gc,
                               int w, int h)
{
    VolatileImage image =
        gc.createCompatibleVolatileImage(w, h, Transparency.OPAQUE);
    image.validate(gc);
    initImage(gc, image);
    return image;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:SourceClippingBlitTest.java

示例15: makeImage

import java.awt.GraphicsConfiguration; //導入方法依賴的package包/類
public Image makeImage(TestEnvironment env, int w, int h) {
    Canvas c = env.getCanvas();
    GraphicsConfiguration gc = c.getGraphicsConfiguration();
    if (transparency == 0) {
        return gc.createCompatibleVolatileImage(w, h);
    } else {
        return gc.createCompatibleVolatileImage(w, h, transparency);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:ImageTests.java


注:本文中的java.awt.GraphicsConfiguration.createCompatibleVolatileImage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。