#define MAGICKCORE_IMPLEMENTATION 1
#define MAGICK_PLUSPLUS_IMPLEMENTATION 1
+#include "Magick++/Include.h"
#include <cstdlib>
#include <string>
#include <string.h>
#include <errno.h>
#include <math.h>
-#include "Magick++/Include.h"
using namespace std;
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
MagickCore::Image* newImage =
- AdaptiveBlurImage( image(), radius_, sigma_, image()->bias, &exceptionInfo);
+ AdaptiveBlurImage( image(), radius_, sigma_, &exceptionInfo);
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
{
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- ChannelType channel_mask = SetPixelChannelMask( image(), channel_);
+ ChannelType channel_mask = SetImageChannelMask( image(), channel_);
MagickCore::Image* newImage =
AddNoiseImage ( image(),
noiseType_, 1.0,
&exceptionInfo );
- (void) SetPixelChannelMapMask( image(), channel_mask );
+ (void) SetPixelChannelMask( image(), channel_mask );
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
MagickCore::Image* newImage =
- BlurImage( image(), radius_, sigma_, image()->bias, &exceptionInfo);
+ BlurImage( image(), radius_, sigma_, &exceptionInfo);
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
{
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- ChannelType channel_mask = SetPixelChannelMask( image(), channel_ );
+ ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
MagickCore::Image* newImage =
- BlurImage( image(), radius_, sigma_, image()->bias, &exceptionInfo);
- (void) SetPixelChannelMapMask( image(), channel_mask );
+ BlurImage( image(), radius_, sigma_, &exceptionInfo);
+ (void) SetPixelChannelMask( image(), channel_mask );
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
MagickCore::Image* newImage =
- CharcoalImage( image(), radius_, sigma_, image()->bias, &exceptionInfo );
+ CharcoalImage( image(), radius_, sigma_, &exceptionInfo );
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
kernel_info=AcquireKernelInfo((const char *) NULL);
kernel_info->width=order_;
kernel_info->height=order_;
- kernel_info->values=(MagickRealType *) color_matrix_;
- MagickCore::Image* newImage =
- ColorMatrixImage( image(), kernel_info, &exceptionInfo );
- kernel_info->values=(MagickRealType *) NULL;
+ kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
+ order_*sizeof(*kernel_info->values));
+ if (kernel_info->values != (MagickRealType *) NULL)
+ {
+ for (ssize_t i=0; i < (order_*order_); i++)
+ kernel_info->values[i]=color_matrix_[i];
+ MagickCore::Image* newImage =
+ ColorMatrixImage( image(), kernel_info, &exceptionInfo );
+ replaceImage( newImage );
+ }
kernel_info=DestroyKernelInfo(kernel_info);
- replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
}
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
CompositeImage( image(),
- compose_,
compositeImage_.constImage(),
+ compose_, MagickFalse,
xOffset_,
yOffset_, &exceptionInfo );
throwException( exceptionInfo );
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
CompositeImage( image(),
- compose_,
compositeImage_.constImage(),
+ compose_, MagickFalse,
x, y, &exceptionInfo );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
CompositeImage( image(),
- compose_,
compositeImage_.constImage(),
+ compose_, MagickFalse,
geometry.x, geometry.y, &exceptionInfo );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
kernel_info=AcquireKernelInfo((const char *) NULL);
kernel_info->width=order_;
kernel_info->height=order_;
- kernel_info->values=(MagickRealType *) kernel_;
- kernel_info->bias=image()->bias;
- MagickCore::Image* newImage =
- ConvolveImage ( image(), kernel_info, &exceptionInfo );
- kernel_info->values=(MagickRealType *) NULL;
+ kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
+ order_*sizeof(*kernel_info->values));
+ if (kernel_info->values != (MagickRealType *) NULL)
+ {
+ for (ssize_t i=0; i < (order_*order_); i++)
+ kernel_info->values[i]=kernel_[i];
+ MagickCore::Image* newImage =
+ ConvolveImage ( image(), kernel_info, &exceptionInfo );
+ replaceImage( newImage );
+ }
kernel_info=DestroyKernelInfo(kernel_info);
- replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
}
//
void Magick::Image::extent ( const Geometry &geometry_ )
{
- RectangleInfo extentInfo = geometry_;
modifyImage();
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
+ RectangleInfo extentInfo = geometry_;
+ extentInfo.x = geometry_.xOff();
+ extentInfo.y = geometry_.yOff();
MagickCore::Image* newImage =
ExtentImage ( image(), &extentInfo, &exceptionInfo );
replaceImage( newImage );
}
void Magick::Image::extent ( const Geometry &geometry_, const GravityType gravity_ )
{
- image()->gravity = gravity_;
- extent ( geometry_ );
+ RectangleInfo geometry;
+
+ SetGeometry(image(), &geometry);
+ geometry.width = geometry_.width();
+ geometry.height = geometry_.height();
+ GravityAdjustGeometry(image()->columns, image()->rows, gravity_, &geometry);
+ extent ( geometry );
}
void Magick::Image::extent ( const Geometry &geometry_, const Color &backgroundColor_, const GravityType gravity_ )
{
- image()->gravity = gravity_;
backgroundColor ( backgroundColor_ );
- extent ( geometry_ );
+ extent ( geometry_, gravity_ );
}
// Flip image (reflect each scanline in the vertical direction)
{
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- ChannelType channel_mask = SetPixelChannelMask( image(), channel );
+ ChannelType channel_mask = SetImageChannelMask( image(), channel );
MagickCore::Image* newImage =
FxImage ( image(), expression.c_str(), &exceptionInfo );
- (void) SetPixelChannelMapMask( image(), channel_mask );
+ (void) SetPixelChannelMask( image(), channel_mask );
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
{
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- ChannelType channel_mask = SetPixelChannelMask( image(), channel_ );
+ ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
MagickCore::Image* newImage =
GaussianBlurImage( image(), width_, sigma_, &exceptionInfo );
- (void) SetPixelChannelMapMask( image(), channel_mask );
+ (void) SetPixelChannelMask( image(), channel_mask );
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
target.green=static_cast<PixelInfo>(target_).green;
target.blue=static_cast<PixelInfo>(target_).blue;
target.alpha=alpha_;
- ChannelType channel_mask = SetPixelChannelMask( image(), AlphaChannel );
+ ChannelType channel_mask = SetImageChannelMask( image(), AlphaChannel );
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
FloodfillPaintImage ( image(), options()->drawInfo(), &target, x_, y_,
method_ == FloodfillMethod ? MagickFalse : MagickTrue, &exceptionInfo);
- (void) SetPixelChannelMapMask( image(), channel_mask );
+ (void) SetPixelChannelMask( image(), channel_mask );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
}
(void) DestroyExceptionInfo( &exceptionInfo );
}
+// Merge layers
+void Magick::Image::mergeLayers( const LayerMethod layerMethod_ )
+{
+ ExceptionInfo exceptionInfo;
+ GetExceptionInfo( &exceptionInfo );
+ MagickCore::Image* newImage =
+ MergeImageLayers ( image(),
+ layerMethod_,
+ &exceptionInfo );
+ replaceImage( newImage );
+ throwException( exceptionInfo );
+ (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
// Reduce image by integral size
void Magick::Image::minify ( void )
{
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
MagickCore::Image* newImage =
- MotionBlurImage( image(), radius_, sigma_, angle_, 0.0, &exceptionInfo);
+ MotionBlurImage( image(), radius_, sigma_, angle_, &exceptionInfo);
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
size_t status =
InvokeDynamicImageFilter( name_.c_str(), &image(), argc, argv,
&exceptionInfo );
+ (void) status;
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
}
{
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- ChannelType channel_mask = SetPixelChannelMask( image(), channel_ );
+ ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
EvaluateImage( image(), operator_, rvalue_, &exceptionInfo);
- (void) SetPixelChannelMapMask( image(), channel_mask );
+ (void) SetPixelChannelMask( image(), channel_mask );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
}
geometry.y = y_;
MagickCore::Image *crop_image = CropImage( image(), &geometry,
&exceptionInfo );
- ChannelType channel_mask = SetPixelChannelMask( image(), channel_);
+ ChannelType channel_mask = SetImageChannelMask( image(), channel_);
EvaluateImage( crop_image, operator_, rvalue_, &exceptionInfo );
- (void) SetPixelChannelMapMask( image(), channel_mask );
- (void) CompositeImage( image(), image()->matte != MagickFalse ?
- OverCompositeOp : CopyCompositeOp, crop_image, geometry.x, geometry.y,
+ (void) SetPixelChannelMask( image(), channel_mask );
+ (void) CompositeImage( image(), crop_image, image()->alpha_trait == BlendPixelTrait ?
+ OverCompositeOp : CopyCompositeOp, MagickFalse, geometry.x, geometry.y,
&exceptionInfo );
crop_image = DestroyImageList(crop_image);
throwException( exceptionInfo );
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
modifyImage();
- ChannelType channel_mask = SetPixelChannelMask( image(), channel_);
+ ChannelType channel_mask = SetImageChannelMask( image(), channel_);
(void) RandomThresholdImage( image(),
static_cast<std::string>(thresholds_).c_str(),
&exceptionInfo );
- (void) SetPixelChannelMapMask( image(), channel_mask );
+ (void) SetPixelChannelMask( image(), channel_mask );
throwImageException();
(void) DestroyExceptionInfo( &exceptionInfo );
}
width,
height,
image()->filter,
- 1.0,
&exceptionInfo);
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
}
-// Charcoal-effect image
+// Simulate an image shadow
void Magick::Image::shadow( const double percent_opacity_, const double sigma_,
const ssize_t x_, const ssize_t y_ )
{
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
MagickCore::Image* newImage = ShadowImage( image(), percent_opacity_, sigma_,
- image()->bias, x_, y_, &exceptionInfo );
+ x_, y_, &exceptionInfo );
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
SharpenImage( image(),
radius_,
sigma_,
- image()->bias,
&exceptionInfo );
replaceImage( newImage );
throwException( exceptionInfo );
{
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- ChannelType channel_mask = SetPixelChannelMask( image(), channel_ );
+ ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
MagickCore::Image* newImage =
SharpenImage( image(),
radius_,
sigma_,
- image()->bias,
&exceptionInfo );
- (void) SetPixelChannelMapMask( image(), channel_mask );
+ (void) SetPixelChannelMask( image(), channel_mask );
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- ChannelType channel_mask = SetPixelChannelMask( image(), channel );
+ ChannelType channel_mask = SetImageChannelMask( image(), channel );
MagickCore::Image* newImage = SparseColorImage ( image(), method,
number_arguments, arguments, &exceptionInfo );
- (void) SetPixelChannelMapMask( image(), channel_mask );
+ (void) SetPixelChannelMask( image(), channel_mask );
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
{
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- ChannelType channel_mask = SetPixelChannelMask( image(), channel_ );
+ ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
MagickCore::Image* newImage =
UnsharpMaskImage( image(),
radius_,
amount_,
threshold_,
&exceptionInfo );
- (void) SetPixelChannelMapMask( image(), channel_mask );
+ (void) SetPixelChannelMask( image(), channel_mask );
replaceImage( newImage );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
size_t length = 2048; // Efficient size for small images
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- void* data = ImageToBlob( imageInfo(),
+ void* data = ImagesToBlob( imageInfo(),
image(),
&length,
&exceptionInfo);
size_t length = 2048; // Efficient size for small images
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- void* data = ImageToBlob( imageInfo(),
+ void* data = ImagesToBlob( imageInfo(),
image(),
&length,
&exceptionInfo);
size_t length = 2048; // Efficient size for small images
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- void* data = ImageToBlob( imageInfo(),
+ void* data = ImagesToBlob( imageInfo(),
image(),
&length,
&exceptionInfo);
width,
height,
image()->filter,
- image()->blur,
&exceptionInfo);
replaceImage( newImage );
throwException( exceptionInfo );
// Image colorspace
void Magick::Image::colorSpace( const ColorspaceType colorSpace_ )
{
- // Nothing to do?
if ( image()->colorspace == colorSpace_ )
return;
modifyImage();
-
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- if ( colorSpace_ != RGBColorspace &&
- colorSpace_ != sRGBColorspace &&
- colorSpace_ != TransparentColorspace &&
- colorSpace_ != GRAYColorspace )
- {
- if (image()->colorspace != RGBColorspace &&
- image()->colorspace != sRGBColorspace &&
- image()->colorspace != TransparentColorspace &&
- image()->colorspace != GRAYColorspace)
- {
- /* Transform to RGB colorspace as intermediate step */
- TransformRGBImage( image(), image()->colorspace, &exceptionInfo );
- throwImageException();
- }
- /* Transform to final non-RGB colorspace */
- RGBTransformImage( image(), colorSpace_, &exceptionInfo );
- throwException( exceptionInfo );
- (void) DestroyExceptionInfo( &exceptionInfo );
- return;
- }
-
- if ( colorSpace_ == RGBColorspace ||
- colorSpace_ == sRGBColorspace ||
- colorSpace_ == TransparentColorspace ||
- colorSpace_ == GRAYColorspace )
- {
- /* Transform to a RGB-type colorspace */
- TransformRGBImage( image(), image()->colorspace, &exceptionInfo );
- throwException( exceptionInfo );
- (void) DestroyExceptionInfo( &exceptionInfo );
- return;
- }
+ TransformImageColorspace(image(), colorSpace_, &exceptionInfo);
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
}
void Magick::Image::colorspaceType( const ColorspaceType colorSpace_ )
{
modifyImage();
+ ExceptionInfo exceptionInfo;
+ GetExceptionInfo( &exceptionInfo );
+ SetImageColorspace(image(), colorSpace_, &exceptionInfo);
+ throwException( exceptionInfo );
+ (void) DestroyExceptionInfo( &exceptionInfo );
options()->colorspaceType( colorSpace_ );
}
Magick::ColorspaceType Magick::Image::colorspaceType ( void ) const
// desired, then set the matte channel to opaque.
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- if ((matteFlag_ && !constImage()->matte) ||
- (constImage()->matte && !matteFlag_))
+ if ((matteFlag_ && !constImage()->alpha_trait) ||
+ (constImage()->alpha_trait && !matteFlag_))
SetImageAlpha(image(),OpaqueAlpha,&exceptionInfo);
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
- image()->matte = (MagickBooleanType) matteFlag_;
+ image()->alpha_trait = matteFlag_ ? BlendPixelTrait : UndefinedPixelTrait;
}
bool Magick::Image::matte ( void ) const
{
- if ( constImage()->matte )
+ if ( constImage()->alpha_trait == BlendPixelTrait )
return true;
else
return false;
Magick::Color Magick::Image::pixelColor ( const ssize_t x_,
const ssize_t y_ ) const
{
- ClassType storage_class;
- storage_class = classType();
- // DirectClass
const Quantum* pixel = getConstPixels( x_, y_, 1, 1 );
if ( pixel )
{
ssize_t result = ProfileImage( image(), name_.c_str(),
(unsigned char *)profile_.data(),
profile_.length(), &exceptionInfo);
+ (void) result;
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
ExceptionInfo exceptionInfo;
GetExceptionInfo( &exceptionInfo );
- ChannelType channel_mask = SetPixelChannelMask( image(), RedChannel);
+ ChannelType channel_mask = SetImageChannelMask( image(), RedChannel);
(void) GetImageRange( image(),&minimum,&maximum,&exceptionInfo);
statistics->red.minimum=minimum;
statistics->red.maximum=maximum;
&statistics->red.standard_deviation,&exceptionInfo);
(void) GetImageKurtosis( image(),&statistics->red.kurtosis,
&statistics->red.skewness,&exceptionInfo);
- (void) SetPixelChannelMapMask( image(), channel_mask );
+ (void) SetPixelChannelMask( image(), channel_mask );
- channel_mask = SetPixelChannelMask( image(), GreenChannel);
+ channel_mask = SetImageChannelMask( image(), GreenChannel);
(void) GetImageRange( image(),&minimum,&maximum,&exceptionInfo);
statistics->green.minimum=minimum;
statistics->green.maximum=maximum;
&statistics->green.standard_deviation,&exceptionInfo);
(void) GetImageKurtosis( image(),&statistics->green.kurtosis,
&statistics->green.skewness,&exceptionInfo);
- (void) SetPixelChannelMapMask( image(), channel_mask );
+ (void) SetPixelChannelMask( image(), channel_mask );
- channel_mask = SetPixelChannelMask( image(), GreenChannel);
+ channel_mask = SetImageChannelMask( image(), GreenChannel);
(void) GetImageRange( image(),&minimum,&maximum,&exceptionInfo);
statistics->blue.minimum=minimum;
statistics->blue.maximum=maximum;
&statistics->blue.standard_deviation,&exceptionInfo);
(void) GetImageKurtosis( image(),&statistics->blue.kurtosis,
&statistics->blue.skewness,&exceptionInfo);
- (void) SetPixelChannelMapMask( image(), channel_mask );
+ (void) SetPixelChannelMask( image(), channel_mask );
- channel_mask = SetPixelChannelMask( image(), AlphaChannel);
+ channel_mask = SetImageChannelMask( image(), AlphaChannel);
(void) GetImageRange( image(),&minimum,&maximum,&exceptionInfo);
statistics->alpha.minimum=minimum;
statistics->alpha.maximum=maximum;
&statistics->alpha.standard_deviation,&exceptionInfo);
(void) GetImageKurtosis( image(),&statistics->alpha.kurtosis,
&statistics->alpha.skewness,&exceptionInfo);
- (void) SetPixelChannelMapMask( image(), channel_mask );
+ (void) SetPixelChannelMask( image(), channel_mask );
throwException( exceptionInfo );
(void) DestroyExceptionInfo( &exceptionInfo );
void Magick::Image::virtualPixelMethod ( const VirtualPixelMethod virtual_pixel_method_ )
{
modifyImage();
- SetImageVirtualPixelMethod( image(), virtual_pixel_method_ );
+ ExceptionInfo exceptionInfo;
+ GetExceptionInfo( &exceptionInfo );
+ SetImageVirtualPixelMethod( image(), virtual_pixel_method_, &exceptionInfo );
+ throwException( exceptionInfo );
+ (void) DestroyExceptionInfo( &exceptionInfo );
}
Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod ( void ) const
{