FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Suggestions
   Software Suggestions
(Moderator: fry)
   saveFrame()
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: saveFrame()  (Read 615 times)
aaron


saveFrame()
« on: Apr 5th, 2004, 8:43pm »

Can this function be made to support file types other than TIFF and Targa?  I would like to save frames as JPEGs or GIFs to keep file sizes down.
 
mKoser

WWW Email
Re: saveFrame()
« Reply #1 on: Apr 14th, 2004, 10:49am »

for now you can use the Martin/Koenie way of doing this:
 
http://processing.org/discourse/yabb/board_Tools_action_display__num_1066742994_start_15.html
 
(not sure if you asked for this, but here ya go!)
 
+ m
« Last Edit: Apr 14th, 2004, 10:49am by mKoser »  

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
TomC

WWW
Re: saveFrame()
« Reply #2 on: Apr 14th, 2004, 11:42am »

I have code to save to PNG which works without using Java 1.4 ImageIO classes.  It's not very well tested yet, but I think it works.  You should get reasonable lossless compression on computer generated graphics.
 
Put http://www.tom-carden.co.uk/p5/PngEncoder.java in your sketch's code folder, and use the following code in your sketch to save to PNG.
 
Code:

 
String savePath = ""; // use "sketchbook/default/YOUR_SKETCH_NAME/data/" to save and load from the same directory
 
void savePNG(BImage img, String filename) {
  PngEncoder encoder = new PngEncoder(img, true, 0, 9); // true means encode alpha, 0 means no filter, 9 means best compression
  byte[] toWrite = encoder.pngEncode();
  if (toWrite != null) {
    if (!filename.toLowerCase().endsWith(".png")) {
      filename += ".png";
    }
    saveBytes(savePath+filename, toWrite);
  }
}
 

 
The PngEncoder class is a cut-down version of the LGPL code here - http://catcode.com/pngencoder/
« Last Edit: Apr 14th, 2004, 11:45am by TomC »  
Markavian

Markavian+iTX WWW
Re: saveFrame()
« Reply #3 on: Apr 16th, 2004, 4:00pm »

So, will processing support these modes as 'default' in future versions? I can live with saving as TIFFs for the moment, not a problem.. but for future convinience?
 
fry


WWW
Re: saveFrame()
« Reply #4 on: Apr 16th, 2004, 5:45pm »

the plan is to support the fancier image i/o when it's available (java 1.4ish) through dynamic loading.. no estimate on when it's available tho..
 
Pages: 1 

« Previous topic | Next topic »