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.");
}
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());
}
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);
}
}
}
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.");
}
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;
}
Aggregations