|     Documentation    |     Premium Support

NativeImageRasterLayer problems in 32-bit application


We need to project large raster maps over the background map. These maps can be e.g. 12000*12000 pixels sometimes. This has been working fine on 64-bit application builds, but we have also requirement to support 32-bit operating systems. We’ve noticed problems in 32-bit application builds with these raster files.

I’m using this code to project a PNG file:

    private void mapView_Loaded(object sender, RoutedEventArgs e)
        // Set the Map Unit.
        mapView.MapUnit = GeographyUnit.Meter;

        // Add a base map overlay.
        var cloudRasterBaseMapOverlay = new ThinkGeoCloudRasterMapsOverlay("USlbIyO5uIMja2y0qoM21RRM6NBXUad4hjK3NBD6pD0~", "f6OJsvCDDzmccnevX55nL7nXpPDXXKANe5cN6czVjCH0s8jhpCH-2A~~", ThinkGeoCloudRasterMapsMapType.Light);

        // Add a raster layer
        var layer = new NativeImageRasterLayer(@"AppData/test.png", @"AppData/test.wld");
        layer.ImageSource.ProjectionConverter = new UnmanagedProjectionConverter(3067, 3857);

        mapView.CurrentExtent = layer.GetBoundingBox();

        LayerOverlay layerOverlay = new LayerOverlay();

I’m using just a test picture, with no real map data in it just for testing purposes. It looks like this in 64-bit build:

This is basically correct, but that white stripe surrounded with red ellipse should not be there. (I’ve seen this kind of artifacts earlier with projected raster files…)

But if I build a 32-bit app variant, at first it looks the same, but when I zoom in, I get this:

“Unable to allocate pixels for the bitmap.” exception gets printed to the map. Also in our production application we are seeing that the raster file can’t be added to the map at all. Layer.Open throws this exception:

MapCoreTestClient.exe Error: 0 : MapCore.Model.LayerImportResult|Exception|System.Exception: Unable to allocate pixels for the bitmap.
   at SkiaSharp.SKBitmap..ctor(SKImageInfo info, Int32 rowBytes)
   at SkiaSharp.SKBitmap.Decode(SKCodec codec, SKImageInfo bitmapInfo)
   at SkiaSharp.SKBitmap.Decode(SKCodec codec)
   at SkiaSharp.SKBitmap.Decode(String filename)
   at ThinkGeo.Core.NativeImageRasterSource.OpenCore()
   at ThinkGeo.Core.RasterSource.Open()
   at ThinkGeo.Core.RasterLayer.OpenCore()
   at ThinkGeo.Core.Layer.Open()

Is there something that can be done to make this work?

I have added the test project here as reference. It has both AnyCPU and x86 build (38.5 KB)


Hi Rasmus,

Thanks for your detailed sample, we have recreated this problem which is proved to be a memory issue, we are working on it now and will see if any options that we can work around it, any progress I will keep you posted.


Hi Rasmus,

This issue is fixed in the latest beta version (ThinkGeo.Core Beta275 and later). Please have a try.

X86 does have strict memory limits and we still recommend you to use X64 especially when launching a big raster file.

Let us know if you have more issues.


Also Rasmus,

Please use singletile for the overlay. It behaves better for your scenario.

layerOverlay.TileType = TileType.SingleTile;


Hi Ben,

It works probably a bit better, but if I just zoom in and out a couple of times with mouse wheel or change the window size, I get the application to crash very easily. I don’t get a stack trace, only this line:

The program ‘[20144] ThinkGeo32Bit.exe’ has exited with code -1073740791 (0xc0000409).

I tried also with TileType.SingleTile and the same crash occurred. I’m not sure, but it might have stayed up for a little while longer and more effort was needed to get the application to crash.


Hi Ben,

Also another finding is that on this provided test app, the raster file loading seems to succeed, but on our production application I’m still getting the same exception, but not always… The application itself takes more memory and resources than the simple test application provided here, so would that be an explanation?

I also tried to reduce the raster file size to one quarter, and that seems to work a bit better, but I was still able to get crash whilst zooming or resizing window.

Do you think that this problem is still somehow solvable or do we need to implement workaround, e.g. restrict the raster file resolution, etc.?

Thanks, Rasmus


Thanks for the further information, it’s an issue in Skia which is used for drawing in SDK. A bit complicated to get it resolved, but now we are trying some options to work it around. May need some time. Sorry for the delay.


Hi Johnny,

No problem, thanks for looking into this.

BR, Rasmus