I’m working on saving a mapEngine as an indexed png file. I can draw the MapEngine to a bmp and then save as a png, but it is not indexed. I’ve tried different PixelFormats when I instantiate the BitMap, but with an indexed PixelFormat I get this error on the DrawStaticLayersCommand : “Error - A Graphics object cannot be created from an image that has an indexed pixel format.”
Here is my code. NexradMap is a mapEngine. Any ideas on how to draw the MapEngine to an indexed PNG?
Bitmap newBMP = new Bitmap(320, 200, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
NexradMap.OpenAllLayers();
NexradMap.DrawStaticLayers(newBMP, GeographyUnit.DecimalDegree);
NexradMap.CloseAllLayers();
// Testing - write to file
newBMP.Save(@"c:\Temp\Nexrad.png", System.Drawing.Imaging.ImageFormat.Png);