![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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? |
|
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? |
#3
| |||
| |||
|
|
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. |
|
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. |
#4
| |||
| |||
|
|
Hmm, why is this? |
|
*sigh* I feared this might be the case. Ah well, thanks for the answer. |
|
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. |
#5
| |||
| |||
|
|
Hmm, why is this? Because the alpha blending is done by the device driver. Alpha blending is not supported for indexed images. |
|
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 |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |