How do I maintain transparency in an image from a Http Handler when using Graphics.DrawImage?


How do I maintain transparency in an image from a Http Handler when using Graphics.DrawImage?



I've got a series of GIFs that I need to crop on the fly, I'm using a HTTP Handler in C# so I can better encapsulate the code - provide caching for the result etc.

Currently, when I draw the existing image to a new Image via the Graphics object all the transparency is lost.

I've tried various techniques to try and maintain the transparency, but to no avail.

Things I've tried:

  • Using the MakeTransparent (Color) method call
  • Using the ImageAttriutes with a combination of ColorMap and SetColorKey

I don't really want to start using unsafe operators or Win32 calls.

Any ideas?




How can I configure ASP.Net membership providers through code?

1:



ASP.net Page Loading popup


Html To Doc(Word) Or RTF Format


Showing/Hiding div CollapsePanel after ClientScript.RegisterClientScriptBlock

2:



ASP.net Page object null when invoking it from within templated control
When I have used transparency I've always used Bitmap.


Exposing .NET WebService to Other Platform (Java)
I.e..
Web Service For Database/Website Status
System.Drawing.Image SourceImage = System.Drawing.Image.FromFile("the.gif"); System.Drawing.Bitmap NewImage = new System.Drawing.Bitmap(SourceImage); // Do Processing NewImage.MakeTransparent(); // Store changes NewImage.Save(..., System.Drawing.Imaging.ImageFormat.Png); 
Of course if you cannot move away from the Graphics object then that may not be of much use..



85 out of 100 based on 75 user ratings 1375 reviews