We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Saving a PGraphics2 as a TIFF
Page Index Toggle Pages: 1
Saving a PGraphics2 as a TIFF (Read 457 times)
Saving a PGraphics2 as a TIFF
Jul 19th, 2006, 3:46pm
 
Hi, I'm trying to save a PGraphics2 as a TIFF using the following code:


void saveImage(PGraphics2 i,String filename) {
BufferedImage img=new BufferedImage(i.width, i.height, BufferedImage.TYPE_INT_RGB);
i.loadPixels();
img.setRGB(0, 0, i.width, i.height, i.pixels, 0, i.width);
try {
  javax.imageio.ImageIO.write(img, "png", new File(savePath(filename)));
  println("saved "+filename);
}
catch(Exception e) {
  println("error while saving "+filename);
}
}

This code works fine with "png" but when I change it to "tiff", it results in a zero kb file. Is there any way to output a TIFF from a PGraphics2?

Edit, I tried replacing the contents of the function with:
i.save(savePath("oot.tif"));
But that gave me a 1.4MB document that I couldn't read in anything x.x
Re: Saving a PGraphics2 as a TIFF
Reply #1 - Aug 14th, 2006, 7:26am
 
Well I've never done it, but I did just read this post:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=os_libraries_tools;action=display;num=1153344411
Re: Saving a PGraphics2 as a TIFF
Reply #2 - Aug 14th, 2006, 11:32am
 
I thought Processing saved tiff files as a default. Have you tried copying the PGraphics2 to a PImage and calling save() from that? Can you read the file normally produced from saving the applet display (saveFrame();)?
Page Index Toggle Pages: 1