// This may look like C code, but it is really -*- C++ -*-
//
// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
-// Copyright Dirk Lemstra 2013-2014
+// Copyright Dirk Lemstra 2013-2015
//
// Implementation of Image
//
#define AbsoluteValue(x) ((x) < 0 ? -(x) : (x))
#define MagickPI 3.14159265358979323846264338327950288419716939937510
#define DegreesToRadians(x) (MagickPI*(x)/180.0)
+#define ThrowImageException ThrowPPException(quiet())
MagickPPExport const char *Magick::borderGeometryDefault="6x6+0+0";
MagickPPExport const char *Magick::frameGeometryDefault="25x25+6+6";
try
{
// Initialize, Allocate and Read images
+ quiet(true);
read(blob_);
+ quiet(false);
}
- catch(const Warning &/*warning_*/)
- {
- // FIXME: need a way to report warnings in constructor
- }
- catch (const Error &/*error_*/)
+ catch (const Error&)
{
// Release resources
delete _imgRef;
try
{
// Read from Blob
+ quiet(true);
read(blob_, size_);
+ quiet(false);
}
- catch(const Warning &/*warning_*/)
- {
- // FIXME: need a way to report warnings in constructor
- }
- catch(const Error &/*error_*/)
+ catch(const Error&)
{
// Release resources
delete _imgRef;
try
{
// Read from Blob
+ quiet(true);
read(blob_,size_,depth_);
+ quiet(false);
}
- catch(const Warning &/*warning_*/)
- {
- // FIXME: need a way to report warnings in constructor
- }
- catch(const Error &/*error_*/)
+ catch(const Error&)
{
// Release resources
delete _imgRef;
try
{
// Read from Blob
+ quiet(true);
read(blob_,size_,depth_,magick_);
+ quiet(false);
}
- catch(const Warning &/*warning_*/)
- {
- // FIXME: need a way to report warnings in constructor
- }
- catch(const Error &/*error_*/)
+ catch(const Error&)
{
// Release resources
delete _imgRef;
try
{
// Read from Blob
+ quiet(true);
read(blob_,size_,magick_);
+ quiet(false);
}
- catch(const Warning &/*warning_*/)
- {
- // FIXME: need a way to report warnings in constructor
- }
- catch(const Error &/*error_*/)
+ catch(const Error&)
{
// Release resources
delete _imgRef;
try
{
+ quiet(true);
// Set image size
size(size_);
// Initialize, Allocate and Read images
read(imageSpec);
+ quiet(false);
}
- catch(const Warning &/*warning_*/)
- {
- // FIXME: need a way to report warnings in constructor
- }
- catch(const Error & /*error_*/)
+ catch(const Error&)
{
// Release resources
delete _imgRef;
_imgRef->increase();
}
+Magick::Image::Image(const Image &image_,const Geometry &geometry_)
+ : _imgRef(new ImageRef)
+{
+ const RectangleInfo
+ geometry=geometry_;
+
+ OffsetInfo
+ offset;
+
+ MagickCore::Image
+ *image;
+
+ GetPPException;
+ image=CloneImage(image_.constImage(),geometry_.width(),geometry_.height(),
+ MagickTrue,exceptionInfo);
+ replaceImage(image);
+ _imgRef->options(new Options(*image_.constOptions()));
+ offset.x=0;
+ offset.y=0;
+ (void) CopyImagePixels(image,image_.constImage(),&geometry,&offset,
+ exceptionInfo);
+ ThrowImageException;
+}
+
Magick::Image::Image(const size_t width_,const size_t height_,
const std::string &map_,const StorageType type_,const void *pixels_)
: _imgRef(new ImageRef)
{
try
{
+ quiet(true);
read(width_,height_,map_.c_str(),type_,pixels_);
+ quiet(false);
}
- catch(const Warning &/*warning_*/)
- {
- // FIXME: need a way to report warnings in constructor
- }
- catch(const Error &/*error_*/)
+ catch(const Error&)
{
// Release resources
delete _imgRef;
try
{
// Initialize, Allocate and Read images
+ quiet(true);
read(imageSpec_);
+ quiet(false);
}
- catch(const Warning &/*warning_*/)
- {
- // FIXME: need a way to report warnings in constructor
- }
- catch(const Error &/*error_*/)
+ catch(const Error&)
{
// Release resources
delete _imgRef;
if ((matteFlag_ && !constImage()->alpha_trait) ||
(constImage()->alpha_trait && !matteFlag_))
SetImageAlpha(image(),OpaqueAlpha,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
image()->alpha_trait=matteFlag_ ? BlendPixelTrait : UndefinedPixelTrait;
}
return(Color(constImage()->matte_color));
}
-void Magick::Image::antiAlias(const bool flag_)
-{
- modifyImage();
- options()->antiAlias(static_cast<size_t>(flag_));
-}
-
-bool Magick::Image::antiAlias(void)
-{
- return(static_cast<bool>(options()->antiAlias()));
-}
-
void Magick::Image::animationDelay(const size_t delay_)
{
modifyImage();
void Magick::Image::attenuate(const double attenuate_)
{
char
- value[MaxTextExtent];
+ value[MagickPathExtent];
modifyImage();
- FormatLocaleString(value,MaxTextExtent,"%.20g",attenuate_);
+ FormatLocaleString(value,MagickPathExtent,"%.20g",attenuate_);
(void) SetImageArtifact(image(),"attenuate",value);
}
GetPPException;
bbox=GetImageBoundingBox(constImage(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
return(Geometry(bbox));
}
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
SetImageDepth(image(),depth_,exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
size_t Magick::Image::channelDepth(const ChannelType channel_)
channel_depth;
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
channel_depth=GetImageDepth(constImage(),exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
return(channel_depth);
}
modifyImage();
GetPPException;
SyncImage(image(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
image()->colormap=(PixelInfo *)RelinquishMagickMemory(image()->colormap);
image()->storage_class=static_cast<MagickCore::ClassType>(DirectClass);
return;
void Magick::Image::colorMapSize(const size_t entries_)
{
if (entries_ >MaxColormapSize)
- throwExceptionExplicit(OptionError,
+ throwExceptionExplicit(MagickCore::OptionError,
"Colormap entries must not exceed MaxColormapSize");
modifyImage();
GetPPException;
(void) AcquireImageColormap(image(),entries_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
size_t Magick::Image::colorMapSize(void) const
{
if (!constImage()->colormap)
- throwExceptionExplicit(OptionError,"Image does not contain a colormap");
+ throwExceptionExplicit(MagickCore::OptionError,
+ "Image does not contain a colormap");
return(constImage()->colors);
}
modifyImage();
GetPPException;
TransformImageColorspace(image(),colorSpace_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
Magick::ColorspaceType Magick::Image::colorSpace(void) const
modifyImage();
GetPPException;
SetImageColorspace(image(),colorSpace_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
options()->colorspaceType(colorSpace_);
}
SetImageProperty(image(),"Comment",NULL,exceptionInfo);
if (comment_.length() > 0)
SetImageProperty(image(),"Comment",comment_.c_str(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
std::string Magick::Image::comment(void) const
GetPPException;
value=GetImageProperty(constImage(),"Comment",exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
if (value)
return(std::string(value));
if (constImage()->directory)
return(std::string(constImage()->directory));
- throwExceptionExplicit(CorruptImageWarning,
- "Image does not contain a directory");
+ if (!quiet())
+ throwExceptionExplicit(MagickCore::CorruptImageWarning,
+ "Image does not contain a directory");
return(std::string());
}
GetPPException;
(void) SetImageProfile(image(),"exif",exif_profile,exceptionInfo);
exif_profile=DestroyStringInfo(exif_profile);
- ThrowPPException;
+ ThrowImageException;
}
}
void Magick::Image::fillColor(const Magick::Color &fillColor_)
{
- std::string
- value;
-
modifyImage();
options()->fillColor(fillColor_);
- value=fillColor_;
- artifact("fill",value);
}
Magick::Color Magick::Image::fillColor(void) const
GetPPException;
image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
texture.replaceImage(image);
- ThrowPPException;
+ ThrowImageException;
}
return(texture);
}
return(constOptions()->font());
}
+void Magick::Image::fontFamily(const std::string &family_)
+{
+ modifyImage();
+ options()->fontFamily(family_);
+}
+
+std::string Magick::Image::fontFamily(void) const
+{
+ return(constOptions()->fontFamily());
+}
+
void Magick::Image::fontPointsize(const double pointSize_)
{
modifyImage();
return(constOptions()->fontPointsize());
}
+void Magick::Image::fontStyle(const StyleType pointSize_)
+{
+ modifyImage();
+ options()->fontStyle(pointSize_);
+}
+
+Magick::StyleType Magick::Image::fontStyle(void) const
+{
+ return(constOptions()->fontStyle());
+}
+
+void Magick::Image::fontWeight(const size_t weight_)
+{
+ modifyImage();
+ options()->fontWeight(weight_);
+}
+
+size_t Magick::Image::fontWeight(void) const
+{
+ return(constOptions()->fontWeight());
+}
+
std::string Magick::Image::format(void) const
{
const MagickInfo
GetPPException;
magick_info=GetMagickInfo(constImage()->magick,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
if ((magick_info != 0) && (*magick_info->description != '\0'))
return(std::string(magick_info->description));
- throwExceptionExplicit(CorruptImageWarning,"Unrecognized image magick type");
+ if (!quiet())
+ throwExceptionExplicit(MagickCore::CorruptImageWarning,
+ "Unrecognized image magick type");
+
return(std::string());
}
text_string=std::string(text);
text=DestroyString(text);
}
- ThrowPPException;
+ ThrowImageException;
return(text_string);
}
if (constImage()->geometry)
return Geometry(constImage()->geometry);
- throwExceptionExplicit(OptionWarning,"Image does not contain a geometry");
+ if (!quiet())
+ throwExceptionExplicit(MagickCore::OptionWarning,
+ "Image does not contain a geometry");
return(Geometry());
}
return(constImage()->dispose);
}
+bool Magick::Image::hasChannel(const PixelChannel channel) const
+{
+ if (GetPixelChannelTraits(constImage(),channel) == UndefinedPixelTrait)
+ return(false);
+
+ if (channel == GreenPixelChannel || channel == BluePixelChannel)
+ return (GetPixelChannelOffset(constImage(),channel) == (ssize_t)channel);
+
+ return(true);
+}
+
void Magick::Image::highlightColor(const Color color_)
{
std::string
void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
{
- profile("icm",colorProfile_);
+ profile("icc",colorProfile_);
}
Magick::Blob Magick::Image::iccColorProfile(void) const
GetPPException;
(void) SetImageProfile(image(),"iptc",iptc_profile,exceptionInfo);
iptc_profile=DestroyStringInfo(iptc_profile);
- ThrowPPException;
+ ThrowImageException;
}
}
iptc_profile)));
}
+bool Magick::Image::isOpaque(void) const
+{
+ MagickBooleanType
+ result;
+
+ GetPPException;
+ result=IsImageOpaque(constImage(),exceptionInfo);
+ ThrowImageException;
+ return(result != MagickFalse ? true : false);
+}
+
void Magick::Image::isValid(const bool isValid_)
{
if (!isValid_)
(void) SetImageProperty(image(),"Label",NULL,exceptionInfo);
if (label_.length() > 0)
(void) SetImageProperty(image(),"Label",label_.c_str(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
std::string Magick::Image::label(void) const
GetPPException;
value=GetImageProperty(constImage(),"Label",exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
if (value)
return(std::string(value));
GetPPException;
if (mask_.isValid())
- SetImageMask(image(),mask_.constImage(),exceptionInfo);
+ SetImageMask(image(),ReadPixelMask,mask_.constImage(),exceptionInfo);
else
- SetImageMask(image(),(MagickCore::Image *) NULL,exceptionInfo);
- ThrowPPException;
+ SetImageMask(image(),ReadPixelMask,(MagickCore::Image *) NULL,
+ exceptionInfo);
+ ThrowImageException;
}
Magick::Image Magick::Image::mask(void) const
GetPPException;
image=GetImageMask(constImage(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
if (image == (MagickCore::Image *) NULL)
return(Magick::Image());
void Magick::Image::magick(const std::string &magick_)
{
+ size_t
+ length;
+
modifyImage();
- magick_.copy(image()->magick,sizeof(image()->magick)-1);
- image()->magick[magick_.length()]=0;
-
+ length=sizeof(image()->magick)-1;
+ if (magick_.length() < length)
+ length=magick_.length();
+
+ if (!magick_.empty())
+ magick_.copy(image()->magick,length);
+ image()->magick[length]=0;
+
options()->magick(magick_);
}
modifyImage();
GetPPException;
SetImageDepth(image(),depth_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
options()->depth(depth_);
}
GetPPException;
depth=GetImageDepth(constImage(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
return(depth);
}
if (constImage()->montage)
return Magick::Geometry(constImage()->montage);
- throwExceptionExplicit(CorruptImageWarning,
+ if (!quiet())
+ throwExceptionExplicit(MagickCore::CorruptImageWarning,
"Image does not contain a montage");
return(Magick::Geometry());
Magick::Geometry Magick::Image::page(void) const
{
return(Geometry(constImage()->page.width,constImage()->page.height,
- AbsoluteValue(constImage()->page.x),AbsoluteValue(constImage()->page.y)));
+ constImage()->page.x,constImage()->page.y));
}
void Magick::Image::quality(const size_t quality_)
return(constOptions()->quantizeTreeDepth());
}
+void Magick::Image::quiet(const bool quiet_)
+{
+ modifyImage();
+ options()->quiet(quiet_);
+}
+
+bool Magick::Image::quiet(void) const
+{
+ return(constOptions()->quiet());
+}
+
void Magick::Image::renderingIntent(
const Magick::RenderingIntent renderingIntent_)
{
GetPPException;
image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
texture.replaceImage(image);
- ThrowPPException;
+ ThrowImageException;
}
return(texture);
}
void Magick::Image::strokeWidth(const double strokeWidth_)
{
char
- value[MaxTextExtent];
+ value[MagickPathExtent];
modifyImage();
options()->strokeWidth(strokeWidth_);
- FormatLocaleString(value,MaxTextExtent,"%.20g",strokeWidth_);
+ FormatLocaleString(value,MagickPathExtent,"%.20g",strokeWidth_);
(void) SetImageArtifact(image(),"strokewidth",value);
}
return(constOptions()->subRange());
}
+void Magick::Image::textAntiAlias(const bool flag_)
+{
+ modifyImage();
+ options()->textAntiAlias(flag_);
+}
+
+bool Magick::Image::textAntiAlias(void) const
+{
+ return(constOptions()->textAntiAlias());
+}
+
void Magick::Image::textDirection(DirectionType direction_)
{
modifyImage();
return(constOptions()->textKerning());
}
+void Magick::Image::textUnderColor(const Color &underColor_)
+{
+ modifyImage();
+ options()->textUnderColor(underColor_);
+}
+
+Magick::Color Magick::Image::textUnderColor(void) const
+{
+ return(constOptions()->textUnderColor());
+}
+
size_t Magick::Image::totalColors(void) const
{
size_t
colors;
GetPPException;
- colors=GetNumberColors(constImage(),0,exceptionInfo);
- ThrowPPException;
+ colors=GetNumberColors(constImage(),(FILE *) NULL,exceptionInfo);
+ ThrowImageException;
return colors;
}
{
if (constOptions()->type() != UndefinedType)
return(constOptions()->type());
- else if (constImage()->type != UndefinedType)
- return(constImage()->type);
- else
- return(determineType());
+ return(GetImageType(constImage()));
}
void Magick::Image::type(const Magick::ImageType type_)
options()->type(type_);
GetPPException;
SetImageType(image(),type_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::verbose(const bool verboseFlag_)
modifyImage();
GetPPException;
SetImageVirtualPixelMethod(image(),virtualPixelMethod_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
GetPPException;
newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::adaptiveResize(const Geometry &geometry_)
GetPPException;
newImage=AdaptiveResizeImage(constImage(),width,height,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
GetPPException;
newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
*newImage;
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
RestorePPChannelMask;
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
- const ssize_t offset_)
+ const double bias_)
{
MagickCore::Image
*newImage;
GetPPException;
- newImage=AdaptiveThresholdImage(constImage(),width_,height_,offset_,
+ newImage=AdaptiveThresholdImage(constImage(),width_,height_,bias_,
exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::addNoise(const NoiseType noiseType_)
GetPPException;
newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::addNoiseChannel(const ChannelType channel_,
*newImage;
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
RestorePPChannelMask;
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::affineTransform(const DrawableAffine &affine_)
GetPPException;
newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::alpha(const unsigned int alpha_)
modifyImage();
GetPPException;
SetImageAlpha(image(),alpha_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
modifyImage();
GetPPException;
SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::annotate(const std::string &text_,
oaffine;
char
- boundingArea[MaxTextExtent];
+ boundingArea[MagickPathExtent];
DrawInfo
*drawInfo;
{
if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
{
- FormatLocaleString(boundingArea,MaxTextExtent,"%+.20g%+.20g",
+ FormatLocaleString(boundingArea,MagickPathExtent,"%+.20g%+.20g",
(double) boundingArea_.xOff(),(double) boundingArea_.yOff());
}
else
{
- (void) CopyMagickString(boundingArea,string(boundingArea_).c_str(),
- MaxTextExtent);
+ (void) CopyMagickString(boundingArea,
+ std::string(boundingArea_).c_str(), MagickPathExtent);
}
drawInfo->geometry=boundingArea;
}
drawInfo->text=0;
drawInfo->geometry=0;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::annotate(const std::string &text_,
drawInfo->gravity=NorthWestGravity;
drawInfo->text=0;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::artifact(const std::string &name_,const std::string &value_)
(void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
}
-std::string Magick::Image::artifact(const std::string &name_)
+std::string Magick::Image::artifact(const std::string &name_) const
{
const char
*value;
modifyImage();
GetPPException;
SetImageProperty(image(),name_.c_str(),value_.c_str(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
-std::string Magick::Image::attribute(const std::string name_)
+std::string Magick::Image::attribute(const std::string name_) const
{
const char
*value;
GetPPException;
value=GetImageProperty(constImage(),name_.c_str(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
if (value)
return(std::string(value));
GetPPException;
(void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
(void) AutoGammaImage(image(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::autoGammaChannel(const ChannelType channel_)
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
(void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
(void) AutoGammaImage(image(),exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::autoLevel(void)
{
modifyImage();
GetPPException;
- (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
(void) AutoLevelImage(image(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::autoLevelChannel(const ChannelType channel_)
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
- (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
+ GetAndSetPPChannelMask(channel_);
(void) AutoLevelImage(image(),exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::autoOrient(void)
return;
GetPPException;
- (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::blackThreshold(const std::string &threshold_)
modifyImage();
GetPPException;
BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::blackThresholdChannel(const ChannelType channel_,
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::blueShift(const double factor_)
GetPPException;
newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::blur(const double radius_,const double sigma_)
GetPPException;
newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::blurChannel(const ChannelType channel_,
*newImage;
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
RestorePPChannelMask;
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::border(const Geometry &geometry_)
newImage=BorderImage(constImage(),&borderInfo,image()->compose,
exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::brightnessContrast(const double brightness_,
modifyImage();
GetPPException;
BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::cannyEdge(const double radius_,const double sigma_,
newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
upperPercent_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
+}
+
+void Magick::Image::cdl(const std::string &cdl_)
+{
+ modifyImage();
+ GetPPException;
+ (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
+ ThrowImageException;
}
void Magick::Image::channel(const ChannelType channel_)
GetPPException;
newImage=SeparateImage(image(),channel_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::charcoal(const double radius_,const double sigma_)
GetPPException;
newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::chop(const Geometry &geometry_)
GetPPException;
newImage=ChopImage(image(),&chopInfo,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::chromaBluePrimary(const double x_,const double y_)
*y_=constImage()->chromaticity.white_point.y;
}
-void Magick::Image::cdl(const std::string &cdl_)
-{
- modifyImage();
- GetPPException;
- (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
- ThrowPPException;
-}
-
void Magick::Image::clamp(void)
{
modifyImage();
GetPPException;
ClampImage(image(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::clampChannel(const ChannelType channel_)
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
ClampImage(image(),exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::clip(void)
modifyImage();
GetPPException;
ClipImage(image(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
GetPPException;
ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::clut(const Image &clutImage_,
modifyImage();
GetPPException;
ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::clutChannel(const ChannelType channel_,
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
const Color &penColor_)
{
char
- blend[MaxTextExtent];
+ blend[MagickPathExtent];
MagickCore::Image
*newImage;
target;
if (!penColor_.isValid())
- throwExceptionExplicit(OptionError,"Pen color argument is invalid");
+ throwExceptionExplicit(MagickCore::OptionError,
+ "Pen color argument is invalid");
- FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
+ FormatLocaleString(blend,MagickPathExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
alphaBlue_);
target=static_cast<PixelInfo>(penColor_);
GetPPException;
newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::colorMap(const size_t index_,const Color &color_)
imageptr=image();
if (index_ > (MaxColormapSize-1))
- throwExceptionExplicit(OptionError,
+ throwExceptionExplicit(MagickCore::OptionError,
"Colormap index must be less than MaxColormapSize");
if (!color_.isValid())
- throwExceptionExplicit(OptionError,"Color argument is invalid");
+ throwExceptionExplicit(MagickCore::OptionError,
+ "Color argument is invalid");
modifyImage();
{
if (!constImage()->colormap)
{
- throwExceptionExplicit(OptionError,"Image does not contain a colormap");
+ throwExceptionExplicit(MagickCore::OptionError,
+ "Image does not contain a colormap");
return(Color());
}
if (index_ > constImage()->colors-1)
- throwExceptionExplicit(OptionError,"Index out of range");
+ throwExceptionExplicit(MagickCore::OptionError,"Index out of range");
return(Magick::Color((constImage()->colormap)[index_]));
}
}
kernel_info=DestroyKernelInfo(kernel_info);
}
- ThrowPPException;
+ ThrowImageException;
}
-bool Magick::Image::compare(const Image &reference_)
+bool Magick::Image::compare(const Image &reference_) const
{
bool
status;
ref=reference_;
GetPPException;
- modifyImage();
- ref.modifyImage();
- status=static_cast<bool>(IsImagesEqual(image(),ref.image(),exceptionInfo));
- ThrowPPException;
+ status=static_cast<bool>(IsImagesEqual(constImage(),ref.constImage(),
+ exceptionInfo));
+ ThrowImageException;
return(status);
}
GetPPException;
GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
return(distortion);
}
distortion=0.0;
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
return(distortion);
}
GetPPException;
newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
if (newImage == (MagickCore::Image *) NULL)
return(Magick::Image());
else
*newImage;
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
if (newImage == (MagickCore::Image *) NULL)
return(Magick::Image());
else
GetPPException;
CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
x,y,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::composite(const Image &compositeImage_,
GetPPException;
CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
geometry.x,geometry.y,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::composite(const Image &compositeImage_,
GetPPException;
CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
xOffset_,yOffset_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::connectedComponents(const size_t connectivity_)
GetPPException;
newImage=ConnectedComponentsImage(constImage(),connectivity_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
-void Magick::Image::contrast(const size_t sharpen_)
+void Magick::Image::contrast(const bool sharpen_)
{
modifyImage();
GetPPException;
ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::contrastStretch(const double blackPoint_,
modifyImage();
GetPPException;
ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::contrastStretchChannel(const ChannelType channel_,
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::convolve(const size_t order_,const double *kernel_)
replaceImage(newImage);
}
kernel_info=DestroyKernelInfo(kernel_info);
- ThrowPPException;
+ ThrowImageException;
+}
+
+void Magick::Image::copyPixels(const Image &source_,const Geometry &geometry_,
+ const Offset &offset_)
+{
+ const OffsetInfo
+ offset=offset_;
+
+ const RectangleInfo
+ geometry=geometry_;
+
+ GetPPException;
+ (void) CopyImagePixels(image(),source_.constImage(),&geometry,&offset,
+ exceptionInfo);
+ ThrowImageException;
}
void Magick::Image::crop(const Geometry &geometry_)
GetPPException;
newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::cycleColormap(const ssize_t amount_)
modifyImage();
GetPPException;
CycleColormapImage(image(),amount_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::decipher(const std::string &passphrase_)
modifyImage();
GetPPException;
DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::defineSet(const std::string &magick_,
GetPPException;
newImage=DeskewImage(constImage(),threshold_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::despeckle(void)
GetPPException;
newImage=DespeckleImage(constImage(),exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
-}
-
-Magick::ImageType Magick::Image::determineType(void) const
-{
- ImageType
- image_type;
-
- GetPPException;
- image_type=GetImageType(constImage(),exceptionInfo);
- ThrowPPException;
- return(image_type);
+ ThrowImageException;
}
void Magick::Image::display(void)
{
GetPPException;
DisplayImages(imageInfo(),image(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::distort(const DistortImageMethod method_,
newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::draw(const Magick::Drawable &drawable_)
ClonePPDrawException(wand);
wand=DestroyDrawingWand(wand);
- ThrowPPDrawException;
+ ThrowPPDrawException(quiet());
}
}
p != drawable_.end(); p++ )
{
p->operator()(wand);
- if (DrawGetExceptionType(wand) != UndefinedException)
+ if (DrawGetExceptionType(wand) != MagickCore::UndefinedException)
break;
}
- if (DrawGetExceptionType(wand) == UndefinedException)
+ if (DrawGetExceptionType(wand) == MagickCore::UndefinedException)
DrawRender(wand);
ClonePPDrawException(wand);
wand=DestroyDrawingWand(wand);
- ThrowPPDrawException;
+ ThrowPPDrawException(quiet());
}
}
GetPPException;
newImage=EdgeImage(constImage(),radius_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::emboss(const double radius_,const double sigma_)
GetPPException;
newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::encipher(const std::string &passphrase_)
modifyImage();
GetPPException;
EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::enhance(void)
GetPPException;
newImage=EnhanceImage(constImage(),exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::equalize(void)
modifyImage();
GetPPException;
EqualizeImage(image(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::erase(void)
modifyImage();
GetPPException;
(void) SetImageBackgroundColor(image(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
+}
+
+void Magick::Image::evaluate(const ChannelType channel_,
+ const MagickEvaluateOperator operator_,double rvalue_)
+{
+ GetPPException;
+ GetAndSetPPChannelMask(channel_);
+ EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
+ RestorePPChannelMask;
+ ThrowImageException;
+}
+
+void Magick::Image::evaluate(const ChannelType channel_,
+ const MagickFunction function_,const size_t number_parameters_,
+ const double *parameters_)
+{
+ GetPPException;
+ GetAndSetPPChannelMask(channel_);
+ FunctionImage(image(),function_,number_parameters_,parameters_,
+ exceptionInfo);
+ RestorePPChannelMask;
+ ThrowImageException;
+}
+
+void Magick::Image::evaluate(const ChannelType channel_,const ssize_t x_,
+ const ssize_t y_,const size_t columns_,const size_t rows_,
+ const MagickEvaluateOperator operator_,const double rvalue_)
+{
+ RectangleInfo
+ geometry;
+
+ MagickCore::Image
+ *cropImage;
+
+ geometry.width = columns_;
+ geometry.height = rows_;
+ geometry.x = x_;
+ geometry.y = y_;
+
+ GetPPException;
+ cropImage=CropImage(image(),&geometry,exceptionInfo);
+ GetAndSetPPChannelMask(channel_);
+ EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
+ RestorePPChannelMask;
+ (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
+ BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
+ geometry.x,geometry.y,exceptionInfo );
+ cropImage=DestroyImageList(cropImage);
+ ThrowImageException;
}
void Magick::Image::extent(const Geometry &geometry_ )
GetPPException;
newImage=ExtentImage(image(),&extentInfo,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::extent(const Geometry &geometry_,
GetPPException;
newImage=FlipImage(constImage(),exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
target=static_cast<PixelInfo>(pixelColor(x_,y_));
target.alpha=alpha_;
GetPPException;
- SetPPChannelMask(AlphaChannel);
+ GetAndSetPPChannelMask(AlphaChannel);
FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
(MagickBooleanType)invert_,exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
target=static_cast<PixelInfo>(target_);
target.alpha=alpha_;
GetPPException;
- SetPPChannelMask(AlphaChannel);
+ GetAndSetPPChannelMask(AlphaChannel);
FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
(MagickBooleanType)invert_,exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::floodFillColor(const Geometry &point_,
GetPPException;
newImage=FlopImage(constImage(),exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::fontTypeMetrics(const std::string &text_,
GetPPException;
GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
drawInfo->text=0;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
GetPPException;
GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
drawInfo->text=0;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::frame(const Geometry &geometry_)
GetPPException;
newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::frame(const size_t width_,const size_t height_,
- const ssize_t outerBevel_,const ssize_t innerBevel_)
+ const ssize_t innerBevel_,const ssize_t outerBevel_)
{
FrameInfo
info;
GetPPException;
newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::fx(const std::string expression_)
GetPPException;
newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::fx(const std::string expression_,
*newImage;
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
RestorePPChannelMask;
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::gamma(const double gamma_)
modifyImage();
GetPPException;
GammaImage(image(),gamma_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
const double gammaBlue_)
{
- char
- gamma[MaxTextExtent + 1];
-
- FormatLocaleString(gamma,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",gammaRed_,
- gammaGreen_,gammaBlue_);
-
modifyImage();
GetPPException;
- GammaImage(image(),atof(gamma),exceptionInfo);
- ThrowPPException;
+ GetAndSetPPChannelMask(RedChannel);
+ (void) GammaImage(image(),gammaRed_,exceptionInfo);
+ SetPPChannelMask(GreenChannel);
+ (void) GammaImage(image(),gammaGreen_,exceptionInfo);
+ SetPPChannelMask(BlueChannel);
+ (void) GammaImage(image(),gammaBlue_,exceptionInfo);
+ RestorePPChannelMask;
+ ThrowImageException;
}
void Magick::Image::gaussianBlur(const double width_,const double sigma_)
GetPPException;
newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
*newImage;
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
RestorePPChannelMask;
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
*p;
GetPPException;
- p=(*GetVirtualPixels)(constImage(),x_, y_,columns_, rows_,exceptionInfo);
- ThrowPPException;
+ p=GetVirtualPixels(constImage(),x_, y_,columns_, rows_,exceptionInfo);
+ ThrowImageException;
return(p);
}
result=GetVirtualMetacontent(constImage());
if(!result)
- throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
+ throwExceptionExplicit(MagickCore::OptionError,
+ "Unable to retrieve meta content.");
return(result);
}
result=GetAuthenticMetacontent(image());
if(!result)
- throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
+ throwExceptionExplicit(MagickCore::OptionError,
+ "Unable to retrieve meta content.");
return(result);
}
modifyImage();
GetPPException;
- result=(*GetAuthenticPixels)(image(),x_, y_,columns_,rows_,exceptionInfo);
- ThrowPPException;
+ result=GetAuthenticPixels(image(),x_, y_,columns_,rows_,exceptionInfo);
+ ThrowImageException;
return(result);
}
modifyImage();
GetPPException;
(void) GrayscaleImage(image(),method_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::haldClut(const Image &clutImage_)
modifyImage();
GetPPException;
(void) HaldClutImage(image(),clutImage_.constImage(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::houghLine(const size_t width_,const size_t height_,
newImage=HoughLineImage(constImage(),width_,height_,threshold_,
exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
+}
+
+Magick::ImageType Magick::Image::identifyType(void) const
+{
+ ImageType
+ image_type;
+
+ GetPPException;
+ image_type=IdentifyImageType(constImage(),exceptionInfo);
+ ThrowImageException;
+ return(image_type);
}
void Magick::Image::implode(const double factor_)
newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::inverseFourierTransform(const Image &phase_)
newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
magnitude_ == true ? MagickTrue : MagickFalse,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::kuwahara(const double radius_,const double sigma_)
GetPPException;
newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::kuwaharaChannel(const ChannelType channel_,
*newImage;
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
replaceImage(newImage);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::level(const double blackPoint_,const double whitePoint_,
modifyImage();
GetPPException;
(void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::levelChannel(const ChannelType channel_,
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
(void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::levelColors(const Color &blackColor_,
GetPPException;
(void) LevelImageColors(image(),&black,&white,invert_ == true ?
MagickTrue : MagickFalse,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::levelColorsChannel(const ChannelType channel_,
black=static_cast<PixelInfo>(blackColor_);
white=static_cast<PixelInfo>(whiteColor_);
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
(void) LevelImageColors(image(),&black,&white,invert_ == true ?
MagickTrue : MagickFalse,exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
+}
+
+void Magick::Image::levelize(const double blackPoint_,const double whitePoint_,
+ const double gamma_)
+{
+ modifyImage();
+ GetPPException;
+ (void) LevelizeImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
+ ThrowImageException;
+}
+
+void Magick::Image::levelizeChannel(const ChannelType channel_,
+ const double blackPoint_,const double whitePoint_,const double gamma_)
+{
+ modifyImage();
+ GetPPException;
+ GetAndSetPPChannelMask(channel_);
+ (void) LevelizeImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
+ RestorePPChannelMask;
+ ThrowImageException;
}
void Magick::Image::linearStretch(const double blackPoint_,
modifyImage();
GetPPException;
LinearStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::liquidRescale(const Geometry &geometry_)
GetPPException;
newImage=LiquidRescaleImage(image(),width,height,x,y,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
+}
+
+void Magick::Image::localContrast(const double radius_,const double strength_)
+{
+ MagickCore::Image
+ *newImage;
+
+ GetPPException;
+ newImage=LocalContrastImage(constImage(),radius_,strength_,exceptionInfo);
+ replaceImage(newImage);
+ ThrowImageException;
}
void Magick::Image::magnify(void)
GetPPException;
newImage=MagnifyImage(constImage(),exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::map(const Image &mapImage_,const bool dither_)
options()->quantizeDither(dither_);
RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::medianFilter(const double radius_)
newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
(size_t) radius_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::minify(void)
GetPPException;
newImage=MinifyImage(constImage(),exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::modulate(const double brightness_,const double saturation_,
const double hue_)
{
char
- modulate[MaxTextExtent + 1];
+ modulate[MagickPathExtent + 1];
- FormatLocaleString(modulate,MaxTextExtent,"%3.6f,%3.6f,%3.6f",brightness_,
+ FormatLocaleString(modulate,MagickPathExtent,"%3.6f,%3.6f,%3.6f",brightness_,
saturation_,hue_);
modifyImage();
GetPPException;
ModulateImage(image(),modulate,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
-Magick::ImageMoments Magick::Image::moments(void)
+Magick::ImageMoments Magick::Image::moments(void) const
{
- return(ImageMoments(constImage()));
+ return(ImageMoments(*this));
}
void Magick::Image::morphology(const MorphologyMethod method_,
GetPPException;
kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
if (kernel == (KernelInfo *) NULL)
- throwExceptionExplicit(OptionError,"Unable to parse kernel.");
+ throwExceptionExplicit(MagickCore::OptionError,"Unable to parse kernel.");
newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
exceptionInfo);
replaceImage(newImage);
kernel=DestroyKernelInfo(kernel);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::morphology(const MorphologyMethod method_,
option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
if (option == (const char *)NULL)
- throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
-
+ {
+ throwExceptionExplicit(MagickCore::OptionError,
+ "Unable to determine kernel type.");
+ return;
+ }
kernel=std::string(option);
if (!arguments_.empty())
kernel+=":"+arguments_;
GetPPException;
kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
if (kernel == (KernelInfo *)NULL)
- throwExceptionExplicit(OptionError,"Unable to parse kernel.");
- SetPPChannelMask(channel_);
+ {
+ throwExceptionExplicit(MagickCore::OptionError,
+ "Unable to parse kernel.");
+ return;
+ }
+ GetAndSetPPChannelMask(channel_);
newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
exceptionInfo);
RestorePPChannelMask;
replaceImage(newImage);
kernel=DestroyKernelInfo(kernel);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::morphologyChannel(const ChannelType channel_,
option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
if (option == (const char *)NULL)
- throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
+ {
+ throwExceptionExplicit(MagickCore::OptionError,
+ "Unable to determine kernel type.");
+ return;
+ }
kernel=std::string(option);
if (!arguments_.empty())
GetPPException;
newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::negate(const bool grayscale_)
modifyImage();
GetPPException;
NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::negateChannel(const ChannelType channel_,
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::normalize(void)
modifyImage();
GetPPException;
NormalizeImage(image(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::oilPaint(const double radius_,const double sigma_)
GetPPException;
newImage=OilPaintImage(constImage(),radius_,sigma_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
pen;
if (!opaqueColor_.isValid())
- throwExceptionExplicit(OptionError,"Opaque color argument is invalid");
+ throwExceptionExplicit(MagickCore::OptionError,
+ "Opaque color argument is invalid");
if (!penColor_.isValid())
- throwExceptionExplicit(OptionError,"Pen color argument is invalid");
+ throwExceptionExplicit(MagickCore::OptionError,
+ "Pen color argument is invalid");
modifyImage();
opaqueColor=opaqueColor_;
exceptionInfo);
OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::orderedDither(std::string thresholdMap_)
modifyImage();
GetPPException;
(void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::orderedDitherChannel(const ChannelType channel_,
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
(void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::perceptible(const double epsilon_)
modifyImage();
GetPPException;
PerceptibleImage(image(),epsilon_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::perceptibleChannel(const ChannelType channel_,
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
PerceptibleImage(image(),epsilon_,exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
- Magick::ImagePerceptualHash Magick::Image::perceptualHash()
+ Magick::ImagePerceptualHash Magick::Image::perceptualHash() const
{
- return(ImagePerceptualHash(constImage()));
+ return(ImagePerceptualHash(*this));
}
void Magick::Image::ping(const std::string &imageSpec_)
// Test arguments to ensure they are within the image.
if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
- throwExceptionExplicit(OptionError,"Access outside of image boundary");
+ throwExceptionExplicit(MagickCore::OptionError,
+ "Access outside of image boundary");
modifyImage();
newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
angle_,method_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
modifyImage();
GetPPException;
PosterizeImage(image(),levels_,method_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::posterizeChannel(const ChannelType channel_,
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
PosterizeImage(image(),levels_,method_,exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::process(std::string name_,const ssize_t argc,
GetPPException;
(void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::profile(const std::string name_,
GetPPException;
(void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
profile_.length(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
Magick::Blob Magick::Image::profile(const std::string name_) const
GetPPException;
QuantizeImage(options()->quantizeInfo(),image(),exceptionInfo);
- ThrowPPException;
-}
-
-void Magick::Image::quantumOperator(const ChannelType channel_,
- const MagickEvaluateOperator operator_,double rvalue_)
-{
- GetPPException;
- SetPPChannelMask(channel_);
- EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
- RestorePPChannelMask;
- ThrowPPException;
-}
-
-void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
- const size_t columns_,const size_t rows_,const ChannelType channel_,
- const MagickEvaluateOperator operator_,const double rvalue_)
-{
- RectangleInfo
- geometry;
-
- MagickCore::Image
- *cropImage;
-
- geometry.width = columns_;
- geometry.height = rows_;
- geometry.x = x_;
- geometry.y = y_;
-
- GetPPException;
- cropImage=CropImage(image(),&geometry,exceptionInfo);
- SetPPChannelMask(channel_);
- EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
- RestorePPChannelMask;
- (void) CompositeImage(image(),cropImage,image()->alpha_trait ==
- BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
- geometry.x,geometry.y,exceptionInfo );
- cropImage=DestroyImageList(cropImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
modifyImage();
RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::randomThreshold(const Geometry &thresholds_)
GetPPException;
(void) RandomThresholdImage(image(),static_cast<std::string>(
thresholds_).c_str(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::randomThresholdChannel(const ChannelType channel_,
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
(void) RandomThresholdImage(image(),static_cast<std::string>(
thresholds_).c_str(),exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::read(const Blob &blob_)
newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::read(const std::string &imageSpec_)
ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
quantum_,source_,exceptionInfo);
quantum_info=DestroyQuantumInfo(quantum_info);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::reduceNoise(void)
{
- reduceNoise(3.0);
+ reduceNoise(3);
}
-void Magick::Image::reduceNoise(const double order_)
+void Magick::Image::reduceNoise(const size_t order_)
{
MagickCore::Image
*newImage;
GetPPException;
- newImage=StatisticImage(constImage(),NonpeakStatistic,(size_t) order_,
- (size_t) order_,exceptionInfo);
+ newImage=StatisticImage(constImage(),NonpeakStatistic,order_,
+ order_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
+}
+
+void Magick::Image::repage()
+{
+ modifyImage();
+ options()->page(Geometry());
+ image()->page.width = 0;
+ image()->page.height = 0;
+ image()->page.x = 0;
+ image()->page.y = 0;
}
void Magick::Image::resample(const Point &density_)
newImage=ResampleImage(constImage(),density_.x(),density_.y(),
image()->filter,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::resize(const Geometry &geometry_)
newImage=ResizeImage(constImage(),width,height,image()->filter,
exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::roll(const Geometry &roll_)
GetPPException;
newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::roll(const size_t columns_,const size_t rows_)
newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
static_cast<ssize_t>(rows_),exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::rotate(const double degrees_)
GetPPException;
newImage=RotateImage(constImage(),degrees_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::rotationalBlur(const double angle_)
GetPPException;
newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
*newImage;
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
RestorePPChannelMask;
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::sample(const Geometry &geometry_)
GetPPException;
newImage=SampleImage(constImage(),width,height,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::scale(const Geometry &geometry_)
GetPPException;
newImage=ScaleImage(constImage(),width,height,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::segment(const double clusterThreshold_,
(MagickBooleanType) options()->verbose(),clusterThreshold_,
smoothingThreshold_,exceptionInfo);
SyncImage(image(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
*newImage;
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
exceptionInfo);
RestorePPChannelMask;
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
-Magick::Image Magick::Image::separate(const ChannelType channel_)
+Magick::Image Magick::Image::separate(const ChannelType channel_) const
{
MagickCore::Image
*image;
GetPPException;
image=SeparateImage(constImage(),channel_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
if (image == (MagickCore::Image *) NULL)
return(Magick::Image());
else
GetPPException;
newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
+}
+
+bool Magick::Image::setColorMetric(const Image &reference_)
+{
+ bool
+ status;
+
+ Image
+ ref=reference_;
+
+ GetPPException;
+ modifyImage();
+ status=static_cast<bool>(SetImageColorMetric(image(),ref.constImage(),
+ exceptionInfo));
+ ThrowImageException;
+ return(status);
}
Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
modifyImage();
GetPPException;
- result=(*QueueAuthenticPixels)(image(),x_,y_,columns_,rows_,exceptionInfo);
- ThrowPPException;
+ result=QueueAuthenticPixels(image(),x_,y_,columns_,rows_,exceptionInfo);
+ ThrowImageException;
return(result);
}
newImage=ShadeImage(constImage(),colorShading_ == true ?
MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::sharpen(const double radius_,const double sigma_)
GetPPException;
newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::sharpenChannel(const ChannelType channel_,
*newImage;
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
RestorePPChannelMask;
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::shave(const Geometry &geometry_)
GetPPException;
newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
GetPPException;
newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
-void Magick::Image::sigmoidalContrast(const size_t sharpen_,
+void Magick::Image::sigmoidalContrast(const bool sharpen_,
const double contrast,const double midpoint)
{
modifyImage();
GetPPException;
(void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
midpoint,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
std::string Magick::Image::signature(const bool force_) const
{
- return(_imgRef->signature());
+ return(_imgRef->signature(force_));
}
void Magick::Image::sketch(const double radius_,const double sigma_,
GetPPException;
newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::solarize(const double factor_)
modifyImage();
GetPPException;
SolarizeImage(image(),factor_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::sparseColor(const ChannelType channel_,
*newImage;
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
exceptionInfo);
RestorePPChannelMask;
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::splice(const Geometry &geometry_)
GetPPException;
newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
+}
+
+void Magick::Image::splice(const Geometry &geometry_,
+ const Color &backgroundColor_)
+{
+ backgroundColor(backgroundColor_);
+ splice(geometry_);
+}
+
+void Magick::Image::splice(const Geometry &geometry_,
+ const Color &backgroundColor_,const GravityType gravity_)
+{
+ backgroundColor(backgroundColor_);
+ image()->gravity=gravity_;
+ splice(geometry_);
}
void Magick::Image::spread(const size_t amount_)
*newImage;
GetPPException;
- newImage=SpreadImage(constImage(),amount_,image()->interpolate,
- exceptionInfo);
+ newImage=SpreadImage(constImage(),image()->interpolate,amount_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
-Magick::ImageStatistics Magick::Image::statistics()
+Magick::ImageStatistics Magick::Image::statistics() const
{
- return(ImageStatistics(constImage()));
+ return(ImageStatistics(*this));
}
void Magick::Image::stegano(const Image &watermark_)
GetPPException;
newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::stereo(const Image &rightImage_)
GetPPException;
newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::strip(void)
modifyImage();
GetPPException;
StripImage(image(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
Magick::Image Magick::Image::subImageSearch(const Image &reference_,
GetPPException;
newImage=SimilarityImage(image(),reference_.constImage(),metric_,
similarityThreshold,&offset,similarityMetric_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
if (offset_ != (Geometry *) NULL)
*offset_=offset;
if (newImage == (MagickCore::Image *) NULL)
newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::syncPixels(void)
{
GetPPException;
- (void) (*SyncAuthenticPixels)(image(),exceptionInfo);
- ThrowPPException;
+ (void) SyncAuthenticPixels(image(),exceptionInfo);
+ ThrowImageException;
}
void Magick::Image::texture(const Image &texture_)
modifyImage();
GetPPException;
TextureImage(image(),texture_.constImage(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::threshold(const double threshold_)
modifyImage();
GetPPException;
BilevelImage(image(),threshold_,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::thumbnail(const Geometry &geometry_)
GetPPException;
newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::tint(const std::string opacity_)
color=static_cast<PixelInfo>(constOptions()->fillColor());
newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::transform(const Geometry &imageGeometry_)
GetPPException;
TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::transform(const Geometry &imageGeometry_,
GetPPException;
TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
imageGeometry_).c_str(), exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::transformOrigin(const double x_,const double y_)
options()->transformScale(sx_,sy_);
}
-void Magick::Image::transparent(const Color &color_)
+void Magick::Image::transparent(const Color &color_,const bool inverse_)
{
PixelInfo
target;
color;
if (!color_.isValid())
- throwExceptionExplicit(OptionError,"Color argument is invalid");
+ throwExceptionExplicit(MagickCore::OptionError,
+ "Color argument is invalid");
color=color_;
GetPPException;
(void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
exceptionInfo);
modifyImage();
- TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
- exceptionInfo);
- ThrowPPException;
+ TransparentPaintImage(image(),&target,TransparentAlpha,
+ inverse_ == true ? MagickTrue : MagickFalse,exceptionInfo);
+ ThrowImageException;
}
void Magick::Image::transparentChroma(const Color &colorLow_,
targetLow;
if (!colorLow_.isValid() || !colorHigh_.isValid())
- throwExceptionExplicit(OptionError,"Color argument is invalid");
+ throwExceptionExplicit(MagickCore::OptionError,
+ "Color argument is invalid");
colorLow=colorLow_;
colorHigh=colorHigh_;
modifyImage();
TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
MagickFalse,exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::transpose(void)
GetPPException;
newImage=TransposeImage(constImage(),exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::transverse(void)
GetPPException;
newImage=TransverseImage(constImage(),exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::trim(void)
GetPPException;
newImage=TrimImage(constImage(),exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
-Magick::Image Magick::Image::uniqueColors(void)
+Magick::Image Magick::Image::uniqueColors(void) const
{
MagickCore::Image
*image;
GetPPException;
image=UniqueImageColors(constImage(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
if (image == (MagickCore::Image *) NULL)
return(Magick::Image());
else
newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
*newImage;
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
exceptionInfo);
RestorePPChannelMask;
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::vignette(const double radius_,const double sigma_,
GetPPException;
newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::wave(const double amplitude_,const double wavelength_)
newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::whiteThreshold(const std::string &threshold_)
modifyImage();
GetPPException;
WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
{
modifyImage();
GetPPException;
- SetPPChannelMask(channel_);
+ GetAndSetPPChannelMask(channel_);
WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
RestorePPChannelMask;
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::write(Blob *blob_)
data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
if (length > 0)
blob_->updateNoCopy(data,length,Blob::MallocAllocator);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::write(Blob *blob_,const std::string &magick_)
data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
if (length > 0)
blob_->updateNoCopy(data,length,Blob::MallocAllocator);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::write(Blob *blob_,const std::string &magick_,
data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
if (length > 0)
blob_->updateNoCopy(data,length,Blob::MallocAllocator);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::write(const ssize_t x_,const ssize_t y_,
GetPPException;
ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::write(const std::string &imageSpec_)
fileName(imageSpec_);
GetPPException;
WriteImage(constImageInfo(),image(),exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::writePixels(const Magick::QuantumType quantum_,
ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
quantum_,destination_, exceptionInfo);
quantum_info=DestroyQuantumInfo(quantum_info);
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::zoom(const Geometry &geometry_)
GetPPException;
newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
replaceImage(newImage);
- ThrowPPException;
+ ThrowImageException;
}
Magick::Image::Image(MagickCore::Image *image_)
void Magick::Image::modifyImage(void)
{
- if (_imgRef->isOwner())
+ if (!_imgRef->isShared())
return;
GetPPException;
replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
- ThrowPPException;
+ ThrowImageException;
}
MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
{
GetPPException;
image=AcquireImage(constImageInfo(),exceptionInfo);
- ThrowPPException;
- }
-
- // We can replace the image if we own it.
- if (!_imgRef->replaceImage(image))
- {
- // We don't own the image, dereference and replace with new reference
- if (_imgRef->decrease() == 0)
- delete _imgRef;
-
- _imgRef=new ImageRef(image,constOptions());
+ ThrowImageException;
}
+ _imgRef=ImageRef::replaceImage(_imgRef,image);
return(image);
}
image == (MagickCore::Image *) NULL)
{
(void) MagickCore::DestroyExceptionInfo(exceptionInfo);
- throwExceptionExplicit(ImageWarning,"No image was loaded.");
+ if (!quiet())
+ throwExceptionExplicit(MagickCore::ImageWarning,
+ "No image was loaded.");
}
- ThrowPPException;
+ ThrowImageException;
}
void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
GetPPException;
fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
exceptionInfo);
- ThrowPPException;
+ ThrowImageException;
}
if (fillPattern_ == (Magick::Image *)NULL)
options()->fillColor(fillColor);
options()->fillPattern(fillPattern);
- ThrowPPException;
+ ThrowImageException;
}