From: cristy Date: Fri, 25 Sep 2009 14:34:31 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~10637 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=809758622d7d1135d333c5394ce4edd4b4c3f150;p=imagemagick --- diff --git a/Makefile.in b/Makefile.in index 4b5bfa384..d26bd03b2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -875,8 +875,7 @@ coders_pdb_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ @WITH_MODULES_TRUE@am_coders_pdb_la_rpath = -rpath $(codersdir) coders_pdf_la_DEPENDENCIES = $(MAGICKCORE_LIBS) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_coders_pdf_la_OBJECTS = coders/coders_pdf_la-pdf.lo coders_pdf_la_OBJECTS = $(am_coders_pdf_la_OBJECTS) coders_pdf_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ @@ -941,7 +940,7 @@ coders_ps_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ @WITH_MODULES_TRUE@am_coders_ps_la_rpath = -rpath $(codersdir) coders_ps2_la_DEPENDENCIES = $(MAGICKCORE_LIBS) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) am_coders_ps2_la_OBJECTS = coders/coders_ps2_la-ps2.lo coders_ps2_la_OBJECTS = $(am_coders_ps2_la_OBJECTS) coders_ps2_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ @@ -950,7 +949,7 @@ coders_ps2_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ @WITH_MODULES_TRUE@am_coders_ps2_la_rpath = -rpath $(codersdir) coders_ps3_la_DEPENDENCIES = $(MAGICKCORE_LIBS) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) am_coders_ps3_la_OBJECTS = coders/coders_ps3_la-ps3.lo coders_ps3_la_OBJECTS = $(am_coders_ps3_la_OBJECTS) coders_ps3_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ @@ -3381,7 +3380,7 @@ coders_pdb_la_LIBADD = $(MAGICKCORE_LIBS) coders_pdf_la_SOURCES = coders/pdf.c coders_pdf_la_CPPFLAGS = $(MODULE_EXTRA_CPPFLAGS) coders_pdf_la_LDFLAGS = $(MODULECOMMONFLAGS) -coders_pdf_la_LIBADD = $(MAGICKCORE_LIBS) $(TIFF_LIBS) $(JBIG_LIBS) $(JPEG_LIBS) $(ZLIB_LIBS) $(GS_LIBS) $(MATH_LIBS) +coders_pdf_la_LIBADD = $(MAGICKCORE_LIBS) $(JBIG_LIBS) $(JPEG_LIBS) $(ZLIB_LIBS) $(GS_LIBS) $(MATH_LIBS) # PICT coder module coders_pict_la_SOURCES = coders/pict.c @@ -3429,13 +3428,13 @@ coders_ps_la_LIBADD = $(MAGICKCORE_LIBS) $(GS_LIBS) $(MATH_LIBS) coders_ps2_la_SOURCES = coders/ps2.c coders_ps2_la_CPPFLAGS = $(MODULE_EXTRA_CPPFLAGS) coders_ps2_la_LDFLAGS = $(MODULECOMMONFLAGS) -coders_ps2_la_LIBADD = $(MAGICKCORE_LIBS) $(TIFF_LIBS) $(JBIG_LIBS) $(JPEG_LIBS) $(ZLIB_LIBS) $(MATH_LIBS) +coders_ps2_la_LIBADD = $(MAGICKCORE_LIBS) $(JBIG_LIBS) $(JPEG_LIBS) $(ZLIB_LIBS) $(MATH_LIBS) # PS3 coder module coders_ps3_la_SOURCES = coders/ps3.c coders_ps3_la_CPPFLAGS = $(MODULE_EXTRA_CPPFLAGS) coders_ps3_la_LDFLAGS = $(MODULECOMMONFLAGS) -coders_ps3_la_LIBADD = $(MAGICKCORE_LIBS) $(TIFF_LIBS) $(JBIG_LIBS) $(JPEG_LIBS) $(ZLIB_LIBS) $(MATH_LIBS) +coders_ps3_la_LIBADD = $(MAGICKCORE_LIBS) $(JBIG_LIBS) $(JPEG_LIBS) $(ZLIB_LIBS) $(MATH_LIBS) # PSD coder module coders_psd_la_SOURCES = coders/psd.c diff --git a/coders/Makefile.am b/coders/Makefile.am index 6ce099941..bdb220c43 100644 --- a/coders/Makefile.am +++ b/coders/Makefile.am @@ -686,7 +686,7 @@ coders_pdb_la_LIBADD = $(MAGICKCORE_LIBS) coders_pdf_la_SOURCES = coders/pdf.c coders_pdf_la_CPPFLAGS = $(MODULE_EXTRA_CPPFLAGS) coders_pdf_la_LDFLAGS = $(MODULECOMMONFLAGS) -coders_pdf_la_LIBADD = $(MAGICKCORE_LIBS) $(TIFF_LIBS) $(JBIG_LIBS) $(JPEG_LIBS) $(ZLIB_LIBS) $(GS_LIBS) $(MATH_LIBS) +coders_pdf_la_LIBADD = $(MAGICKCORE_LIBS) $(JBIG_LIBS) $(JPEG_LIBS) $(ZLIB_LIBS) $(GS_LIBS) $(MATH_LIBS) # PICT coder module coders_pict_la_SOURCES = coders/pict.c @@ -734,13 +734,13 @@ coders_ps_la_LIBADD = $(MAGICKCORE_LIBS) $(GS_LIBS) $(MATH_LIBS) coders_ps2_la_SOURCES = coders/ps2.c coders_ps2_la_CPPFLAGS = $(MODULE_EXTRA_CPPFLAGS) coders_ps2_la_LDFLAGS = $(MODULECOMMONFLAGS) -coders_ps2_la_LIBADD = $(MAGICKCORE_LIBS) $(TIFF_LIBS) $(JBIG_LIBS) $(JPEG_LIBS) $(ZLIB_LIBS) $(MATH_LIBS) +coders_ps2_la_LIBADD = $(MAGICKCORE_LIBS) $(JBIG_LIBS) $(JPEG_LIBS) $(ZLIB_LIBS) $(MATH_LIBS) # PS3 coder module coders_ps3_la_SOURCES = coders/ps3.c coders_ps3_la_CPPFLAGS = $(MODULE_EXTRA_CPPFLAGS) coders_ps3_la_LDFLAGS = $(MODULECOMMONFLAGS) -coders_ps3_la_LIBADD = $(MAGICKCORE_LIBS) $(TIFF_LIBS) $(JBIG_LIBS) $(JPEG_LIBS) $(ZLIB_LIBS) $(MATH_LIBS) +coders_ps3_la_LIBADD = $(MAGICKCORE_LIBS) $(JBIG_LIBS) $(JPEG_LIBS) $(ZLIB_LIBS) $(MATH_LIBS) # PSD coder module coders_psd_la_SOURCES = coders/psd.c diff --git a/coders/pdf.c b/coders/pdf.c index 30e309ef0..8fbbb321e 100644 --- a/coders/pdf.c +++ b/coders/pdf.c @@ -73,11 +73,11 @@ #include "magick/transform.h" #include "magick/utility.h" #include "magick/module.h" + +/* + Define declarations. +*/ #if defined(MAGICKCORE_TIFF_DELEGATE) -#if defined(MAGICKCORE_HAVE_TIFFCONF_H) -#include "tiffconf.h" -#endif -#include "tiffio.h" #define CCITTParam "-1" #else #define CCITTParam "0" @@ -851,154 +851,41 @@ static char *EscapeParenthesis(const char *text) return(buffer); } -#if defined(MAGICKCORE_TIFF_DELEGATE) static MagickBooleanType Huffman2DEncodeImage(const ImageInfo *image_info, Image *image,Image *inject_image) { - char - filename[MaxTextExtent]; - - FILE - *file; - Image - *huffman_image; + *group4_image; ImageInfo *write_info; - int - unique_file; - MagickBooleanType status; - register long - i; - - ssize_t - count; - - TIFF - *tiff; - - uint16 - fillorder; - - uint32 - *byte_count, - strip_size; + size_t + length; unsigned char - *buffer; + *group4; - /* - Write image as CCITTFax4 TIFF image to a temporary file. - */ - 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); - huffman_image=CloneImage(inject_image,0,0,MagickTrue,&image->exception); - if (huffman_image == (Image *) NULL) - return(MagickFalse); - file=(FILE *) NULL; - unique_file=AcquireUniqueFileResource(filename); - if (unique_file != -1) - file=fdopen(unique_file,"wb"); - if ((unique_file == -1) || (file == (FILE *) NULL)) - { - ThrowFileException(&image->exception,FileOpenError, - "UnableToCreateTemporaryFile",filename); - return(MagickFalse); - } - (void) FormatMagickString(huffman_image->filename,MaxTextExtent,"tiff:%s", - filename); write_info=CloneImageInfo(image_info); - SetImageInfoFile(write_info,file); - write_info->compression=Group4Compression; - write_info->type=BilevelType; - (void) SetImageOption(write_info,"quantum:polarity","min-is-white"); - status=WriteImage(write_info,huffman_image); - (void) fflush(file); + (void) CopyMagickString(write_info->filename,"GROUP4:",MaxTextExtent); + (void) CopyMagickString(write_info->magick,"GROUP4",MaxTextExtent); + group4_image=CloneImage(inject_image,0,0,MagickTrue,&image->exception); + if (group4_image == (Image *) NULL) + return(MagickFalse); + group4=(unsigned char *) ImageToBlob(write_info,group4_image,&length, + &image->exception); + group4_image=DestroyImage(group4_image); + if (group4 == (unsigned char *) NULL) + return(MagickFalse); write_info=DestroyImageInfo(write_info); - if (status == MagickFalse) - { - (void) RelinquishUniqueFileResource(filename); - return(MagickFalse); - } - 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); + if (WriteBlob(image,length,group4) != (ssize_t) length) + status=MagickFalse; + group4=(unsigned char *) RelinquishMagickMemory(group4); + return(status); } -#endif static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image) { @@ -1571,7 +1458,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image) MaxTextExtent); (void) WriteBlobString(image,buffer); (void) FormatMagickString(buffer,MaxTextExtent,"/DecodeParms [ << " - "/K %s /BlackIs1 true /Columns %ld /Rows %ld >> ]\n",CCITTParam, + "/K %s /BlackIs1 false /Columns %ld /Rows %ld >> ]\n",CCITTParam, image->columns,image->rows); break; } @@ -2013,7 +1900,7 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image) MaxTextExtent); (void) WriteBlobString(image,buffer); (void) FormatMagickString(buffer,MaxTextExtent,"/DecodeParms [ << " - "/K %s /BlackIs1 true /Columns %lu /Rows %lu >> ]\n",CCITTParam, + "/K %s /BlackIs1 false /Columns %lu /Rows %lu >> ]\n",CCITTParam, tile_image->columns,tile_image->rows); break; } diff --git a/coders/ps2.c b/coders/ps2.c index c6b1912ea..d51e73c78 100644 --- a/coders/ps2.c +++ b/coders/ps2.c @@ -67,11 +67,11 @@ #include "magick/string_.h" #include "magick/module.h" #include "magick/utility.h" + +/* + Define declarations. +*/ #if defined(MAGICKCORE_TIFF_DELEGATE) -#if defined(MAGICKCORE_HAVE_TIFFCONF_H) -#include "tiffconf.h" -#endif -#include "tiffio.h" #define CCITTParam "-1" #else #define CCITTParam "0" @@ -180,154 +180,41 @@ ModuleExport void UnregisterPS2Image(void) % */ -#if defined(MAGICKCORE_TIFF_DELEGATE) static MagickBooleanType Huffman2DEncodeImage(const ImageInfo *image_info, Image *image,Image *inject_image) { - char - filename[MaxTextExtent]; - - FILE - *file; - Image - *huffman_image; + *group4_image; ImageInfo *write_info; - int - unique_file; - MagickBooleanType status; - register long - i; - - ssize_t - count; - - TIFF - *tiff; - - uint16 - fillorder; - - uint32 - *byte_count, - strip_size; + size_t + length; unsigned char - *buffer; + *group4; - /* - Write image as CCITTFax4 TIFF image to a temporary file. - */ - 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); - huffman_image=CloneImage(inject_image,0,0,MagickTrue,&image->exception); - if (huffman_image == (Image *) NULL) - return(MagickFalse); - file=(FILE *) NULL; - unique_file=AcquireUniqueFileResource(filename); - if (unique_file != -1) - file=fdopen(unique_file,"wb"); - if ((unique_file == -1) || (file == (FILE *) NULL)) - { - ThrowFileException(&image->exception,FileOpenError, - "UnableToCreateTemporaryFile",filename); - return(MagickFalse); - } - (void) FormatMagickString(huffman_image->filename,MaxTextExtent,"tiff:%s", - filename); write_info=CloneImageInfo(image_info); - SetImageInfoFile(write_info,file); - write_info->compression=Group4Compression; - write_info->type=BilevelType; - (void) SetImageOption(write_info,"quantum:polarity","min-is-white"); - status=WriteImage(write_info,huffman_image); - (void) fflush(file); + (void) CopyMagickString(write_info->filename,"GROUP4:",MaxTextExtent); + (void) CopyMagickString(write_info->magick,"GROUP4",MaxTextExtent); + group4_image=CloneImage(inject_image,0,0,MagickTrue,&image->exception); + if (group4_image == (Image *) NULL) + return(MagickFalse); + group4=(unsigned char *) ImageToBlob(write_info,group4_image,&length, + &image->exception); + group4_image=DestroyImage(group4_image); + if (group4 == (unsigned char *) NULL) + return(MagickFalse); write_info=DestroyImageInfo(write_info); - if (status == MagickFalse) - { - (void) RelinquishUniqueFileResource(filename); - return(MagickFalse); - } - 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); + if (WriteBlob(image,length,group4) != (ssize_t) length) + status=MagickFalse; + group4=(unsigned char *) RelinquishMagickMemory(group4); + return(status); } -#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); -} -#endif static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image) { @@ -356,8 +243,8 @@ static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image) " /Decode [0 1 0 1 0 1]", " /ImageMatrix [columns 0 0 rows neg 0 rows]", " compression 0 gt", - " { /DataSource pixel_stream /%s filter }", - " { /DataSource pixel_stream /%s filter } ifelse", + " { /DataSource pixel_stream %s }", + " { /DataSource pixel_stream %s } ifelse", " >> image", " }", " {", @@ -370,8 +257,8 @@ static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image) " /Decode [1 0 1 0 1 0 1 0]", " /ImageMatrix [columns 0 0 rows neg 0 rows]", " compression 0 gt", - " { /DataSource pixel_stream /%s filter }", - " { /DataSource pixel_stream /%s filter } ifelse", + " { /DataSource pixel_stream %s }", + " { /DataSource pixel_stream %s } ifelse", " >> image", " } ifelse", "} bind def", @@ -402,9 +289,9 @@ static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image) " /Decode [0 1]", " /ImageMatrix [columns 0 0 rows neg 0 rows]", " compression 0 gt", - " { /DataSource pixel_stream /%s filter }", + " { /DataSource pixel_stream %s }", " {", - " /DataSource pixel_stream /%s filter", + " /DataSource pixel_stream %s", " <<", " /K "CCITTParam, " /Columns columns", @@ -430,8 +317,8 @@ static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image) " /Decode [0 255]", " /ImageMatrix [columns 0 0 rows neg 0 rows]", " compression 0 gt", - " { /DataSource pixel_stream /%s filter }", - " { /DataSource pixel_stream /%s filter } ifelse", + " { /DataSource pixel_stream %s }", + " { /DataSource pixel_stream %s } ifelse", " >> image", " } ifelse", "} bind def", @@ -732,30 +619,31 @@ static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image) case NoCompression: { (void) FormatMagickString(buffer,MaxTextExtent,*q, - "ASCII85Decode"); + "/ASCII85Decode filter"); break; } case JPEGCompression: { - (void) FormatMagickString(buffer,MaxTextExtent,*q,"DCTDecode"); + (void) FormatMagickString(buffer,MaxTextExtent,*q, + "/DCTDecode filter"); break; } case LZWCompression: { - (void) FormatMagickString(buffer,MaxTextExtent,*q,"LZWDecode"); + (void) FormatMagickString(buffer,MaxTextExtent,*q, + "/LZWDecode filter"); break; } case FaxCompression: case Group4Compression: { - (void) FormatMagickString(buffer,MaxTextExtent,*q, - "ASCII85Decode"); + (void) FormatMagickString(buffer,MaxTextExtent,*q," "); break; } default: { (void) FormatMagickString(buffer,MaxTextExtent,*q, - "RunLengthDecode"); + "/RunLengthDecode filter"); break; } } diff --git a/coders/ps3.c b/coders/ps3.c index f7eb69e78..8bb6345a9 100644 --- a/coders/ps3.c +++ b/coders/ps3.c @@ -69,15 +69,6 @@ #include "magick/token.h" #include "magick/utility.h" #include "magick/module.h" -#if defined(MAGICKCORE_TIFF_DELEGATE) -#if defined(MAGICKCORE_HAVE_TIFFCONF_H) -#include "tiffconf.h" -#endif -#include "tiffio.h" -#define CCITTParam "-1" -#else -#define CCITTParam "0" -#endif /* Define declarations. @@ -94,6 +85,13 @@ #define PS3_DirectClass "0" #define PS3_PseudoClass "1" + +#if defined(MAGICKCORE_TIFF_DELEGATE) +#include "tiffio.h" +#define CCITTParam "-1" +#else +#define CCITTParam "0" +#endif /* Forward declarations. @@ -194,154 +192,42 @@ ModuleExport void UnregisterPS3Image(void) % */ -#if defined(MAGICKCORE_TIFF_DELEGATE) static MagickBooleanType Huffman2DEncodeImage(const ImageInfo *image_info, Image *image,Image *inject_image) { - char - filename[MaxTextExtent]; - - FILE - *file; - Image - *huffman_image; + *group4_image; ImageInfo *write_info; - int - unique_file; - MagickBooleanType status; - register long - i; - - ssize_t - count; - - TIFF - *tiff; - - uint16 - fillorder; - - uint32 - *byte_count, - strip_size; + size_t + length; unsigned char - *buffer; + *group4; - /* - Write image as CCITTFax4 TIFF image to a temporary file. - */ - 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); - huffman_image=CloneImage(inject_image,0,0,MagickTrue,&image->exception); - if (huffman_image == (Image *) NULL) - return(MagickFalse); - file=(FILE *) NULL; - unique_file=AcquireUniqueFileResource(filename); - if (unique_file != -1) - file=fdopen(unique_file,"wb"); - if ((unique_file == -1) || (file == (FILE *) NULL)) - { - ThrowFileException(&image->exception,FileOpenError, - "UnableToCreateTemporaryFile",filename); - return(MagickFalse); - } - (void) FormatMagickString(huffman_image->filename,MaxTextExtent,"tiff:%s", - filename); write_info=CloneImageInfo(image_info); - SetImageInfoFile(write_info,file); - write_info->compression=Group4Compression; - write_info->type=BilevelType; - (void) SetImageOption(write_info,"quantum:polarity","min-is-white"); - status=WriteImage(write_info,huffman_image); - (void) fflush(file); + (void) CopyMagickString(write_info->filename,"GROUP4:",MaxTextExtent); + (void) CopyMagickString(write_info->magick,"GROUP4",MaxTextExtent); + group4_image=CloneImage(inject_image,0,0,MagickTrue,&image->exception); + if (group4_image == (Image *) NULL) + return(MagickFalse); + group4=(unsigned char *) ImageToBlob(write_info,group4_image,&length, + &image->exception); + group4_image=DestroyImage(group4_image); + if (group4 == (unsigned char *) NULL) + return(MagickFalse); write_info=DestroyImageInfo(write_info); - if (status == MagickFalse) - { - (void) RelinquishUniqueFileResource(filename); - return(MagickFalse); - } - 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); + if (WriteBlob(image,length,group4) != (ssize_t) length) + status=MagickFalse; + group4=(unsigned char *) RelinquishMagickMemory(group4); + return(status); } -#endif + static MagickBooleanType SerializeImage(const ImageInfo *image_info, Image *image,unsigned char **pixels,size_t *length) diff --git a/magick/version.h b/magick/version.h index 1c8c1bd83..3ae390ccf 100644 --- a/magick/version.h +++ b/magick/version.h @@ -32,7 +32,7 @@ extern "C" { #define MagickLibVersionNumber 2,0,0 #define MagickLibSubversion "-5" #define MagickReleaseDate "2009-09-25" -#define MagickChangeDate "20090922" +#define MagickChangeDate "20090925" #define MagickAuthoritativeURL "http://www.imagemagick.org" #define MagickHomeURL "file:///usr/local/share/doc/ImageMagick-6.5.6/index.html" #if (MAGICKCORE_QUANTUM_DEPTH == 8)