use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class AcceleratedScaleTest method main.
public static void main(String[] args) {
Frame f = new Frame();
f.pack();
GraphicsConfiguration gc = f.getGraphicsConfiguration();
if (gc.getColorModel().getPixelSize() < 16) {
System.out.printf("Bit depth: %d . Test considered passed.", gc.getColorModel().getPixelSize());
f.dispose();
return;
}
BufferedImage bi = new BufferedImage(IMAGE_SIZE / 4, IMAGE_SIZE / 4, BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) bi.getGraphics();
g.setColor(Color.red);
g.fillRect(0, 0, bi.getWidth(), bi.getHeight());
BufferedImage snapshot;
do {
initVI(gc);
g = (Graphics2D) destVI.getGraphics();
// "accelerate" BufferedImage
for (int i = 0; i < 5; i++) {
g.drawImage(bi, 0, 0, null);
}
g.setColor(Color.white);
g.fillRect(0, 0, destVI.getWidth(), destVI.getHeight());
// this will force the use of Transform primitive instead of
// Scale (the latter doesn't do bilinear filtering required by
// VALUE_RENDER_QUALITY, which triggers the bug in D3D pipeline
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g.drawImage(bi, 0, 0, destVI.getWidth(), destVI.getHeight(), null);
g.fillRect(0, 0, destVI.getWidth(), destVI.getHeight());
g.drawImage(bi, 0, 0, destVI.getWidth(), destVI.getHeight(), null);
snapshot = destVI.getSnapshot();
} while (destVI.contentsLost());
f.dispose();
int whitePixel = Color.white.getRGB();
for (int y = 0; y < snapshot.getHeight(); y++) {
for (int x = 0; x < snapshot.getWidth(); x++) {
if (snapshot.getRGB(x, y) == whitePixel) {
System.out.printf("Found untouched pixel at %dx%d\n", x, y);
System.out.println("Dumping the dest. image to " + "AcceleratedScaleTest_dst.png");
try {
ImageIO.write(snapshot, "png", new File("AcceleratedScaleTest_dst.png"));
} catch (IOException ex) {
ex.printStackTrace();
}
throw new RuntimeException("Test failed.");
}
}
}
System.out.println("Test Passed.");
}
use of java.awt.GraphicsConfiguration 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.");
}
use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class IncorrectSourceOffset method main.
public static void main(final String[] args) throws IOException {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
VolatileImage vi = gc.createCompatibleVolatileImage(511, 255);
BufferedImage bi = new BufferedImage(511, 255, BufferedImage.TYPE_INT_ARGB);
BufferedImage gold = new BufferedImage(511, 255, BufferedImage.TYPE_INT_ARGB);
fill(gold);
while (true) {
vi.validate(gc);
fill(vi);
if (vi.validate(gc) != VolatileImage.IMAGE_OK) {
try {
Thread.sleep(100);
} catch (final InterruptedException ignored) {
}
continue;
}
Graphics2D big = bi.createGraphics();
big.drawImage(vi, 7, 11, 127, 111, 7, 11, 127, 111, null);
big.dispose();
if (vi.contentsLost()) {
try {
Thread.sleep(100);
} catch (final InterruptedException ignored) {
}
continue;
}
break;
}
for (int x = 7; x < 127; ++x) {
for (int y = 11; y < 111; ++y) {
if (gold.getRGB(x, y) != bi.getRGB(x, y)) {
ImageIO.write(gold, "png", new File("gold.png"));
ImageIO.write(bi, "png", new File("bi.png"));
throw new RuntimeException("Test failed.");
}
}
}
}
use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class bug8071705 method checkConfigs.
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {
GraphicsDevice correctDevice = null;
if (devices.length < 2) {
return correctDevice;
}
Toolkit toolkit = Toolkit.getDefaultToolkit();
Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
int halfScreen = screenBounds.height / 2;
for (int i = 0; i < devices.length; i++) {
if (devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
GraphicsConfiguration conf = devices[i].getDefaultConfiguration();
Rectangle bounds = conf.getBounds();
if (bounds.y >= halfScreen) {
// found
correctDevice = devices[i];
break;
}
}
}
return correctDevice;
}
use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class bug8071705 method setLocation.
private static Rectangle setLocation(JFrame frame, GraphicsDevice device) {
GraphicsConfiguration conf = device.getDefaultConfiguration();
Rectangle bounds = conf.getBounds();
// put just below half screen
int x = bounds.x + bounds.width / 2;
int y = bounds.y + bounds.height / 2;
frame.setLocation(x, y);
return bounds;
}
Aggregations