I can't believe this hasn't been asked yet, but...
How can I replace the transparent background of a GIF image to white, without breaking the animation?
I am way out of my field here, so I'm pretty much lost (I really don't know what to do).
This is what I tried without luck:
public byte[] RemoveTransparency(byte[] gifBytes)
{
using(MemoryStream gifStream = new MemoryStream(gifBytes))
using(Image gifImage = Image.FromStream(gifStream))
using(Image newImage = new Bitmap(gifImage.Width, gifImage.Height, PixelFormat.Format32bppPArgb))
using(MemoryStream newImageStream = new MemoryStream())
{
Color background = Color.White;
newImage.SetResolution(gifImage.HorizontalResolution, gifImage.VerticalResolution);
using (Graphics graphics = Graphics.FromImage(newImage))
{
graphics.Clear(background );
graphics.DrawImage(gifImage, 0, 0, gifImage.Width, gifImage.Height);
}
newImage.Save(newImageStream);
return newImageStream.ToArray();
}
}