[OpenJDK 2D-Dev] 6603887: Where are transparent areas filled with bgColor?
Clemens Eisserer
linuxhippy at gmail.com
Fri Sep 28 17:26:12 UTC 2007
Hi Dimitri,
I hope the test fits your/the needs, I was not able to produce an
image that triggers the problem so I simply used the graybox_error.gif
- it does not contain black (which the uninitialized areas are
painted) so I can simply check for that.
However it depends one some assumptions (VI is accalerated, blitting
two times leads to accaleration, ??).
lg Clemens
Thanks for open-sourcing java :)
The test:
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
public class BgRegTest
{
public static void main(String[] args)
{
JFrame testFrame = new JFrame();
testFrame.setVisible(true);
/*
* 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 = new BufferedImage(25, 25,
BufferedImage.TYPE_INT_RGB);
Image tImg = new
ImageIcon(testFrame.getClass().getResource("/graybox_error.gif")).getImage();
Graphics readBackG = readBackBImg.getGraphics();
do
{
if (vImg == null ||
vImg.validate(testFrame.getGraphicsConfiguration()) ==
VolatileImage.IMAGE_INCOMPATIBLE)
{
vImg = testFrame.createVolatileImage(25, 25);
}
Graphics viG = vImg.getGraphics();
viG.setColor(Color.white);
viG.fillRect(0, 0, 25, 25);
//Blit it at least two times to make sure it becomes accalerated -
This is an assumption and may break if implementation changes
viG.drawImage(tImg, 0, 0, Color.white, testFrame);
viG.drawImage(tImg, 0, 0, Color.white, testFrame);
readBackG.drawImage(vImg, 0, 0, testFrame);
} while (vImg.contentsLost());
//Check wether un-initialized pixels (black) exist
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.black.getRGB())
{
throw new RuntimeException("Background has changed!");
}
}
}
}
}
More information about the 2d-dev
mailing list