Hi Clemens,
I'm having issues with reproducing the bug with
this or the original test.
I've tried on solaris and linux, it works fine in
both cases on all jdks I've tried. Weird.
In the debugger I see that the pixel passed to
X11SD_GetPixmapWithBg is 0x00ffffff, not 0xffffffff,
so pixel+1 != 0 .
What is your desktop bit depth? I've tried on 24bit
systems.
Thanks,
Dmitri
Clemens Eisserer wrote:
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!");
}
}
}
}
}