% June 2000 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2012 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 "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/resource_.h"
#include "MagickCore/pixel-accessor.h"
#include "MagickCore/quantum-private.h"
-#include "MagickCore/shear.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;
- exception=(&image->exception);
switch (bpp)
{
case 1: /* Convert bitmap scanline. */
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
break;
for (x=0; x < ((ssize_t) image->columns-7); x+=8)
{
{
index=((*p) & (0x80 >> bit) ? 0x01 : 0x00);
SetPixelIndex(image,index,q);
- SetPixelPacket(image,image->colormap+(ssize_t) index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
q+=GetPixelChannels(image);
}
p++;
{
index=((*p) & (0x80 >> bit) ? 0x01 : 0x00);
SetPixelIndex(image,index,q);
- SetPixelPacket(image,image->colormap+(ssize_t) index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
q+=GetPixelChannels(image);
}
p++;
case 2: /* Convert PseudoColor scanline. */
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
break;
for (x=0; x < ((ssize_t) image->columns-1); x+=2)
{
- index=ConstrainColormapIndex(image,(*p >> 6) & 0x3);
+ index=ConstrainColormapIndex(image,(*p >> 6) & 0x3,exception);
SetPixelIndex(image,index,q);
- SetPixelPacket(image,image->colormap+(ssize_t) index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
q+=GetPixelChannels(image);
- index=ConstrainColormapIndex(image,(*p >> 4) & 0x3);
+ index=ConstrainColormapIndex(image,(*p >> 4) & 0x3,exception);
SetPixelIndex(image,index,q);
- SetPixelPacket(image,image->colormap+(ssize_t) index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
q+=GetPixelChannels(image);
- index=ConstrainColormapIndex(image,(*p >> 2) & 0x3);
+ index=ConstrainColormapIndex(image,(*p >> 2) & 0x3,exception);
SetPixelIndex(image,index,q);
- SetPixelPacket(image,image->colormap+(ssize_t) index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
q+=GetPixelChannels(image);
- index=ConstrainColormapIndex(image,(*p) & 0x3);
+ index=ConstrainColormapIndex(image,(*p) & 0x3,exception);
SetPixelIndex(image,index,q);
- SetPixelPacket(image,image->colormap+(ssize_t) index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
p++;
q+=GetPixelChannels(image);
}
if ((image->columns % 4) != 0)
{
- index=ConstrainColormapIndex(image,(*p >> 6) & 0x3);
+ index=ConstrainColormapIndex(image,(*p >> 6) & 0x3,exception);
SetPixelIndex(image,index,q);
- SetPixelPacket(image,image->colormap+(ssize_t) index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
q+=GetPixelChannels(image);
if ((image->columns % 4) >= 1)
{
- index=ConstrainColormapIndex(image,(*p >> 4) & 0x3);
+ index=ConstrainColormapIndex(image,(*p >> 4) & 0x3,exception);
SetPixelIndex(image,index,q);
- SetPixelPacket(image,image->colormap+(ssize_t) index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
q+=GetPixelChannels(image);
if ((image->columns % 4) >= 2)
{
- index=ConstrainColormapIndex(image,(*p >> 2) & 0x3);
+ index=ConstrainColormapIndex(image,(*p >> 2) & 0x3,
+ exception);
SetPixelIndex(image,index,q);
- SetPixelPacket(image,image->colormap+(ssize_t) index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
q+=GetPixelChannels(image);
}
}
case 4: /* Convert PseudoColor scanline. */
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
break;
for (x=0; x < ((ssize_t) image->columns-1); x+=2)
{
- index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f);
+ index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f,exception);
SetPixelIndex(image,index,q);
- SetPixelPacket(image,image->colormap+(ssize_t) index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
q+=GetPixelChannels(image);
- index=ConstrainColormapIndex(image,(*p) & 0x0f);
+ index=ConstrainColormapIndex(image,(*p) & 0x0f,exception);
SetPixelIndex(image,index,q);
- SetPixelPacket(image,image->colormap+(ssize_t) index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
p++;
q+=GetPixelChannels(image);
}
if ((image->columns % 2) != 0)
{
- index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f);
+ index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f,exception);
SetPixelIndex(image,index,q);
- SetPixelPacket(image,image->colormap+(ssize_t) index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
p++;
q+=GetPixelChannels(image);
}
case 8: /* Convert PseudoColor scanline. */
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (const Quantum *) NULL) break;
+ if (q == (Quantum *) NULL) break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- index=ConstrainColormapIndex(image,*p);
+ index=ConstrainColormapIndex(image,*p,exception);
SetPixelIndex(image,index,q);
- SetPixelPacket(image,image->colormap+(ssize_t) index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
p++;
q+=GetPixelChannels(image);
}
case 24: /* Convert DirectColor scanline. */
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
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;