%
% The format of the CropToFitImage method is:
%
-% Image *CropToFitImage(Image **image,const MagickRealType x_shear,
-% const MagickRealType x_shear,const MagickRealType width,
-% const MagickRealType height,const MagickBooleanType rotate,
-% ExceptionInfo *exception)
+% MagickBooleanType CropToFitImage(Image **image,
+% const MagickRealType x_shear,const MagickRealType x_shear,
+% const MagickRealType width,const MagickRealType height,
+% const MagickBooleanType rotate,ExceptionInfo *exception)
%
% A description of each parameter follows.
%
% o exception: return any errors or warnings in this structure.
%
*/
-static inline void CropToFitImage(Image **image,const MagickRealType x_shear,
- const MagickRealType y_shear,const MagickRealType width,
- const MagickRealType height,const MagickBooleanType rotate,
- ExceptionInfo *exception)
+static MagickBooleanType CropToFitImage(Image **image,
+ const MagickRealType x_shear,const MagickRealType y_shear,
+ const MagickRealType width,const MagickRealType height,
+ const MagickBooleanType rotate,ExceptionInfo *exception)
{
Image
*crop_image;
page=(*image)->page;
(void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
crop_image=CropImage(*image,&geometry,exception);
- (*image)->page=page;
- if (crop_image != (Image *) NULL)
- {
- crop_image->page=page;
- *image=DestroyImage(*image);
- *image=crop_image;
- }
+ if (crop_image == (Image *) NULL)
+ return(MagickFalse);
+ crop_image->page=page;
+ *image=DestroyImage(*image);
+ *image=crop_image;
+ return(MagickTrue);
}
\f
/*
status=MagickFalse;
}
}
- (void) SetImageProgress(image,RotateImageTag,image->rows-1,image->rows);
+ (void) SetImageProgress(image,RotateImageTag,(MagickOffsetType)
+ image->rows-1,image->rows);
Swap(page.width,page.height);
Swap(page.x,page.y);
if (page.width != 0)
status=MagickFalse;
}
}
- (void) SetImageProgress(image,RotateImageTag,image->rows-1,image->rows);
+ (void) SetImageProgress(image,RotateImageTag,(MagickOffsetType)
+ image->rows-1,image->rows);
Swap(page.width,page.height);
Swap(page.x,page.y);
if (page.height != 0)
%
% MagickBooleanType XShearImage(Image *image,const MagickRealType degrees,
% const unsigned long width,const unsigned long height,
-% const long x_offset,const long y_offset)
+% const long x_offset,const long y_offset,ExceptionInfo *exception)
%
% A description of each parameter follows.
%
% o width, height, x_offset, y_offset: Defines a region of the image
% to shear.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
static MagickBooleanType XShearImage(Image *image,const MagickRealType degrees,
const unsigned long width,const unsigned long height,const long x_offset,
- const long y_offset)
+ const long y_offset,ExceptionInfo *exception)
{
#define XShearImageTag "XShear/Image"
CacheView
*image_view;
- ExceptionInfo
- *exception;
-
long
progress,
y;
*/
status=MagickTrue;
progress=0;
- exception=(&image->exception);
image_view=AcquireCacheView(image);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress, status)
%
% MagickBooleanType YShearImage(Image *image,const MagickRealType degrees,
% const unsigned long width,const unsigned long height,
-% const long x_offset,const long y_offset)
+% const long x_offset,const long y_offset,ExceptionInfo *exception)
%
% A description of each parameter follows.
%
% o width, height, x_offset, y_offset: Defines a region of the image
% to shear.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
static MagickBooleanType YShearImage(Image *image,const MagickRealType degrees,
const unsigned long width,const unsigned long height,const long x_offset,
- const long y_offset)
+ const long y_offset,ExceptionInfo *exception)
{
#define YShearImageTag "YShear/Image"
CacheView
*image_view;
- ExceptionInfo
- *exception;
-
long
progress,
x;
*/
status=MagickTrue;
progress=0;
- exception=(&image->exception);
image_view=AcquireCacheView(image);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress, status)
x_offset,
y_offset;
+ MagickBooleanType
+ status;
+
MagickRealType
angle;
/*
Rotate the image.
*/
- (void) XShearImage(rotate_image,shear.x,width,height,x_offset,
- ((long) rotate_image->rows-height)/2);
- (void) YShearImage(rotate_image,shear.y,y_width,height,
- ((long) rotate_image->columns-y_width)/2,y_offset);
- (void) XShearImage(rotate_image,shear.x,y_width,rotate_image->rows,
- ((long) rotate_image->columns-y_width)/2,0);
- CropToFitImage(&rotate_image,shear.x,shear.y,(MagickRealType) width,
+ status=XShearImage(rotate_image,shear.x,width,height,x_offset,((long)
+ rotate_image->rows-height)/2,exception);
+ if (status == MagickFalse)
+ {
+ rotate_image=DestroyImage(rotate_image);
+ return((Image *) NULL);
+ }
+ status=YShearImage(rotate_image,shear.y,y_width,height,((long)
+ rotate_image->columns-y_width)/2,y_offset,exception);
+ if (status == MagickFalse)
+ {
+ rotate_image=DestroyImage(rotate_image);
+ return((Image *) NULL);
+ }
+ status=XShearImage(rotate_image,shear.x,y_width,rotate_image->rows,((long)
+ rotate_image->columns-y_width)/2,0,exception);
+ if (status == MagickFalse)
+ {
+ rotate_image=DestroyImage(rotate_image);
+ return((Image *) NULL);
+ }
+ status=CropToFitImage(&rotate_image,shear.x,shear.y,(MagickRealType) width,
(MagickRealType) height,MagickTrue,exception);
+ if (status == MagickFalse)
+ {
+ rotate_image=DestroyImage(rotate_image);
+ return((Image *) NULL);
+ }
rotate_image->compose=image->compose;
rotate_image->page.width=0;
rotate_image->page.height=0;
x_offset,
y_offset;
+ MagickBooleanType
+ status;
+
PointInfo
shear;
border_info.width=(unsigned long) x_offset;
border_info.height=(unsigned long) y_offset;
shear_image=BorderImage(integral_image,&border_info,exception);
+ integral_image=DestroyImage(integral_image);
if (shear_image == (Image *) NULL)
ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
- integral_image=DestroyImage(integral_image);
/*
Shear the image.
*/
if (shear_image->matte == MagickFalse)
(void) SetImageAlphaChannel(shear_image,OpaqueAlphaChannel);
- (void) XShearImage(shear_image,shear.x,image->columns,image->rows,x_offset,
- ((long) shear_image->rows-image->rows)/2);
- (void) YShearImage(shear_image,shear.y,y_width,image->rows,
- ((long) shear_image->columns-y_width)/2,y_offset);
- CropToFitImage(&shear_image,shear.x,shear.y,(MagickRealType) image->columns,
- (MagickRealType) image->rows,MagickFalse,exception);
+ status=XShearImage(shear_image,shear.x,image->columns,image->rows,x_offset,
+ ((long) shear_image->rows-image->rows)/2,exception);
+ if (status == MagickFalse)
+ {
+ shear_image=DestroyImage(shear_image);
+ return((Image *) NULL);
+ }
+ status=YShearImage(shear_image,shear.y,y_width,image->rows,((long)
+ shear_image->columns-y_width)/2,y_offset,exception);
+ if (status == MagickFalse)
+ {
+ shear_image=DestroyImage(shear_image);
+ return((Image *) NULL);
+ }
+ status=CropToFitImage(&shear_image,shear.x,shear.y,(MagickRealType)
+ image->columns,(MagickRealType) image->rows,MagickFalse,exception);
+ if (status == MagickFalse)
+ {
+ shear_image=DestroyImage(shear_image);
+ return((Image *) NULL);
+ }
shear_image->compose=image->compose;
shear_image->page.width=0;
shear_image->page.height=0;