Print at Dec 16, 2025, 3:31:19 AM

Posted by Puybaret at Nov 2, 2010, 5:40:22 PM
Re: Getting a PNG Photo Image
I just tried your code and it worked as expected (under Mac OS X). You don't need to create the BufferedImage instance, and you can call create getOffScreenImage directly, as shown in this test case:

public class Export3DViewToPNG {
public static void main(String [] args) throws RecorderException, IOException {
Home home = new HomeFileRecorder().readHome("test.sh3d");
HomeComponent3D homeComponent3D = new HomeComponent3D(home);
BufferedImage image = homeComponent3D.getOffScreenImage(400, 400);
File file = new File("tmp.png");
ImageIO.write(image, "png", file);
}
}

Under which system do you work?
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator