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 › How to read transparency/ alpha channel of gif
Page Index Toggle Pages: 1
How to read transparency/ alpha channel of gif (Read 708 times)
How to read transparency/ alpha channel of gif
Apr 22nd, 2009, 5:59am
 
Dear all,

I really hope this is a stupid question. I searched the boards, reference, but couldn't find the solution.

Code:

   logo_array[i] = loadImage("logo_"+nr+".gif");
   logo_array[i].loadPixels();

   totalpixels += logo_array[i].pixels.length;

   for (int pix = 0; pix < logo_array[i].pixels.length; pix++) {
int r = int(red(logo_array[i].pixels[pix]));
int g = int(green(logo_array[i].pixels[pix]));
int b = int(blue(logo_array[i].pixels[pix]));

rgbcount[r][g][b]++;
   }


I have a code running through the pixels of a gif image with transparency and stores pixels by their color. So far, so good. Problem is that I can't find a way to test for transparant pixels. At present, transparant pixels are simply stored as white. I don't know how or where Processing stores the alpha channel of the imported gif.

Please help.
Re: How to read transparency/ alpha channel of gif
Reply #1 - Apr 22nd, 2009, 6:20am
 
maybe you can read it with alpha?

http://processing.org/reference/alpha_.html
Re: How to read transparency/ alpha channel of gif
Reply #2 - Apr 24th, 2009, 1:25am
 
As i know, gif defines one color as transparent, this could be every color. not only white. Depends on the software you create it or you j ust define it yourself. Sometimes its a pink too...  So if you get a white back, thats maybe allready your color. Try to creat a gif with a different transparent color and check it...
Re: How to read transparency/ alpha channel of gif
Reply #3 - Apr 24th, 2009, 1:26am
 
I strongly believed that didn't work.. but it doed, it seems
Re: How to read transparency/ alpha channel of gif
Reply #4 - Apr 24th, 2009, 6:38am
 
Cedric wrote on Apr 24th, 2009, 1:25am:
As i know, gif defines one color as transparent
More exactly, one palette entry.
Quote:
Sometimes its a pink too...
Probably magenta... Smiley
Quote:
So if you get a white back, thats maybe allready your color.
Beware, nothing prevents from having, say a transparent white and an opaque one in the same file (two different palette entries).
Re: How to read transparency/ alpha channel of gif
Reply #5 - Apr 24th, 2009, 6:52am
 
PINK!  Cheesy
Page Index Toggle Pages: 1