pixel-accessor.h

Go to the documentation of this file.
00001 /*
00002   Copyright 1999-2019 ImageMagick Studio LLC, a non-profit organization
00003   dedicated to making software imaging solutions freely available.
00004 
00005   You may not use this file except in compliance with the License.  You may
00006   obtain a copy of the License at
00007 
00008     https://imagemagick.org/script/license.php
00009 
00010   Unless required by applicable law or agreed to in writing, software
00011   distributed under the License is distributed on an "AS IS" BASIS,
00012   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013   See the License for the specific language governing permissions and
00014   limitations under the License.
00015 
00016   MagickCore pixel accessor methods.
00017 */
00018 #ifndef MAGICKCORE_PIXEL_ACCESSOR_H
00019 #define MAGICKCORE_PIXEL_ACCESSOR_H
00020 
00021 #include <assert.h>
00022 #include "MagickCore/cache.h"
00023 #include "MagickCore/cache-view.h"
00024 #include "MagickCore/color.h"
00025 #include "MagickCore/colorspace.h"
00026 #include "MagickCore/gem.h"
00027 #include "MagickCore/image.h"
00028 #include "MagickCore/memory_.h"
00029 
00030 #if defined(__cplusplus) || defined(c_plusplus)
00031 extern "C" {
00032 #endif
00033 
00034 #undef index
00035 
00036 static inline Quantum ClampPixel(const MagickRealType pixel)
00037 {
00038   if (pixel < 0.0f)
00039     return((Quantum) 0);
00040   if (pixel >= (MagickRealType) QuantumRange)
00041     return((Quantum) QuantumRange);
00042 #if !defined(MAGICKCORE_HDRI_SUPPORT)
00043   return((Quantum) (pixel+0.5f));
00044 #else
00045   return((Quantum) pixel);
00046 #endif
00047 }
00048 
00049 static inline Quantum GetPixela(const Image *magick_restrict image,
00050   const Quantum *magick_restrict pixel)
00051 {
00052   return(pixel[image->channel_map[aPixelChannel].offset]);
00053 }
00054 
00055 static inline Quantum GetPixelAlpha(const Image *magick_restrict image,
00056   const Quantum *magick_restrict pixel)
00057 {
00058   if (image->channel_map[AlphaPixelChannel].traits == UndefinedPixelTrait)
00059     return(OpaqueAlpha);
00060   return(pixel[image->channel_map[AlphaPixelChannel].offset]);
00061 }
00062 
00063 static inline PixelTrait GetPixelAlphaTraits(
00064   const Image *magick_restrict image)
00065 {
00066   return(image->channel_map[AlphaPixelChannel].traits);
00067 }
00068 
00069 static inline Quantum GetPixelb(const Image *magick_restrict image,
00070   const Quantum *magick_restrict pixel)
00071 {
00072   return(pixel[image->channel_map[bPixelChannel].offset]);
00073 }
00074 
00075 static inline Quantum GetPixelBlack(const Image *magick_restrict image,
00076   const Quantum *magick_restrict pixel)
00077 {
00078   if (image->channel_map[BlackPixelChannel].traits == UndefinedPixelTrait)
00079     return((Quantum) 0);
00080   return(pixel[image->channel_map[BlackPixelChannel].offset]);
00081 }
00082 
00083 static inline PixelTrait GetPixelBlackTraits(
00084   const Image *magick_restrict image)
00085 {
00086   return(image->channel_map[BlackPixelChannel].traits);
00087 }
00088 
00089 static inline Quantum GetPixelBlue(const Image *magick_restrict image,
00090   const Quantum *magick_restrict pixel)
00091 {
00092   return(pixel[image->channel_map[BluePixelChannel].offset]);
00093 }
00094 
00095 static inline PixelTrait GetPixelBlueTraits(const Image *magick_restrict image)
00096 {
00097   return(image->channel_map[BluePixelChannel].traits);
00098 }
00099 
00100 static inline Quantum GetPixelCb(const Image *magick_restrict image,
00101   const Quantum *magick_restrict pixel)
00102 {
00103   return(pixel[image->channel_map[CbPixelChannel].offset]);
00104 }
00105 
00106 static inline PixelTrait GetPixelCbTraits(const Image *magick_restrict image)
00107 {
00108   return(image->channel_map[CbPixelChannel].traits);
00109 }
00110 
00111 static inline Quantum GetPixelChannel(const Image *magick_restrict image,
00112   const PixelChannel channel,const Quantum *magick_restrict pixel)
00113 {
00114   if (image->channel_map[channel].traits == UndefinedPixelTrait)
00115     return((Quantum) 0);
00116   return(pixel[image->channel_map[channel].offset]);
00117 }
00118 
00119 static inline PixelChannel GetPixelChannelChannel(
00120   const Image *magick_restrict image,const ssize_t offset)
00121 {
00122   return(image->channel_map[offset].channel);
00123 }
00124 
00125 static inline ssize_t GetPixelChannelOffset(const Image *magick_restrict image,
00126   const PixelChannel channel)
00127 {
00128   return(image->channel_map[channel].offset);
00129 }
00130 
00131 static inline PixelTrait GetPixelChannelTraits(
00132   const Image *magick_restrict image,const PixelChannel channel)
00133 {
00134   return(image->channel_map[channel].traits);
00135 }
00136 
00137 static inline size_t GetPixelChannels(const Image *magick_restrict image)
00138 {
00139   return(image->number_channels);
00140 }
00141 
00142 static inline Quantum GetPixelCompositeMask(const Image *magick_restrict image,
00143   const Quantum *magick_restrict pixel)
00144 {
00145   if (image->channel_map[CompositeMaskPixelChannel].traits == UndefinedPixelTrait)
00146     return((Quantum) QuantumRange);
00147   return(pixel[image->channel_map[CompositeMaskPixelChannel].offset]);
00148 }
00149 
00150 static inline Quantum GetPixelCr(const Image *magick_restrict image,
00151   const Quantum *magick_restrict pixel)
00152 {
00153   return(pixel[image->channel_map[CrPixelChannel].offset]);
00154 }
00155 
00156 static inline PixelTrait GetPixelCrTraits(const Image *magick_restrict image)
00157 {
00158   return(image->channel_map[CrPixelChannel].traits);
00159 }
00160 
00161 static inline Quantum GetPixelCyan(const Image *magick_restrict image,
00162   const Quantum *magick_restrict pixel)
00163 {
00164   return(pixel[image->channel_map[CyanPixelChannel].offset]);
00165 }
00166 
00167 static inline PixelTrait GetPixelCyanTraits(const Image *magick_restrict image)
00168 {
00169   return(image->channel_map[CyanPixelChannel].traits);
00170 }
00171 
00172 static inline Quantum GetPixelGray(const Image *magick_restrict image,
00173   const Quantum *magick_restrict pixel)
00174 {
00175   return(pixel[image->channel_map[GrayPixelChannel].offset]);
00176 }
00177 
00178 static inline PixelTrait GetPixelGrayTraits(const Image *magick_restrict image)
00179 {
00180   return(image->channel_map[GrayPixelChannel].traits);
00181 }
00182 
00183 static inline Quantum GetPixelGreen(const Image *magick_restrict image,
00184   const Quantum *magick_restrict pixel)
00185 {
00186   return(pixel[image->channel_map[GreenPixelChannel].offset]);
00187 }
00188 
00189 static inline PixelTrait GetPixelGreenTraits(
00190   const Image *magick_restrict image)
00191 {
00192   return(image->channel_map[GreenPixelChannel].traits);
00193 }
00194 
00195 static inline Quantum GetPixelIndex(const Image *magick_restrict image,
00196   const Quantum *magick_restrict pixel)
00197 {
00198   if (image->channel_map[IndexPixelChannel].traits == UndefinedPixelTrait)
00199     return((Quantum) 0);
00200   return(pixel[image->channel_map[IndexPixelChannel].offset]);
00201 }
00202 
00203 static inline PixelTrait GetPixelIndexTraits(
00204   const Image *magick_restrict image)
00205 {
00206   return(image->channel_map[IndexPixelChannel].traits);
00207 }
00208 
00209 static inline MagickRealType GetPixelInfoChannel(
00210   const PixelInfo *magick_restrict pixel_info,const PixelChannel channel)
00211 {
00212   switch (channel)
00213   {
00214     case RedPixelChannel: return(pixel_info->red);
00215     case GreenPixelChannel: return(pixel_info->green);
00216     case BluePixelChannel: return(pixel_info->blue);
00217     case BlackPixelChannel: return(pixel_info->black);
00218     case AlphaPixelChannel: return(pixel_info->alpha);
00219     case IndexPixelChannel: return(pixel_info->index);
00220     default: return((MagickRealType) 0.0);
00221   }
00222 }
00223 
00224 static inline double PerceptibleReciprocal(const double x)
00225 {
00226   double
00227     sign;
00228 
00229   /*
00230     Return 1/x where x is perceptible (not unlimited or infinitesimal).
00231   */
00232   sign=x < 0.0 ? -1.0 : 1.0;
00233   if ((sign*x) >= MagickEpsilon)
00234     return(1.0/x);
00235   return(sign/MagickEpsilon);
00236 }
00237 
00238 static inline MagickRealType GetPixelInfoLuma(
00239   const PixelInfo *magick_restrict pixel)
00240 {
00241   MagickRealType
00242     intensity;
00243 
00244   if (pixel->colorspace == sRGBColorspace)
00245     {
00246       intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
00247         0.072186f*pixel->blue);
00248       return(intensity);
00249     }
00250   intensity=(MagickRealType) (0.212656f*EncodePixelGamma(pixel->red)+
00251     0.715158f*EncodePixelGamma(pixel->green)+
00252     0.072186f*EncodePixelGamma(pixel->blue));
00253   return(intensity);
00254 }
00255 
00256 static inline MagickRealType GetPixelInfoLuminance(
00257   const PixelInfo *magick_restrict pixel)
00258 {
00259   MagickRealType
00260     intensity;
00261 
00262   if (pixel->colorspace != sRGBColorspace)
00263     {
00264       intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
00265         0.072186f*pixel->blue);
00266       return(intensity);
00267     }
00268   intensity=(MagickRealType) (0.212656f*DecodePixelGamma(pixel->red)+
00269     0.715158f*DecodePixelGamma(pixel->green)+
00270     0.072186f*DecodePixelGamma(pixel->blue));
00271   return(intensity);
00272 }
00273 
00274 static inline Quantum GetPixelL(const Image *magick_restrict image,
00275   const Quantum *magick_restrict pixel)
00276 {
00277   return(pixel[image->channel_map[LPixelChannel].offset]);
00278 }
00279 
00280 static inline ssize_t GetPixelLabel(const Image *magick_restrict image,
00281   const Quantum *magick_restrict pixel)
00282 {
00283   return((ssize_t) pixel[image->channel_map[LabelPixelChannel].offset]);
00284 }
00285 
00286 static inline MagickRealType GetPixelLuma(const Image *magick_restrict image,
00287   const Quantum *magick_restrict pixel)
00288 {
00289   MagickRealType
00290     intensity;
00291 
00292   intensity=(MagickRealType) (
00293     0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
00294     0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
00295     0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
00296   return(intensity);
00297 }
00298 
00299 static inline MagickRealType GetPixelLuminance(
00300   const Image *magick_restrict image,const Quantum *magick_restrict pixel)
00301 {
00302   MagickRealType
00303     intensity;
00304 
00305   if (image->colorspace != sRGBColorspace)
00306     {
00307       intensity=(MagickRealType) (
00308         0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
00309         0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
00310         0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
00311       return(intensity);
00312     }
00313   intensity=(MagickRealType) (0.212656f*DecodePixelGamma((MagickRealType)
00314     pixel[image->channel_map[RedPixelChannel].offset])+0.715158f*
00315     DecodePixelGamma((MagickRealType)
00316     pixel[image->channel_map[GreenPixelChannel].offset])+0.072186f*
00317     DecodePixelGamma((MagickRealType)
00318     pixel[image->channel_map[BluePixelChannel].offset]));
00319   return(intensity);
00320 }
00321 
00322 static inline Quantum GetPixelMagenta(const Image *magick_restrict image,
00323   const Quantum *magick_restrict pixel)
00324 {
00325   return(pixel[image->channel_map[MagentaPixelChannel].offset]);
00326 }
00327 
00328 static inline PixelTrait GetPixelMagentaTraits(
00329   const Image *magick_restrict image)
00330 {
00331   return(image->channel_map[MagentaPixelChannel].traits);
00332 }
00333 
00334 static inline Quantum GetPixelReadMask(const Image *magick_restrict image,
00335   const Quantum *magick_restrict pixel)
00336 {
00337   if (image->channel_map[ReadMaskPixelChannel].traits == UndefinedPixelTrait)
00338     return((Quantum) QuantumRange);
00339   return(pixel[image->channel_map[ReadMaskPixelChannel].offset]);
00340 }
00341 
00342 static inline Quantum GetPixelWriteMask(const Image *magick_restrict image,
00343   const Quantum *magick_restrict pixel)
00344 {
00345   if (image->channel_map[WriteMaskPixelChannel].traits == UndefinedPixelTrait)
00346     return((Quantum) QuantumRange);
00347   return(pixel[image->channel_map[WriteMaskPixelChannel].offset]);
00348 }
00349 
00350 static inline PixelTrait GetPixelReadMaskTraits(
00351   const Image *magick_restrict image)
00352 {
00353   return(image->channel_map[ReadMaskPixelChannel].traits);
00354 }
00355 
00356 static inline size_t GetPixelMetaChannels(const Image *magick_restrict image)
00357 {
00358   return(image->number_meta_channels);
00359 }
00360 
00361 static inline size_t GetPixelMetacontentExtent(
00362   const Image *magick_restrict image)
00363 {
00364   return(image->metacontent_extent);
00365 }
00366 
00367 static inline Quantum GetPixelOpacity(const Image *magick_restrict image,
00368   const Quantum *magick_restrict pixel)
00369 {
00370   if (image->channel_map[AlphaPixelChannel].traits != BlendPixelTrait)
00371     return(QuantumRange-OpaqueAlpha);
00372   return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
00373 }
00374 
00375 static inline Quantum GetPixelRed(const Image *magick_restrict image,
00376   const Quantum *magick_restrict pixel)
00377 {
00378   return(pixel[image->channel_map[RedPixelChannel].offset]);
00379 }
00380 
00381 static inline PixelTrait GetPixelRedTraits(const Image *magick_restrict image)
00382 {
00383   return(image->channel_map[RedPixelChannel].traits);
00384 }
00385 
00386 static inline void GetPixelInfoPixel(const Image *magick_restrict image,
00387   const Quantum *magick_restrict pixel,PixelInfo *magick_restrict pixel_info)
00388 {
00389   (void) ResetMagickMemory(pixel_info,0,sizeof(*pixel_info));
00390   pixel_info->storage_class=DirectClass;
00391   pixel_info->colorspace=sRGBColorspace;
00392   pixel_info->depth=MAGICKCORE_QUANTUM_DEPTH;
00393   pixel_info->alpha_trait=UndefinedPixelTrait;
00394   pixel_info->alpha=(MagickRealType) OpaqueAlpha;
00395   if (image != (Image *) NULL)
00396     {
00397       pixel_info->storage_class=image->storage_class;
00398       pixel_info->colorspace=image->colorspace;
00399       pixel_info->fuzz=image->fuzz;
00400       pixel_info->depth=image->depth;
00401       pixel_info->alpha_trait=image->alpha_trait;
00402       if (pixel != (Quantum *) NULL)
00403         {
00404           pixel_info->red=(MagickRealType)
00405             pixel[image->channel_map[RedPixelChannel].offset];
00406           pixel_info->green=(MagickRealType)
00407             pixel[image->channel_map[GreenPixelChannel].offset];
00408           pixel_info->blue=(MagickRealType)
00409             pixel[image->channel_map[BluePixelChannel].offset];
00410           if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
00411             pixel_info->black=(MagickRealType)
00412               pixel[image->channel_map[BlackPixelChannel].offset];
00413           if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
00414             {
00415               pixel_info->alpha=(MagickRealType)
00416                 pixel[image->channel_map[AlphaPixelChannel].offset];
00417               pixel_info->alpha_trait=BlendPixelTrait;
00418             }
00419           if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
00420             pixel_info->index=(MagickRealType)
00421           pixel[image->channel_map[IndexPixelChannel].offset];
00422         }
00423     }
00424 }
00425 
00426 static inline PixelTrait GetPixelTraits(const Image *magick_restrict image,
00427   const PixelChannel channel)
00428 {
00429   return(image->channel_map[channel].traits);
00430 }
00431 
00432 static inline Quantum GetPixelY(const Image *magick_restrict image,
00433   const Quantum *magick_restrict pixel)
00434 {
00435   return(pixel[image->channel_map[YPixelChannel].offset]);
00436 }
00437 
00438 static inline PixelTrait GetPixelYTraits(const Image *magick_restrict image)
00439 {
00440   return(image->channel_map[YPixelChannel].traits);
00441 }
00442 
00443 static inline Quantum GetPixelYellow(const Image *magick_restrict image,
00444   const Quantum *magick_restrict pixel)
00445 {
00446   return(pixel[image->channel_map[YellowPixelChannel].offset]);
00447 }
00448 
00449 static inline PixelTrait GetPixelYellowTraits(
00450   const Image *magick_restrict image)
00451 {
00452   return(image->channel_map[YellowPixelChannel].traits);
00453 }
00454 
00455 static inline MagickRealType AbsolutePixelValue(const MagickRealType x)
00456 {
00457   return(x < 0.0f ? -x : x);
00458 }
00459 
00460 static inline MagickBooleanType IsPixelAtDepth(const Quantum pixel,
00461   const QuantumAny range)
00462 {
00463   Quantum
00464     quantum;
00465 
00466   if (range == 0)
00467     return(MagickTrue);
00468 #if !defined(MAGICKCORE_HDRI_SUPPORT)
00469   quantum=(Quantum) (((MagickRealType) QuantumRange*((QuantumAny)
00470     (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range+0.5);
00471 #else
00472   quantum=(Quantum) (((MagickRealType) QuantumRange*((QuantumAny)
00473     (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range);
00474 #endif
00475   return(pixel == quantum ? MagickTrue : MagickFalse);
00476 }
00477 
00478 static inline MagickBooleanType IsPixelEquivalent(
00479   const Image *magick_restrict image,const Quantum *magick_restrict p,
00480   const PixelInfo *magick_restrict q)
00481 {
00482   MagickRealType
00483     alpha,
00484     beta,
00485     color;
00486 
00487   color=(MagickRealType) p[image->channel_map[AlphaPixelChannel].offset];
00488   alpha=image->alpha_trait == UndefinedPixelTrait ? (MagickRealType)
00489     OpaqueAlpha : color;
00490   beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
00491     q->alpha;
00492   if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
00493     return(MagickFalse);
00494   if ((AbsolutePixelValue(alpha-TransparentAlpha) < MagickEpsilon) ||
00495       (AbsolutePixelValue(beta-TransparentAlpha) < MagickEpsilon))
00496     return(MagickTrue);  /* no color component if pixel is transparent */
00497   color=(MagickRealType) p[image->channel_map[RedPixelChannel].offset];
00498   if (AbsolutePixelValue(color-q->red) >= MagickEpsilon)
00499     return(MagickFalse);
00500   color=(MagickRealType) p[image->channel_map[GreenPixelChannel].offset];
00501   if (AbsolutePixelValue(color-q->green) >= MagickEpsilon)
00502     return(MagickFalse);
00503   color=(MagickRealType) p[image->channel_map[BluePixelChannel].offset];
00504   if (AbsolutePixelValue(color-q->blue) >= MagickEpsilon)
00505     return(MagickFalse);
00506   if (image->colorspace == CMYKColorspace)
00507     {
00508       color=(MagickRealType) p[image->channel_map[BlackPixelChannel].offset];
00509       if (AbsolutePixelValue(color-q->black) >= MagickEpsilon)
00510         return(MagickFalse);
00511     }
00512   return(MagickTrue);
00513 }
00514 
00515 static inline MagickBooleanType IsPixelGray(const Image *magick_restrict image,
00516   const Quantum *magick_restrict pixel)
00517 {
00518   MagickRealType
00519     green_blue,
00520     red_green;
00521 
00522   red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
00523     pixel[image->channel_map[GreenPixelChannel].offset];
00524   green_blue=(MagickRealType)
00525     pixel[image->channel_map[GreenPixelChannel].offset]-
00526     pixel[image->channel_map[BluePixelChannel].offset];
00527   if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
00528       (AbsolutePixelValue(green_blue) < MagickEpsilon))
00529     return(MagickTrue);
00530   return(MagickFalse);
00531 }
00532 
00533 static inline MagickBooleanType IsPixelInfoEquivalent(
00534   const PixelInfo *magick_restrict p,const PixelInfo *magick_restrict q)
00535 {
00536   MagickRealType
00537     alpha,
00538     beta;
00539 
00540   alpha=p->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
00541     p->alpha;
00542   beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
00543     q->alpha;
00544   if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
00545     return(MagickFalse);
00546   if ((AbsolutePixelValue(alpha-TransparentAlpha) < MagickEpsilon) ||
00547       (AbsolutePixelValue(beta-TransparentAlpha) < MagickEpsilon))
00548     return(MagickTrue);  /* no color component if pixel is transparent */
00549   if (AbsolutePixelValue(p->red-q->red) >= MagickEpsilon)
00550     return(MagickFalse);
00551   if (AbsolutePixelValue(p->green-q->green) >= MagickEpsilon)
00552     return(MagickFalse);
00553   if (AbsolutePixelValue(p->blue-q->blue) >= MagickEpsilon)
00554     return(MagickFalse);
00555   if (p->colorspace == CMYKColorspace)
00556     {
00557       if (AbsolutePixelValue(p->black-q->black) >= MagickEpsilon)
00558         return(MagickFalse);
00559     }
00560   return(MagickTrue);
00561 }
00562 
00563 static inline MagickBooleanType IsPixelMonochrome(
00564   const Image *magick_restrict image,const Quantum *magick_restrict pixel)
00565 {
00566   MagickRealType
00567     green_blue,
00568     red,
00569     red_green;
00570 
00571   red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
00572   if ((AbsolutePixelValue(red) >= MagickEpsilon) &&
00573       (AbsolutePixelValue(red-QuantumRange) >= MagickEpsilon))
00574     return(MagickFalse);
00575   red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
00576     pixel[image->channel_map[GreenPixelChannel].offset];
00577   green_blue=(MagickRealType)
00578     pixel[image->channel_map[GreenPixelChannel].offset]-
00579     pixel[image->channel_map[BluePixelChannel].offset];
00580   if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
00581       (AbsolutePixelValue(green_blue) < MagickEpsilon))
00582     return(MagickTrue);
00583   return(MagickFalse);
00584 }
00585 
00586 static inline MagickBooleanType IsPixelInfoGray(
00587   const PixelInfo *magick_restrict pixel)
00588 {
00589   if ((AbsolutePixelValue(pixel->red-pixel->green) < MagickEpsilon) &&
00590       (AbsolutePixelValue(pixel->green-pixel->blue) < MagickEpsilon))
00591     return(MagickTrue);
00592   return(MagickFalse);
00593 }
00594 
00595 static inline MagickBooleanType IsPixelInfoMonochrome(
00596   const PixelInfo *magick_restrict pixel_info)
00597 {
00598   MagickRealType
00599     green_blue,
00600     red_green;
00601 
00602   if ((AbsolutePixelValue(pixel_info->red) >= MagickEpsilon) ||
00603       (AbsolutePixelValue(pixel_info->red-QuantumRange) >= MagickEpsilon))
00604     return(MagickFalse);
00605   red_green=pixel_info->red-pixel_info->green;
00606   green_blue=pixel_info->green-pixel_info->blue;
00607   if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
00608       (AbsolutePixelValue(green_blue) < MagickEpsilon))
00609     return(MagickTrue);
00610   return(MagickFalse);
00611 }
00612 
00613 static inline void SetPixela(const Image *magick_restrict image,
00614   const Quantum a,Quantum *magick_restrict pixel)
00615 {
00616   if (image->channel_map[aPixelChannel].traits != UndefinedPixelTrait)
00617     pixel[image->channel_map[aPixelChannel].offset]=a;
00618 }
00619 
00620 static inline void SetPixelAlpha(const Image *magick_restrict image,
00621   const Quantum alpha,Quantum *magick_restrict pixel)
00622 {
00623   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
00624     pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
00625 }
00626 
00627 static inline void SetPixelAlphaTraits(Image *image,const PixelTrait traits)
00628 {
00629   image->channel_map[AlphaPixelChannel].traits=traits;
00630 }
00631 
00632 static inline void SetPixelb(const Image *magick_restrict image,
00633   const Quantum b,Quantum *magick_restrict pixel)
00634 {
00635   if (image->channel_map[bPixelChannel].traits != UndefinedPixelTrait)
00636     pixel[image->channel_map[bPixelChannel].offset]=b;
00637 }
00638 
00639 static inline void SetPixelBackgoundColor(const Image *magick_restrict image,
00640   Quantum *magick_restrict pixel)
00641 {
00642   ssize_t
00643     i;
00644 
00645   for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
00646     pixel[i]=(Quantum) 0;
00647   pixel[image->channel_map[RedPixelChannel].offset]=
00648     ClampToQuantum(image->background_color.red);
00649   pixel[image->channel_map[GreenPixelChannel].offset]=
00650     ClampToQuantum(image->background_color.green);
00651   pixel[image->channel_map[BluePixelChannel].offset]=
00652     ClampToQuantum(image->background_color.blue);
00653   if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
00654     pixel[image->channel_map[BlackPixelChannel].offset]=
00655       ClampToQuantum(image->background_color.black);
00656   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
00657     pixel[image->channel_map[AlphaPixelChannel].offset]=
00658       image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
00659       ClampToQuantum(image->background_color.alpha);
00660 }
00661 
00662 static inline void SetPixelBlack(const Image *magick_restrict image,
00663   const Quantum black,Quantum *magick_restrict pixel)
00664 {
00665   if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
00666     pixel[image->channel_map[BlackPixelChannel].offset]=black;
00667 }
00668 
00669 static inline void SetPixelBlackTraits(Image *image,const PixelTrait traits)
00670 {
00671   image->channel_map[BlackPixelChannel].traits=traits;
00672 }
00673 
00674 static inline void SetPixelBlue(const Image *magick_restrict image,
00675   const Quantum blue,Quantum *magick_restrict pixel)
00676 {
00677   pixel[image->channel_map[BluePixelChannel].offset]=blue;
00678 }
00679 
00680 static inline void SetPixelBlueTraits(Image *image,const PixelTrait traits)
00681 {
00682   image->channel_map[BluePixelChannel].traits=traits;
00683 }
00684 
00685 static inline void SetPixelCb(const Image *magick_restrict image,
00686   const Quantum cb,Quantum *magick_restrict pixel)
00687 {
00688   pixel[image->channel_map[CbPixelChannel].offset]=cb;
00689 }
00690 
00691 static inline void SetPixelCbTraits(Image *image,const PixelTrait traits)
00692 {
00693   image->channel_map[CbPixelChannel].traits=traits;
00694 }
00695 
00696 static inline void SetPixelChannel(const Image *magick_restrict image,
00697   const PixelChannel channel,const Quantum quantum,
00698   Quantum *magick_restrict pixel)
00699 {
00700   if (image->channel_map[channel].traits != UndefinedPixelTrait)
00701     pixel[image->channel_map[channel].offset]=quantum;
00702 }
00703 
00704 static inline void SetPixelChannelAttributes(
00705   const Image *magick_restrict image,const PixelChannel channel,
00706   const PixelTrait traits,const ssize_t offset)
00707 {
00708   assert((ssize_t) channel < MaxPixelChannels);
00709   assert(offset < MaxPixelChannels);
00710   image->channel_map[offset].channel=channel;
00711   image->channel_map[channel].offset=offset;
00712   image->channel_map[channel].traits=traits;
00713 }
00714 
00715 static inline void SetPixelChannelChannel(const Image *magick_restrict image,
00716   const PixelChannel channel,const ssize_t offset)
00717 {
00718   image->channel_map[offset].channel=channel;
00719   image->channel_map[channel].offset=offset;
00720 }
00721 
00722 static inline void SetPixelChannels(Image *image,const size_t number_channels)
00723 {
00724   image->number_channels=number_channels;
00725 }
00726 
00727 static inline void SetPixelChannelTraits(Image *image,
00728   const PixelChannel channel,const PixelTrait traits)
00729 {
00730   image->channel_map[channel].traits=traits;
00731 }
00732 
00733 static inline void SetPixelCompositeMask(const Image *magick_restrict image,
00734   const Quantum mask,Quantum *magick_restrict pixel)
00735 {
00736   if (image->channel_map[CompositeMaskPixelChannel].traits != UndefinedPixelTrait)
00737     pixel[image->channel_map[CompositeMaskPixelChannel].offset]=mask;
00738 }
00739 
00740 static inline void SetPixelCr(const Image *magick_restrict image,
00741   const Quantum cr,Quantum *magick_restrict pixel)
00742 {
00743   pixel[image->channel_map[CrPixelChannel].offset]=cr;
00744 }
00745 
00746 static inline void SetPixelCrTraits(Image *image,const PixelTrait traits)
00747 {
00748   image->channel_map[CrPixelChannel].traits=traits;
00749 }
00750 
00751 static inline void SetPixelCyan(const Image *magick_restrict image,
00752   const Quantum cyan,Quantum *magick_restrict pixel)
00753 {
00754   pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
00755 }
00756 
00757 static inline void SetPixelGray(const Image *magick_restrict image,
00758   const Quantum gray,Quantum *magick_restrict pixel)
00759 {
00760   pixel[image->channel_map[GrayPixelChannel].offset]=gray;
00761 }
00762 
00763 static inline void SetPixelGrayTraits(Image *image,const PixelTrait traits)
00764 {
00765   image->channel_map[GrayPixelChannel].traits=traits;
00766 }
00767 
00768 static inline void SetPixelGreen(const Image *magick_restrict image,
00769   const Quantum green,Quantum *magick_restrict pixel)
00770 {
00771   pixel[image->channel_map[GreenPixelChannel].offset]=green;
00772 }
00773 
00774 static inline void SetPixelGreenTraits(Image *image,const PixelTrait traits)
00775 {
00776   image->channel_map[GreenPixelChannel].traits=traits;
00777 }
00778 
00779 static inline void SetPixelIndex(const Image *magick_restrict image,
00780   const Quantum index,Quantum *magick_restrict pixel)
00781 {
00782   if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
00783     pixel[image->channel_map[IndexPixelChannel].offset]=index;
00784 }
00785 
00786 static inline void SetPixelIndexTraits(Image *image,const PixelTrait traits)
00787 {
00788   image->channel_map[IndexPixelChannel].traits=traits;
00789 }
00790 
00791 static inline void SetPixelViaPixelInfo(const Image *magick_restrict image,
00792   const PixelInfo *magick_restrict pixel_info,Quantum *magick_restrict pixel)
00793 {
00794   pixel[image->channel_map[RedPixelChannel].offset]=
00795     ClampToQuantum(pixel_info->red);
00796   pixel[image->channel_map[GreenPixelChannel].offset]=
00797     ClampToQuantum(pixel_info->green);
00798   pixel[image->channel_map[BluePixelChannel].offset]=
00799     ClampToQuantum(pixel_info->blue);
00800   if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
00801     pixel[image->channel_map[BlackPixelChannel].offset]=
00802       ClampToQuantum(pixel_info->black);
00803   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
00804     pixel[image->channel_map[AlphaPixelChannel].offset]=
00805       pixel_info->alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
00806       ClampToQuantum(pixel_info->alpha);
00807 }
00808 
00809 static inline void SetPixelL(const Image *magick_restrict image,const Quantum L,
00810   Quantum *magick_restrict pixel)
00811 {
00812   if (image->channel_map[LPixelChannel].traits != UndefinedPixelTrait)
00813     pixel[image->channel_map[LPixelChannel].offset]=L;
00814 }
00815 
00816 static inline void SetPixelMagenta(const Image *magick_restrict image,
00817   const Quantum magenta,Quantum *magick_restrict pixel)
00818 {
00819   pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
00820 }
00821 
00822 static inline void SetPixelMagentaTraits(Image *image,const PixelTrait traits)
00823 {
00824   image->channel_map[MagentaPixelChannel].traits=traits;
00825 }
00826 
00827 static inline void SetPixelReadMask(const Image *magick_restrict image,
00828   const Quantum mask,Quantum *magick_restrict pixel)
00829 {
00830   if (image->channel_map[ReadMaskPixelChannel].traits != UndefinedPixelTrait)
00831     pixel[image->channel_map[ReadMaskPixelChannel].offset]=mask;
00832 }
00833 
00834 static inline void SetPixelWriteMask(const Image *magick_restrict image,
00835   const Quantum mask,Quantum *magick_restrict pixel)
00836 {
00837   if (image->channel_map[WriteMaskPixelChannel].traits != UndefinedPixelTrait)
00838     pixel[image->channel_map[WriteMaskPixelChannel].offset]=mask;
00839 }
00840 
00841 static inline void SetPixelMetacontentExtent(Image *image,const size_t extent)
00842 {
00843   image->metacontent_extent=extent;
00844 }
00845 
00846 static inline void SetPixelOpacity(const Image *magick_restrict image,
00847   const Quantum alpha,Quantum *magick_restrict pixel)
00848 {
00849   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
00850     pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
00851 }
00852 
00853 static inline void SetPixelRed(const Image *magick_restrict image,
00854   const Quantum red,Quantum *magick_restrict pixel)
00855 {
00856   pixel[image->channel_map[RedPixelChannel].offset]=red;
00857 }
00858 
00859 static inline void SetPixelRedTraits(Image *image,const PixelTrait traits)
00860 {
00861   image->channel_map[RedPixelChannel].traits=traits;
00862 }
00863 
00864 static inline void SetPixelYellow(const Image *magick_restrict image,
00865   const Quantum yellow,Quantum *magick_restrict pixel)
00866 {
00867   pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
00868 }
00869 
00870 static inline void SetPixelYellowTraits(Image *image,const PixelTrait traits)
00871 {
00872   image->channel_map[YellowPixelChannel].traits=traits;
00873 }
00874 
00875 static inline void SetPixelY(const Image *magick_restrict image,
00876   const Quantum y,Quantum *magick_restrict pixel)
00877 {
00878   pixel[image->channel_map[YPixelChannel].offset]=y;
00879 }
00880 
00881 static inline void SetPixelYTraits(Image *image,const PixelTrait traits)
00882 {
00883   image->channel_map[YPixelChannel].traits=traits;
00884 }
00885 
00886 #if defined(__cplusplus) || defined(c_plusplus)
00887 }
00888 #endif
00889 
00890 #endif

Generated on 26 Aug 2019 for MagickCore by  doxygen 1.6.1