From: Cristy Date: Sun, 19 May 2019 16:43:54 +0000 (-0400) Subject: https://imagemagick.org/discourse-server/viewtopic.php?f=1&t=36053 X-Git-Tag: 7.0.8-47~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=241632f924c9bb470340423e70b7540bdcc6511d;p=imagemagick https://imagemagick.org/discourse-server/viewtopic.php?f=1&t=36053 --- diff --git a/ChangeLog b/ChangeLog index 382d1beb5..1b9243d7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2019-05-19 7.0.8-47 Cristy + * Release ImageMagick version 7.0.8-47, GIT revision 15... + +2019-05-19 7.0.8-47 Cristy + * Support 16 and 32 bit tiled float TIFF images. + 2019-05-14 7.0.8-46 Cristy * Release ImageMagick version 7.0.8-46, GIT revision 15655:84dd3301c:20190518 diff --git a/coders/tiff.c b/coders/tiff.c index 02f616b67..171268226 100644 --- a/coders/tiff.c +++ b/coders/tiff.c @@ -121,6 +121,7 @@ typedef enum ReadYCCKMethod, ReadStripMethod, ReadTileMethod, + ReadRGBATileMethod, ReadGenericMethod } TIFFMethodType; @@ -1785,7 +1786,11 @@ RestoreMSCWarning if (compress_tag == COMPRESSION_JBIG) method=ReadStripMethod; if (TIFFIsTiled(tiff) != MagickFalse) - method=ReadTileMethod; + { + method=ReadRGBATileMethod; + if (bits_per_sample > 16) + method=ReadTileMethod; + } quantum_info->endian=LSBEndian; quantum_type=RGBQuantum; if (TIFFScanlineSize(tiff) <= 0) @@ -2063,6 +2068,110 @@ RestoreMSCWarning break; } case ReadTileMethod: + { + register unsigned char + *p; + + uint32 + columns, + rows; + + unsigned char + *tile_pixels; + + /* + Convert tiled TIFF image to DirectClass MIFF image. + */ + quantum_type=IndexQuantum; + pad=(size_t) MagickMax((ssize_t) samples_per_pixel-1,0); + if (image->alpha_trait != UndefinedPixelTrait) + { + if (image->storage_class != PseudoClass) + { + quantum_type=samples_per_pixel == 1 ? AlphaQuantum : + GrayAlphaQuantum; + pad=(size_t) MagickMax((ssize_t) samples_per_pixel-2,0); + } + else + { + quantum_type=IndexAlphaQuantum; + pad=(size_t) MagickMax((ssize_t) samples_per_pixel-2,0); + } + } + else + if (image->storage_class != PseudoClass) + { + quantum_type=GrayQuantum; + pad=(size_t) MagickMax((ssize_t) samples_per_pixel-1,0); + } + status=SetQuantumPad(image,quantum_info,pad*pow(2,ceil(log( + bits_per_sample)/log(2)))); + if (status == MagickFalse) + ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed"); + if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) != 1) || + (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) != 1)) + ThrowTIFFException(CoderError,"ImageIsNotTiled"); + if ((AcquireMagickResource(WidthResource,columns) == MagickFalse) || + (AcquireMagickResource(HeightResource,rows) == MagickFalse)) + ThrowTIFFException(ImageError,"WidthOrHeightExceedsLimit"); + (void) SetImageStorageClass(image,DirectClass,exception); + number_pixels=(MagickSizeType) columns*rows; + if (HeapOverflowSanityCheck(rows,sizeof(*tile_pixels)) != MagickFalse) + ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed"); + tile_pixels=(unsigned char *) AcquireQuantumMemory(TIFFTileSize(tiff)+ + sizeof(uint32),sizeof(*tile_pixels)); + if (tile_pixels == (unsigned char *) NULL) + ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed"); + for (y=0; y < (ssize_t) image->rows; y+=rows) + { + register ssize_t + x; + + size_t + rows_remaining; + + rows_remaining=image->rows-y; + if ((ssize_t) (y+rows) < (ssize_t) image->rows) + rows_remaining=rows; + for (x=0; x < (ssize_t) image->columns; x+=columns) + { + size_t + columns_remaining, + row; + + columns_remaining=image->columns-x; + if ((ssize_t) (x+columns) < (ssize_t) image->columns) + columns_remaining=columns; + if (TIFFReadTile(tiff,tile_pixels,(uint32) x,(uint32) y,0,0) == 0) + break; + p=tile_pixels; + for (row=0; row < rows_remaining; row++) + { + register Quantum + *magick_restrict q; + + q=GetAuthenticPixels(image,x,y+row,columns_remaining,1,exception); + if (q == (Quantum *) NULL) + break; + (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, + quantum_type,p,exception); + p+=TIFFTileRowSize(tiff); + if (SyncAuthenticPixels(image,exception) == MagickFalse) + break; + } + } + if (image->previous == (Image *) NULL) + { + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, + image->rows); + if (status == MagickFalse) + break; + } + } + tile_pixels=(unsigned char *) RelinquishMagickMemory(tile_pixels); + break; + } + case ReadRGBATileMethod: { register uint32 *p;