use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.
the class JPEGsNotAcceleratedTest method runTestOnImage.
public void runTestOnImage(String desc, BufferedImage bi, Rectangle srcROI) {
if (srcROI == null) {
srcROI = new Rectangle(0, 0, TEST_W, TEST_H);
}
VolatileImage testVI = accelerateImage(bi);
ImageCapabilities ic = bi.getCapabilities(f.getGraphicsConfiguration());
boolean accelerated = ic.isAccelerated();
System.err.println("Testing: " + desc + " -- bi.isAccelerated(): " + accelerated);
BufferedImage snapshot = testVI.getSnapshot();
if (showRes) {
showRes(desc, snapshot);
}
for (int y = 0; y < srcROI.height; y++) {
for (int x = 0; x < srcROI.width; x++) {
int destRGB = snapshot.getRGB(x, y);
if (destRGB != testRGB && destRGB != 0xfffe0000) {
failed = true;
System.err.printf("Test failed at %dx%d pixel=%x\n", x, y, snapshot.getRGB(x, y));
if (!showRes) {
showRes(desc, snapshot);
}
break;
}
}
}
}
use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.
the class JPEGsNotAcceleratedTest method accelerateImage.
public VolatileImage accelerateImage(BufferedImage bi) {
VolatileImage testVI = f.createVolatileImage(TEST_W, TEST_H);
do {
if (testVI.validate(f.getGraphicsConfiguration()) == VolatileImage.IMAGE_INCOMPATIBLE) {
testVI = f.createVolatileImage(TEST_W, TEST_H);
}
Graphics2D g = testVI.createGraphics();
g.setComposite(AlphaComposite.Src);
g.setColor(Color.green);
g.fillRect(0, 0, TEST_W, TEST_H);
g.drawImage(bi, 0, 0, null);
g.drawImage(bi, 0, 0, null);
g.drawImage(bi, 0, 0, null);
g.dispose();
} while (testVI.contentsLost());
return testVI;
}
use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.
the class DrawImageBgTest method main.
public static void main(String[] args) {
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
if (gc.getColorModel().getPixelSize() <= 8) {
System.out.println("8-bit color model, test considered passed");
return;
}
/*
* Set up images:
* 1.) VolatileImge for rendering to,
* 2.) BufferedImage for reading back the contents of the VI
* 3.) The image triggering the problem
*/
VolatileImage vImg = null;
BufferedImage readBackBImg;
// create a BITMASK ICM such that the transparent color is
// tr. black (and it's the first in the color map so a buffered image
// created with this ICM is transparent
byte[] r = { 0x00, (byte) 0xff };
byte[] g = { 0x00, (byte) 0xff };
byte[] b = { 0x00, (byte) 0xff };
IndexColorModel icm = new IndexColorModel(8, 2, r, g, b, 0);
WritableRaster wr = icm.createCompatibleWritableRaster(25, 25);
BufferedImage tImg = new BufferedImage(icm, wr, false, null);
do {
if (vImg == null || vImg.validate(gc) == VolatileImage.IMAGE_INCOMPATIBLE) {
vImg = gc.createCompatibleVolatileImage(tImg.getWidth(), tImg.getHeight());
}
Graphics viG = vImg.getGraphics();
viG.setColor(Color.red);
viG.fillRect(0, 0, vImg.getWidth(), vImg.getHeight());
viG.drawImage(tImg, 0, 0, Color.green, null);
viG.fillRect(0, 0, vImg.getWidth(), vImg.getHeight());
viG.drawImage(tImg, 0, 0, Color.white, null);
readBackBImg = vImg.getSnapshot();
} while (vImg.contentsLost());
for (int x = 0; x < readBackBImg.getWidth(); x++) {
for (int y = 0; y < readBackBImg.getHeight(); y++) {
int currPixel = readBackBImg.getRGB(x, y);
if (currPixel != Color.white.getRGB()) {
String fileName = "DrawImageBgTest.png";
try {
ImageIO.write(readBackBImg, "png", new File(fileName));
System.err.println("Dumped image to " + fileName);
} catch (IOException ex) {
}
throw new RuntimeException("Test Failed: found wrong color: 0x" + Integer.toHexString(currPixel));
}
}
}
System.out.println("Test Passed.");
}
use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.
the class bug7181438 method main.
public static void main(final String[] args) {
final BufferedImage bi = createBufferedImage();
final VolatileImage vi = createVolatileImage();
final Graphics s2dVi = vi.getGraphics();
//sw->texture->surface blit
s2dVi.drawImage(bi, 0, 0, null);
final BufferedImage results = vi.getSnapshot();
for (int i = 0; i < SIZE; ++i) {
for (int j = 0; j < SIZE; ++j) {
//Image should be opaque: (black color and alpha = 255)
if (results.getRGB(i, j) != 0xFF000000) {
throw new RuntimeException("Failed: Wrong alpha");
}
}
}
System.out.println("Passed");
}
use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.
the class DrawCachedImageAndTransform method main.
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();
}
Aggregations