1 module dmagick.c.pixel; 2 3 import dmagick.c.cacheView; 4 import dmagick.c.colorspace; 5 import dmagick.c.constitute; 6 import dmagick.c.exception; 7 import dmagick.c.image; 8 import dmagick.c.magickType; 9 import dmagick.c.magickVersion; 10 11 alias ptrdiff_t ssize_t; 12 13 extern(C) 14 { 15 /** 16 * The pixel color interpolation method. 17 */ 18 enum InterpolatePixelMethod 19 { 20 UndefinedInterpolatePixel, /// 21 AverageInterpolatePixel, /// The average color of the surrounding four pixels. 22 BicubicInterpolatePixel, /// Fitted bicubic-spines of surrounding 16 pixels. 23 BilinearInterpolatePixel, /// A double linear interpolation of pixels (the default). 24 FilterInterpolatePixel, /// Use resize filter settings. 25 IntegerInterpolatePixel, /// The color of the top-left pixel (floor function). 26 MeshInterpolatePixel, /// Divide area into two flat triangular interpolations. 27 NearestNeighborInterpolatePixel, /// The nearest pixel to the lookup point (rounded function). 28 SplineInterpolatePixel, /// Direct spline curves (colors are blurred). 29 Average9InterpolatePixel, /// Average 9 nearest neighbours. 30 Average16InterpolatePixel, /// Average 16 nearest neighbours. 31 BlendInterpolatePixel, /// blend of nearest 1, 2 or 4 pixels. 32 BackgroundInterpolatePixel, /// just return background color. 33 CatromInterpolatePixel /// Catmull-Rom interpolation. 34 } 35 36 37 static if ( MagickLibVersion >= 0x671 ) 38 { 39 enum PixelComponent 40 { 41 PixelRed = 0, 42 PixelCyan = 0, 43 PixelGray = 0, 44 PixelY = 0, 45 PixelGreen = 1, 46 PixelMagenta = 1, 47 PixelCb = 1, 48 PixelBlue = 2, 49 PixelYellow = 2, 50 PixelCr = 2, 51 PixelAlpha = 3, 52 PixelBlack = 4, 53 PixelIndex = 4, 54 } 55 } 56 else 57 { 58 enum PixelComponent 59 { 60 RedPixelComponent = 0, 61 CyanPixelComponent = 0, 62 GrayPixelComponent = 0, 63 YPixelComponent = 0, 64 GreenPixelComponent = 1, 65 MagentaPixelComponent = 1, 66 CbPixelComponent = 1, 67 BluePixelComponent = 2, 68 YellowPixelComponent = 2, 69 CrPixelComponent = 2, 70 AlphaPixelComponent = 3, 71 BlackPixelComponent = 4, 72 IndexPixelComponent = 4, 73 MaskPixelComponent = 5 74 } 75 } 76 77 enum PixelIntensityMethod 78 { 79 UndefinedPixelIntensityMethod = 0, 80 AveragePixelIntensityMethod, 81 BrightnessPixelIntensityMethod, 82 LightnessPixelIntensityMethod, 83 Rec601LumaPixelIntensityMethod, 84 Rec601LuminancePixelIntensityMethod, 85 Rec709LumaPixelIntensityMethod, 86 Rec709LuminancePixelIntensityMethod, 87 RMSPixelIntensityMethod, 88 MSPixelIntensityMethod 89 } 90 91 struct DoublePixelPacket 92 { 93 double 94 red, 95 green, 96 blue, 97 opacity, 98 index; 99 } 100 101 struct LongPixelPacket 102 { 103 uint 104 red, 105 green, 106 blue, 107 opacity, 108 index; 109 } 110 111 struct MagickPixelPacket 112 { 113 ClassType 114 storage_class; 115 116 ColorspaceType 117 colorspace; 118 119 MagickBooleanType 120 matte; 121 122 double 123 fuzz; 124 125 size_t 126 depth; 127 128 MagickRealType 129 red, 130 green, 131 blue, 132 opacity, 133 index; 134 } 135 136 alias Quantum IndexPacket; 137 138 struct PixelPacket 139 { 140 Quantum 141 blue, 142 green, 143 red, 144 opacity; 145 } 146 147 static if ( MagickLibVersion >= 0x680 ) 148 { 149 struct QuantumPixelPacket 150 { 151 Quantum 152 red, 153 green, 154 blue, 155 opacity, 156 index; 157 } 158 } 159 160 MagickBooleanType ExportImagePixels(const(Image)*, const ssize_t, const ssize_t, const size_t, const size_t, const(char)*, const StorageType, void*, ExceptionInfo*); 161 MagickBooleanType ImportImagePixels(Image*, const ssize_t, const ssize_t, const size_t, const size_t, const(char)*, const StorageType, const(void)*); 162 163 static if ( MagickLibVersion >= 0x669 ) 164 { 165 MagickBooleanType InterpolateMagickPixelPacket(const(Image)*, const(CacheView)*, const InterpolatePixelMethod, const double, const double, MagickPixelPacket*, ExceptionInfo*); 166 } 167 168 static if ( MagickLibVersion >= 0x678 ) 169 { 170 MagickPixelPacket* CloneMagickPixelPacket(const(MagickPixelPacket)*); 171 } 172 173 static if ( MagickLibVersion >= 0x682 ) 174 { 175 MagickRealType DecodePixelGamma(const MagickRealType); 176 MagickRealType EncodePixelGamma(const MagickRealType); 177 } 178 179 static if ( MagickLibVersion >= 0x691 ) 180 { 181 MagickRealType GetMagickPixelIntensity(const(Image)* image, const(MagickPixelPacket)* restrict); 182 } 183 184 static if ( MagickLibVersion >= 0x684 ) 185 { 186 MagickRealType GetPixelIntensity(const(Image)* image, const(PixelPacket)* restrict); 187 } 188 189 static if ( MagickLibVersion >= 0x690 ) 190 { 191 void ConformMagickPixelPacket(Image*, const(MagickPixelPacket)*, MagickPixelPacket*, ExceptionInfo*); 192 } 193 194 void GetMagickPixelPacket(const(Image)*, MagickPixelPacket*); 195 }