GoogleCodeArchive / piccolo2d

Automatically exported from code.google.com/p/piccolo2d
0 stars 0 forks source link

Calling toImage() on a composite node often returns an empty image. #137

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Calling toImage() on a composite node often returns an empty image.

The problem looks like it is due to using getWidth() and getHeight()
instead of getFullBounds().getWidth() and getFullBounds().getHeight() in
PNode.toImage

A debugger session indicates that getWidth() is zero for composite nodes,
therefore, dividing by getWidth() is problematic.

Original issue reported on code.google.com by reids%co...@gtempaccount.com on 14 Oct 2009 at 7:46

GoogleCodeExporter commented 9 years ago
Thank you for reporting this. I will resolve it shortly. (After putting in a 
unit
test to test it.)

Original comment by allain.lalonde on 14 Oct 2009 at 8:10

GoogleCodeExporter commented 9 years ago
Failing test is: 
public void testToImageUsesFullBoundsWhenConvertingImage() throws IOException {
        node.setBounds(0, 0, 50, 50);
        PNode child1 = new PNode();
        child1.setBounds(0, 0, 100, 50);
        child1.setPaint(Color.RED);
        node.addChild(child1);

        PNode child2 = new PNode();
        child2.setBounds(0, 0, 50, 100);
        child2.setPaint(Color.BLUE);
        node.addChild(child2);

        BufferedImage image = (BufferedImage) node.toImage();
        assertNotNull(image);
        assertEquals(100, image.getWidth());
        assertEquals(100, image.getHeight());        
        assertEquals(Color.RED.getRGB(), image.getRGB(99, 1));
        assertEquals(Color.BLUE.getRGB(), image.getRGB(1, 99));
    }

Original comment by allain.lalonde on 14 Oct 2009 at 8:36

GoogleCodeExporter commented 9 years ago
Fixed in r709

Original comment by allain.lalonde on 14 Oct 2009 at 8:41

GoogleCodeExporter commented 9 years ago

Original comment by heue...@gmail.com on 30 Oct 2009 at 2:58