HighTechTalks DotNet Forums  

Animated GIF colour depth

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Animated GIF colour depth in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Chris Jones
 
Posts: n/a

Default Animated GIF colour depth - 12-08-2007 , 04:31 PM






I'm having a problem using C# to load image files. I'm writing an
application to do some palette processing with palettized (ie. 8-bit) image
files. With most files it works fine, and with standard GIF files it works
too. But when I try and load an animated GIF file it seems to convert the
frames to 32-bit colour.
My code is just this:

Bitmap bmp = new Bitmap("filename.gif");

After this when I go on to check the PixelFormat of the bitmap, I find that
if an animated GIF is loaded it has loaded it as a 32-bit image rather than
the 8-bit image that I'm expecting (the files are all 8-bit images).

How can I stop it doing this, and enable me to access the palette for each
frame of the animation?



Reply With Quote
  #2  
Old   
Michael Phillips, Jr.
 
Posts: n/a

Default Re: Animated GIF colour depth - 12-09-2007 , 12:12 PM






Quote:
After this when I go on to check the PixelFormat of the bitmap, I find
that
if an animated GIF is loaded it has loaded it as a 32-bit image rather
than
the 8-bit image that I'm expecting (the files are all 8-bit images).
You may be expecting an 8-bit image but the unpacking of this image to a
32-bit alpha pixel formatted image is by design.

Quote:
How can I stop it doing this, and enable me to access the palette for each
frame of the animation?
I do not believe this is possible unless you write your own .gif codec or
use the Microsoft unmanaged Windows Imaging Component.

The unmanaged WIC COM API allows you to access each frame with the palette
in it's native indexed pixel format.

"Chris Jones" <dosuser (AT) REMOVETHISbigfoot (DOT) com> wrote

Quote:
I'm having a problem using C# to load image files. I'm writing an
application to do some palette processing with palettized (ie. 8-bit)
image
files. With most files it works fine, and with standard GIF files it works
too. But when I try and load an animated GIF file it seems to convert the
frames to 32-bit colour.
My code is just this:

Bitmap bmp = new Bitmap("filename.gif");

After this when I go on to check the PixelFormat of the bitmap, I find
that
if an animated GIF is loaded it has loaded it as a 32-bit image rather
than
the 8-bit image that I'm expecting (the files are all 8-bit images).

How can I stop it doing this, and enable me to access the palette for each
frame of the animation?





Reply With Quote
  #3  
Old   
Chris Jones
 
Posts: n/a

Default Re: Animated GIF colour depth - 12-11-2007 , 12:50 PM



Quote:
You may be expecting an 8-bit image but the unpacking of this image to
a 32-bit alpha pixel formatted image is by design.
Hmm, why is this? The documentation doesn't mention anything about it (in
fact, the whole .NET Framework documentation is pretty useless, come to
think of it).

Quote:
I do not believe this is possible unless you write your own .gif codec
or use the Microsoft unmanaged Windows Imaging Component.

The unmanaged WIC COM API allows you to access each frame with the
palette in it's native indexed pixel format.
*sigh* I feared this might be the case. Ah well, thanks for the answer.




Reply With Quote
  #4  
Old   
Michael Phillips, Jr.
 
Posts: n/a

Default Re: Animated GIF colour depth - 12-11-2007 , 01:27 PM



Quote:
Hmm, why is this?
Because the alpha blending is done by the device driver.

Alpha blending is not supported for indexed images.

Quote:
*sigh* I feared this might be the case. Ah well, thanks for the answer.
It is very easy to use WIC. Check out the MSDN WIC forum.

I have provided example code to show how easy it is to bypass the .Net 3.0,
3.5. code and to use WIC with com interop
http://forums.microsoft.com/MSDN/Sho...=1874&SiteID=1



"Chris Jones" <dosuser (AT) REMOVETHISbigfoot (DOT) com> wrote

Quote:
You may be expecting an 8-bit image but the unpacking of this image to
a 32-bit alpha pixel formatted image is by design.

Hmm, why is this? The documentation doesn't mention anything about it (in
fact, the whole .NET Framework documentation is pretty useless, come to
think of it).

I do not believe this is possible unless you write your own .gif codec
or use the Microsoft unmanaged Windows Imaging Component.

The unmanaged WIC COM API allows you to access each frame with the
palette in it's native indexed pixel format.

*sigh* I feared this might be the case. Ah well, thanks for the answer.





Reply With Quote
  #5  
Old   
Chris Jones
 
Posts: n/a

Default Re: Animated GIF colour depth - 12-11-2007 , 02:06 PM



Quote:
Hmm, why is this?

Because the alpha blending is done by the device driver.

Alpha blending is not supported for indexed images.
But I don't want alpha blending, why is it forcing this on me?!?

Quote:
It is very easy to use WIC. Check out the MSDN WIC forum.

I have provided example code to show how easy it is to bypass the .Net
3.0,
3.5. code and to use WIC with com interop
http://forums.microsoft.com/MSDN/Sho...=1874&SiteID=1
Thanks, I'll take a look.




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.