]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/pixel-accessor.h
Fix CLUT interpolation method
[imagemagick] / MagickCore / pixel-accessor.h
index e61f65142927696689f502f63a639d103233e339..78d9bcc31f13c12775602145af4f56100abd878d 100644 (file)
@@ -23,6 +23,7 @@ extern "C" {
 #endif
 
 #include <math.h>
+#include <MagickCore/cache.h>
 #include <MagickCore/cache-view.h>
 #include <MagickCore/color.h>
 #include <MagickCore/image.h>
@@ -197,11 +198,8 @@ static inline Quantum GetPixelIntensity(const Image *restrict image,
   const Quantum *restrict pixel)
 {
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
-  if ((pixel[image->channel_map[RedPixelChannel].offset] ==
-       pixel[image->channel_map[GreenPixelChannel].offset]) &&
-      (pixel[image->channel_map[GreenPixelChannel].offset] ==
-       pixel[image->channel_map[BluePixelChannel].offset]))
-    return(pixel[image->channel_map[RedPixelChannel].offset]);
+  if (image->colorspace == GRAYColorspace)
+    return(pixel[image->channel_map[GrayPixelChannel].offset]);
   return((Quantum) (0.299*pixel[image->channel_map[RedPixelChannel].offset]+
     0.587*pixel[image->channel_map[GreenPixelChannel].offset]+0.114*
     pixel[image->channel_map[BluePixelChannel].offset]+0.5));
@@ -249,6 +247,19 @@ static inline PixelTrait GetPixelMagentaTraits(const Image *restrict image)
   return(image->channel_map[MagentaPixelChannel].traits);
 }
 
+static inline Quantum GetPixelMask(const Image *restrict image,
+  const Quantum *restrict pixel)
+{
+  if (image->channel_map[MaskPixelChannel].traits == UndefinedPixelTrait)
+    return(0);
+  return(pixel[image->channel_map[MaskPixelChannel].offset]);
+}
+
+static inline PixelTrait GetPixelMaskTraits(const Image *restrict image)
+{
+  return(image->channel_map[MaskPixelChannel].traits);
+}
+
 static inline size_t GetPixelMetaChannels(const Image *restrict image)
 {
   return(image->number_meta_channels);
@@ -259,6 +270,14 @@ static inline size_t GetPixelMetacontentExtent(const Image *restrict image)
   return(image->metacontent_extent);
 }
 
+static inline Quantum GetPixelOpacity(const Image *restrict image,
+  const Quantum *restrict pixel)
+{
+  if (image->channel_map[AlphaPixelChannel].traits == UndefinedPixelTrait)
+    return(QuantumRange-OpaqueAlpha);
+  return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
+}
+
 static inline Quantum GetPixelRed(const Image *restrict image,
   const Quantum *restrict pixel)
 {
@@ -273,23 +292,23 @@ static inline PixelTrait GetPixelRedTraits(const Image *restrict image)
 static inline void GetPixelInfoPixel(const Image *restrict image,
   const Quantum *restrict pixel,PixelInfo *restrict pixel_info)
 {
-  pixel_info->red=(MagickRealType)
+  pixel_info->red=(double)
     pixel[image->channel_map[RedPixelChannel].offset];
-  pixel_info->green=(MagickRealType)
+  pixel_info->green=(double)
     pixel[image->channel_map[GreenPixelChannel].offset];
-  pixel_info->blue=(MagickRealType)
+  pixel_info->blue=(double)
     pixel[image->channel_map[BluePixelChannel].offset];
   pixel_info->black=0;
   if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
-    pixel_info->black=(MagickRealType)
+    pixel_info->black=(double)
       pixel[image->channel_map[BlackPixelChannel].offset];
   pixel_info->alpha=OpaqueAlpha;
   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
-    pixel_info->alpha=(MagickRealType)
+    pixel_info->alpha=(double)
       pixel[image->channel_map[AlphaPixelChannel].offset];
   pixel_info->index=0;
   if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
-    pixel_info->index=(MagickRealType)
+    pixel_info->index=(double)
       pixel[image->channel_map[IndexPixelChannel].offset];
 }
 
@@ -625,10 +644,11 @@ static inline void SetPixelMagentaTraits(Image *image,const PixelTrait traits)
   image->channel_map[MagentaPixelChannel].traits=traits;
 }
 
-static inline void SetPixelMetaChannels(Image *image,
-  const size_t number_meta_channels)
+static inline void SetPixelMask(const Image *restrict image,
+  const Quantum mask,Quantum *restrict pixel)
 {
-  image->number_meta_channels=number_meta_channels;
+  if (image->channel_map[MaskPixelChannel].traits != UndefinedPixelTrait)
+    pixel[image->channel_map[MaskPixelChannel].offset]=mask;
 }
 
 static inline void SetPixelMetacontentExtent(Image *image,const size_t extent)
@@ -636,6 +656,13 @@ static inline void SetPixelMetacontentExtent(Image *image,const size_t extent)
   image->metacontent_extent=extent;
 }
 
+static inline void SetPixelOpacity(const Image *restrict image,
+  const Quantum alpha,Quantum *restrict pixel)
+{
+  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
+    pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
+}
+
 static inline void SetPixelRed(const Image *restrict image,const Quantum red,
   Quantum *restrict pixel)
 {