From a085a43d43f06b9c2675020a1d7126ebbaebfd7b Mon Sep 17 00:00:00 2001 From: cristy Date: Sat, 30 Jul 2011 01:39:32 +0000 Subject: [PATCH] --- MagickCore/pixel.c | 72 +++++++++++++++++++++++++++++++++++++++++++++ MagickCore/pixel.h | 3 ++ MagickCore/resize.c | 6 +++- 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/MagickCore/pixel.c b/MagickCore/pixel.c index b95c79743..a03c37f42 100644 --- a/MagickCore/pixel.c +++ b/MagickCore/pixel.c @@ -3567,6 +3567,78 @@ MagickExport MagickBooleanType ImportImagePixels(Image *image, % % % % % % +% I n t e r p o l a t e P i x e l C h a n n e l % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% InterpolatePixelChannel() applies bi-linear or tri-linear interpolation +% between a floating point coordinate and the pixels surrounding that +% coordinate. No pixel area resampling, or scaling of the result is +% performed. +% +% The format of the InterpolatePixelChannel method is: +% +% MagickBooleanType InterpolatePixelChannel(const Image *image, +% const PixelChannel channel,const CacheView *image_view, +% const InterpolatePixelMethod method,const double x,const double y, +% double *pixel,ExceptionInfo *exception) +% +% A description of each parameter follows: +% +% o image: the image. +% +% o image_view: the image view. +% +% o channel: the pixel channel to interpolate. +% +% o method: the pixel color interpolation method. +% +% o x,y: A double representing the current (x,y) position of the pixel. +% +% o pixel: return the interpolated pixel here. +% +% o exception: return any errors or warnings in this structure. +% +*/ +MagickExport MagickBooleanType InterpolatePixelChannel(const Image *image, + const CacheView *image_view,const PixelChannel channel, + const InterpolatePixelMethod method,const double x,const double y, + double *pixel,ExceptionInfo *exception) +{ + MagickBooleanType + status; + + ssize_t + x_offset, + y_offset; + + assert(image != (Image *) NULL); + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + assert(image_view != (CacheView *) NULL); + status=MagickTrue; + *pixel=0; + x_offset=(ssize_t) floor(x); + y_offset=(ssize_t) floor(y); + switch (method == UndefinedInterpolatePixel ? image->interpolate : method) + { + case MeshInterpolatePixel: + { + break; + } + default: + break; + } + return(status); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % I n t e r p o l a t e P i x e l I n f o % % % % % diff --git a/MagickCore/pixel.h b/MagickCore/pixel.h index 185eda2d6..0917049ab 100644 --- a/MagickCore/pixel.h +++ b/MagickCore/pixel.h @@ -146,6 +146,9 @@ extern MagickExport MagickBooleanType const size_t,const char *,const StorageType,void *,ExceptionInfo *), ImportImagePixels(Image *,const ssize_t,const ssize_t,const size_t, const size_t,const char *,const StorageType,const void *), + InterpolatePixelChannel(const Image *,const CacheView_ *, + const PixelChannel,const InterpolatePixelMethod,const double,const double, + double *,ExceptionInfo *), InterpolatePixelInfo(const Image *,const CacheView_ *, const InterpolatePixelMethod,const double,const double,PixelInfo *, ExceptionInfo *), diff --git a/MagickCore/resize.c b/MagickCore/resize.c index 366f33c08..c1682830e 100644 --- a/MagickCore/resize.c +++ b/MagickCore/resize.c @@ -1239,7 +1239,7 @@ MagickExport Image *AdaptiveResizeImage(const Image *image, MeshInterpolatePixel,offset.x-0.5,offset.y-0.5,&pixel_info,exception); for (i=0; i < (ssize_t) GetPixelChannels(image); i++) { - MagickRealType + double pixel; PixelChannel @@ -1261,6 +1261,10 @@ MagickExport Image *AdaptiveResizeImage(const Image *image, q[channel]=p[i]; continue; } + status=InterpolatePixelChannel(image,interpolate_view,i, + MeshInterpolatePixel,offset.x-0.5,offset.y-0.5,&pixel,exception); + if (status == MagickFalse) + continue; switch (channel) { case RedPixelChannel: pixel=pixel_info.red; break; -- 2.40.0