# NativeImageRasterLayer width OutOfRange Exception

**URL:** <https://community.thinkgeo.com/t/nativeimagerasterlayer-width-outofrange-exception/9942>\
**Category:** WPF\
**Created:** [October 29, 2020, 9:12pm UTC](https://community.thinkgeo.com/t/nativeimagerasterlayer-width-outofrange-exception/9942 "2020-10-29T21:12:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fred\_Thomas](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@Fred\_Thomas](https://community.thinkgeo.com/u/Fred_Thomas)\
**Post date:** [October 29, 2020, 9:12pm UTC](https://community.thinkgeo.com/t/nativeimagerasterlayer-width-outofrange-exception/9942/1 "2020-10-29T21:12:02Z")

</div>

Greetings,

We use a NativeImageRasterLayer to display a bitmap file to serve as texture for the world. Once zoomed in enough, it no longer displays, and instead shows “the input double value is out of range. parameter name: width” instead.

Are there any options to automatically prevent drawing the layer if it is going to fail at ValidatorHelper’s CheckInputValuesInRange function? Not attempting to display the layer would be much better than both showing exception text on the screen and seconds of slowdown/garbage collector churn.

Thanks!

---

<div class="post-metadata">

**Author:** ![Frank4](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/frank4/32/25224_2.png) [@Frank4](https://community.thinkgeo.com/u/Frank4)\
**Post date:** [October 30, 2020, 2:46pm UTC](https://community.thinkgeo.com/t/nativeimagerasterlayer-width-outofrange-exception/9942/2 "2020-10-30T14:46:33Z")

</div>

Thanks Fred,  
I tested on my environment. I didn’t see the error. Could you attach you sample project. We can look into more detail. I attached my demo project. You can modify it if you want.

[WpfApp38.zip](https://community.thinkgeo.com/uploads/short-url/uimebwpeOB8jPP3oIqBUXdxnOWE.zip) (5.2 KB)

Thanks

Frank

---

<div class="post-metadata">

**Author:** ![Fred\_Thomas](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@Fred\_Thomas](https://community.thinkgeo.com/u/Fred_Thomas)\
**Post date:** [October 30, 2020, 5:43pm UTC](https://community.thinkgeo.com/t/nativeimagerasterlayer-width-outofrange-exception/9942/3 "2020-10-30T17:43:01Z")

</div>

Main difference would be that we have

mapView.MapUnit = ThinkGeo.Core.GeographyUnit.DecimalDegree;

And an extent for the layer of -180,90,180,-90.

What would be the best way to prevent drawing when zoomed too far in? Setting Thresholds? If so, what’s the best way to automatically calculate that automatically? Thanks.

[WholeEarthNight.bmp](https://community.thinkgeo.com/uploads/short-url/sIi89nhrWF9J9ZXyyUTisvoGlfG.bmp) (2.0 MB)

---

<div class="post-metadata">

**Author:** ![Frank4](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/frank4/32/25224_2.png) [@Frank4](https://community.thinkgeo.com/u/Frank4)\
**Post date:** [October 30, 2020, 7:35pm UTC](https://community.thinkgeo.com/t/nativeimagerasterlayer-width-outofrange-exception/9942/4 "2020-10-30T19:35:17Z")

</div>

Thanks Fred,  
The single bmp file can not work. You need a file to specify the geo reference. That mean where to put the bmp file on the map. I generate one for you. It may not precise you may need adjust it or find the correct one for your bmp file. The code will be like this one  
private void Window\_Loaded(object sender, RoutedEventArgs e)  
{  
mapView.MapUnit = ThinkGeo.Core.GeographyUnit.DecimalDegree;  
NativeImageRasterLayer test = new NativeImageRasterLayer(@“D:\WholeEarthNight.bmp”);  
LayerOverlay lo = new LayerOverlay();  
lo.TileType = TileType.SingleTile;  
lo.Layers.Add(test);  
mapView.Overlays.Add(lo);  
mapView.Refresh();  
}

[File.zip](https://community.thinkgeo.com/uploads/short-url/9gy4FtN0mA4MCvtnmHy4YIYXBnp.zip) (379.6 KB)

[2020-10-30\_14-29-15.zip](https://community.thinkgeo.com/uploads/short-url/dC77cRV5wMI6nw3gFYanssYEprI.zip) (3.7 MB)

Thanks

Frank
