/*
- 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.
#endif
#include <math.h>
+#include <MagickCore/cache.h>
#include <MagickCore/cache-view.h>
#include <MagickCore/color.h>
#include <MagickCore/image.h>
return((Quantum) luminance);
}
+static inline Quantum GetPixelIntensity(const Image *restrict image,
+ const Quantum *restrict pixel)
+{
+#if !defined(MAGICKCORE_HDRI_SUPPORT)
+ 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));
+#else
+ {
+ double
+ alpha,
+ beta;
+
+ alpha=pixel[image->channel_map[RedPixelChannel].offset]-(double)
+ pixel[image->channel_map[GreenPixelChannel].offset];
+ beta=pixel[image->channel_map[GreenPixelChannel].offset]-(double)
+ pixel[image->channel_map[BluePixelChannel].offset];
+ if ((fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
+ return(pixel[image->channel_map[RedPixelChannel].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]));
+ }
+#endif
+}
+
+static inline Quantum GetPixelLuminance(const Image *restrict image,
+ const Quantum *restrict pixel)
+{
+#if !defined(MAGICKCORE_HDRI_SUPPORT)
+ return((Quantum) (0.21267*pixel[image->channel_map[RedPixelChannel].offset]+
+ 0.71516*pixel[image->channel_map[GreenPixelChannel].offset]+0.07217*
+ pixel[image->channel_map[BluePixelChannel].offset]+0.5));
+#else
+ return((Quantum) (0.21267*pixel[image->channel_map[RedPixelChannel].offset]+
+ 0.71516*pixel[image->channel_map[GreenPixelChannel].offset]+0.07217*
+ pixel[image->channel_map[BluePixelChannel].offset]));
+#endif
+}
+
static inline Quantum GetPixelMagenta(const Image *restrict image,
const Quantum *restrict pixel)
{
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);
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)
{
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];
}
image->channel_map[IndexPixelChannel].traits=traits;
}
-static inline void SetPixelInfo(const Image *restrict image,
- const PixelInfo *restrict p,PixelInfo *restrict q)
-{
- q->red=p->red;
- q->green=p->green;
- q->blue=p->blue;
- q->black=0;
- if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
- q->black=p->black;
- q->alpha=OpaqueAlpha;
- if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
- q->alpha=p->alpha;
- q->index=0;
- if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
- q->index=p->index;
-}
-
static inline void SetPixelInfoPixel(const Image *restrict image,
const PixelInfo *restrict pixel_info,Quantum *restrict pixel)
{
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)
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)
{
image->channel_map[YPixelChannel].traits=traits;
}
-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]);
- 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));
-#else
- {
- double
- alpha,
- beta;
-
- alpha=pixel[image->channel_map[RedPixelChannel].offset]-(double)
- pixel[image->channel_map[GreenPixelChannel].offset];
- beta=pixel[image->channel_map[GreenPixelChannel].offset]-(double)
- pixel[image->channel_map[BluePixelChannel].offset];
- if ((fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
- return(pixel[image->channel_map[RedPixelChannel].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]));
- }
-#endif
-}
-
-static inline Quantum GetPixelLuminance(const Image *restrict image,
- const Quantum *restrict pixel)
-{
-#if !defined(MAGICKCORE_HDRI_SUPPORT)
- return((Quantum) (0.21267*pixel[image->channel_map[RedPixelChannel].offset]+
- 0.71516*pixel[image->channel_map[GreenPixelChannel].offset]+0.07217*
- pixel[image->channel_map[BluePixelChannel].offset]+0.5));
-#else
- return((Quantum) (0.21267*pixel[image->channel_map[RedPixelChannel].offset]+
- 0.71516*pixel[image->channel_map[GreenPixelChannel].offset]+0.07217*
- pixel[image->channel_map[BluePixelChannel].offset]));
-#endif
-}
-
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif