|
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.
|
|
|
|
TomC
|
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
|
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
|
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..
|
|
|
|
|