Fix crash when trying to write 16-bit TIFF file (LP bug 1222922)

Note: does not actually add support for writing 16-bit tifs; Panda just doesn't crash but automatically downsamples to 8-bit.
This commit is contained in:
rdb 2016-12-23 00:36:59 +01:00
parent 601b6b8678
commit 2ac1734566
2 changed files with 3 additions and 2 deletions

View File

@ -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 ------------------------

View File

@ -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;
}