From: dirk Date: Sat, 9 Aug 2014 20:50:48 +0000 (+0000) Subject: The read method in Magick++ will raise a warning when it fails to read an image but... X-Git-Tag: 7.0.1-0~2115 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=671b5d721987b2a12d84b656de888be1c99aa881;p=imagemagick The read method in Magick++ will raise a warning when it fails to read an image but no exception was raised. --- diff --git a/Magick++/lib/Image.cpp b/Magick++/lib/Image.cpp index 168f57cb5..5eb2b53af 100644 --- a/Magick++/lib/Image.cpp +++ b/Magick++/lib/Image.cpp @@ -3882,8 +3882,7 @@ void Magick::Image::read(const Blob &blob_) GetPPException; newImage=BlobToImage(imageInfo(),static_cast(blob_.data()), blob_.length(),exceptionInfo); - replaceImage(newImage); - ThrowPPException; + read(newImage,exceptionInfo); } void Magick::Image::read(const Blob &blob_,const Geometry &size_) @@ -3948,21 +3947,7 @@ void Magick::Image::read(const std::string &imageSpec_) GetPPException; options()->fileName(imageSpec_); newImage=ReadImage(imageInfo(),exceptionInfo); - - // Ensure that multiple image frames were not read. - if (newImage && newImage->next) - { - MagickCore::Image - *next; - - // Destroy any extra image frames - next=newImage->next; - newImage->next=0; - next->previous=0; - DestroyImageList(next); - } - replaceImage(newImage); - ThrowPPException; + read(newImage,exceptionInfo); } void Magick::Image::readPixels(const Magick::QuantumType quantum_, @@ -4997,6 +4982,32 @@ void Magick::Image::unregisterId(void) _imgRef->id(-1); } +void Magick::Image::read(MagickCore::Image *image, + MagickCore::ExceptionInfo *exceptionInfo) +{ + // Ensure that multiple image frames were not read. + if (image != (MagickCore::Image *) NULL && + image->next != (MagickCore::Image *) NULL) + { + MagickCore::Image + *next; + + // Destroy any extra image frames + next=image->next; + image->next=(MagickCore::Image *) NULL; + next->previous=(MagickCore::Image *) NULL; + DestroyImageList(next); + } + replaceImage(image); + if (exceptionInfo->severity == MagickCore::UndefinedException && + image == (MagickCore::Image *) NULL) + { + (void) MagickCore::DestroyExceptionInfo(exceptionInfo); + throwExceptionExplicit(ImageWarning,"No image was loaded."); + } + ThrowPPException; +} + void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_, const Magick::Image *fillPattern_,const Magick::Color &fill_, const MagickCore::PixelInfo *target_,const bool invert_) diff --git a/Magick++/lib/Magick++/Image.h b/Magick++/lib/Magick++/Image.h index d83c1f61c..be45d57b3 100644 --- a/Magick++/lib/Magick++/Image.h +++ b/Magick++/lib/Magick++/Image.h @@ -1495,6 +1495,9 @@ namespace Magick private: + void read(MagickCore::Image *image, + MagickCore::ExceptionInfo *exceptionInfo); + void floodFill(const ssize_t x_,const ssize_t y_, const Magick::Image *fillPattern_,const Color &fill_, const PixelInfo *target,const bool invert_);