<p>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.</p>

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

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

<p>Things I've tried:</p>

<ul>
<li>Using the <code>MakeTransparent (Color)</code> method call</li>
<li>Using the <code>ImageAttriutes</code> with a combination of <code>ColorMap</code> and <code>SetColorKey</code></li>
</ul>

<p>I don't really want to start using unsafe operators or Win32 calls.</p>

<p>Any ideas?</p>

When I have used transparency I've always used
```
Bitmap
```
. I.e.
```
```
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.