]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sat, 30 Jul 2011 01:39:32 +0000 (01:39 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sat, 30 Jul 2011 01:39:32 +0000 (01:39 +0000)
MagickCore/pixel.c
MagickCore/pixel.h
MagickCore/resize.c

index b95c79743dc3384f2b8e541c71cdabb09383c364..a03c37f423872c9f8d67641a023f65fe7c1b161f 100644 (file)
@@ -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);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   I n t e r p o l a t e P i x e l I n f o                                   %
 %                                                                             %
 %                                                                             %
index 185eda2d6eb2937dd6df20e42f7363ace0af0fb9..0917049ab5ca81302e9072376f87363f11bf3d0e 100644 (file)
@@ -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 *),
index 366f33c087fcea99c7e1d9b609f289b4bd475b2d..c1682830e7fcf2bb1b2b90400024a18a6c6a455f 100644 (file)
@@ -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;