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 & HelpSyntax Questions › PNG transparency
Page Index Toggle Pages: 1
PNG transparency (Read 595 times)
PNG transparency
Oct 28th, 2009, 10:26am
 
I'm using saveFrame to save the frame as a PNG.

Is there a way to set a color as the transparency?

ex. i have a white background that i want transparent in the PNG.
Re: PNG transparency
Reply #1 - Oct 28th, 2009, 10:58am
 
My guess is that you could iterate over the PImage pixels[] array and set pixels that match the desired colour to be transparent.

Having said that you might want to check the reference for saveFrame, in particular the bit that says:

"All images saved from the main drawing window will be opaque. To save images without a background, use createGraphics()."
Re: PNG transparency
Reply #2 - Oct 28th, 2009, 12:59pm
 
Thanks!

Using Graphics class did the trick
Page Index Toggle Pages: 1