I want to draw one picture over another and dump it to HttpResponse. My code looks like this:
//file name points to a gif image
System.Drawing.Image originalImage = System.Drawing.Image.FromFile(filename);
System.Drawing.Image smallImage = System.Drawing.Image.FromFile(smallFilename);
using(Bitmap tempImage = new Bitmap(originalImage))
{
Graphics graphics = Graphics.FromImage(tempImage);
PointF ulCorner = new PointF(10.0F, 10.0F);
graphics.DrawImage(windfarmImage, ulCorner);
}
tempImage.Save(Response.OutputStream, ImageFormat.Gif);
If I change last line to
tempImage.Save(Response.OutputStream, ImageFormat.Jpeg);
it fixes the problem. But I have to have png as a result. Can I somehow keep palette from original file? Original file is gif, so it should be possible to have gif as a result without loosing any colors I guess.