Fix setting of nodata value for grayscale rasters

This commit is contained in:
Sandro Santilli 2016-03-23 20:28:58 +01:00
parent f72baaade1
commit cdc800b086

View file

@ -269,15 +269,13 @@ mapnik::raster_ptr read_grayscale_band(mapnik::box2d<double> const& bbox,
image.set(0xffffffff);
int val;
int nodataval;
uint8_t * data = image.bytes();
int ps = 4; // sizeof(image::pixel_type)
int off;
nodataval = reader(); // nodata value, need to read anyway
int nodataval = reader();
for (int y=0; y<height; ++y) {
for (int x=0; x<width; ++x) {
val = reader();
int val = reader();
// Apply harsh type clipping rules ala GDAL
if ( val < 0 ) val = 0;
if ( val > 255 ) val = 255;
@ -297,7 +295,7 @@ mapnik::raster_ptr read_grayscale_band(mapnik::box2d<double> const& bbox,
}
}
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(bbox, image, 1.0);
if ( hasnodata ) raster->set_nodata(val);
if ( hasnodata ) raster->set_nodata(nodataval);
return raster;
}