pixel-accessor.h

Go to the documentation of this file.
00001 /*
00002   Copyright 1999-2020 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:
00218     {
00219       if (pixel_info->colorspace != CMYKColorspace)
00220         return(0.0);
00221       return(pixel_info->black);
00222     }
00223     case AlphaPixelChannel:
00224     {
00225       if (pixel_info->alpha_trait == UndefinedPixelTrait)
00226         return(OpaqueAlpha);
00227       return(pixel_info->alpha);
00228     }
00229     case IndexPixelChannel: return(pixel_info->index);
00230     default: return((MagickRealType) 0.0);
00231   }
00232 }
00233 
00234 static inline double PerceptibleReciprocal(const double x)
00235 {
00236   double
00237     sign;
00238 
00239   /*
00240     Return 1/x where x is perceptible (not unlimited or infinitesimal).
00241   */
00242   sign=x < 0.0 ? -1.0 : 1.0;
00243   if ((sign*x) >= MagickEpsilon)
00244     return(1.0/x);
00245   return(sign/MagickEpsilon);
00246 }
00247 
00248 static inline MagickRealType GetPixelInfoLuma(
00249   const PixelInfo *magick_restrict pixel)
00250 {
00251   MagickRealType
00252     intensity;
00253 
00254   if (pixel->colorspace == sRGBColorspace)
00255     {
00256       intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
00257         0.072186f*pixel->blue);
00258       return(intensity);
00259     }
00260   intensity=(MagickRealType) (0.212656f*EncodePixelGamma(pixel->red)+
00261     0.715158f*EncodePixelGamma(pixel->green)+
00262     0.072186f*EncodePixelGamma(pixel->blue));
00263   return(intensity);
00264 }
00265 
00266 static inline MagickRealType GetPixelInfoLuminance(
00267   const PixelInfo *magick_restrict pixel)
00268 {
00269   MagickRealType
00270     intensity;
00271 
00272   if (pixel->colorspace != sRGBColorspace)
00273     {
00274       intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
00275         0.072186f*pixel->blue);
00276       return(intensity);
00277     }
00278   intensity=(MagickRealType) (0.212656f*DecodePixelGamma(pixel->red)+
00279     0.715158f*DecodePixelGamma(pixel->green)+
00280     0.072186f*DecodePixelGamma(pixel->blue));
00281   return(intensity);
00282 }
00283 
00284 static inline Quantum GetPixelL(const Image *magick_restrict image,
00285   const Quantum *magick_restrict pixel)
00286 {
00287   return(pixel[image->channel_map[LPixelChannel].offset]);
00288 }
00289 
00290 static inline ssize_t GetPixelLabel(const Image *magick_restrict image,
00291   const Quantum *magick_restrict pixel)
00292 {
00293   return((ssize_t) pixel[image->channel_map[LabelPixelChannel].offset]);
00294 }
00295 
00296 static inline MagickRealType GetPixelLuma(const Image *magick_restrict image,
00297   const Quantum *magick_restrict pixel)
00298 {
00299   MagickRealType
00300     intensity;
00301 
00302   intensity=(MagickRealType) (
00303     0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
00304     0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
00305     0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
00306   return(intensity);
00307 }
00308 
00309 static inline MagickRealType GetPixelLuminance(
00310   const Image *magick_restrict image,const Quantum *magick_restrict pixel)
00311 {
00312   MagickRealType
00313     intensity;
00314 
00315   if (image->colorspace != sRGBColorspace)
00316     {
00317       intensity=(MagickRealType) (
00318         0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
00319         0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
00320         0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
00321       return(intensity);
00322     }
00323   intensity=(MagickRealType) (0.212656f*DecodePixelGamma((MagickRealType)
00324     pixel[image->channel_map[RedPixelChannel].offset])+0.715158f*
00325     DecodePixelGamma((MagickRealType)
00326     pixel[image->channel_map[GreenPixelChannel].offset])+0.072186f*
00327     DecodePixelGamma((MagickRealType)
00328     pixel[image->channel_map[BluePixelChannel].offset]));
00329   return(intensity);
00330 }
00331 
00332 static inline Quantum GetPixelMagenta(const Image *magick_restrict image,
00333   const Quantum *magick_restrict pixel)
00334 {
00335   return(pixel[image->channel_map[MagentaPixelChannel].offset]);
00336 }
00337 
00338 static inline PixelTrait GetPixelMagentaTraits(
00339   const Image *magick_restrict image)
00340 {
00341   return(image->channel_map[MagentaPixelChannel].traits);
00342 }
00343 
00344 static inline Quantum GetPixelReadMask(const Image *magick_restrict image,
00345   const Quantum *magick_restrict pixel)
00346 {
00347   if (image->channel_map[ReadMaskPixelChannel].traits == UndefinedPixelTrait)
00348     return((Quantum) QuantumRange);
00349   return(pixel[image->channel_map[ReadMaskPixelChannel].offset]);
00350 }
00351 
00352 static inline Quantum GetPixelWriteMask(const Image *magick_restrict image,
00353   const Quantum *magick_restrict pixel)
00354 {
00355   if (image->channel_map[WriteMaskPixelChannel].traits == UndefinedPixelTrait)
00356     return((Quantum) QuantumRange);
00357   return(pixel[image->channel_map[WriteMaskPixelChannel].offset]);
00358 }
00359 
00360 static inline PixelTrait GetPixelReadMaskTraits(
00361   const Image *magick_restrict image)
00362 {
00363   return(image->channel_map[ReadMaskPixelChannel].traits);
00364 }
00365 
00366 static inline size_t GetPixelMetaChannels(const Image *magick_restrict image)
00367 {
00368   return(image->number_meta_channels);
00369 }
00370 
00371 static inline size_t GetPixelMetacontentExtent(
00372   const Image *magick_restrict image)
00373 {
00374   return(image->metacontent_extent);
00375 }
00376 
00377 static inline Quantum GetPixelOpacity(const Image *magick_restrict image,
00378   const Quantum *magick_restrict pixel)
00379 {
00380   if (image->channel_map[AlphaPixelChannel].traits != BlendPixelTrait)
00381     return(QuantumRange-OpaqueAlpha);
00382   return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
00383 }
00384 
00385 static inline Quantum GetPixelRed(const Image *magick_restrict image,
00386   const Quantum *magick_restrict pixel)
00387 {
00388   return(pixel[image->channel_map[RedPixelChannel].offset]);
00389 }
00390 
00391 static inline PixelTrait GetPixelRedTraits(const Image *magick_restrict image)
00392 {
00393   return(image->channel_map[RedPixelChannel].traits);
00394 }
00395 
00396 static inline void GetPixelInfoPixel(const Image *magick_restrict image,
00397   const Quantum *magick_restrict pixel,PixelInfo *magick_restrict pixel_info)
00398 {
00399   (void) ResetMagickMemory(pixel_info,0,sizeof(*pixel_info));
00400   pixel_info->storage_class=DirectClass;
00401   pixel_info->colorspace=sRGBColorspace;
00402   pixel_info->depth=MAGICKCORE_QUANTUM_DEPTH;
00403   pixel_info->alpha_trait=UndefinedPixelTrait;
00404   pixel_info->alpha=(MagickRealType) OpaqueAlpha;
00405   if (image != (Image *) NULL)
00406     {
00407       pixel_info->storage_class=image->storage_class;
00408       pixel_info->colorspace=image->colorspace;
00409       pixel_info->fuzz=image->fuzz;
00410       pixel_info->depth=image->depth;
00411       pixel_info->alpha_trait=image->alpha_trait;
00412       if (pixel != (Quantum *) NULL)
00413         {
00414           pixel_info->red=(MagickRealType)
00415             pixel[image->channel_map[RedPixelChannel].offset];
00416           pixel_info->green=(MagickRealType)
00417             pixel[image->channel_map[GreenPixelChannel].offset];
00418           pixel_info->blue=(MagickRealType)
00419             pixel[image->channel_map[BluePixelChannel].offset];
00420           if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
00421             pixel_info->black=(MagickRealType)
00422               pixel[image->channel_map[BlackPixelChannel].offset];
00423           if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
00424             {
00425               pixel_info->alpha=(MagickRealType)
00426                 pixel[image->channel_map[AlphaPixelChannel].offset];
00427               pixel_info->alpha_trait=BlendPixelTrait;
00428             }
00429           if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
00430             pixel_info->index=(MagickRealType)
00431           pixel[image->channel_map[IndexPixelChannel].offset];
00432         }
00433     }
00434 }
00435 
00436 static inline PixelTrait GetPixelTraits(const Image *magick_restrict image,
00437   const PixelChannel channel)
00438 {
00439   return(image->channel_map[channel].traits);
00440 }
00441 
00442 static inline Quantum GetPixelY(const Image *magick_restrict image,
00443   const Quantum *magick_restrict pixel)
00444 {
00445   return(pixel[image->channel_map[YPixelChannel].offset]);
00446 }
00447 
00448 static inline PixelTrait GetPixelYTraits(const Image *magick_restrict image)
00449 {
00450   return(image->channel_map[YPixelChannel].traits);
00451 }
00452 
00453 static inline Quantum GetPixelYellow(const Image *magick_restrict image,
00454   const Quantum *magick_restrict pixel)
00455 {
00456   return(pixel[image->channel_map[YellowPixelChannel].offset]);
00457 }
00458 
00459 static inline PixelTrait GetPixelYellowTraits(
00460   const Image *magick_restrict image)
00461 {
00462   return(image->channel_map[YellowPixelChannel].traits);
00463 }
00464 
00465 static inline MagickRealType AbsolutePixelValue(const MagickRealType x)
00466 {
00467   return(x < 0.0f ? -x : x);
00468 }
00469 
00470 static inline MagickBooleanType IsPixelAtDepth(const Quantum pixel,
00471   const QuantumAny range)
00472 {
00473   Quantum
00474     quantum;
00475 
00476   if (range == 0)
00477     return(MagickTrue);
00478 #if !defined(MAGICKCORE_HDRI_SUPPORT)
00479   quantum=(Quantum) (((MagickRealType) QuantumRange*((QuantumAny)
00480     (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range+0.5);
00481 #else
00482   quantum=(Quantum) (((MagickRealType) QuantumRange*((QuantumAny)
00483     (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range);
00484 #endif
00485   return(pixel == quantum ? MagickTrue : MagickFalse);
00486 }
00487 
00488 static inline MagickBooleanType IsPixelEquivalent(
00489   const Image *magick_restrict image,const Quantum *magick_restrict p,
00490   const PixelInfo *magick_restrict q)
00491 {
00492   MagickRealType
00493     alpha,
00494     beta,
00495     color;
00496 
00497   color=(MagickRealType) p[image->channel_map[AlphaPixelChannel].offset];
00498   alpha=image->alpha_trait == UndefinedPixelTrait ? (MagickRealType)
00499     OpaqueAlpha : color;
00500   beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
00501     q->alpha;
00502   if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
00503     return(MagickFalse);
00504   if ((AbsolutePixelValue(alpha-TransparentAlpha) < MagickEpsilon) ||
00505       (AbsolutePixelValue(beta-TransparentAlpha) < MagickEpsilon))
00506     return(MagickTrue);  /* no color component if pixel is transparent */
00507   color=(MagickRealType) p[image->channel_map[RedPixelChannel].offset];
00508   if (AbsolutePixelValue(color-q->red) >= MagickEpsilon)
00509     return(MagickFalse);
00510   color=(MagickRealType) p[image->channel_map[GreenPixelChannel].offset];
00511   if (AbsolutePixelValue(color-q->green) >= MagickEpsilon)
00512     return(MagickFalse);
00513   color=(MagickRealType) p[image->channel_map[BluePixelChannel].offset];
00514   if (AbsolutePixelValue(color-q->blue) >= MagickEpsilon)
00515     return(MagickFalse);
00516   if (image->colorspace == CMYKColorspace)
00517     {
00518       color=(MagickRealType) p[image->channel_map[BlackPixelChannel].offset];
00519       if (AbsolutePixelValue(color-q->black) >= MagickEpsilon)
00520         return(MagickFalse);
00521     }
00522   return(MagickTrue);
00523 }
00524 
00525 static inline MagickBooleanType IsPixelGray(const Image *magick_restrict image,
00526   const Quantum *magick_restrict pixel)
00527 {
00528   MagickRealType
00529     green_blue,
00530     red_green;
00531 
00532   red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
00533     pixel[image->channel_map[GreenPixelChannel].offset];
00534   green_blue=(MagickRealType)
00535     pixel[image->channel_map[GreenPixelChannel].offset]-
00536     pixel[image->channel_map[BluePixelChannel].offset];
00537   if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
00538       (AbsolutePixelValue(green_blue) < MagickEpsilon))
00539     return(MagickTrue);
00540   return(MagickFalse);
00541 }
00542 
00543 static inline MagickBooleanType IsPixelInfoEquivalent(
00544   const PixelInfo *magick_restrict p,const PixelInfo *magick_restrict q)
00545 {
00546   MagickRealType
00547     alpha,
00548     beta;
00549 
00550   alpha=p->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
00551     p->alpha;
00552   beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
00553     q->alpha;
00554   if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
00555     return(MagickFalse);
00556   if ((AbsolutePixelValue(alpha-TransparentAlpha) < MagickEpsilon) ||
00557       (AbsolutePixelValue(beta-TransparentAlpha) < MagickEpsilon))
00558     return(MagickTrue);  /* no color component if pixel is transparent */
00559   if (AbsolutePixelValue(p->red-q->red) >= MagickEpsilon)
00560     return(MagickFalse);
00561   if (AbsolutePixelValue(p->green-q->green) >= MagickEpsilon)
00562     return(MagickFalse);
00563   if (AbsolutePixelValue(p->blue-q->blue) >= MagickEpsilon)
00564     return(MagickFalse);
00565   if (p->colorspace == CMYKColorspace)
00566     {
00567       if (AbsolutePixelValue(p->black-q->black) >= MagickEpsilon)
00568         return(MagickFalse);
00569     }
00570   return(MagickTrue);
00571 }
00572 
00573 static inline MagickBooleanType IsPixelMonochrome(
00574   const Image *magick_restrict image,const Quantum *magick_restrict pixel)
00575 {
00576   MagickRealType
00577     green_blue,
00578     red,
00579     red_green;
00580 
00581   red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
00582   if ((AbsolutePixelValue(red) >= MagickEpsilon) &&
00583       (AbsolutePixelValue(red-QuantumRange) >= MagickEpsilon))
00584     return(MagickFalse);
00585   red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
00586     pixel[image->channel_map[GreenPixelChannel].offset];
00587   green_blue=(MagickRealType)
00588     pixel[image->channel_map[GreenPixelChannel].offset]-
00589     pixel[image->channel_map[BluePixelChannel].offset];
00590   if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
00591       (AbsolutePixelValue(green_blue) < MagickEpsilon))
00592     return(MagickTrue);
00593   return(MagickFalse);
00594 }
00595 
00596 static inline MagickBooleanType IsPixelInfoGray(
00597   const PixelInfo *magick_restrict pixel)
00598 {
00599   if ((AbsolutePixelValue(pixel->red-pixel->green) < MagickEpsilon) &&
00600       (AbsolutePixelValue(pixel->green-pixel->blue) < MagickEpsilon))
00601     return(MagickTrue);
00602   return(MagickFalse);
00603 }
00604 
00605 static inline MagickBooleanType IsPixelInfoMonochrome(
00606   const PixelInfo *magick_restrict pixel_info)
00607 {
00608   MagickRealType
00609     green_blue,
00610     red_green;
00611 
00612   if ((AbsolutePixelValue(pixel_info->red) >= MagickEpsilon) ||
00613       (AbsolutePixelValue(pixel_info->red-QuantumRange) >= MagickEpsilon))
00614     return(MagickFalse);
00615   red_green=pixel_info->red-pixel_info->green;
00616   green_blue=pixel_info->green-pixel_info->blue;
00617   if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
00618       (AbsolutePixelValue(green_blue) < MagickEpsilon))
00619     return(MagickTrue);
00620   return(MagickFalse);
00621 }
00622 
00623 static inline void SetPixela(const Image *magick_restrict image,
00624   const Quantum a,Quantum *magick_restrict pixel)
00625 {
00626   if (image->channel_map[aPixelChannel].traits != UndefinedPixelTrait)
00627     pixel[image->channel_map[aPixelChannel].offset]=a;
00628 }
00629 
00630 static inline void SetPixelAlpha(const Image *magick_restrict image,
00631   const Quantum alpha,Quantum *magick_restrict pixel)
00632 {
00633   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
00634     pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
00635 }
00636 
00637 static inline void SetPixelAlphaTraits(Image *image,const PixelTrait traits)
00638 {
00639   image->channel_map[AlphaPixelChannel].traits=traits;
00640 }
00641 
00642 static inline void SetPixelb(const Image *magick_restrict image,
00643   const Quantum b,Quantum *magick_restrict pixel)
00644 {
00645   if (image->channel_map[bPixelChannel].traits != UndefinedPixelTrait)
00646     pixel[image->channel_map[bPixelChannel].offset]=b;
00647 }
00648 
00649 static inline void SetPixelBackgoundColor(const Image *magick_restrict image,
00650   Quantum *magick_restrict pixel)
00651 {
00652   ssize_t
00653     i;
00654 
00655   for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
00656     pixel[i]=(Quantum) 0;
00657   pixel[image->channel_map[RedPixelChannel].offset]=
00658     ClampToQuantum(image->background_color.red);
00659   pixel[image->channel_map[GreenPixelChannel].offset]=
00660     ClampToQuantum(image->background_color.green);
00661   pixel[image->channel_map[BluePixelChannel].offset]=
00662     ClampToQuantum(image->background_color.blue);
00663   if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
00664     pixel[image->channel_map[BlackPixelChannel].offset]=
00665       ClampToQuantum(image->background_color.black);
00666   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
00667     pixel[image->channel_map[AlphaPixelChannel].offset]=
00668       image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
00669       ClampToQuantum(image->background_color.alpha);
00670 }
00671 
00672 static inline void SetPixelBlack(const Image *magick_restrict image,
00673   const Quantum black,Quantum *magick_restrict pixel)
00674 {
00675   if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
00676     pixel[image->channel_map[BlackPixelChannel].offset]=black;
00677 }
00678 
00679 static inline void SetPixelBlackTraits(Image *image,const PixelTrait traits)
00680 {
00681   image->channel_map[BlackPixelChannel].traits=traits;
00682 }
00683 
00684 static inline void SetPixelBlue(const Image *magick_restrict image,
00685   const Quantum blue,Quantum *magick_restrict pixel)
00686 {
00687   pixel[image->channel_map[BluePixelChannel].offset]=blue;
00688 }
00689 
00690 static inline void SetPixelBlueTraits(Image *image,const PixelTrait traits)
00691 {
00692   image->channel_map[BluePixelChannel].traits=traits;
00693 }
00694 
00695 static inline void SetPixelCb(const Image *magick_restrict image,
00696   const Quantum cb,Quantum *magick_restrict pixel)
00697 {
00698   pixel[image->channel_map[CbPixelChannel].offset]=cb;
00699 }
00700 
00701 static inline void SetPixelCbTraits(Image *image,const PixelTrait traits)
00702 {
00703   image->channel_map[CbPixelChannel].traits=traits;
00704 }
00705 
00706 static inline void SetPixelChannel(const Image *magick_restrict image,
00707   const PixelChannel channel,const Quantum quantum,
00708   Quantum *magick_restrict pixel)
00709 {
00710   if (image->channel_map[channel].traits != UndefinedPixelTrait)
00711     pixel[image->channel_map[channel].offset]=quantum;
00712 }
00713 
00714 static inline void SetPixelChannelAttributes(
00715   const Image *magick_restrict image,const PixelChannel channel,
00716   const PixelTrait traits,const ssize_t offset)
00717 {
00718   assert((ssize_t) channel < MaxPixelChannels);
00719   assert(offset < MaxPixelChannels);
00720   image->channel_map[offset].channel=channel;
00721   image->channel_map[channel].offset=offset;
00722   image->channel_map[channel].traits=traits;
00723 }
00724 
00725 static inline void SetPixelChannelChannel(const Image *magick_restrict image,
00726   const PixelChannel channel,const ssize_t offset)
00727 {
00728   image->channel_map[offset].channel=channel;
00729   image->channel_map[channel].offset=offset;
00730 }
00731 
00732 static inline void SetPixelChannels(Image *image,const size_t number_channels)
00733 {
00734   image->number_channels=number_channels;
00735 }
00736 
00737 static inline void SetPixelChannelTraits(Image *image,
00738   const PixelChannel channel,const PixelTrait traits)
00739 {
00740   image->channel_map[channel].traits=traits;
00741 }
00742 
00743 static inline void SetPixelCompositeMask(const Image *magick_restrict image,
00744   const Quantum mask,Quantum *magick_restrict pixel)
00745 {
00746   if (image->channel_map[CompositeMaskPixelChannel].traits != UndefinedPixelTrait)
00747     pixel[image->channel_map[CompositeMaskPixelChannel].offset]=mask;
00748 }
00749 
00750 static inline void SetPixelCr(const Image *magick_restrict image,
00751   const Quantum cr,Quantum *magick_restrict pixel)
00752 {
00753   pixel[image->channel_map[CrPixelChannel].offset]=cr;
00754 }
00755 
00756 static inline void SetPixelCrTraits(Image *image,const PixelTrait traits)
00757 {
00758   image->channel_map[CrPixelChannel].traits=traits;
00759 }
00760 
00761 static inline void SetPixelCyan(const Image *magick_restrict image,
00762   const Quantum cyan,Quantum *magick_restrict pixel)
00763 {
00764   pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
00765 }
00766 
00767 static inline void SetPixelGray(const Image *magick_restrict image,
00768   const Quantum gray,Quantum *magick_restrict pixel)
00769 {
00770   pixel[image->channel_map[GrayPixelChannel].offset]=gray;
00771 }
00772 
00773 static inline void SetPixelGrayTraits(Image *image,const PixelTrait traits)
00774 {
00775   image->channel_map[GrayPixelChannel].traits=traits;
00776 }
00777 
00778 static inline void SetPixelGreen(const Image *magick_restrict image,
00779   const Quantum green,Quantum *magick_restrict pixel)
00780 {
00781   pixel[image->channel_map[GreenPixelChannel].offset]=green;
00782 }
00783 
00784 static inline void SetPixelGreenTraits(Image *image,const PixelTrait traits)
00785 {
00786   image->channel_map[GreenPixelChannel].traits=traits;
00787 }
00788 
00789 static inline void SetPixelIndex(const Image *magick_restrict image,
00790   const Quantum index,Quantum *magick_restrict pixel)
00791 {
00792   if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
00793     pixel[image->channel_map[IndexPixelChannel].offset]=index;
00794 }
00795 
00796 static inline void SetPixelIndexTraits(Image *image,const PixelTrait traits)
00797 {
00798   image->channel_map[IndexPixelChannel].traits=traits;
00799 }
00800 
00801 static inline void SetPixelViaPixelInfo(const Image *magick_restrict image,
00802   const PixelInfo *magick_restrict pixel_info,Quantum *magick_restrict pixel)
00803 {
00804   pixel[image->channel_map[RedPixelChannel].offset]=
00805     ClampToQuantum(pixel_info->red);
00806   pixel[image->channel_map[GreenPixelChannel].offset]=
00807     ClampToQuantum(pixel_info->green);
00808   pixel[image->channel_map[BluePixelChannel].offset]=
00809     ClampToQuantum(pixel_info->blue);
00810   if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
00811     pixel[image->channel_map[BlackPixelChannel].offset]=
00812       ClampToQuantum(pixel_info->black);
00813   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
00814     pixel[image->channel_map[AlphaPixelChannel].offset]=
00815       pixel_info->alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
00816       ClampToQuantum(pixel_info->alpha);
00817 }
00818 
00819 static inline void SetPixelL(const Image *magick_restrict image,const Quantum L,
00820   Quantum *magick_restrict pixel)
00821 {
00822   if (image->channel_map[LPixelChannel].traits != UndefinedPixelTrait)
00823     pixel[image->channel_map[LPixelChannel].offset]=L;
00824 }
00825 
00826 static inline void SetPixelMagenta(const Image *magick_restrict image,
00827   const Quantum magenta,Quantum *magick_restrict pixel)
00828 {
00829   pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
00830 }
00831 
00832 static inline void SetPixelMagentaTraits(Image *image,const PixelTrait traits)
00833 {
00834   image->channel_map[MagentaPixelChannel].traits=traits;
00835 }
00836 
00837 static inline void SetPixelReadMask(const Image *magick_restrict image,
00838   const Quantum mask,Quantum *magick_restrict pixel)
00839 {
00840   if (image->channel_map[ReadMaskPixelChannel].traits != UndefinedPixelTrait)
00841     pixel[image->channel_map[ReadMaskPixelChannel].offset]=mask;
00842 }
00843 
00844 static inline void SetPixelWriteMask(const Image *magick_restrict image,
00845   const Quantum mask,Quantum *magick_restrict pixel)
00846 {
00847   if (image->channel_map[WriteMaskPixelChannel].traits != UndefinedPixelTrait)
00848     pixel[image->channel_map[WriteMaskPixelChannel].offset]=mask;
00849 }
00850 
00851 static inline void SetPixelMetacontentExtent(Image *image,const size_t extent)
00852 {
00853   image->metacontent_extent=extent;
00854 }
00855 
00856 static inline void SetPixelOpacity(const Image *magick_restrict image,
00857   const Quantum alpha,Quantum *magick_restrict pixel)
00858 {
00859   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
00860     pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
00861 }
00862 
00863 static inline void SetPixelRed(const Image *magick_restrict image,
00864   const Quantum red,Quantum *magick_restrict pixel)
00865 {
00866   pixel[image->channel_map[RedPixelChannel].offset]=red;
00867 }
00868 
00869 static inline void SetPixelRedTraits(Image *image,const PixelTrait traits)
00870 {
00871   image->channel_map[RedPixelChannel].traits=traits;
00872 }
00873 
00874 static inline void SetPixelYellow(const Image *magick_restrict image,
00875   const Quantum yellow,Quantum *magick_restrict pixel)
00876 {
00877   pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
00878 }
00879 
00880 static inline void SetPixelYellowTraits(Image *image,const PixelTrait traits)
00881 {
00882   image->channel_map[YellowPixelChannel].traits=traits;
00883 }
00884 
00885 static inline void SetPixelY(const Image *magick_restrict image,
00886   const Quantum y,Quantum *magick_restrict pixel)
00887 {
00888   pixel[image->channel_map[YPixelChannel].offset]=y;
00889 }
00890 
00891 static inline void SetPixelYTraits(Image *image,const PixelTrait traits)
00892 {
00893   image->channel_map[YPixelChannel].traits=traits;
00894 }
00895 
00896 #if defined(__cplusplus) || defined(c_plusplus)
00897 }
00898 #endif
00899 
00900 #endif

Generated on 11 May 2020 for MagickCore by  doxygen 1.6.1