...
diff --git a/coders/ps2.c b/coders/ps2.c
index 1ed77e3..6cd898a 100644
--- a/coders/ps2.c
+++ b/coders/ps2.c
@@ -227,157 +227,151 @@
ExceptionInfo *exception)
{
static const char
- *const PostscriptProlog[]=
- {
- "%%%%BeginProlog",
- "%%",
- "%% Display a color image. The image is displayed in color on",
- "%% Postscript viewers or printers that support color, otherwise",
- "%% it is displayed as grayscale.",
- "%%",
- "/DirectClassImage",
- "{",
- " %%",
- " %% Display a DirectClass image.",
- " %%",
- " colorspace 0 eq",
- " {",
- " /DeviceRGB setcolorspace",
- " <<",
- " /ImageType 1",
- " /Width columns",
- " /Height rows",
- " /BitsPerComponent 8",
- " /Decode [0 1 0 1 0 1]",
- " /ImageMatrix [columns 0 0 rows neg 0 rows]",
- " compression 0 gt",
- " { /DataSource pixel_stream %s }",
- " { /DataSource pixel_stream %s } ifelse",
- " >> image",
- " }",
- " {",
- " /DeviceCMYK setcolorspace",
- " <<",
- " /ImageType 1",
- " /Width columns",
- " /Height rows",
- " /BitsPerComponent 8",
- " /Decode [1 0 1 0 1 0 1 0]",
- " /ImageMatrix [columns 0 0 rows neg 0 rows]",
- " compression 0 gt",
- " { /DataSource pixel_stream %s }",
- " { /DataSource pixel_stream %s } ifelse",
- " >> image",
- " } ifelse",
- "} bind def",
- "",
- "/PseudoClassImage",
- "{",
- " %%",
- " %% Display a PseudoClass image.",
- " %%",
- " %% Parameters:",
- " %% colors: number of colors in the colormap.",
- " %%",
- " currentfile buffer readline pop",
- " token pop /colors exch def pop",
- " colors 0 eq",
- " {",
- " %%",
- " %% Image is grayscale.",
- " %%",
- " 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]",
- " compression 0 gt",
- " { /DataSource pixel_stream %s }",
- " {",
- " /DataSource pixel_stream %s",
- " <<",
- " /K " CCITTParam,
- " /Columns columns",
- " /Rows rows",
- " >> /CCITTFaxDecode filter",
- " } ifelse",
- " >> image",
- " }",
- " {",
- " %%",
- " %% Parameters:",
- " %% colormap: red, green, blue color packets.",
- " %%",
- " /colormap colors 3 mul string def",
- " currentfile colormap readhexstring pop pop",
- " currentfile buffer readline pop",
- " [ /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]",
- " compression 0 gt",
- " { /DataSource pixel_stream %s }",
- " { /DataSource pixel_stream %s } ifelse",
- " >> image",
- " } ifelse",
- "} bind def",
- "",
- "/DisplayImage",
- "{",
- " %%",
- " %% Display a DirectClass or PseudoClass image.",
- " %%",
- " %% Parameters:",
- " %% x & y translation.",
- " %% x & y scale.",
- " %% label pointsize.",
- " %% image label.",
- " %% image columns & rows.",
- " %% class: 0-DirectClass or 1-PseudoClass.",
- " %% colorspace: 0-RGB or 1-CMYK.",
- " %% compression: 0-RLECompression or 1-NoCompression.",
- " %% hex color packets.",
- " %%",
- " gsave",
- " /buffer 512 string def",
- " /pixel_stream currentfile def",
- "",
- " currentfile buffer readline pop",
- " token pop /x exch def",
- " token pop /y exch def pop",
- " x y translate",
- " 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",
- " currentfile buffer readline pop",
- " token pop /columns exch def",
- " token pop /rows exch def pop",
- " currentfile buffer readline pop",
- " token pop /class exch def pop",
- " currentfile buffer readline pop",
- " token pop /colorspace exch def pop",
- " currentfile buffer readline pop",
- " token pop /compression exch def pop",
- " class 0 gt { PseudoClassImage } { DirectClassImage } ifelse",
- " grestore",
- (const char *) NULL
- };
+ PostscriptProlog[] =
+ "%%%%BeginProlog\n"
+ "%%\n"
+ "%% Display a color image. The image is displayed in color on\n"
+ "%% Postscript viewers or printers that support color, otherwise\n"
+ "%% it is displayed as grayscale.\n"
+ "%%\n"
+ "/DirectClassImage\n"
+ "{\n"
+ " %%\n"
+ " %% Display a DirectClass image.\n"
+ " %%\n"
+ " colorspace 0 eq\n"
+ " {\n"
+ " /DeviceRGB setcolorspace\n"
+ " <<\n"
+ " /ImageType 1\n"
+ " /Width columns\n"
+ " /Height rows\n"
+ " /BitsPerComponent 8\n"
+ " /Decode [0 1 0 1 0 1]\n"
+ " /ImageMatrix [columns 0 0 rows neg 0 rows]\n"
+ " compression 0 gt\n"
+ " { /DataSource pixel_stream %s }\n"
+ " { /DataSource pixel_stream %s } ifelse\n"
+ " >> image\n"
+ " }\n"
+ " {\n"
+ " /DeviceCMYK setcolorspace\n"
+ " <<\n"
+ " /ImageType 1\n"
+ " /Width columns\n"
+ " /Height rows\n"
+ " /BitsPerComponent 8\n"
+ " /Decode [1 0 1 0 1 0 1 0]\n"
+ " /ImageMatrix [columns 0 0 rows neg 0 rows]\n"
+ " compression 0 gt\n"
+ " { /DataSource pixel_stream %s }\n"
+ " { /DataSource pixel_stream %s } ifelse\n"
+ " >> image\n"
+ " } ifelse\n"
+ "} bind def\n"
+ "\n"
+ "/PseudoClassImage\n"
+ "{\n"
+ " %%\n"
+ " %% Display a PseudoClass image.\n"
+ " %%\n"
+ " %% Parameters:\n"
+ " %% colors: number of colors in the colormap.\n"
+ " %%\n"
+ " currentfile buffer readline pop\n"
+ " token pop /colors exch def pop\n"
+ " colors 0 eq\n"
+ " {\n"
+ " %%\n"
+ " %% Image is grayscale.\n"
+ " %%\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"
+ " compression 0 gt\n"
+ " { /DataSource pixel_stream %s }\n"
+ " {\n"
+ " /DataSource pixel_stream %s\n"
+ " <<\n"
+ " /K " CCITTParam "\n"
+ " /Columns columns\n"
+ " /Rows rows\n"
+ " >> /CCITTFaxDecode filter\n"
+ " } ifelse\n"
+ " >> image\n"
+ " }\n"
+ " {\n"
+ " %%\n"
+ " %% Parameters:\n"
+ " %% colormap: red, green, blue color packets.\n"
+ " %%\n"
+ " /colormap colors 3 mul string def\n"
+ " currentfile colormap readhexstring pop pop\n"
+ " currentfile buffer readline pop\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"
+ " compression 0 gt\n"
+ " { /DataSource pixel_stream %s }\n"
+ " { /DataSource pixel_stream %s } ifelse\n"
+ " >> image\n"
+ " } ifelse\n"
+ "} bind def\n"
+ "\n"
+ "/DisplayImage\n"
+ "{\n"
+ " %%\n"
+ " %% Display a DirectClass or PseudoClass image.\n"
+ " %%\n"
+ " %% Parameters:\n"
+ " %% x & y translation.\n"
+ " %% x & y scale.\n"
+ " %% label pointsize.\n"
+ " %% image label.\n"
+ " %% image columns & rows.\n"
+ " %% class: 0-DirectClass or 1-PseudoClass.\n"
+ " %% colorspace: 0-RGB or 1-CMYK.\n"
+ " %% compression: 0-RLECompression or 1-NoCompression.\n"
+ " %% hex color packets.\n"
+ " %%\n"
+ " gsave\n"
+ " /buffer 512 string def\n"
+ " /pixel_stream currentfile def\n"
+ "\n"
+ " currentfile buffer readline pop\n"
+ " token pop /x exch def\n"
+ " token pop /y exch def pop\n"
+ " x y translate\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",
+ PostscriptEpilog[] =
+ " x y scale\n"
+ " currentfile buffer readline pop\n"
+ " token pop /columns exch def\n"
+ " token pop /rows exch def pop\n"
+ " currentfile buffer readline pop\n"
+ " token pop /class exch def pop\n"
+ " currentfile buffer readline pop\n"
+ " token pop /colorspace exch def pop\n"
+ " currentfile buffer readline pop\n"
+ " token pop /compression exch def pop\n"
+ " class 0 gt { PseudoClassImage } { DirectClassImage } ifelse\n"
+ " grestore\n";
char
buffer[MagickPathExtent],
@@ -389,7 +383,7 @@
compression;
const char
- *const *q,
+ *filter,
*value;
double
@@ -622,44 +616,38 @@
/*
Output Postscript commands.
*/
- for (q=PostscriptProlog; *q; q++)
+ switch (compression)
{
- switch (compression)
+ case NoCompression:
{
- case NoCompression:
- {
- (void) FormatLocaleString(buffer,MagickPathExtent,*q,
- "/ASCII85Decode filter");
- break;
- }
- case JPEGCompression:
- {
- (void) FormatLocaleString(buffer,MagickPathExtent,*q,
- "/DCTDecode filter");
- break;
- }
- case LZWCompression:
- {
- (void) FormatLocaleString(buffer,MagickPathExtent,*q,
- "/LZWDecode filter");
- break;
- }
- case FaxCompression:
- case Group4Compression:
- {
- (void) FormatLocaleString(buffer,MagickPathExtent,*q," ");
- break;
- }
- default:
- {
- (void) FormatLocaleString(buffer,MagickPathExtent,*q,
- "/RunLengthDecode filter");
- break;
- }
+ filter="/ASCII85Decode filter";
+ break;
}
- (void) WriteBlobString(image,buffer);
- (void) WriteBlobByte(image,'\n');
+ case JPEGCompression:
+ {
+ filter="/DCTDecode filter";
+ break;
+ }
+ case LZWCompression:
+ {
+ filter="/LZWDecode filter";
+ break;
+ }
+ case FaxCompression:
+ case Group4Compression:
+ {
+ filter=" ";
+ break;
+ }
+ default:
+ {
+ filter="/RunLengthDecode filter";
+ break;
+ }
}
+ (void) FormatLocaleString(buffer,MagickPathExtent,PostscriptProlog,
+ filter,filter,filter,filter,filter,filter,filter,filter);
+ (void) WriteBlob(image,strlen(buffer),buffer);
value=GetImageProperty(image,"label",exception);
if (value != (const char *) NULL)
{
@@ -675,11 +663,8 @@
(void) WriteBlobString(image,buffer);
}
}
- for (q=PostscriptEpilog; *q; q++)
- {
- (void) FormatLocaleString(buffer,MagickPathExtent,"%s\n",*q);
- (void) WriteBlobString(image,buffer);
- }
+ (void) WriteBlob(image,sizeof(PostscriptEpilog)-1,
+ (const unsigned char *) PostscriptEpilog);
if (LocaleCompare(image_info->magick,"PS2") == 0)
(void) WriteBlobString(image," showpage\n");
(void) WriteBlobString(image,"} bind def\n");