MagickCore: pixel-private.h Source File

# pixel-private.h

Go to the documentation of this file.

    00001 /*
    00002   Copyright 1999-2010 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.
    00006   obtain a copy of the License at
    00007
    00008     http://www.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 image pixel private methods.
    00017 */
    00018 #ifndef _MAGICKCORE_PIXEL_PRIVATE_H
    00019 #define _MAGICKCORE_PIXEL_PRIVATE_H
    00020
    00021 #if defined(__cplusplus) || defined(c_plusplus)
    00022 extern "C" {
    00023 #endif
    00024
    00025 #include <magick/exception-private.h>
    00026 #include <magick/image.h>
    00027 #include <magick/color.h>
    00028 #include <magick/image-private.h>
    00029 #include <magick/quantum-private.h>
    00030
    00031 typedef struct _RealPixelPacket
    00032 {
    00033   MagickRealType
    00034     red,
    00035     green,
    00036     blue,
    00037     opacity;
    00038 } RealPixelPacket;
    00039
    00040 static inline MagickPixelPacket *CloneMagickPixelPacket(
    00041   const MagickPixelPacket *pixel)
    00042 {
    00043   MagickPixelPacket
    00044     *clone_pixel;
    00045
    00046   clone_pixel=(MagickPixelPacket *) AcquireMagickMemory(sizeof(*clone_pixel));
    00047   if (clone_pixel == (MagickPixelPacket *) NULL)
    00048     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
    00049   *clone_pixel=(*pixel);
    00050   return(clone_pixel);
    00051 }
    00052
    00053 static inline void SetMagickPixelPacket(const Image *image,
    00054   const PixelPacket *color,const IndexPacket *index,MagickPixelPacket *pixel)
    00055 {
    00056   pixel->red=(MagickRealType) color->red;
    00057   pixel->green=(MagickRealType) color->green;
    00058   pixel->blue=(MagickRealType) color->blue;
    00059   pixel->opacity=(MagickRealType) color->opacity;
    00060   if (((image->colorspace == CMYKColorspace) ||
    00061        (image->storage_class == PseudoClass)) &&
    00062       (index != (const IndexPacket *) NULL))
    00063     pixel->index=(MagickRealType) *index;
    00064 }
    00065
    00066 static inline void SetPixelPacket(const Image *image,
    00067   const MagickPixelPacket *pixel,PixelPacket *color,IndexPacket *index)
    00068 {
    00069   color->red=RoundToQuantum(pixel->red);
    00070   color->green=RoundToQuantum(pixel->green);
    00071   color->blue=RoundToQuantum(pixel->blue);
    00072   color->opacity=RoundToQuantum(pixel->opacity);
    00073   if (((image->colorspace == CMYKColorspace) ||
    00074        (image->storage_class == PseudoClass)) &&
    00075       (index != (const IndexPacket *) NULL))
    00076     *index=RoundToQuantum(pixel->index);
    00077 }
    00078
    00079 #if defined(__cplusplus) || defined(c_plusplus)
    00080 }
    00081 #endif
    00082
    00083 #endif