diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 4ba7c0930f..3ad0ecd49b 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -76,6 +76,7 @@ remained in the 1.9.1 release, including: * Fix constant reloading of texture when gl-ignore-mipmaps is set * BamReader now releases the GIL (so it can be used threaded) * Fix AttributeError in direct.stdpy.threading module +* Fix crash when writing 16-bit .tif file (now silently downsamples) ------------------------ RELEASE 1.9.1 ------------------------ diff --git a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx index ab09b1f034..5bfb87e5c3 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx @@ -1114,13 +1114,13 @@ write_data(xel *array, xelval *alpha) { bytesperrow = _x_size * samplesperpixel; } else if ( grayscale ) { samplesperpixel = 1; - bitspersample = pm_maxvaltobits( _maxval ); + bitspersample = min(8, pm_maxvaltobits(_maxval)); photometric = PHOTOMETRIC_MINISBLACK; i = 8 / bitspersample; bytesperrow = ( _x_size + i - 1 ) / i; } else { samplesperpixel = 1; - bitspersample = 8; + bitspersample = min(8, pm_maxvaltobits(_maxval)); photometric = PHOTOMETRIC_PALETTE; bytesperrow = _x_size; }