% July 1992 %
% %
% %
-% Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2018 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, %
static Image *ReadGRAYImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
- const void
+ const unsigned char
*pixels;
Image
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);
if ((image->columns == 0) || (image->rows == 0))
ThrowReaderException(OptionError,"MustSpecifyImageSize");
+ status=SetImageExtent(image,image->columns,image->rows,exception);
+ if (status == MagickFalse)
+ return(DestroyImageList(image));
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
- if (DiscardBlobBytes(image,(size_t) image->offset) == MagickFalse)
+ if (DiscardBlobBytes(image,(MagickSizeType) image->offset) == MagickFalse)
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
/*
Create virtual canvas to support cropping (i.e. image.gray[100x100+10+20]).
*/
- SetImageColorspace(image,GRAYColorspace,exception);
+ (void) SetImageColorspace(image,GRAYColorspace,exception);
canvas_image=CloneImage(image,image->extract_info.width,1,MagickFalse,
exception);
(void) SetImageVirtualPixelMethod(canvas_image,BlackVirtualPixelMethod,
quantum_info=AcquireQuantumInfo(image_info,canvas_image);
if (quantum_info == (QuantumInfo *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
- pixels=(const void *) NULL;
+ pixels=(const unsigned char *) NULL;
if (image_info->number_scenes != 0)
while (image->scene < image_info->scene)
{
length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
for (y=0; y < (ssize_t) image->rows; y++)
{
- pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
- &count);
+ pixels=(const unsigned char *) ReadBlobStream(image,length,
+ GetQuantumPixels(quantum_info),&count);
if (count != (ssize_t) length)
break;
}
scene=0;
count=0;
length=0;
+ status=MagickTrue;
do
{
/*
break;
status=SetImageExtent(image,image->columns,image->rows,exception);
if (status == MagickFalse)
- return(DestroyImageList(image));
- SetImageColorspace(image,GRAYColorspace,exception);
+ break;
+ if (SetImageColorspace(image,GRAYColorspace,exception) == MagickFalse)
+ break;
if (scene == 0)
{
length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
- pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
- &count);
+ pixels=(const unsigned char *) ReadBlobStream(image,length,
+ GetQuantumPixels(quantum_info),&count);
+ if (count != (ssize_t) length)
+ break;
}
for (y=0; y < (ssize_t) image->extract_info.height; y++)
{
register const Quantum
- *restrict p;
+ *magick_restrict p;
register ssize_t
x;
register Quantum
- *restrict q;
+ *magick_restrict q;
if (count != (ssize_t) length)
{
+ status=MagickFalse;
ThrowFileException(exception,CorruptImageError,
"UnexpectedEndOfFile",image->filename);
break;
image->columns,1,exception);
q=QueueAuthenticPixels(image,0,y-image->extract_info.y,image->columns,
1,exception);
- if ((p == (const Quantum *) NULL) ||
- (q == (Quantum *) NULL))
+ if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
if (status == MagickFalse)
break;
}
- pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
- &count);
+ pixels=(const unsigned char *) ReadBlobStream(image,length,
+ GetQuantumPixels(quantum_info),&count);
+ if (count != (ssize_t) length)
+ break;
}
SetQuantumImageType(image,quantum_type);
/*
quantum_info=DestroyQuantumInfo(quantum_info);
canvas_image=DestroyImage(canvas_image);
(void) CloseBlob(image);
+ if (status == MagickFalse)
+ return(DestroyImageList(image));
return(GetFirstImageInList(image));
}
\f
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);
quantum_info=AcquireQuantumInfo(image_info,image);
if (quantum_info == (QuantumInfo *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
- pixels=GetQuantumPixels(quantum_info);
+ pixels=(unsigned char *) GetQuantumPixels(quantum_info);
for (y=0; y < (ssize_t) image->rows; y++)
{
register const Quantum
- *restrict p;
+ *magick_restrict p;
p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)