Last post Dec 02, 2009 06:19 AM by pottyoszebra
Dec 02, 2009 06:19 AM|pottyoszebra|LINK
I am trying to write a simple page that inverts the palette of a transparent gif image it receives, then outputs it as png.
The code is below:
WebRequest request = HttpWebRequest.Create(Sources.BuxGrafikon15Url);
WebResponse response = request.GetResponse();
Bitmap pic = new Bitmap(response.GetResponseStream());
ColorPalette palette = pic.Palette;
for (int i = 0; i < palette.Entries.Length; i++)
Color curr = palette.Entries[i];
Color newColor = Color.FromArgb(curr.A, 255 - curr.R, 255 - curr.G, 255 - curr.B);
palette.Entries[i] = newColor;
pic.Palette = palette;
Response.ContentType = "image/png";
Response.BufferOutput = true;
The problem is, while it works perfectly on my dev machine (win7 x64), it does not work on my other test machines (xp 32bit, server 2003 x64). If I change the format to jpeg, it works, except it does not do the palette manipulation on the test systems.
I tried looking up whatever I might be missing, but the code seems to match all the samples on the web closely. So now I wonder, maybe I'm missing some requirement to do this transformation properly? Do I need to install or import or set anything to make
this code work on all servers?