Re: Change ColorPalette

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



See the GDI+ FAQ redarding transparent GIFS. This shows the technique.

In fact after a bitmap has been loaded with a certain palette the encoder
will ignore all new palettes and re-save with the original. The use of
lockbits and the copying of the existing GIF byte array data into the new
image permits the encoder to consider this as a fresh image so it will take
the new palette.

It's an annoyance of the IMO poorly written image encoder-decoder system.
Why they didn't do a pluggable system in there when it would have been so
simple to implement I'll never guess <sigh>

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.



"César Chalom" <cchvfp@xxxxxxxxxx> wrote in message
news:%23lCZSA$cGHA.2188@xxxxxxxxxxxxxxxxxxxxxxx
Hello,

Is it possible to change the colorpalette of a GIF image without using
Lockbits ?

I'm doing the following :

1 - load any bitmap
2 - save as GIF (MS GDI+ saves using its default half tone palette)
3 - load this just created image
4 - retrieve the colorpalette
5 - change an entry, setting its ALPHA to 0 (zero)
6 - SetColorPalette to the just modified one
7 - Call Getpalette again, and check if it has the modified
8 Save as GIF

When I retrieve the just saved GIF, I get the original color Palette.

What am I doing wrong ?

AFAIK, lockbits should be used when there is the need to change some pixel
data, or am I wrong ?

TIA
Cesar



.



Relevant Pages

  • Re: Lousy quality when drawing an image on another
    ... It's not the bitmap quality that's the problem but the amount of colour ... The palette used in GDI+ GIF image saving is a "spread palette" with a ... To get the best from a GIF you *must* use an optimised palette. ... Answer those GDI+ questions with the GDI+ FAQ ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Change ColorPalette
    ... Sometimes I just cannot understand some complications that GDI+ brings... ... In fact after a bitmap has been loaded with a certain palette the encoder ... Is it possible to change the colorpalette of a GIF image without using ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Converting 2 colors picture from TIFF to GIF
    ... The overhead of the GIF palette is negligable so why worry?. ... Answer those GDI+ questions with the GDI+ FAQ ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Resizing gif down. Quality suffers.
    ... This will be because the colour palette, ... to create palettes for GIF images. ... Answer those GDI+ questions with the GDI+ FAQ ... > I'm writing some file upload code using C# for users on my website. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Help with extending a still frame
    ... GIF is also lossless in the sense that you can recompress a GIF ... palette entry within a GIF file can be designated as "transparent". ... palette entries, that is, where multiple palette entries define the ...
    (rec.video.desktop)