% July 1992 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
#include "MagickCore/string_.h"
#include "MagickCore/string-private.h"
#include "MagickCore/thread-private.h"
+#include "MagickCore/token.h"
#include "MagickCore/utility.h"
#include "MagickCore/utility-private.h"
#include "MagickCore/version.h"
}
static MagickRealType Kaiser(const MagickRealType x,
- const ResizeFilter *magick_unused(resize_filter))
+ const ResizeFilter *resize_filter)
{
-#define Alpha 6.5
-#define I0A (1.0/I0(Alpha))
-
/*
- Kaiser Windowing Function (bessel windowing): Alpha is a free value
- from 5 to 8 (currently hardcoded to 6.5). Future: make alpha the IOA
- pre-calculation, an 'expert' setting.
+ Kaiser Windowing Function (bessel windowing)
+ Alpha (c[0]) is a free value from 5 to 8 (defaults to 6.5).
+ A scaling factor (c[1]) is not needed as filter is normalized
*/
- return(I0A*I0(Alpha*sqrt((double) (1.0-x*x))));
+ return(resize_filter->coefficient[1]*
+ I0(resize_filter->coefficient[0]*sqrt((double) (1.0-x*x))));
}
static MagickRealType Lagrange(const MagickRealType x,
% Blackman Hanning Hamming Kaiser Lanczos
%
% Special purpose Filters
-% SincFast LanczosSharp Lanczos2D Lanczos2DSharp Robidoux
+% SincFast LanczosSharp Lanczos2 Lanczos2Sharp
+% Robidoux RobidouxSharp
%
% The users "-filter" selection is used to lookup the default 'expert'
% settings for that filter from a internal table. However any provided
% suited to this style of image resampling. This typically happens when using
% such a filter for images distortions.
%
+% SPECIFIC FILTERS:
+%
% Directly requesting 'Sinc', 'Jinc' function as a filter will force the use
% of function without any windowing, or promotion for cylindrical usage. This
% is not recommended, except by image processing experts, especially as part
% crossing is at (36 sqrt(2) + 123)/(72 sqrt(2) + 47), almost the same as the
% first crossing of Mitchell and Lanczos2Sharp.
%
+% RodidouxSharp is a slightly sharper version of Rodidoux, some believe it
+% is too sharp. It is designed to minimize the maximum possible change in
+% a pixel value which is at one of the extremes (e.g., 0 or 255) under no-op
+% conditions. Amazingly Mitchell falls roughly between Rodidoux and
+% RodidouxSharp, though this seems to have been pure coincidence.
+%
% 'EXPERT' OPTIONS:
%
% These artifact "defines" are not recommended for production use without
% The format of the AcquireResizeFilter method is:
%
% ResizeFilter *AcquireResizeFilter(const Image *image,
-% const FilterTypes filter_type, const MagickBooleanType radial,
+% const FilterTypes filter_type,const MagickBooleanType cylindrical,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
*/
MagickPrivate ResizeFilter *AcquireResizeFilter(const Image *image,
- const FilterTypes filter,const MagickRealType blur,
- const MagickBooleanType cylindrical,ExceptionInfo *exception)
+ const FilterTypes filter,const MagickBooleanType cylindrical,
+ ExceptionInfo *exception)
{
const char
*artifact;
MagickRealType
B,
C,
- sigma;
+ value;
register ResizeFilter
*resize_filter;
{ Lanczos2Filter, Lanczos2Filter }, /* | special handling */
{ Lanczos2SharpFilter, Lanczos2SharpFilter },
{ RobidouxFilter, BoxFilter }, /* Cubic Keys tuned for EWA */
+ { RobidouxSharpFilter, BoxFilter }, /* Sharper Cubic Keys for EWA */
};
/*
Table mapping the filter/window from the above table to an actual function.
MagickRealType
(*function)(const MagickRealType,const ResizeFilter*),
lobes, /* Default lobes/support size of the weighting filter. */
- scale, /* Support when function used as a windowing function. Typically
- equal to the location of the first zero crossing. */
- B,
- C; /* BC-spline coefficients, ignored if not a CubicBC filter. */
+ scale, /* Support when function used as a windowing function
+ Typically equal to the location of the first zero crossing. */
+ B,C; /* BC-spline coefficients, ignored if not a CubicBC filter. */
} const filters[SentinelFilter] =
{
+ /* .--- support window
+ | .--- first crossing (if used as a Windowing function)
+ | | .--- B value for Cubic Function
+ | | | .---- C value for Cubic Function
+ | | | | */
{ Box, 0.5, 0.5, 0.0, 0.0 }, /* Undefined (default to Box) */
{ Box, 0.0, 0.5, 0.0, 0.0 }, /* Point (special handling) */
{ Box, 0.5, 0.5, 0.0, 0.0 }, /* Box */
{ SincFast, 3.0, 1.0, 0.0, 0.0 }, /* lanczos, Sharpened */
{ SincFast, 2.0, 1.0, 0.0, 0.0 }, /* Lanczos, 2-lobed */
{ SincFast, 2.0, 1.0, 0.0, 0.0 }, /* Lanczos2, sharpened */
- { CubicBC, 2.0, 1.1685777620836932, 0.37821575509399867,
- 0.31089212245300067 }
- /* Robidoux: Keys cubic close to Lanczos2D sharpened */
+ /* Robidoux: Keys cubic close to Lanczos2D sharpened */
+ { CubicBC, 2.0, 1.1685777620836932,
+ 0.37821575509399867, 0.31089212245300067 },
+ /* RobidouxSharp: Sharper version of Robidoux */
+ { CubicBC, 2.0, 1.105822933719019,
+ 0.2620145123990142, 0.3689927438004929 }
};
/*
The known zero crossings of the Jinc() or more accurately the Jinc(x*PI)
users do not have to deal with the highly irrational lobe sizes of the Jinc
filter.
- Values taken from http://cose.math.bas.bg/webMathematica/webComputing/
- BesselZeros.jsp using Jv-function with v=1, then dividing by PI.
+ Values taken from
+ http://cose.math.bas.bg/webMathematica/webComputing/BesselZeros.jsp
+ using Jv-function with v=1, then dividing by PI.
*/
static MagickRealType
jinc_zeros[16] =
*/
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
+ if( IfMagickTrue(image->debug) )
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(UndefinedFilter < filter && filter < SentinelFilter);
assert(exception != (ExceptionInfo *) NULL);
*/
filter_type=mapping[filter].filter;
window_type=mapping[filter].window;
- resize_filter->blur = blur; /* function argument blur factor */
- sigma=0.5; /* gaussian sigma of half a pixel by default */
- if ((cylindrical != MagickFalse) && (filter_type == SincFastFilter) &&
+ resize_filter->blur=1.0;
+ /* Promote 1D Windowed Sinc Filters to a 2D Windowed Jinc filters */
+ if( IfMagickTrue(cylindrical) && (filter_type == SincFastFilter) &&
(filter != SincFastFilter))
filter_type=JincFilter; /* 1D Windowed Sinc => 2D Windowed Jinc filters */
+
+ /* Expert filter setting override */
artifact=GetImageArtifact(image,"filter:filter");
if (artifact != (const char *) NULL)
{
ssize_t
option;
- /*
- Expert filter setting override.
- */
option=ParseCommandOption(MagickFilterOptions,MagickFalse,artifact);
if ((UndefinedFilter < option) && (option < SentinelFilter))
- {
- /*
- Raw filter request - no window function.
- */
+ { /* Raw filter request - no window function. */
filter_type=(FilterTypes) option;
window_type=BoxFilter;
}
+ /* Filter override with a specific window function. */
artifact=GetImageArtifact(image,"filter:window");
if (artifact != (const char *) NULL)
{
- /*
- Filter override with a specific window function.
- */
option=ParseCommandOption(MagickFilterOptions,MagickFalse,artifact);
if ((UndefinedFilter < option) && (option < SentinelFilter))
window_type=(FilterTypes) option;
}
else
{
+ /* Window specified, but no filter function? Assume Sinc/Jinc. */
artifact=GetImageArtifact(image,"filter:window");
if (artifact != (const char *) NULL)
{
ssize_t
option;
- /*
- Window specified, but no filter function? Assume Sinc/Jinc.
- */
option=ParseCommandOption(MagickFilterOptions,MagickFalse,artifact);
if ((UndefinedFilter < option) && (option < SentinelFilter))
{
- filter_type=cylindrical != MagickFalse ? JincFilter :
- SincFastFilter;
+ filter_type= IfMagickTrue(cylindrical) ? JincFilter
+ : SincFastFilter;
window_type=(FilterTypes) option;
}
}
}
- /*
- Assign the real functions to use for the filters selected.
- */
+
+ /* Assign the real functions to use for the filters selected. */
resize_filter->filter=filters[filter_type].function;
resize_filter->support=filters[filter_type].lobes;
resize_filter->window=filters[window_type].function;
resize_filter->scale=filters[window_type].scale;
resize_filter->signature=MagickSignature;
- /*
- Filter Modifications for orthogonal/cylindrical usage.
- */
+
+ /* Filter Modifications for orthogonal/cylindrical usage */
if (cylindrical != MagickFalse)
switch (filter_type)
{
case BoxFilter:
- {
- /*
- Support for Cylindrical Box should be sqrt(2)/2.
- */
+ /* Support for Cylindrical Box should be sqrt(2)/2 */
resize_filter->support=(MagickRealType) MagickSQ1_2;
break;
- }
case LanczosFilter:
case LanczosSharpFilter:
case Lanczos2Filter:
case Lanczos2SharpFilter:
- {
- /*
- Number of lobes (support window size) remain unchanged.
- */
resize_filter->filter=filters[JincFilter].function;
resize_filter->window=filters[JincFilter].function;
resize_filter->scale=filters[JincFilter].scale;
+ /* number of lobes (support window size) remain unchanged */
break;
- }
default:
break;
}
- /*
- Global Sharpening (regardless of orthoginal/cylindrical).
- */
+ /* Global Sharpening (regardless of orthoginal/cylindrical) */
switch (filter_type)
{
case LanczosSharpFilter:
- {
- resize_filter->blur*=0.9812505644269356;
+ resize_filter->blur *= 0.9812505644269356;
break;
- }
case Lanczos2SharpFilter:
- {
- resize_filter->blur*=0.9549963639785485;
+ resize_filter->blur *= 0.9549963639785485;
break;
- }
default:
break;
}
- artifact=GetImageArtifact(image,"filter:sigma");
- if (artifact != (const char *) NULL)
- sigma=InterpretLocaleValue(artifact,(char **) NULL); /* override sigma */
- if (GaussianFilter)
- {
- /*
- Define coefficents for Gaussian.
- */
- resize_filter->coefficient[0]=1.0/(2.0*sigma*sigma);
- resize_filter->coefficient[1]=(MagickRealType) (1.0/(Magick2PI*sigma*
- sigma)); /* normalization multiplier - unneeded for filters */
- }
+
+ /*
+ Expert Option Modifications.
+ */
+
+ /* User Gaussian Sigma Override - no support change */
+ value=0.5; /* guassian sigma default, half pixel */
+ if ( GaussianFilter ) {
+ artifact=GetImageArtifact(image,"filter:sigma");
+ if (artifact != (const char *) NULL)
+ value=StringToDouble(artifact,(char **) NULL);
+ /* Define coefficents for Gaussian */
+ resize_filter->coefficient[0]=1.0/(2.0*value*value); /* X scaling */
+ resize_filter->coefficient[1]=(MagickRealType) (1.0/(Magick2PI*value*
+ value)); /* normalization */
+ }
+ /* User Kaiser Alpha Override - no support change */
+ if ( KaiserFilter ) {
+ value=6.5; /* default alpha value for Kaiser bessel windowing function */
+ artifact=GetImageArtifact(image,"filter:alpha");
+ if (artifact != (const char *) NULL)
+ value=StringToDouble(artifact,(char **) NULL);
+ /* Define coefficents for Kaiser Windowing Function */
+ resize_filter->coefficient[0]=value; /* X scaling */
+ resize_filter->coefficient[1]=1.0/I0(value); /* normalization */
+ }
+
+ /* Blur Override */
artifact=GetImageArtifact(image,"filter:blur");
if (artifact != (const char *) NULL)
- resize_filter->blur*=InterpretLocaleValue(artifact,
- (char **) NULL); /* override blur */
+ resize_filter->blur*=StringToDouble(artifact,(char **) NULL);
if (resize_filter->blur < MagickEpsilon)
resize_filter->blur=(MagickRealType) MagickEpsilon;
+
+ /* Support Overrides */
artifact=GetImageArtifact(image,"filter:lobes");
if (artifact != (const char *) NULL)
{
- /*
- Override lobes.
- */
- ssize_t lobes=(ssize_t) StringToLong(artifact);
+ ssize_t
+ lobes;
+
+ lobes=(ssize_t) StringToLong(artifact);
if (lobes < 1)
lobes=1;
resize_filter->support=(MagickRealType) lobes;
}
+ /* Convert a Jinc function lobes value to a real support value */
if (resize_filter->filter == Jinc)
{
- /*
- Convert a Jinc function lobes value to a real support value.
- */
if (resize_filter->support > 16)
resize_filter->support=jinc_zeros[15]; /* largest entry in table */
else
resize_filter->support=jinc_zeros[((long)resize_filter->support)-1];
}
+ /* expert override of the support setting */
artifact=GetImageArtifact(image,"filter:support");
if (artifact != (const char *) NULL)
- resize_filter->support=fabs(InterpretLocaleValue(artifact,
- (char **) NULL)); /* override support */
+ resize_filter->support=fabs(StringToDouble(artifact,(char **) NULL));
/*
- Scale windowing function separately to the support 'clipping' window that
- calling operator is planning to actually use (expert override).
+ Scale windowing function separately to the support 'clipping'
+ window that calling operator is planning to actually use. (Expert
+ override)
*/
resize_filter->window_support=resize_filter->support; /* default */
artifact=GetImageArtifact(image,"filter:win-support");
if (artifact != (const char *) NULL)
- resize_filter->window_support=fabs(InterpretLocaleValue(artifact,
- (char **) NULL));
+ resize_filter->window_support=fabs(StringToDouble(artifact,(char **) NULL));
/*
- Adjust window function scaling to match windowing support for weighting
- function. This avoids a division on every filter call.
+ Adjust window function scaling to match windowing support for
+ weighting function. This avoids a division on every filter call.
*/
resize_filter->scale/=resize_filter->window_support;
+
/*
- Set Cubic Spline B,C values, calculate cubic coefficients.
+ * Set Cubic Spline B,C values, calculate Cubic coefficients.
*/
B=0.0;
C=0.0;
artifact=GetImageArtifact(image,"filter:b");
if (artifact != (const char *) NULL)
{
- B=InterpretLocaleValue(artifact,(char **) NULL);
+ B=StringToDouble(artifact,(char **) NULL);
C=(1.0-B)/2.0; /* Calculate C to get a Keys cubic filter. */
artifact=GetImageArtifact(image,"filter:c"); /* user C override */
if (artifact != (const char *) NULL)
- C=InterpretLocaleValue(artifact,(char **) NULL);
+ C=StringToDouble(artifact,(char **) NULL);
}
else
{
artifact=GetImageArtifact(image,"filter:c");
if (artifact != (const char *) NULL)
{
- C=InterpretLocaleValue(artifact,(char **) NULL);
+ C=StringToDouble(artifact,(char **) NULL);
B=1.0-2.0*C; /* Calculate B to get a Keys cubic filter. */
}
}
+ /* Convert B,C values into Cubic Coefficents. See CubicBC(). */
{
- double
- B_squared;
-
- /*
- Convert B,C values into Cubic Coefficents. See CubicBC().
- */
- B_squared=B+B;
+ const double twoB = B+B;
resize_filter->coefficient[0]=1.0-(1.0/3.0)*B;
- resize_filter->coefficient[1]=-3.0+B_squared+C;
+ resize_filter->coefficient[1]=-3.0+twoB+C;
resize_filter->coefficient[2]=2.0-1.5*B-C;
resize_filter->coefficient[3]=(4.0/3.0)*B+4.0*C;
- resize_filter->coefficient[4]=-8.0*C-B_squared;
+ resize_filter->coefficient[4]=-8.0*C-twoB;
resize_filter->coefficient[5]=B+5.0*C;
resize_filter->coefficient[6]=(-1.0/6.0)*B-C;
}
}
+
/*
- Expert option request for verbose details of the resulting filter.
+ Expert Option Request for verbose details of the resulting filter.
*/
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp master
{
#endif
- artifact=GetImageArtifact(image,"filter:verbose");
- if (IsMagickTrue(artifact) != MagickFalse)
+ if (IfStringTrue(GetImageArtifact(image,"filter:verbose")))
{
double
support,
x;
/*
- Set the weighting function properly when the weighting function may
- not exactly match the filter of the same name. EG: a point filter
- really uses a box weighting function with a different support than is
- typically used.
+ Set the weighting function properly when the weighting
+ function may not exactly match the filter of the same name.
+ EG: a Point filter is really uses a Box weighting function
+ with a different support than is typically used.
*/
- if (resize_filter->filter == Box)
- filter_type=BoxFilter;
- if (resize_filter->filter == Sinc)
- filter_type=SincFilter;
- if (resize_filter->filter == SincFast)
- filter_type=SincFastFilter;
- if (resize_filter->filter == Jinc)
- filter_type=JincFilter;
- if (resize_filter->filter == CubicBC)
- filter_type=CubicFilter;
- if (resize_filter->window == Box)
- window_type=BoxFilter;
- if (resize_filter->window == Sinc)
- window_type=SincFilter;
- if (resize_filter->window == SincFast)
- window_type=SincFastFilter;
- if (resize_filter->window == Jinc)
- window_type=JincFilter;
- if (resize_filter->window == CubicBC)
- window_type=CubicFilter;
+ if (resize_filter->filter == Box) filter_type=BoxFilter;
+ if (resize_filter->filter == Sinc) filter_type=SincFilter;
+ if (resize_filter->filter == SincFast) filter_type=SincFastFilter;
+ if (resize_filter->filter == Jinc) filter_type=JincFilter;
+ if (resize_filter->filter == CubicBC) filter_type=CubicFilter;
+ if (resize_filter->window == Box) window_type=BoxFilter;
+ if (resize_filter->window == Sinc) window_type=SincFilter;
+ if (resize_filter->window == SincFast) window_type=SincFastFilter;
+ if (resize_filter->window == Jinc) window_type=JincFilter;
+ if (resize_filter->window == CubicBC) window_type=CubicFilter;
/*
- Report filter details.
+ Report Filter Details.
*/
support=GetResizeFilterSupport(resize_filter); /* practical_support */
(void) FormatLocaleFile(stdout,"# Resize Filter (for graphing)\n#\n");
(void) FormatLocaleFile(stdout,"# filter = %s\n",
- CommandOptionToMnemonic(MagickFilterOptions,filter_type));
+ CommandOptionToMnemonic(MagickFilterOptions,filter_type));
(void) FormatLocaleFile(stdout,"# window = %s\n",
- CommandOptionToMnemonic(MagickFilterOptions, window_type));
+ CommandOptionToMnemonic(MagickFilterOptions, window_type));
(void) FormatLocaleFile(stdout,"# support = %.*g\n",
- GetMagickPrecision(),(double) resize_filter->support);
+ GetMagickPrecision(),(double) resize_filter->support);
(void) FormatLocaleFile(stdout,"# win-support = %.*g\n",
- GetMagickPrecision(),(double) resize_filter->window_support);
+ GetMagickPrecision(),(double) resize_filter->window_support);
(void) FormatLocaleFile(stdout,"# scale_blur = %.*g\n",
- GetMagickPrecision(), (double)resize_filter->blur);
- if (filter_type == GaussianFilter)
+ GetMagickPrecision(), (double)resize_filter->blur);
+ if ( filter_type == GaussianFilter )
(void) FormatLocaleFile(stdout,"# gaussian_sigma = %.*g\n",
- GetMagickPrecision(), (double)sigma);
+ GetMagickPrecision(), (double)value);
+ if ( filter_type == KaiserFilter )
+ (void) FormatLocaleFile(stdout,"# kaiser_alpha = %.*g\n",
+ GetMagickPrecision(), (double)value);
(void) FormatLocaleFile(stdout,"# practical_support = %.*g\n",
- GetMagickPrecision(), (double)support);
+ GetMagickPrecision(), (double)support);
if ( filter_type == CubicFilter || window_type == CubicFilter )
(void) FormatLocaleFile(stdout,"# B,C = %.*g,%.*g\n",
- GetMagickPrecision(),(double)B, GetMagickPrecision(),(double)C);
+ GetMagickPrecision(),(double)B, GetMagickPrecision(),(double)C);
(void) FormatLocaleFile(stdout,"\n");
/*
- Output values of resulting filter graph -- for graphing filter result.
+ Output values of resulting filter graph -- for graphing
+ filter result.
*/
for (x=0.0; x <= support; x+=0.01f)
- (void) FormatLocaleFile(stdout,"%5.2lf\t%.*g\n",x,
- GetMagickPrecision(),(double) GetResizeFilterWeight(resize_filter,
- x));
- /*
- A final value so gnuplot can graph the 'stop' properly.
- */
+ (void) FormatLocaleFile(stdout,"%5.2lf\t%.*g\n",x,GetMagickPrecision(),
+ (double) GetResizeFilterWeight(resize_filter,x));
+ /* A final value so gnuplot can graph the 'stop' properly. */
(void) FormatLocaleFile(stdout,"%5.2lf\t%.*g\n",support,
GetMagickPrecision(),0.0);
}
- /*
- Output the above once only for each image - remove setting.
- */
+ /* Output the above once only for each image - remove setting */
(void) DeleteImageArtifact((Image *) image,"filter:verbose");
#if defined(MAGICKCORE_OPENMP_SUPPORT)
}
%
% AdaptiveResizeImage() adaptively resize image with pixel resampling.
%
+% This is shortcut function for a fast interpolative resize using mesh
+% interpolation. It works well for small resizes of less than +/- 50%
+% of the original image size. For larger resizing on images a full
+% filtered and slower resize function should be used instead.
+%
% The format of the AdaptiveResizeImage method is:
%
% Image *AdaptiveResizeImage(const Image *image,const size_t columns,
-% const size_t rows,const PixelInterpolateMethod method,
-% ExceptionInfo *exception)
+% const size_t rows, ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o rows: the number of rows in the resized image.
%
-% o method: the pixel interpolation method.
-%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *AdaptiveResizeImage(const Image *image,
- const size_t columns,const size_t rows,const PixelInterpolateMethod method,
- ExceptionInfo *exception)
+ const size_t columns,const size_t rows,ExceptionInfo *exception)
{
-#define AdaptiveResizeImageTag "Resize/Image"
-
- CacheView
- *image_view,
- *resize_view;
-
Image
*resize_image;
- MagickBooleanType
- status;
-
- MagickOffsetType
- progress;
-
- ssize_t
- y;
-
- /*
- Adaptively resize image.
- */
- assert(image != (const Image *) NULL);
- assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
- if ((columns == 0) || (rows == 0))
- return((Image *) NULL);
- if ((columns == image->columns) && (rows == image->rows))
- return(CloneImage(image,0,0,MagickTrue,exception));
- resize_image=CloneImage(image,columns,rows,MagickTrue,exception);
- if (resize_image == (Image *) NULL)
- return((Image *) NULL);
- if (SetImageStorageClass(resize_image,DirectClass,exception) == MagickFalse)
- {
- resize_image=DestroyImage(resize_image);
- return((Image *) NULL);
- }
- status=MagickTrue;
- progress=0;
- image_view=AcquireCacheView(image);
- resize_view=AcquireCacheView(resize_image);
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1)
-#endif
- for (y=0; y < (ssize_t) resize_image->rows; y++)
- {
- PointInfo
- offset;
-
- register Quantum
- *restrict q;
-
- register ssize_t
- x;
-
- if (status == MagickFalse)
- continue;
- q=QueueCacheViewAuthenticPixels(resize_view,0,y,resize_image->columns,1,
- exception);
- if (q == (Quantum *) NULL)
- continue;
- offset.y=((MagickRealType) (y+0.5)*image->rows/resize_image->rows);
- for (x=0; x < (ssize_t) resize_image->columns; x++)
- {
- offset.x=((MagickRealType) (x+0.5)*image->columns/resize_image->columns);
- status=InterpolatePixelChannels(image,image_view,resize_image,
- method,offset.x-0.5,offset.y-0.5,q,exception);
- q+=GetPixelChannels(resize_image);
- }
- if (SyncCacheViewAuthenticPixels(resize_view,exception) == MagickFalse)
- continue;
- if (image->progress_monitor != (MagickProgressMonitor) NULL)
- {
- MagickBooleanType
- proceed;
-
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_AdaptiveResizeImage)
-#endif
- proceed=SetImageProgress(image,AdaptiveResizeImageTag,progress++,
- image->rows);
- if (proceed == MagickFalse)
- status=MagickFalse;
- }
- }
- resize_view=DestroyCacheView(resize_view);
- image_view=DestroyCacheView(image_view);
- if (status == MagickFalse)
- resize_image=DestroyImage(resize_image);
+ resize_image=InterpolativeResizeImage(image,columns,rows,MeshInterpolatePixel,
+ exception);
return(resize_image);
}
\f
weight=scale*resize_filter->filter(x_blur,resize_filter);
return(weight);
}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% I n t e r p o l a t i v e R e s i z e I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% InterpolativeResizeImage() resizes an image using the specified
+% interpolation method.
+%
+% The format of the InterpolativeResizeImage method is:
+%
+% Image *InterpolativeResizeImage(const Image *image,const size_t columns,
+% const size_t rows,const PixelInterpolateMethod method,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o image: the image.
+%
+% o columns: the number of columns in the resized image.
+%
+% o rows: the number of rows in the resized image.
+%
+% o method: the pixel interpolation method.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+MagickExport Image *InterpolativeResizeImage(const Image *image,
+ const size_t columns,const size_t rows,const PixelInterpolateMethod method,
+ ExceptionInfo *exception)
+{
+#define InterpolativeResizeImageTag "Resize/Image"
+
+ CacheView
+ *image_view,
+ *resize_view;
+
+ Image
+ *resize_image;
+
+ MagickBooleanType
+ status;
+
+ MagickOffsetType
+ progress;
+
+ PointInfo
+ scale;
+
+ ssize_t
+ y;
+
+ /*
+ Interpolatively resize image.
+ */
+ assert(image != (const Image *) NULL);
+ assert(image->signature == MagickSignature);
+ if( IfMagickTrue(image->debug) )
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ if ((columns == 0) || (rows == 0))
+ return((Image *) NULL);
+ if ((columns == image->columns) && (rows == image->rows))
+ return(CloneImage(image,0,0,MagickTrue,exception));
+ resize_image=CloneImage(image,columns,rows,MagickTrue,exception);
+ if (resize_image == (Image *) NULL)
+ return((Image *) NULL);
+ if( IfMagickFalse(SetImageStorageClass(resize_image,DirectClass,exception)) )
+ {
+ resize_image=DestroyImage(resize_image);
+ return((Image *) NULL);
+ }
+ status=MagickTrue;
+ progress=0;
+ image_view=AcquireVirtualCacheView(image,exception);
+ resize_view=AcquireAuthenticCacheView(resize_image,exception);
+ scale.x=(double) image->columns/resize_image->columns;
+ scale.y=(double) image->rows/resize_image->rows;
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
+ #pragma omp parallel for schedule(static) shared(progress,status)
+#endif
+ for (y=0; y < (ssize_t) resize_image->rows; y++)
+ {
+ PointInfo
+ offset;
+
+ register Quantum
+ *restrict q;
+
+ register ssize_t
+ x;
+
+ if( IfMagickFalse(status) )
+ continue;
+ q=QueueCacheViewAuthenticPixels(resize_view,0,y,resize_image->columns,1,
+ exception);
+ if (q == (Quantum *) NULL)
+ continue;
+ offset.y=((MagickRealType) y+0.5)*scale.y-0.5;
+ for (x=0; x < (ssize_t) resize_image->columns; x++)
+ {
+ register ssize_t
+ i;
+
+ if (GetPixelMask(resize_image,q) != 0)
+ {
+ q+=GetPixelChannels(resize_image);
+ continue;
+ }
+ for (i=0; i < (ssize_t) GetPixelChannels(resize_image); i++)
+ {
+ PixelChannel
+ channel;
+
+ PixelTrait
+ resize_traits,
+ traits;
+
+ channel=GetPixelChannelMapChannel(image,i);
+ traits=GetPixelChannelMapTraits(image,channel);
+ resize_traits=GetPixelChannelMapTraits(resize_image,channel);
+ if ((traits == UndefinedPixelTrait) ||
+ (resize_traits == UndefinedPixelTrait))
+ continue;
+ offset.x=((MagickRealType) x+0.5)*scale.x-0.5;
+ status=InterpolatePixelChannels(image,image_view,resize_image,method,
+ offset.x,offset.y,q,exception);
+ }
+ q+=GetPixelChannels(resize_image);
+ }
+ if( IfMagickFalse(SyncCacheViewAuthenticPixels(resize_view,exception)) )
+ continue;
+ if (image->progress_monitor != (MagickProgressMonitor) NULL)
+ {
+ MagickBooleanType
+ proceed;
+
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
+ #pragma omp critical (MagickCore_InterpolativeResizeImage)
+#endif
+ proceed=SetImageProgress(image,InterpolativeResizeImageTag,progress++,
+ image->rows);
+ if( IfMagickFalse(proceed) )
+ status=MagickFalse;
+ }
+ }
+ resize_view=DestroyCacheView(resize_view);
+ image_view=DestroyCacheView(image_view);
+ if( IfMagickFalse(status) )
+ resize_image=DestroyImage(resize_image);
+ return(resize_image);
+}
#if defined(MAGICKCORE_LQR_DELEGATE)
\f
/*
*/
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
+ if( IfMagickTrue(image->debug) )
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
if ((columns == image->columns) && (rows == image->rows))
return(CloneImage(image,0,0,MagickTrue,exception));
if ((columns <= 2) || (rows <= 2))
- return(ResizeImage(image,columns,rows,image->filter,image->blur,exception));
+ return(ResizeImage(image,columns,rows,image->filter,exception));
if ((columns >= (2*image->columns)) || (rows >= (2*image->rows)))
{
Image
*/
for (width=image->columns; columns >= (2*width-1); width*=2);
for (height=image->rows; rows >= (2*height-1); height*=2);
- resize_image=ResizeImage(image,width,height,image->filter,image->blur,
- exception);
+ resize_image=ResizeImage(image,width,height,image->filter,exception);
if (resize_image == (Image *) NULL)
return((Image *) NULL);
rescale_image=LiquidRescaleImage(resize_image,columns,rows,delta_x,
return((Image *) NULL);
status=MagickTrue;
q=pixels;
- image_view=AcquireCacheView(image);
+ image_view=AcquireVirtualCacheView(image,exception);
for (y=0; y < (ssize_t) image->rows; y++)
{
register const Quantum
register ssize_t
x;
- if (status == MagickFalse)
+ if( IfMagickFalse(status) )
continue;
p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
pixels=(gfloat *) RelinquishMagickMemory(pixels);
return((Image *) NULL);
}
- if (SetImageStorageClass(rescale_image,DirectClass,exception) == MagickFalse)
+ if( IfMagickFalse(SetImageStorageClass(rescale_image,DirectClass,exception)) )
{
pixels=(gfloat *) RelinquishMagickMemory(pixels);
rescale_image=DestroyImage(rescale_image);
return((Image *) NULL);
}
- rescale_view=AcquireCacheView(rescale_image);
+ rescale_view=AcquireAuthenticCacheView(rescale_image,exception);
(void) lqr_carver_scan_reset(carver);
while (lqr_carver_scan_ext(carver,&x_offset,&y_offset,(void **) &packet) != 0)
{
rescale_traits,
traits;
- traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
- channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
+ channel=GetPixelChannelMapChannel(image,i);
+ traits=GetPixelChannelMapTraits(image,channel);
rescale_traits=GetPixelChannelMapTraits(rescale_image,channel);
if ((traits == UndefinedPixelTrait) ||
(rescale_traits == UndefinedPixelTrait))
SetPixelChannel(rescale_image,channel,ClampToQuantum(QuantumRange*
packet[i]),q);
}
- if (SyncCacheViewAuthenticPixels(rescale_view,exception) == MagickFalse)
+ if( IfMagickFalse(SyncCacheViewAuthenticPixels(rescale_view,exception)) )
break;
}
rescale_view=DestroyCacheView(rescale_view);
{
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
+ if( IfMagickTrue(image->debug) )
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
(void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
- "DelegateLibrarySupportNotBuiltIn","`%s' (LQR)",image->filename);
+ "DelegateLibrarySupportNotBuiltIn","'%s' (LQR)",image->filename);
return((Image *) NULL);
}
#endif
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
+ if( IfMagickTrue(image->debug) )
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
magnify_image=ResizeImage(image,2*image->columns,2*image->rows,CubicFilter,
- 1.0,exception);
+ exception);
return(magnify_image);
}
\f
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
+ if( IfMagickTrue(image->debug) )
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- minify_image=ResizeImage(image,image->columns/2,image->rows/2,CubicFilter,1.0,
+ minify_image=ResizeImage(image,image->columns/2,image->rows/2,CubicFilter,
exception);
return(minify_image);
}
% The format of the ResampleImage method is:
%
% Image *ResampleImage(Image *image,const double x_resolution,
-% const double y_resolution,const FilterTypes filter,const double blur,
+% const double y_resolution,const FilterTypes filter,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o filter: Image filter to use.
%
-% o blur: the blur factor where > 1 is blurry, < 1 is sharp.
+% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *ResampleImage(const Image *image,const double x_resolution,
- const double y_resolution,const FilterTypes filter,const double blur,
- ExceptionInfo *exception)
+ const double y_resolution,const FilterTypes filter,ExceptionInfo *exception)
{
#define ResampleImageTag "Resample/Image"
*/
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
+ if( IfMagickTrue(image->debug) )
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
72.0 : image->resolution.x)+0.5);
height=(size_t) (y_resolution*image->rows/(image->resolution.y == 0.0 ?
72.0 : image->resolution.y)+0.5);
- resample_image=ResizeImage(image,width,height,filter,blur,exception);
+ resample_image=ResizeImage(image,width,height,filter,exception);
if (resample_image != (Image *) NULL)
{
resample_image->resolution.x=x_resolution;
assert(contribution != (ContributionInfo **) NULL);
for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
if (contribution[i] != (ContributionInfo *) NULL)
- contribution[i]=(ContributionInfo *) RelinquishMagickMemory(
+ contribution[i]=(ContributionInfo *) RelinquishAlignedMemory(
contribution[i]);
contribution=(ContributionInfo **) RelinquishMagickMemory(contribution);
return(contribution);
(void) ResetMagickMemory(contribution,0,number_threads*sizeof(*contribution));
for (i=0; i < (ssize_t) number_threads; i++)
{
- contribution[i]=(ContributionInfo *) AcquireQuantumMemory(count,
+ contribution[i]=(ContributionInfo *) AcquireAlignedMemory(count,
sizeof(**contribution));
if (contribution[i] == (ContributionInfo *) NULL)
return(DestroyContributionThreadSet(contribution));
scale=MagickMax(1.0/x_factor+MagickEpsilon,1.0);
support=scale*GetResizeFilterSupport(resize_filter);
storage_class=support > 0.5 ? DirectClass : image->storage_class;
- if (SetImageStorageClass(resize_image,storage_class,exception) == MagickFalse)
+ if( IfMagickFalse(SetImageStorageClass(resize_image,storage_class,exception)) )
return(MagickFalse);
if (support < 0.5)
{
if (contributions == (ContributionInfo **) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",image->filename);
return(MagickFalse);
}
status=MagickTrue;
scale=1.0/scale;
- image_view=AcquireCacheView(image);
- resize_view=AcquireCacheView(resize_image);
+ image_view=AcquireVirtualCacheView(image,exception);
+ resize_view=AcquireAuthenticCacheView(resize_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status)
#endif
for (x=0; x < (ssize_t) resize_image->columns; x++)
{
start,
stop;
- if (status == MagickFalse)
+ if( IfMagickFalse(status) )
continue;
- bisect=(MagickRealType) (x+0.5)/x_factor;
+ bisect=(MagickRealType) (x+0.5)/x_factor+MagickEpsilon;
start=(ssize_t) MagickMax(bisect-support+0.5,0.0);
stop=(ssize_t) MagickMin(bisect+support+0.5,(double) image->columns);
density=0.0;
register ssize_t
i;
- for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+ if (GetPixelMask(resize_image,q) != 0)
+ {
+ q+=GetPixelChannels(resize_image);
+ continue;
+ }
+ for (i=0; i < (ssize_t) GetPixelChannels(resize_image); i++)
{
MagickRealType
alpha,
ssize_t
k;
- traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
- channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
+ channel=GetPixelChannelMapChannel(image,i);
+ traits=GetPixelChannelMapTraits(image,channel);
resize_traits=GetPixelChannelMapTraits(resize_image,channel);
if ((traits == UndefinedPixelTrait) ||
(resize_traits == UndefinedPixelTrait))
}
q+=GetPixelChannels(resize_image);
}
- if (SyncCacheViewAuthenticPixels(resize_view,exception) == MagickFalse)
+ if( IfMagickFalse(SyncCacheViewAuthenticPixels(resize_view,exception)) )
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
#pragma omp critical (MagickCore_HorizontalFilter)
#endif
proceed=SetImageProgress(image,ResizeImageTag,(*offset)++,span);
- if (proceed == MagickFalse)
+ if( IfMagickFalse(proceed) )
status=MagickFalse;
}
}
scale=MagickMax(1.0/y_factor+MagickEpsilon,1.0);
support=scale*GetResizeFilterSupport(resize_filter);
storage_class=support > 0.5 ? DirectClass : image->storage_class;
- if (SetImageStorageClass(resize_image,storage_class,exception) == MagickFalse)
+ if( IfMagickFalse(SetImageStorageClass(resize_image,storage_class,exception)) )
return(MagickFalse);
if (support < 0.5)
{
if (contributions == (ContributionInfo **) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",image->filename);
return(MagickFalse);
}
status=MagickTrue;
scale=1.0/scale;
(void) ResetMagickMemory(&zero,0,sizeof(zero));
- image_view=AcquireCacheView(image);
- resize_view=AcquireCacheView(resize_image);
+ image_view=AcquireVirtualCacheView(image,exception);
+ resize_view=AcquireAuthenticCacheView(resize_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for shared(status)
+ #pragma omp parallel for schedule(static,4) shared(status)
#endif
for (y=0; y < (ssize_t) resize_image->rows; y++)
{
start,
stop;
- if (status == MagickFalse)
+ if( IfMagickFalse(status) )
continue;
- bisect=(MagickRealType) (y+0.5)/y_factor;
+ bisect=(MagickRealType) (y+0.5)/y_factor+MagickEpsilon;
start=(ssize_t) MagickMax(bisect-support+0.5,0.0);
stop=(ssize_t) MagickMin(bisect+support+0.5,(double) image->rows);
density=0.0;
register ssize_t
i;
- for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+ if (GetPixelMask(resize_image,q) != 0)
+ {
+ q+=GetPixelChannels(resize_image);
+ continue;
+ }
+ for (i=0; i < (ssize_t) GetPixelChannels(resize_image); i++)
{
MagickRealType
alpha,
ssize_t
k;
- traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
- channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
+ channel=GetPixelChannelMapChannel(image,i);
+ traits=GetPixelChannelMapTraits(image,channel);
resize_traits=GetPixelChannelMapTraits(resize_image,channel);
if ((traits == UndefinedPixelTrait) ||
(resize_traits == UndefinedPixelTrait))
}
q+=GetPixelChannels(resize_image);
}
- if (SyncCacheViewAuthenticPixels(resize_view,exception) == MagickFalse)
+ if( IfMagickFalse(SyncCacheViewAuthenticPixels(resize_view,exception)) )
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
#pragma omp critical (MagickCore_VerticalFilter)
#endif
proceed=SetImageProgress(image,ResizeImageTag,(*offset)++,span);
- if (proceed == MagickFalse)
+ if( IfMagickFalse(proceed) )
status=MagickFalse;
}
}
}
MagickExport Image *ResizeImage(const Image *image,const size_t columns,
- const size_t rows,const FilterTypes filter,const double blur,
- ExceptionInfo *exception)
+ const size_t rows,const FilterTypes filter,ExceptionInfo *exception)
{
#define WorkLoadFactor 0.265
*/
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
+ if( IfMagickTrue(image->debug) )
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
if ((columns == 0) || (rows == 0))
ThrowImageException(ImageError,"NegativeOrZeroImageSize");
if ((columns == image->columns) && (rows == image->rows) &&
- (filter == UndefinedFilter) && (blur == 1.0))
+ (filter == UndefinedFilter))
return(CloneImage(image,0,0,MagickTrue,exception));
resize_image=CloneImage(image,columns,rows,MagickTrue,exception);
if (resize_image == (Image *) NULL)
filter_type=PointFilter;
else
if ((image->storage_class == PseudoClass) ||
- (image->matte != MagickFalse) || ((x_factor*y_factor) > 1.0))
+ IfMagickTrue(image->matte) ||
+ ((x_factor*y_factor) > 1.0))
filter_type=MitchellFilter;
- resize_filter=AcquireResizeFilter(image,filter_type,blur,MagickFalse,
- exception);
+ resize_filter=AcquireResizeFilter(image,filter_type,MagickFalse,exception);
/*
Resize image.
*/
*/
filter_image=DestroyImage(filter_image);
resize_filter=DestroyResizeFilter(resize_filter);
- if (status == MagickFalse)
+ if( IfMagickFalse(status) )
{
resize_image=DestroyImage(resize_image);
return((Image *) NULL);
*/
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
+ if( IfMagickTrue(image->debug) )
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
*/
status=MagickTrue;
progress=0;
- image_view=AcquireCacheView(image);
- sample_view=AcquireCacheView(sample_image);
+ image_view=AcquireVirtualCacheView(image,exception);
+ sample_view=AcquireAuthenticCacheView(sample_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1)
+ #pragma omp parallel for schedule(static) shared(progress,status)
#endif
for (y=0; y < (ssize_t) sample_image->rows; y++)
{
ssize_t
y_offset;
- if (status == MagickFalse)
+ if( IfMagickFalse(status) )
continue;
y_offset=(ssize_t) (((MagickRealType) y+0.5)*image->rows/
sample_image->rows);
register ssize_t
i;
- for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+ if (GetPixelMask(sample_image,q) != 0)
+ {
+ q+=GetPixelChannels(sample_image);
+ continue;
+ }
+ for (i=0; i < (ssize_t) GetPixelChannels(sample_image); i++)
{
PixelChannel
channel;
sample_traits,
traits;
- traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
- channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
+ channel=GetPixelChannelMapChannel(image,i);
+ traits=GetPixelChannelMapTraits(image,channel);
sample_traits=GetPixelChannelMapTraits(sample_image,channel);
if ((traits == UndefinedPixelTrait) ||
(sample_traits == UndefinedPixelTrait))
}
q+=GetPixelChannels(sample_image);
}
- if (SyncCacheViewAuthenticPixels(sample_view,exception) == MagickFalse)
+ if( IfMagickFalse(SyncCacheViewAuthenticPixels(sample_view,exception)) )
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
#pragma omp critical (MagickCore_SampleImage)
#endif
proceed=SetImageProgress(image,SampleImageTag,progress++,image->rows);
- if (proceed == MagickFalse)
+ if( IfMagickFalse(proceed) )
status=MagickFalse;
}
}
*/
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
+ if( IfMagickTrue(image->debug) )
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
scale_image=CloneImage(image,columns,rows,MagickTrue,exception);
if (scale_image == (Image *) NULL)
return((Image *) NULL);
- if (SetImageStorageClass(scale_image,DirectClass,exception) == MagickFalse)
+ if( IfMagickFalse(SetImageStorageClass(scale_image,DirectClass,exception)) )
{
scale_image=DestroyImage(scale_image);
return((Image *) NULL);
scanline=(MagickRealType *) AcquireQuantumMemory((size_t) image->columns,
GetPixelChannels(image)*sizeof(*scanline));
scale_scanline=(MagickRealType *) AcquireQuantumMemory((size_t)
- scale_image->columns,GetPixelChannels(scale_image)*sizeof(*scale_scanline));
+ scale_image->columns,MaxPixelChannels*sizeof(*scale_scanline));
y_vector=(MagickRealType *) AcquireQuantumMemory((size_t) image->columns,
GetPixelChannels(image)*sizeof(*y_vector));
if ((scanline == (MagickRealType *) NULL) ||
for (i=0; i < (ssize_t) (GetPixelChannels(image)*image->columns); i++)
y_vector[i]=0.0;
n=0;
- image_view=AcquireCacheView(image);
- scale_view=AcquireCacheView(scale_image);
+ image_view=AcquireVirtualCacheView(image,exception);
+ scale_view=AcquireAuthenticCacheView(scale_image,exception);
for (y=0; y < (ssize_t) scale_image->rows; y++)
{
register const Quantum
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
+ if (GetPixelMask(image,p) != 0)
+ {
+ p+=GetPixelChannels(image);
+ continue;
+ }
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
+ PixelChannel
+ channel;
+
+ PixelTrait
+ traits;
+
+ channel=GetPixelChannelMapChannel(image,i);
+ traits=GetPixelChannelMapTraits(image,channel);
if ((traits & BlendPixelTrait) == 0)
{
x_vector[x*GetPixelChannels(image)+i]=(MagickRealType) p[i];
*/
while (scale.y < span.y)
{
- if ((next_row != MagickFalse) &&
- (number_rows < (ssize_t) image->rows))
+ if( IfMagickTrue(next_row) && (number_rows < (ssize_t) image->rows))
{
/*
Read a new scanline.
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
+ if (GetPixelMask(image,p) != 0)
+ {
+ p+=GetPixelChannels(image);
+ continue;
+ }
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
+ PixelChannel
+ channel;
+
+ PixelTrait
+ traits;
+
+ channel=GetPixelChannelMapChannel(image,i);
+ traits=GetPixelChannelMapTraits(image,channel);
if ((traits & BlendPixelTrait) == 0)
{
x_vector[x*GetPixelChannels(image)+i]=(MagickRealType)
scale.y=(double) scale_image->rows/(double) image->rows;
next_row=MagickTrue;
}
- if ((next_row != MagickFalse) && (number_rows < (ssize_t) image->rows))
+ if( IfMagickTrue(next_row) && (number_rows < (ssize_t) image->rows))
{
/*
Read a new scanline.
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
+ if (GetPixelMask(image,p) != 0)
+ {
+ p+=GetPixelChannels(image);
+ continue;
+ }
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
+ PixelChannel
+ channel;
+
+ PixelTrait
+ traits;
+
+ channel=GetPixelChannelMapChannel(image,i);
+ traits=GetPixelChannelMapTraits(image,channel);
if ((traits & BlendPixelTrait) == 0)
{
- x_vector[x*GetPixelChannels(image)+i]=(MagickRealType) p[i];
+ x_vector[x*GetPixelChannels(image)+i]=(MagickRealType)
+ p[i];
continue;
}
alpha=QuantumScale*GetPixelAlpha(image,p);
*/
for (x=0; x < (ssize_t) scale_image->columns; x++)
{
- for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+ if (GetPixelMask(scale_image,q) != 0)
+ {
+ q+=GetPixelChannels(scale_image);
+ continue;
+ }
+ for (i=0; i < (ssize_t) GetPixelChannels(scale_image); i++)
{
- traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
- channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
+ ssize_t
+ offset;
+
+ channel=GetPixelChannelMapChannel(scale_image,i);
+ traits=GetPixelChannelMapTraits(image,channel);
scale_traits=GetPixelChannelMapTraits(scale_image,channel);
if ((traits == UndefinedPixelTrait) ||
(scale_traits == UndefinedPixelTrait))
continue;
- if ((scale_traits & BlendPixelTrait) == 0)
+ offset=GetPixelChannelMapOffset(image,channel);
+ if ((traits & BlendPixelTrait) == 0)
{
- SetPixelChannel(scale_image,channel,ClampToQuantum(scanline[
- x*GetPixelChannels(image)+i]),q);
+ SetPixelChannel(scale_image,channel,ClampToQuantum(
+ scanline[x*GetPixelChannels(image)+offset]),q);
continue;
}
alpha=QuantumScale*scanline[x*GetPixelChannels(image)+
GetPixelChannelMapChannel(image,AlphaPixelChannel)];
gamma=1.0/(fabs((double) alpha) <= MagickEpsilon ? 1.0 : alpha);
SetPixelChannel(scale_image,channel,ClampToQuantum(gamma*scanline[
- x*GetPixelChannels(image)+i]),q);
+ x*GetPixelChannels(image)+offset]),q);
}
q+=GetPixelChannels(scale_image);
}
scale.x=(double) scale_image->columns/(double) image->columns;
while (scale.x >= span.x)
{
- if (next_column != MagickFalse)
+ if( IfMagickTrue(next_column) )
{
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
pixel[i]=0.0;
}
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
+ PixelChannel
+ channel;
+
+ PixelTrait
+ traits;
+
+ channel=GetPixelChannelMapChannel(image,i);
+ traits=GetPixelChannelMapTraits(image,channel);
if (traits == UndefinedPixelTrait)
continue;
- channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
pixel[i]+=span.x*scanline[x*GetPixelChannels(image)+i];
- scale_scanline[n*GetPixelChannels(scale_image)+channel]=pixel[i];
+ scale_scanline[n*MaxPixelChannels+channel]=pixel[i];
}
scale.x-=span.x;
span.x=1.0;
}
if (scale.x > 0)
{
- if (next_column != MagickFalse)
+ if( IfMagickTrue(next_column) )
{
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
pixel[i]=0.0;
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
pixel[i]+=span.x*scanline[(x-1)*GetPixelChannels(image)+i];
}
- if ((next_column == MagickFalse) &&
+ if( IfMagickFalse(next_column) &&
((ssize_t) n < (ssize_t) scale_image->columns))
- for (i=0; i < (ssize_t) GetPixelChannels(scale_image); i++)
- scale_scanline[n*GetPixelChannels(scale_image)+i]=pixel[i];
+ for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+ {
+ channel=GetPixelChannelMapChannel(image,i);
+ scale_scanline[n*MaxPixelChannels+channel]=pixel[i];
+ }
/*
Transfer scanline to scaled image.
*/
for (x=0; x < (ssize_t) scale_image->columns; x++)
{
+ if (GetPixelMask(scale_image,q) != 0)
+ {
+ q+=GetPixelChannels(scale_image);
+ continue;
+ }
for (i=0; i < (ssize_t) GetPixelChannels(scale_image); i++)
{
- traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
- channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
+ channel=GetPixelChannelMapChannel(scale_image,i);
+ traits=GetPixelChannelMapTraits(image,channel);
scale_traits=GetPixelChannelMapTraits(scale_image,channel);
if ((traits == UndefinedPixelTrait) ||
(scale_traits == UndefinedPixelTrait))
continue;
- if ((scale_traits & BlendPixelTrait) == 0)
+ if ((traits & BlendPixelTrait) == 0)
{
SetPixelChannel(scale_image,channel,ClampToQuantum(
- scale_scanline[x*GetPixelChannels(scale_image)+channel]),q);
+ scale_scanline[x*MaxPixelChannels+channel]),q);
continue;
}
alpha=QuantumScale*scanline[x*GetPixelChannels(image)+
GetPixelChannelMapChannel(image,AlphaPixelChannel)];
gamma=1.0/(fabs((double) alpha) <= MagickEpsilon ? 1.0 : alpha);
SetPixelChannel(scale_image,channel,ClampToQuantum(gamma*
- scale_scanline[x*GetPixelChannels(scale_image)+channel]),q);
+ scale_scanline[x*MaxPixelChannels+channel]),q);
}
q+=GetPixelChannels(scale_image);
}
}
- if (SyncCacheViewAuthenticPixels(scale_view,exception) == MagickFalse)
+ if( IfMagickFalse(SyncCacheViewAuthenticPixels(scale_view,exception)) )
break;
proceed=SetImageProgress(image,ScaleImageTag,(MagickOffsetType) y,
image->rows);
- if (proceed == MagickFalse)
+ if( IfMagickFalse(proceed) )
break;
}
scale_view=DestroyCacheView(scale_view);
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
- if (image->debug != MagickFalse)
+ if( IfMagickTrue(image->debug) )
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
x_factor=(MagickRealType) columns/(MagickRealType) image->columns;
y_factor=(MagickRealType) rows/(MagickRealType) image->rows;
if ((x_factor*y_factor) > 0.1)
- thumbnail_image=ResizeImage(image,columns,rows,image->filter,image->blur,
- exception);
+ thumbnail_image=ResizeImage(image,columns,rows,image->filter,exception);
else
if (((SampleFactor*columns) < 128) || ((SampleFactor*rows) < 128))
- thumbnail_image=ResizeImage(image,columns,rows,image->filter,
- image->blur,exception);
+ thumbnail_image=ResizeImage(image,columns,rows,image->filter,exception);
else
{
Image
if (sample_image == (Image *) NULL)
return((Image *) NULL);
thumbnail_image=ResizeImage(sample_image,columns,rows,image->filter,
- image->blur,exception);
+ exception);
sample_image=DestroyImage(sample_image);
}
if (thumbnail_image == (Image *) NULL)
return(thumbnail_image);
(void) ParseAbsoluteGeometry("0x0+0+0",&thumbnail_image->page);
- if (thumbnail_image->matte == MagickFalse)
+ if( IfMagickFalse(thumbnail_image->matte) )
(void) SetImageAlphaChannel(thumbnail_image,OpaqueAlphaChannel,exception);
thumbnail_image->depth=8;
thumbnail_image->interlace=NoInterlace;
image->magick_filename);
(void) SetImageProperty(thumbnail_image,"Thumb::URI",value,exception);
(void) CopyMagickString(value,image->magick_filename,MaxTextExtent);
- if (GetPathAttributes(image->filename,&attributes) != MagickFalse)
+ if( IfMagickTrue(GetPathAttributes(image->filename,&attributes)) )
{
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
attributes.st_mtime);
exception);
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
image->magick_rows);
- (void) SetImageProperty(thumbnail_image,"Thumb::Image::height",value,
+ (void) SetImageProperty(thumbnail_image,"Thumb::Image::Height",value,
exception);
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
GetImageListLength(image));