% July 1992 %
% %
% %
-% 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/cache.h"
-#include "magick/colorspace.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/image.h"
-#include "magick/image-private.h"
-#include "magick/list.h"
-#include "magick/magick.h"
-#include "magick/memory_.h"
-#include "magick/monitor.h"
-#include "magick/monitor-private.h"
-#include "magick/quantum-private.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/module.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/cache.h"
+#include "MagickCore/colormap.h"
+#include "MagickCore/colorspace.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/magick.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/monitor.h"
+#include "MagickCore/monitor-private.h"
+#include "MagickCore/pixel-accessor.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MagickBooleanType
status;
+ register Quantum
+ *q;
+
register ssize_t
x;
- register PixelPacket
- *q;
-
register unsigned char
*p;
size_t
- height,
- length,
- width;
+ length;
ssize_t
- count,
+ offset,
y;
unsigned char
+ count,
+ bit,
+ byte,
*pixels;
/*
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- image=AcquireImage(image_info);
+ image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
/*
Read MAC X image.
*/
- width=ReadBlobMSBLong(image);
- height=ReadBlobMSBLong(image);
- if (EOFBlob(image) != MagickFalse)
- ThrowReaderException(CorruptImageError,"ImproperImageHeader");
- if ((width == 0UL) || (height == 0UL))
- ThrowReaderException(CorruptImageError,"ImproperImageHeader");
- do
- {
- /*
- Convert MAC raster image to pixel packets.
- */
- image->columns=width;
- image->rows=height;
- image->depth=8;
- if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
- if (image->scene >= (image_info->scene+image_info->number_scenes-1))
- break;
- pixels=(unsigned char *) AcquireQuantumMemory(image->columns,
- 4*sizeof(*pixels));
- if (pixels == (unsigned char *) NULL)
- ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
- length=(size_t) 4*image->columns;
- for (y=0; y < (ssize_t) image->rows; y++)
+ length=ReadBlobLSBShort(image);
+ if ((length & 0xff) != 0)
+ ThrowReaderException(CorruptImageError,"CorruptImage");
+ for (x=0; x < (ssize_t) 638; x++)
+ if (ReadBlobByte(image) == EOF)
+ ThrowReaderException(CorruptImageError,"CorruptImage");
+ image->columns=576;
+ image->rows=720;
+ image->depth=1;
+ if (AcquireImageColormap(image,2,exception) == MagickFalse)
+ ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ if (image_info->ping != MagickFalse)
{
- count=ReadBlob(image,length,pixels);
- if ((size_t) count != length)
- ThrowReaderException(CorruptImageError,"UnableToReadImageData");
- p=pixels;
- q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
- break;
- for (x=0; x < (ssize_t) image->columns; x++)
- {
- q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(*p++));
- q->red=ScaleCharToQuantum(*p++);
- q->green=ScaleCharToQuantum(*p++);
- q->blue=ScaleCharToQuantum(*p++);
- if (q->opacity != OpaqueOpacity)
- image->matte=MagickTrue;
- q++;
- }
- if (SyncAuthenticPixels(image,exception) == MagickFalse)
- break;
- if ((image->previous == (Image *) NULL) &&
- (SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,image->rows) == MagickFalse))
- break;
+ (void) CloseBlob(image);
+ return(GetFirstImageInList(image));
}
- pixels=(unsigned char *) RelinquishMagickMemory(pixels);
+ /*
+ Convert MAC raster image to pixel packets.
+ */
+ length=(image->columns+7)/8;
+ pixels=(unsigned char *) AcquireQuantumMemory(length+1,sizeof(*pixels));
+ if (pixels == (unsigned char *) NULL)
+ ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ p=pixels;
+ offset=0;
+ for (y=0; y < (ssize_t) image->rows; )
+ {
+ count=(unsigned char) ReadBlobByte(image);
if (EOFBlob(image) != MagickFalse)
+ break;
+ if ((count <= 0) || (count >= 128))
{
- ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
- image->filename);
- break;
+ byte=(unsigned char) (~ReadBlobByte(image));
+ count=(~count)+2;
+ while (count != 0)
+ {
+ *p++=byte;
+ offset++;
+ count--;
+ if (offset >= (ssize_t) length)
+ {
+ q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
+ if (q == (Quantum *) NULL)
+ break;
+ p=pixels;
+ bit=0;
+ byte=0;
+ for (x=0; x < (ssize_t) image->columns; x++)
+ {
+ if (bit == 0)
+ byte=(*p++);
+ SetPixelIndex(image,((byte & 0x80) != 0 ? 0x01 : 0x00),q);
+ bit++;
+ byte<<=1;
+ if (bit == 8)
+ bit=0;
+ q+=GetPixelChannels(image);
+ }
+ if (SyncAuthenticPixels(image,exception) == MagickFalse)
+ break;
+ offset=0;
+ p=pixels;
+ y++;
+ }
+ }
+ continue;
}
- /*
- Proceed to next image.
- */
- if (image_info->number_scenes != 0)
- if (image->scene >= (image_info->scene+image_info->number_scenes-1))
- break;
- width=ReadBlobMSBLong(image);
- height=ReadBlobMSBLong(image);
- if ((width != 0UL) && (height != 0UL))
- {
- /*
- Allocate next image structure.
- */
- AcquireNextImage(image_info,image);
- if (GetNextImageInList(image) == (Image *) NULL)
+ count++;
+ while (count != 0)
+ {
+ byte=(unsigned char) (~ReadBlobByte(image));
+ *p++=byte;
+ offset++;
+ count--;
+ if (offset >= (ssize_t) length)
+ {
+ q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
+ if (q == (Quantum *) NULL)
+ break;
+ p=pixels;
+ bit=0;
+ byte=0;
+ for (x=0; x < (ssize_t) image->columns; x++)
{
- image=DestroyImageList(image);
- return((Image *) NULL);
+ if (bit == 0)
+ byte=(*p++);
+ SetPixelIndex(image,((byte & 0x80) != 0 ? 0x01 : 0x00),q);
+ bit++;
+ byte<<=1;
+ if (bit == 8)
+ bit=0;
+ q+=GetPixelChannels(image);
}
- image=SyncNextImageInList(image);
- status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
- GetBlobSize(image));
- if (status == MagickFalse)
- break;
- }
- } while ((width != 0UL) && (height != 0UL));
+ if (SyncAuthenticPixels(image,exception) == MagickFalse)
+ break;
+ offset=0;
+ p=pixels;
+ y++;
+ }
+ }
+ }
+ pixels=(unsigned char *) RelinquishMagickMemory(pixels);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}