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 › Export on Grayscale and not on RGB
Page Index Toggle Pages: 1
Export on Grayscale and not on RGB? (Read 567 times)
Export on Grayscale and not on RGB?
Jul 21st, 2007, 8:57pm
 
Hi all,

I want to export images/sketches from processing in GRAYSCALE(black and white only,8bit) colormode, not RGB.

(the reason is that im importing them realtime to matlab, so each of R,G,B are imported as different matrix-or better as an [X x Y x 3] matrix. I need one matrix made of BW colors , u see...)

Is there any chance to change Pro124 colormode into GRAYSCALE ?

best,
alekuh

Re: Export on Grayscale and not on RGB?
Reply #1 - Jul 21st, 2007, 9:43pm
 
you can do it with a hack..

Code:
// Copy everything from the screen
PImage img = get();
// Make it grayscale
img.filter(GRAY);
// Use undocumented image format (for fonts)
img.format = ALPHA;
// Save as targa format (only works w/ targa)
img.save("gray.tga");

The hack part is that ALPHA format images (where one channel determines transparency--this is used for fonts) are saved as 8-bit grayscale when saved in targa format.
Page Index Toggle Pages: 1