Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 4
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 4435 times and has 3 replies Next Thread
javivf
Newbie
Member's Avatar


Joined: Mar 21, 2010
Post Count: 6
Status: Offline
Reply to this Post  Reply with Quote 
Getting a PNG Photo Image

Hi there,

I'm trying to save a png image with this code but not works :


HomeComponent3D homeComponent3D = new HomeComponent3D(getHome());
int imageWidth = 400;
int imageHeight = 400;
BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
image = homeComponent3D.getOffScreenImage(imageWidth, imageHeight);
File file = new File("tmp.png");
ImageIO.write(image, "png", file);


Anybody can tell me what i'm doing wrong?

Thanks.
[Nov 2, 2010, 3:51:07 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9426
Status: Offline
Reply to this Post  Reply with Quote 
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
----------------------------------------
[Edit 1 times, last edit by Puybaret at Nov 2, 2010, 5:41:16 PM]
[Nov 2, 2010, 5:40:22 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9426
Status: Offline
Reply to this Post  Reply with Quote 
Re: Getting a PNG Photo Image

I checked under Windows and Linux and it worked too.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator
[Nov 2, 2010, 5:53:44 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
javivf
Newbie
Member's Avatar


Joined: Mar 21, 2010
Post Count: 6
Status: Offline
Reply to this Post  Reply with Quote 
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


True, it works fine. It was a permissions problem with windows vista. Thanks for tip, i'm just a java newbie. I hope this changes in the future :)
[Nov 2, 2010, 10:09:42 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

  Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads  
© Copyright 2024 Space Mushrooms - All rights reserved