% July 1992 %
% %
% %
-% Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2017 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 %
% obtain a copy of the License at %
% %
-% http://www.imagemagick.org/script/license.php %
+% https://www.imagemagick.org/script/license.php %
% %
% Unless required by applicable law or agreed to in writing, software %
% distributed under the License is distributed on an "AS IS" BASIS, %
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
/*
Read record header.
*/
- img_offset=(ssize_t) ((int) ReadBlobMSBLong(image));
+ img_offset=(ssize_t) ReadBlobMSBSignedLong(image);
attributes=(unsigned char) ReadBlobByte(image);
(void) attributes;
count=ReadBlob(image,3,(unsigned char *) tag);
ThrowReaderException(CorruptImageError,"CorruptImage");
if (pdb_info.number_records > 1)
{
- comment_offset=(ssize_t) ((int) ReadBlobMSBLong(image));
+ comment_offset=(ssize_t) ReadBlobMSBSignedLong(image);
attributes=(unsigned char) ReadBlobByte(image);
count=ReadBlob(image,3,(unsigned char *) tag);
if (count != 3 || memcmp(tag,"\x6f\x80\x01",3) != 0)
ThrowReaderException(CorruptImageError,"CorruptImage");
}
num_pad_bytes = (size_t) (img_offset - TellBlob( image ));
- while (num_pad_bytes--) ReadBlobByte( image );
+ while (num_pad_bytes-- != 0)
+ {
+ int
+ c;
+
+ c=ReadBlobByte(image);
+ if (c == EOF)
+ break;
+ }
/*
Read image header.
*/
if (count != sizeof(pdb_image.name))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
pdb_image.version=ReadBlobByte(image);
- pdb_image.type=(unsigned char) ((int) ReadBlobByte(image));
+ pdb_image.type=(unsigned char) (ReadBlobByte(image));
pdb_image.reserved_1=ReadBlobMSBLong(image);
pdb_image.note=ReadBlobMSBLong(image);
pdb_image.x_last=(short) ReadBlobMSBShort(image);
image->columns=(size_t) pdb_image.width;
image->rows=(size_t) pdb_image.height;
image->depth=8;
- status=SetImageExtent(image,image->columns,image->rows,exception);
- if (status == MagickFalse)
- return(DestroyImageList(image));
image->storage_class=PseudoClass;
bits_per_pixel=pdb_image.type == 0 ? 2UL : pdb_image.type == 2 ? 4UL : 1UL;
one=1;
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
+ status=SetImageExtent(image,image->columns,image->rows,exception);
+ if (status == MagickFalse)
+ return(DestroyImageList(image));
packets=(bits_per_pixel*image->columns+7)/8;
- pixels=(unsigned char *) AcquireQuantumMemory(packets+256UL,image->rows*
+ pixels=(unsigned char *) AcquireQuantumMemory(packets+257UL,image->rows*
sizeof(*pixels));
if (pixels == (unsigned char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
case 0:
{
image->compression=NoCompression;
- count=(ssize_t) ReadBlob(image, packets * image -> rows, pixels);
+ count=(ssize_t) ReadBlob(image,packets*image->rows,pixels);
break;
}
case 1:
{
image->compression=RLECompression;
- if (!DecodeImage(image, pixels, packets * image -> rows))
- ThrowReaderException( CorruptImageError, "RLEDecoderError" );
+ if (!DecodeImage(image,pixels,packets*image->rows))
+ {
+ pixels=(unsigned char *) RelinquishMagickMemory(pixels);
+ ThrowReaderException(CorruptImageError,"RLEDecoderError");
+ }
break;
}
default:
+ {
+ pixels=(unsigned char *) RelinquishMagickMemory(pixels);
ThrowReaderException(CorruptImageError,
- "UnrecognizedImageCompressionType" );
+ "UnrecognizedImageCompressionType");
+ }
}
p=pixels;
switch (bits_per_pixel)
break;
}
default:
+ {
+ pixels=(unsigned char *) RelinquishMagickMemory(pixels);
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+ }
}
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (EOFBlob(image) != MagickFalse)
length;
num_pad_bytes = (size_t) (comment_offset - TellBlob( image ));
- while (num_pad_bytes--) ReadBlobByte( image );
+ while (num_pad_bytes-- != 0)
+ {
+ int
+ c;
+
+ c=ReadBlobByte(image);
+ if (c == EOF)
+ break;
+ }
/*
Read comment.
*/
c=ReadBlobByte(image);
- length=MaxTextExtent;
+ length=MagickPathExtent;
comment=AcquireString((char *) NULL);
for (p=comment; c != EOF; p++)
{
- if ((size_t) (p-comment+MaxTextExtent) >= length)
+ if ((size_t) (p-comment+MagickPathExtent) >= length)
{
*p='\0';
length<<=1;
- length+=MaxTextExtent;
- comment=(char *) ResizeQuantumMemory(comment,length+MaxTextExtent,
+ length+=MagickPathExtent;
+ comment=(char *) ResizeQuantumMemory(comment,length+MagickPathExtent,
sizeof(*comment));
if (comment == (char *) NULL)
break;
MagickInfo
*entry;
- entry=SetMagickInfo("PDB");
+ entry=AcquireMagickInfo("PDB","PDB","Palm Database ImageViewer Format");
entry->decoder=(DecodeImageHandler *) ReadPDBImage;
entry->encoder=(EncodeImageHandler *) WritePDBImage;
entry->magick=(IsImageFormatHandler *) IsPDB;
- entry->description=ConstantString("Palm Database ImageViewer Format");
- entry->module=ConstantString("PDB");
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
Open output image file.
*/
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
(void) TransformImageColorspace(image,sRGBColorspace,exception);
- if ((image->colors <= 2) ||
- (GetImageType(image,exception ) == BilevelType)) {
+ if (SetImageMonochrome(image,exception) != MagickFalse) {
bits_per_pixel=1;
} else if (image->colors <= 4) {
bits_per_pixel=2;
} else {
bits_per_pixel=4;
}
- (void) ResetMagickMemory(&pdb_info.name,0,sizeof(pdb_info));
+ (void) ResetMagickMemory(&pdb_info,0,sizeof(pdb_info));
(void) CopyMagickString(pdb_info.name,image_info->filename,
sizeof(pdb_info.name));
pdb_info.attributes=0;
pdb_image.width=(short) (16*(image->columns/16+1));
pdb_image.height=(short) image->rows;
packets=((bits_per_pixel*image->columns+7)/8);
- runlength=(unsigned char *) AcquireQuantumMemory(2UL*packets,
+ runlength=(unsigned char *) AcquireQuantumMemory(9UL*packets,
image->rows*sizeof(*runlength));
if (runlength == (unsigned char *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
- buffer=(unsigned char *) AcquireQuantumMemory(256UL,sizeof(*buffer));
+ buffer=(unsigned char *) AcquireQuantumMemory(512,sizeof(*buffer));
if (buffer == (unsigned char *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
- packet_size=(size_t) (image->depth > 8 ? 2: 1);
+ packet_size=(size_t) (image->depth > 8 ? 2 : 1);
scanline=(unsigned char *) AcquireQuantumMemory(image->columns,packet_size*
sizeof(*scanline));
if (scanline == (unsigned char *) NULL)
quantum_info=AcquireQuantumInfo(image_info,image);
if (quantum_info == (QuantumInfo *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
+ status=SetQuantumDepth(image,quantum_info,image->depth > 8 ? 16 : 8);
bits=8/(int) bits_per_pixel-1; /* start at most significant bits */
literal=0;
repeat=0;