Transparency and GIF output

Topics: Web Controls
May 18, 2007 at 9:18 PM
I'm using SharpMap as a WMS server within OpenLayers and have a quick question (hopefully). Because IE 6 doesn't support transparency and PNG properly I have to request a GIF format from SharpMap WMS. However, the GIF image that SharpMap is returning does not seem to have transparency either. It is returning an image with a black background. I was wondering if I am missing something or if there was a way I can remedy this problem. Thanks, rdp
May 18, 2007 at 11:10 PM
Use the code provided at this MSDN article this way:
      OctreeQuantizer quantizer = new OctreeQuantizer ( 255 , 8 ) ;
      quantizer.DitherLevel = 0;
      using ( Bitmap quantized = quantizer.Quantize ( image ) )
         Response.ContentType = "image/gif" ;
         quantized.Save ( Response.OutputStream , ImageFormat.Gif ) ;

Note that OctreeQuantizer class is declared as unsafe, so you have to change your compiler settings accordingly (better you put it in another assembly apart).

Best regards,
Ricardo Stuven.