Before Windows 7 (and the new image codecs: WIC) I used the following (very fast but dirty) method to create a Gif encoded image with white as the transparent color:
MemoryStream target = new memoryStream(4096);
image.Save(target, imageFormat.Gif);
byte[] data = target.ToArray();
// Set transparency
// Check Graphic Control Extension signature (0x21 0xF9)
if (data[0x30D] == 0x21 && data[0x30E] == 0xF9)
data[0x313] = 0xFF; // Set palette index 255 (=white) as transparent
This method worked because .NET used to encode Gif with a standard palette in which index 255 was the color white.
In Windows 7 however this method is not working anymore. It seems the standard palette is changed and now the index 251 is the color white. I am however not sure. Maybe the new Gif encoder is dynamically generating a palette based on the used colors?
My question: Does anybody have insight in the new Gif encoder of Windows 7 and what would be a good and fast way to make the color white transparent?