ThinkGeo.com    |     Documentation    |     Premium Support

Convert GeoImage to Bitmap

Hi,

I’ve previously used the following code to get a preview image to use as symbology on forms and controls.

GdiPlusGeoCanvas canvas = new GdiPlusGeoCanvas();
canvas.BeginDrawing(newImage, new RectangleShape(0, newImage.Width, newImage.Height, 0), GeographyUnit.Meter);

style.DrawSample(canvas);

if (canvas.IsDrawing)
{
canvas.EndDrawing();
}

With the change in v12 to SkiaGeoCanvas, it appears the BeginDrawing method now expects only a GeoImage object instead of a regular Image.

The output Image I need is going to get painted on a form, so it can’t be of type GeoImage.

How do I convert GeoImage back to regular Image? Is the above code even correct anymore?

Also, it appears that you can not use the new GeoImage(Width, Height) constructor as input into BeginDrawing. It only seems to accept new GeoImage([]bytes).

Thanks,
Damian

Thanks Damian,
Here is the way to convert the geoimage to the regular image.

GeoImage geoImage = new GeoImage(“Your file path”);
Image image = new Bitmap(geoImage.GetImageStream(GeoImageFormat.Png));

Thanks

Frank

Thanks Frank, that worked.

Regards,
Damian