- tiff=TIFFOpen(filename,"rb");
- if (tiff == (TIFF *) NULL)
- {
- huffman_image=DestroyImage(huffman_image);
- (void) fclose(file);
- (void) RelinquishUniqueFileResource(filename);
- ThrowFileException(&image->exception,FileOpenError,"UnableToOpenFile",
- image_info->filename);
- return(MagickFalse);
- }
- /*
- Allocate raw strip buffer.
- */
- byte_count=0;
- (void) TIFFGetField(tiff,TIFFTAG_STRIPBYTECOUNTS,&byte_count);
- strip_size=byte_count[0];
- for (i=1; i < (long) TIFFNumberOfStrips(tiff); i++)
- if (byte_count[i] > strip_size)
- strip_size=byte_count[i];
- buffer=(unsigned char *) AcquireQuantumMemory((size_t) strip_size,
- sizeof(*buffer));
- if (buffer == (unsigned char *) NULL)
- {
- TIFFClose(tiff);
- huffman_image=DestroyImage(huffman_image);
- (void) fclose(file);
- (void) RelinquishUniqueFileResource(filename);
- ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
- image_info->filename);
- }
- /*
- Compress runlength encoded to 2D Huffman pixels.
- */
- fillorder=FILLORDER_LSB2MSB;
- (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_FILLORDER,&fillorder);
- for (i=0; i < (long) TIFFNumberOfStrips(tiff); i++)
- {
- count=(ssize_t) TIFFReadRawStrip(tiff,(uint32) i,buffer,(long)
- byte_count[i]);
- if (fillorder == FILLORDER_LSB2MSB)
- TIFFReverseBits(buffer,(unsigned long) count);
- (void) WriteBlob(image,(size_t) count,buffer);
- }
- buffer=(unsigned char *) RelinquishMagickMemory(buffer);
- TIFFClose(tiff);
- huffman_image=DestroyImage(huffman_image);
- (void) fclose(file);
- (void) RelinquishUniqueFileResource(filename);
- return(MagickTrue);
-}
-#else
-static MagickBooleanType Huffman2DEncodeImage(const ImageInfo *image_info,
- Image *image,Image *inject_image)
-{
- assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
- assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- assert(inject_image != (Image *) NULL);
- assert(inject_image->signature == MagickSignature);
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
- MissingDelegateError,"DelegateLibrarySupportNotBuiltIn","`%s' (TIFF)",
- image->filename);
- return(MagickFalse);