From 892ba02da0ccff75da48b55ad23f31fd50864f4b Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 11 May 2019 19:04:52 -0400 Subject: [PATCH] ... --- coders/jpeg.c | 2 +- coders/ps3.c | 394 ++++++++++++++++++++++++-------------------------- coders/sfw.c | 2 +- coders/ttf.c | 2 +- 4 files changed, 193 insertions(+), 207 deletions(-) diff --git a/coders/jpeg.c b/coders/jpeg.c index e32a3b182..164c9399f 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -178,7 +178,7 @@ typedef struct _QuantizationTable Const declarations. */ static const char - *xmp_namespace = "http://ns.adobe.com/xap/1.0/ "; + xmp_namespace[] = "http://ns.adobe.com/xap/1.0/ "; #define XmpNamespaceExtent 28 /* diff --git a/coders/ps3.c b/coders/ps3.c index 7b9722fcd..29e8900b2 100644 --- a/coders/ps3.c +++ b/coders/ps3.c @@ -624,196 +624,191 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image, ExceptionInfo *exception) { static const char - *const PostscriptProlog[]= - { - "/ByteStreamDecodeFilter", - "{", - " /z exch def", - " /r exch def", - " /c exch def", - " z " PS3_NoCompression " eq { /ASCII85Decode filter } if", - " z " PS3_FaxCompression " eq", - " {", - " <<", - " /K " CCITTParam, - " /Columns c", - " /Rows r", - " >>", - " /CCITTFaxDecode filter", - " } if", - " z " PS3_JPEGCompression " eq { /DCTDecode filter } if", - " z " PS3_LZWCompression " eq { /LZWDecode filter } if", - " z " PS3_RLECompression " eq { /RunLengthDecode filter } if", - " z " PS3_ZipCompression " eq { /FlateDecode filter } if", - "} bind def", - "", - "/DirectClassImageDict", - "{", - " colorspace " PS3_RGBColorspace " eq", - " {", - " /DeviceRGB setcolorspace", - " <<", - " /ImageType 1", - " /Width columns", - " /Height rows", - " /BitsPerComponent 8", - " /DataSource pixel_stream", - " /MultipleDataSources false", - " /ImageMatrix [columns 0 0 rows neg 0 rows]", - " /Decode [0 1 0 1 0 1]", - " >>", - " }", - " {", - " /DeviceCMYK setcolorspace", - " <<", - " /ImageType 1", - " /Width columns", - " /Height rows", - " /BitsPerComponent 8", - " /DataSource pixel_stream", - " /MultipleDataSources false", - " /ImageMatrix [columns 0 0 rows neg 0 rows]", - " /Decode", - " compression " PS3_JPEGCompression " eq", - " { [1 0 1 0 1 0 1 0] }", - " { [0 1 0 1 0 1 0 1] }", - " ifelse", - " >>", - " }", - " ifelse", - "} bind def", - "", - "/PseudoClassImageDict", - "{", - " % Colors in colormap image.", - " currentfile buffer readline pop", - " token pop /colors exch def pop", - " colors 0 eq", - " {", - " % Depth of grayscale image.", - " currentfile buffer readline pop", - " token pop /bits exch def pop", - " /DeviceGray setcolorspace", - " <<", - " /ImageType 1", - " /Width columns", - " /Height rows", - " /BitsPerComponent bits", - " /Decode [0 1]", - " /ImageMatrix [columns 0 0 rows neg 0 rows]", - " /DataSource pixel_stream", - " >>", - " }", - " {", - " % RGB colormap.", - " /colormap colors 3 mul string def", - " compression " PS3_NoCompression " eq", - " { currentfile /ASCII85Decode filter colormap readstring pop pop }", - " { currentfile colormap readstring pop pop }", - " ifelse", - " [ /Indexed /DeviceRGB colors 1 sub colormap ] setcolorspace", - " <<", - " /ImageType 1", - " /Width columns", - " /Height rows", - " /BitsPerComponent 8", - " /Decode [0 255]", - " /ImageMatrix [columns 0 0 rows neg 0 rows]", - " /DataSource pixel_stream", - " >>", - " }", - " ifelse", - "} bind def", - "", - "/NonMaskedImageDict", - "{", - " class " PS3_PseudoClass " eq", - " { PseudoClassImageDict }", - " { DirectClassImageDict }", - " ifelse", - "} bind def", - "", - "/MaskedImageDict", - "{", - " <<", - " /ImageType 3", - " /InterleaveType 3", - " /DataDict NonMaskedImageDict", - " /MaskDict", - " <<", - " /ImageType 1", - " /Width columns", - " /Height rows", - " /BitsPerComponent 1", - " /DataSource mask_stream", - " /MultipleDataSources false", - " /ImageMatrix [ columns 0 0 rows neg 0 rows]", - " /Decode [ 0 1 ]", - " >>", - " >>", - "} bind def", - "", - "/ClipImage", - "{} def", - "", - "/DisplayImage", - "{", - " gsave", - " /buffer 512 string def", - " % Translation.", - " currentfile buffer readline pop", - " token pop /x exch def", - " token pop /y exch def pop", - " x y translate", - " % Image size and font size.", - " currentfile buffer readline pop", - " token pop /x exch def", - " token pop /y exch def pop", - " currentfile buffer readline pop", - " token pop /pointsize exch def pop", - (const char *) NULL - }, - *const PostscriptEpilog[]= - { - " x y scale", - " % Clipping path.", - " currentfile buffer readline pop", - " token pop /clipped exch def pop", - " % Showpage.", - " currentfile buffer readline pop", - " token pop /sp exch def pop", - " % Image pixel size.", - " currentfile buffer readline pop", - " token pop /columns exch def", - " token pop /rows exch def pop", - " % Colorspace (RGB/CMYK).", - " currentfile buffer readline pop", - " token pop /colorspace exch def pop", - " % Transparency.", - " currentfile buffer readline pop", - " token pop /alpha exch def pop", - " % Stencil mask?", - " currentfile buffer readline pop", - " token pop /stencil exch def pop", - " % Image class (direct/pseudo).", - " currentfile buffer readline pop", - " token pop /class exch def pop", - " % Compression type.", - " currentfile buffer readline pop", - " token pop /compression exch def pop", - " % Clip and render.", - " /pixel_stream currentfile columns rows compression ByteStreamDecodeFilter def", - " clipped { ClipImage } if", - " alpha stencil not and", - " { MaskedImageDict mask_stream resetfile }", - " { NonMaskedImageDict }", - " ifelse", - " stencil { 0 setgray imagemask } { image } ifelse", - " grestore", - " sp { showpage } if", - "} bind def", - (const char *) NULL - }; + PostscriptProlog[] = + "/ByteStreamDecodeFilter\n" + "{\n" + " /z exch def\n" + " /r exch def\n" + " /c exch def\n" + " z " PS3_NoCompression " eq { /ASCII85Decode filter } if\n" + " z " PS3_FaxCompression " eq\n" + " {\n" + " <<\n" + " /K " CCITTParam "\n" + " /Columns c\n" + " /Rows r\n" + " >>\n" + " /CCITTFaxDecode filter\n" + " } if\n" + " z " PS3_JPEGCompression " eq { /DCTDecode filter } if\n" + " z " PS3_LZWCompression " eq { /LZWDecode filter } if\n" + " z " PS3_RLECompression " eq { /RunLengthDecode filter } if\n" + " z " PS3_ZipCompression " eq { /FlateDecode filter } if\n" + "} bind def\n" + "\n" + "/DirectClassImageDict\n" + "{\n" + " colorspace " PS3_RGBColorspace " eq\n" + " {\n" + " /DeviceRGB setcolorspace\n" + " <<\n" + " /ImageType 1\n" + " /Width columns\n" + " /Height rows\n" + " /BitsPerComponent 8\n" + " /DataSource pixel_stream\n" + " /MultipleDataSources false\n" + " /ImageMatrix [columns 0 0 rows neg 0 rows]\n" + " /Decode [0 1 0 1 0 1]\n" + " >>\n" + " }\n" + " {\n" + " /DeviceCMYK setcolorspace\n" + " <<\n" + " /ImageType 1\n" + " /Width columns\n" + " /Height rows\n" + " /BitsPerComponent 8\n" + " /DataSource pixel_stream\n" + " /MultipleDataSources false\n" + " /ImageMatrix [columns 0 0 rows neg 0 rows]\n" + " /Decode\n" + " compression " PS3_JPEGCompression " eq\n" + " { [1 0 1 0 1 0 1 0] }\n" + " { [0 1 0 1 0 1 0 1] }\n" + " ifelse\n" + " >>\n" + " }\n" + " ifelse\n" + "} bind def\n" + "\n" + "/PseudoClassImageDict\n" + "{\n" + " % Colors in colormap image.\n" + " currentfile buffer readline pop\n" + " token pop /colors exch def pop\n" + " colors 0 eq\n" + " {\n" + " % Depth of grayscale image.\n" + " currentfile buffer readline pop\n" + " token pop /bits exch def pop\n" + " /DeviceGray setcolorspace\n" + " <<\n" + " /ImageType 1\n" + " /Width columns\n" + " /Height rows\n" + " /BitsPerComponent bits\n" + " /Decode [0 1]\n" + " /ImageMatrix [columns 0 0 rows neg 0 rows]\n" + " /DataSource pixel_stream\n" + " >>\n" + " }\n" + " {\n" + " % RGB colormap.\n" + " /colormap colors 3 mul string def\n" + " compression " PS3_NoCompression " eq\n" + " { currentfile /ASCII85Decode filter colormap readstring pop pop }\n" + " { currentfile colormap readstring pop pop }\n" + " ifelse\n" + " [ /Indexed /DeviceRGB colors 1 sub colormap ] setcolorspace\n" + " <<\n" + " /ImageType 1\n" + " /Width columns\n" + " /Height rows\n" + " /BitsPerComponent 8\n" + " /Decode [0 255]\n" + " /ImageMatrix [columns 0 0 rows neg 0 rows]\n" + " /DataSource pixel_stream\n" + " >>\n" + " }\n" + " ifelse\n" + "} bind def\n" + "\n" + "/NonMaskedImageDict\n" + "{\n" + " class " PS3_PseudoClass " eq\n" + " { PseudoClassImageDict }\n" + " { DirectClassImageDict }\n" + " ifelse\n" + "} bind def\n" + "\n" + "/MaskedImageDict\n" + "{\n" + " <<\n" + " /ImageType 3\n" + " /InterleaveType 3\n" + " /DataDict NonMaskedImageDict\n" + " /MaskDict\n" + " <<\n" + " /ImageType 1\n" + " /Width columns\n" + " /Height rows\n" + " /BitsPerComponent 1\n" + " /DataSource mask_stream\n" + " /MultipleDataSources false\n" + " /ImageMatrix [ columns 0 0 rows neg 0 rows]\n" + " /Decode [ 0 1 ]\n" + " >>\n" + " >>\n" + "} bind def\n" + "\n" + "/ClipImage\n" + "{} def\n" + "\n" + "/DisplayImage\n" + "{\n" + " gsave\n" + " /buffer 512 string def\n" + " % Translation.\n" + " currentfile buffer readline pop\n" + " token pop /x exch def\n" + " token pop /y exch def pop\n" + " x y translate\n" + " % Image size and font size.\n" + " currentfile buffer readline pop\n" + " token pop /x exch def\n" + " token pop /y exch def pop\n" + " currentfile buffer readline pop\n" + " token pop /pointsize exch def pop\n"; + static const char + PostscriptEpilog[] = + " x y scale\n" + " % Clipping path.\n" + " currentfile buffer readline pop\n" + " token pop /clipped exch def pop\n" + " % Showpage.\n" + " currentfile buffer readline pop\n" + " token pop /sp exch def pop\n" + " % Image pixel size.\n" + " currentfile buffer readline pop\n" + " token pop /columns exch def\n" + " token pop /rows exch def pop\n" + " % Colorspace (RGB/CMYK).\n" + " currentfile buffer readline pop\n" + " token pop /colorspace exch def pop\n" + " % Transparency.\n" + " currentfile buffer readline pop\n" + " token pop /alpha exch def pop\n" + " % Stencil mask?\n" + " currentfile buffer readline pop\n" + " token pop /stencil exch def pop\n" + " % Image class (direct/pseudo).\n" + " currentfile buffer readline pop\n" + " token pop /class exch def pop\n" + " % Compression type.\n" + " currentfile buffer readline pop\n" + " token pop /compression exch def pop\n" + " % Clip and render.\n" + " /pixel_stream currentfile columns rows compression ByteStreamDecodeFilter def\n" + " clipped { ClipImage } if\n" + " alpha stencil not and\n" + " { MaskedImageDict mask_stream resetfile }\n" + " { NonMaskedImageDict }\n" + " ifelse\n" + " stencil { 0 setgray imagemask } { image } ifelse\n" + " grestore\n" + " sp { showpage } if\n" + "} bind def\n"; char buffer[MagickPathExtent], @@ -826,7 +821,6 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image, const char *option, - *const *q, *value; double @@ -1084,19 +1078,15 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image, /* The static postscript procedures prolog. */ - (void)WriteBlobString(image,"%%BeginProlog\n"); - for (q=PostscriptProlog; *q; q++) - { - (void) WriteBlobString(image,*q); - (void) WriteBlobByte(image,'\n'); - } + (void) WriteBlobString(image,"%%BeginProlog\n"); + (void) WriteBlob(image,sizeof(PostscriptProlog)-1,PostscriptProlog); /* One label line for each line in label string. */ value=GetImageProperty(image,"label",exception); if (value != (const char *) NULL) { - (void) WriteBlobString(image,"\n %% Labels.\n /Helvetica " + (void) WriteBlobString(image,"\n %% Labels.\n /Helvetica " " findfont pointsize scalefont setfont\n"); for (i=(ssize_t) MultilineCensus(value)-1; i >= 0; i--) { @@ -1110,12 +1100,8 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image, /* The static postscript procedures epilog. */ - for (q=PostscriptEpilog; *q; q++) - { - (void) WriteBlobString(image,*q); - (void) WriteBlobByte(image,'\n'); - } - (void)WriteBlobString(image,"%%EndProlog\n"); + (void) WriteBlob(image,sizeof(PostscriptEpilog)-1,PostscriptEpilog); + (void) WriteBlobString(image,"%%EndProlog\n"); } (void) FormatLocaleString(buffer,MagickPathExtent,"%%%%Page: 1 %.20g\n", (double) page); diff --git a/coders/sfw.c b/coders/sfw.c index 345dcb061..0d02e44f8 100644 --- a/coders/sfw.c +++ b/coders/sfw.c @@ -155,7 +155,7 @@ static void TranslateSFWMarker(unsigned char *marker) static Image *ReadSFWImage(const ImageInfo *image_info,ExceptionInfo *exception) { - static unsigned char + static const unsigned char HuffmanTable[] = { 0xFF, 0xC4, 0x01, 0xA2, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, diff --git a/coders/ttf.c b/coders/ttf.c index 57779a844..633280058 100644 --- a/coders/ttf.c +++ b/coders/ttf.c @@ -172,7 +172,7 @@ static Image *ReadTTFImage(const ImageInfo *image_info,ExceptionInfo *exception) *text; const char - *Text = (char *) + Text[] = "abcdefghijklmnopqrstuvwxyz\n" "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n" "0123456789.:,;(*!?}^)#${%^&-+@\n"; -- 2.40.0