% June 2000 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
/*
Include declarations.
*/
-#include "magick/studio.h"
-#include "magick/blob.h"
-#include "magick/blob-private.h"
-#include "magick/color-private.h"
-#include "magick/colormap.h"
-#include "magick/colormap-private.h"
-#include "magick/constitute.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/cache.h"
-#include "magick/image.h"
-#include "magick/image-private.h"
-#include "magick/list.h"
-#include "magick/magic.h"
-#include "magick/magick.h"
-#include "magick/memory_.h"
-#include "magick/resource_.h"
-#include "magick/quantum-private.h"
-#include "magick/shear.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/module.h"
-#include "magick/transform.h"
-#include "magick/utility.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/color-private.h"
+#include "MagickCore/colormap.h"
+#include "MagickCore/colormap-private.h"
+#include "MagickCore/constitute.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/cache.h"
+#include "MagickCore/distort.h"
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/magic.h"
+#include "MagickCore/magick.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/resource_.h"
+#include "MagickCore/pixel-accessor.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
+#include "MagickCore/transform.h"
+#include "MagickCore/utility.h"
+#include "MagickCore/utility-private.h"
\f
typedef struct
{
return;
}
-static void InsertRow(unsigned char *p,ssize_t y,Image *image, int bpp)
+static void InsertRow(Image *image,unsigned char *p,ssize_t y,int bpp,
+ ExceptionInfo *exception)
{
- ExceptionInfo
- *exception;
-
int
bit;
- ssize_t
- x;
+ Quantum
+ index;
- register PixelPacket
+ register Quantum
*q;
- IndexPacket
- index;
-
- register IndexPacket
- *indexes;
+ ssize_t
+ x;
- exception=(&image->exception);
switch (bpp)
{
case 1: /* Convert bitmap scanline. */
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
- indexes=GetAuthenticIndexQueue(image);
for (x=0; x < ((ssize_t) image->columns-7); x+=8)
+ {
+ for (bit=0; bit < 8; bit++)
{
- for (bit=0; bit < 8; bit++)
- {
- index=((*p) & (0x80 >> bit) ? 0x01 : 0x00);
- SetIndexPixelComponent(indexes+x+bit,index);
- SetRGBOPixelComponent(q,image->colormap+index);
- q++;
- }
- p++;
+ index=((*p) & (0x80 >> bit) ? 0x01 : 0x00);
+ SetPixelIndex(image,index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
+ q+=GetPixelChannels(image);
}
+ p++;
+ }
if ((image->columns % 8) != 0)
{
for (bit=0; bit < (ssize_t) (image->columns % 8); bit++)
- {
- index=((*p) & (0x80 >> bit) ? 0x01 : 0x00);
- SetIndexPixelComponent(indexes+x+bit,index);
- SetRGBOPixelComponent(q,image->colormap+index);
- q++;
- }
+ {
+ index=((*p) & (0x80 >> bit) ? 0x01 : 0x00);
+ SetPixelIndex(image,index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
+ q+=GetPixelChannels(image);
+ }
p++;
}
if (!SyncAuthenticPixels(image,exception))
case 2: /* Convert PseudoColor scanline. */
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
- indexes=GetAuthenticIndexQueue(image);
for (x=0; x < ((ssize_t) image->columns-1); x+=2)
{
- index=ConstrainColormapIndex(image,(*p >> 6) & 0x3);
- SetIndexPixelComponent(indexes+x,index);
- SetRGBOPixelComponent(q,image->colormap+index);
- q++;
- index=ConstrainColormapIndex(image,(*p >> 4) & 0x3);
- SetIndexPixelComponent(indexes+x,index);
- SetRGBOPixelComponent(q,image->colormap+index);
- q++;
- index=ConstrainColormapIndex(image,(*p >> 2) & 0x3);
- SetIndexPixelComponent(indexes+x,index);
- SetRGBOPixelComponent(q,image->colormap+index);
- q++;
- index=ConstrainColormapIndex(image,(*p) & 0x3);
- SetIndexPixelComponent(indexes+x+1,index);
- SetRGBOPixelComponent(q,image->colormap+index);
+ index=ConstrainColormapIndex(image,(*p >> 6) & 0x3,exception);
+ SetPixelIndex(image,index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
+ q+=GetPixelChannels(image);
+ index=ConstrainColormapIndex(image,(*p >> 4) & 0x3,exception);
+ SetPixelIndex(image,index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
+ q+=GetPixelChannels(image);
+ index=ConstrainColormapIndex(image,(*p >> 2) & 0x3,exception);
+ SetPixelIndex(image,index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
+ q+=GetPixelChannels(image);
+ index=ConstrainColormapIndex(image,(*p) & 0x3,exception);
+ SetPixelIndex(image,index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
p++;
- q++;
+ q+=GetPixelChannels(image);
}
if ((image->columns % 4) != 0)
{
- index=ConstrainColormapIndex(image,(*p >> 6) & 0x3);
- SetIndexPixelComponent(indexes+x,index);
- SetRGBOPixelComponent(q,image->colormap+index);
- q++;
+ index=ConstrainColormapIndex(image,(*p >> 6) & 0x3,exception);
+ SetPixelIndex(image,index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
+ q+=GetPixelChannels(image);
if ((image->columns % 4) >= 1)
{
- index=ConstrainColormapIndex(image,(*p >> 4) & 0x3);
- SetIndexPixelComponent(indexes+x,index);
- SetRGBOPixelComponent(q,image->colormap+index);
- q++;
+ index=ConstrainColormapIndex(image,(*p >> 4) & 0x3,exception);
+ SetPixelIndex(image,index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
+ q+=GetPixelChannels(image);
if ((image->columns % 4) >= 2)
{
- index=ConstrainColormapIndex(image,(*p >> 2) & 0x3);
- SetIndexPixelComponent(indexes+x,index);
- SetRGBOPixelComponent(q,image->colormap+index);
- q++;
+ index=ConstrainColormapIndex(image,(*p >> 2) & 0x3,
+ exception);
+ SetPixelIndex(image,index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
+ q+=GetPixelChannels(image);
}
}
p++;
case 4: /* Convert PseudoColor scanline. */
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
- indexes=GetAuthenticIndexQueue(image);
for (x=0; x < ((ssize_t) image->columns-1); x+=2)
{
- index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f);
- SetIndexPixelComponent(indexes+x,index);
- SetRGBOPixelComponent(q,image->colormap+index);
- q++;
- index=ConstrainColormapIndex(image,(*p) & 0x0f);
- SetIndexPixelComponent(indexes+x+1,index);
- SetRGBOPixelComponent(q,image->colormap+index);
+ index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f,exception);
+ SetPixelIndex(image,index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
+ q+=GetPixelChannels(image);
+ index=ConstrainColormapIndex(image,(*p) & 0x0f,exception);
+ SetPixelIndex(image,index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
p++;
- q++;
+ q+=GetPixelChannels(image);
}
if ((image->columns % 2) != 0)
{
- index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f);
- SetIndexPixelComponent(indexes+x,index);
- SetRGBOPixelComponent(q,image->colormap+index);
+ index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f,exception);
+ SetPixelIndex(image,index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
p++;
- q++;
+ q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
case 8: /* Convert PseudoColor scanline. */
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL) break;
- indexes=GetAuthenticIndexQueue(image);
+ if (q == (Quantum *) NULL) break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- index=ConstrainColormapIndex(image,*p);
- SetIndexPixelComponent(indexes+x,index);
- SetRGBOPixelComponent(q,image->colormap+index);
+ index=ConstrainColormapIndex(image,*p,exception);
+ SetPixelIndex(image,index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
p++;
- q++;
+ q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
case 24: /* Convert DirectColor scanline. */
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- SetRedPixelComponent(q,ScaleCharToQuantum(*p++));
- SetGreenPixelComponent(q,ScaleCharToQuantum(*p++));
- SetBluePixelComponent(q,ScaleCharToQuantum(*p++));
- q++;
+ SetPixelRed(image,ScaleCharToQuantum(*p++),q);
+ SetPixelGreen(image,ScaleCharToQuantum(*p++),q);
+ SetPixelBlue(image,ScaleCharToQuantum(*p++),q);
+ q+=GetPixelChannels(image);
}
if (!SyncAuthenticPixels(image,exception))
break;
x++; \
if((ssize_t) x>=ldblk) \
{ \
- InsertRow(BImgBuff,(ssize_t) y,image,bpp); \
+ InsertRow(image,BImgBuff,(ssize_t) y,bpp,exception); \
x=0; \
y++; \
} \
}
/* WPG1 raster reader. */
-static int UnpackWPGRaster(Image *image,int bpp)
+static int UnpackWPGRaster(Image *image,int bpp,ExceptionInfo *exception)
{
int
x,
BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff);
return(-4);
}
- InsertRow(BImgBuff,y-1,image,bpp);
+ InsertRow(image,BImgBuff,y-1,bpp,exception);
}
}
}
x++; \
if((ssize_t) x >= ldblk) \
{ \
- InsertRow(BImgBuff,(ssize_t) y,image,bpp); \
+ InsertRow(image,BImgBuff,(ssize_t) y,bpp,exception); \
x=0; \
y++; \
} \
}
/* WPG2 raster reader. */
-static int UnpackWPG2Raster(Image *image,int bpp)
+static int UnpackWPG2Raster(Image *image,int bpp,ExceptionInfo *exception)
{
size_t
x,
/* duplicate the previous row RunCount x */
for(i=0;i<=RunCount;i++)
{
- InsertRow(BImgBuff,(ssize_t) (image->rows >= y ? y : image->rows-1),
- image,bpp);
+ InsertRow(image,BImgBuff,(ssize_t) (image->rows >= y ? y : image->rows-1),
+ bpp,exception);
y++;
}
}
/* Obtain temporary file */
AcquireUniqueFilename(postscript_file);
- ps_file=OpenMagickStream(postscript_file,"wb");
+ ps_file=fopen_utf8(postscript_file,"wb");
if (ps_file == (FILE *) NULL)
goto FINISH;
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
one=1;
- image=AcquireImage(image_info);
+ image=AcquireImage(image_info,exception);
image->depth=8;
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
if(BitmapHeader1.HorzRes && BitmapHeader1.VertRes)
{
image->units=PixelsPerCentimeterResolution;
- image->x_resolution=BitmapHeader1.HorzRes/470.0;
- image->y_resolution=BitmapHeader1.VertRes/470.0;
+ image->resolution.x=BitmapHeader1.HorzRes/470.0;
+ image->resolution.y=BitmapHeader1.VertRes/470.0;
}
image->columns=BitmapHeader1.Width;
image->rows=BitmapHeader1.Heigth;
WPG_Palette.NumOfEntries=ReadBlobLSBShort(image);
image->colors=WPG_Palette.NumOfEntries;
- if (!AcquireImageColormap(image,image->colors))
+ if (!AcquireImageColormap(image,image->colors,exception))
goto NoMemory;
for (i=WPG_Palette.StartIndex;
i < (int)WPG_Palette.NumOfEntries; i++)
image->page.y=(int) (BitmapHeader2.LowLeftX/470.0);
if(BitmapHeader2.HorzRes && BitmapHeader2.VertRes)
{
- image->x_resolution=BitmapHeader2.HorzRes/470.0;
- image->y_resolution=BitmapHeader2.VertRes/470.0;
+ image->resolution.x=BitmapHeader2.HorzRes/470.0;
+ image->resolution.y=BitmapHeader2.VertRes/470.0;
}
image->columns=BitmapHeader2.Width;
image->rows=BitmapHeader2.Heigth;
if ((image->colors == 0) && (bpp != 24))
{
image->colors=one << bpp;
- if (!AcquireImageColormap(image,image->colors))
+ if (!AcquireImageColormap(image,image->colors,exception))
{
NoMemory:
ThrowReaderException(ResourceLimitError,
{
if (bpp < 24)
if ( (image->colors < (one << bpp)) && (bpp != 24) )
- image->colormap=(PixelPacket *) ResizeQuantumMemory(
+ image->colormap=(PixelInfo *) ResizeQuantumMemory(
image->colormap,(size_t) (one << bpp),
sizeof(*image->colormap));
}
}
}
- if(UnpackWPGRaster(image,bpp) < 0)
+ if(UnpackWPGRaster(image,bpp,exception) < 0)
/* The raster cannot be unpacked */
{
DecompressionFailed:
}
/* Allocate next image structure. */
- AcquireNextImage(image_info,image);
+ AcquireNextImage(image_info,image,exception);
image->depth=8;
if (image->next == (Image *) NULL)
goto Finish;
WPG_Palette.NumOfEntries=ReadBlobLSBShort(image);
image->colors=WPG_Palette.NumOfEntries;
- if (AcquireImageColormap(image,image->colors) == MagickFalse)
+ if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)
ThrowReaderException(ResourceLimitError,
"MemoryAllocationFailed");
for (i=WPG_Palette.StartIndex;
one=1;
image->colors=one << bpp;
- if (!AcquireImageColormap(image,image->colors))
+ if (!AcquireImageColormap(image,image->colors,exception))
goto NoMemory;
}
else
{
if(bpp < 24)
if( image->colors<(one << bpp) && bpp!=24 )
- image->colormap=(PixelPacket *) ResizeQuantumMemory(
+ image->colormap=(PixelInfo *) ResizeQuantumMemory(
image->colormap,(size_t) (one << bpp),
sizeof(*image->colormap));
}
for(i=0; i< (ssize_t) image->rows; i++)
{
(void) ReadBlob(image,ldblk,BImgBuff);
- InsertRow(BImgBuff,i,image,bpp);
+ InsertRow(image,BImgBuff,i,bpp,exception);
}
if(BImgBuff)
}
case 1: /*RLE for WPG2 */
{
- if( UnpackWPG2Raster(image,bpp) < 0)
+ if( UnpackWPG2Raster(image,bpp,exception) < 0)
goto DecompressionFailed;
break;
}
/* Allocate next image structure. */
- AcquireNextImage(image_info,image);
+ AcquireNextImage(image_info,image,exception);
image->depth=8;
if (image->next == (Image *) NULL)
goto Finish;