| 1 | /* |
|---|
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 3 | % % |
|---|
| 4 | % % |
|---|
| 5 | % % |
|---|
| 6 | % PPPP IIIII X X EEEEE L % |
|---|
| 7 | % P P I X X E L % |
|---|
| 8 | % PPPP I X EEE L % |
|---|
| 9 | % P I X X E L % |
|---|
| 10 | % P IIIII X X EEEEE LLLLL % |
|---|
| 11 | % % |
|---|
| 12 | % MagickCore Methods to Import/Export Pixels % |
|---|
| 13 | % % |
|---|
| 14 | % Software Design % |
|---|
| 15 | % John Cristy % |
|---|
| 16 | % October 1998 % |
|---|
| 17 | % % |
|---|
| 18 | % % |
|---|
| 19 | % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization % |
|---|
| 20 | % dedicated to making software imaging solutions freely available. % |
|---|
| 21 | % % |
|---|
| 22 | % You may not use this file except in compliance with the License. You may % |
|---|
| 23 | % obtain a copy of the License at % |
|---|
| 24 | % % |
|---|
| 25 | % http://www.imagemagick.org/script/license.php % |
|---|
| 26 | % % |
|---|
| 27 | % Unless required by applicable law or agreed to in writing, software % |
|---|
| 28 | % distributed under the License is distributed on an "AS IS" BASIS, % |
|---|
| 29 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
|---|
| 30 | % See the License for the specific language governing permissions and % |
|---|
| 31 | % limitations under the License. % |
|---|
| 32 | % % |
|---|
| 33 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 34 | % |
|---|
| 35 | % |
|---|
| 36 | */ |
|---|
| 37 | |
|---|
| 38 | /* |
|---|
| 39 | Include declarations. |
|---|
| 40 | */ |
|---|
| 41 | #include "magick/studio.h" |
|---|
| 42 | #include "magick/property.h" |
|---|
| 43 | #include "magick/blob.h" |
|---|
| 44 | #include "magick/blob-private.h" |
|---|
| 45 | #include "magick/color-private.h" |
|---|
| 46 | #include "magick/draw.h" |
|---|
| 47 | #include "magick/exception.h" |
|---|
| 48 | #include "magick/exception-private.h" |
|---|
| 49 | #include "magick/cache.h" |
|---|
| 50 | #include "magick/constitute.h" |
|---|
| 51 | #include "magick/delegate.h" |
|---|
| 52 | #include "magick/geometry.h" |
|---|
| 53 | #include "magick/list.h" |
|---|
| 54 | #include "magick/magick.h" |
|---|
| 55 | #include "magick/memory_.h" |
|---|
| 56 | #include "magick/monitor.h" |
|---|
| 57 | #include "magick/option.h" |
|---|
| 58 | #include "magick/pixel.h" |
|---|
| 59 | #include "magick/pixel-private.h" |
|---|
| 60 | #include "magick/quantum.h" |
|---|
| 61 | #include "magick/resource_.h" |
|---|
| 62 | #include "magick/semaphore.h" |
|---|
| 63 | #include "magick/statistic.h" |
|---|
| 64 | #include "magick/stream.h" |
|---|
| 65 | #include "magick/string_.h" |
|---|
| 66 | #include "magick/transform.h" |
|---|
| 67 | #include "magick/utility.h" |
|---|
| 68 | |
|---|
| 69 | /* |
|---|
| 70 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 71 | % % |
|---|
| 72 | % % |
|---|
| 73 | % % |
|---|
| 74 | % E x p o r t I m a g e P i x e l s % |
|---|
| 75 | % % |
|---|
| 76 | % % |
|---|
| 77 | % % |
|---|
| 78 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 79 | % |
|---|
| 80 | % ExportImagePixels() extracts pixel data from an image and returns it to you. |
|---|
| 81 | % The method returns MagickTrue on success otherwise MagickFalse if an error is |
|---|
| 82 | % encountered. The data is returned as char, short int, int, ssize_t, float, |
|---|
| 83 | % or double in the order specified by map. |
|---|
| 84 | % |
|---|
| 85 | % Suppose you want to extract the first scanline of a 640x480 image as |
|---|
| 86 | % character data in red-green-blue order: |
|---|
| 87 | % |
|---|
| 88 | % ExportImagePixels(image,0,0,640,1,"RGB",CharPixel,pixels,exception); |
|---|
| 89 | % |
|---|
| 90 | % The format of the ExportImagePixels method is: |
|---|
| 91 | % |
|---|
| 92 | % MagickBooleanType ExportImagePixels(const Image *image, |
|---|
| 93 | % const ssize_t x_offset,const ssize_t y_offset,const size_t columns, |
|---|
| 94 | % const size_t rows,const char *map,const StorageType type, |
|---|
| 95 | % void *pixels,ExceptionInfo *exception) |
|---|
| 96 | % |
|---|
| 97 | % A description of each parameter follows: |
|---|
| 98 | % |
|---|
| 99 | % o image: the image. |
|---|
| 100 | % |
|---|
| 101 | % o x_offset,y_offset,columns,rows: These values define the perimeter |
|---|
| 102 | % of a region of pixels you want to extract. |
|---|
| 103 | % |
|---|
| 104 | % o map: This string reflects the expected ordering of the pixel array. |
|---|
| 105 | % It can be any combination or order of R = red, G = green, B = blue, |
|---|
| 106 | % A = alpha (0 is transparent), O = opacity (0 is opaque), C = cyan, |
|---|
| 107 | % Y = yellow, M = magenta, K = black, I = intensity (for grayscale), |
|---|
| 108 | % P = pad. |
|---|
| 109 | % |
|---|
| 110 | % o type: Define the data type of the pixels. Float and double types are |
|---|
| 111 | % normalized to [0..1] otherwise [0..QuantumRange]. Choose from these |
|---|
| 112 | % types: CharPixel, DoublePixel, FloatPixel, IntegerPixel, LongPixel, |
|---|
| 113 | % QuantumPixel, or ShortPixel. |
|---|
| 114 | % |
|---|
| 115 | % o pixels: This array of values contain the pixel components as defined by |
|---|
| 116 | % map and type. You must preallocate this array where the expected |
|---|
| 117 | % length varies depending on the values of width, height, map, and type. |
|---|
| 118 | % |
|---|
| 119 | % o exception: return any errors or warnings in this structure. |
|---|
| 120 | % |
|---|
| 121 | */ |
|---|
| 122 | MagickExport MagickBooleanType ExportImagePixels(const Image *image, |
|---|
| 123 | const ssize_t x_offset,const ssize_t y_offset,const size_t columns, |
|---|
| 124 | const size_t rows,const char *map,const StorageType type,void *pixels, |
|---|
| 125 | ExceptionInfo *exception) |
|---|
| 126 | { |
|---|
| 127 | QuantumType |
|---|
| 128 | *quantum_map; |
|---|
| 129 | |
|---|
| 130 | register ssize_t |
|---|
| 131 | i, |
|---|
| 132 | x; |
|---|
| 133 | |
|---|
| 134 | register const IndexPacket |
|---|
| 135 | *indexes; |
|---|
| 136 | |
|---|
| 137 | register const PixelPacket |
|---|
| 138 | *p; |
|---|
| 139 | |
|---|
| 140 | size_t |
|---|
| 141 | length; |
|---|
| 142 | |
|---|
| 143 | ssize_t |
|---|
| 144 | y; |
|---|
| 145 | |
|---|
| 146 | assert(image != (Image *) NULL); |
|---|
| 147 | assert(image->signature == MagickSignature); |
|---|
| 148 | if (image->debug != MagickFalse) |
|---|
| 149 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
|---|
| 150 | length=strlen(map); |
|---|
| 151 | quantum_map=(QuantumType *) AcquireQuantumMemory(length,sizeof(*quantum_map)); |
|---|
| 152 | if (quantum_map == (QuantumType *) NULL) |
|---|
| 153 | { |
|---|
| 154 | (void) ThrowMagickException(exception,GetMagickModule(), |
|---|
| 155 | ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); |
|---|
| 156 | return(MagickFalse); |
|---|
| 157 | } |
|---|
| 158 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 159 | { |
|---|
| 160 | switch (map[i]) |
|---|
| 161 | { |
|---|
| 162 | case 'A': |
|---|
| 163 | case 'a': |
|---|
| 164 | { |
|---|
| 165 | quantum_map[i]=AlphaQuantum; |
|---|
| 166 | break; |
|---|
| 167 | } |
|---|
| 168 | case 'B': |
|---|
| 169 | case 'b': |
|---|
| 170 | { |
|---|
| 171 | quantum_map[i]=BlueQuantum; |
|---|
| 172 | break; |
|---|
| 173 | } |
|---|
| 174 | case 'C': |
|---|
| 175 | case 'c': |
|---|
| 176 | { |
|---|
| 177 | quantum_map[i]=CyanQuantum; |
|---|
| 178 | if (image->colorspace == CMYKColorspace) |
|---|
| 179 | break; |
|---|
| 180 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
|---|
| 181 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
|---|
| 182 | "ColorSeparatedImageRequired","`%s'",map); |
|---|
| 183 | return(MagickFalse); |
|---|
| 184 | } |
|---|
| 185 | case 'g': |
|---|
| 186 | case 'G': |
|---|
| 187 | { |
|---|
| 188 | quantum_map[i]=GreenQuantum; |
|---|
| 189 | break; |
|---|
| 190 | } |
|---|
| 191 | case 'I': |
|---|
| 192 | case 'i': |
|---|
| 193 | { |
|---|
| 194 | quantum_map[i]=IndexQuantum; |
|---|
| 195 | break; |
|---|
| 196 | } |
|---|
| 197 | case 'K': |
|---|
| 198 | case 'k': |
|---|
| 199 | { |
|---|
| 200 | quantum_map[i]=BlackQuantum; |
|---|
| 201 | if (image->colorspace == CMYKColorspace) |
|---|
| 202 | break; |
|---|
| 203 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
|---|
| 204 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
|---|
| 205 | "ColorSeparatedImageRequired","`%s'",map); |
|---|
| 206 | return(MagickFalse); |
|---|
| 207 | } |
|---|
| 208 | case 'M': |
|---|
| 209 | case 'm': |
|---|
| 210 | { |
|---|
| 211 | quantum_map[i]=MagentaQuantum; |
|---|
| 212 | if (image->colorspace == CMYKColorspace) |
|---|
| 213 | break; |
|---|
| 214 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
|---|
| 215 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
|---|
| 216 | "ColorSeparatedImageRequired","`%s'",map); |
|---|
| 217 | return(MagickFalse); |
|---|
| 218 | } |
|---|
| 219 | case 'o': |
|---|
| 220 | case 'O': |
|---|
| 221 | { |
|---|
| 222 | quantum_map[i]=OpacityQuantum; |
|---|
| 223 | break; |
|---|
| 224 | } |
|---|
| 225 | case 'P': |
|---|
| 226 | case 'p': |
|---|
| 227 | { |
|---|
| 228 | quantum_map[i]=UndefinedQuantum; |
|---|
| 229 | break; |
|---|
| 230 | } |
|---|
| 231 | case 'R': |
|---|
| 232 | case 'r': |
|---|
| 233 | { |
|---|
| 234 | quantum_map[i]=RedQuantum; |
|---|
| 235 | break; |
|---|
| 236 | } |
|---|
| 237 | case 'Y': |
|---|
| 238 | case 'y': |
|---|
| 239 | { |
|---|
| 240 | quantum_map[i]=YellowQuantum; |
|---|
| 241 | if (image->colorspace == CMYKColorspace) |
|---|
| 242 | break; |
|---|
| 243 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
|---|
| 244 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
|---|
| 245 | "ColorSeparatedImageRequired","`%s'",map); |
|---|
| 246 | return(MagickFalse); |
|---|
| 247 | } |
|---|
| 248 | default: |
|---|
| 249 | { |
|---|
| 250 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
|---|
| 251 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
|---|
| 252 | "UnrecognizedPixelMap","`%s'",map); |
|---|
| 253 | return(MagickFalse); |
|---|
| 254 | } |
|---|
| 255 | } |
|---|
| 256 | } |
|---|
| 257 | switch (type) |
|---|
| 258 | { |
|---|
| 259 | case CharPixel: |
|---|
| 260 | { |
|---|
| 261 | register unsigned char |
|---|
| 262 | *q; |
|---|
| 263 | |
|---|
| 264 | q=(unsigned char *) pixels; |
|---|
| 265 | if (LocaleCompare(map,"BGR") == 0) |
|---|
| 266 | { |
|---|
| 267 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 268 | { |
|---|
| 269 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 270 | if (p == (const PixelPacket *) NULL) |
|---|
| 271 | break; |
|---|
| 272 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 273 | { |
|---|
| 274 | *q++=ScaleQuantumToChar(GetBluePixelComponent(p)); |
|---|
| 275 | *q++=ScaleQuantumToChar(GetGreenPixelComponent(p)); |
|---|
| 276 | *q++=ScaleQuantumToChar(GetRedPixelComponent(p)); |
|---|
| 277 | p++; |
|---|
| 278 | } |
|---|
| 279 | } |
|---|
| 280 | break; |
|---|
| 281 | } |
|---|
| 282 | if (LocaleCompare(map,"BGRA") == 0) |
|---|
| 283 | { |
|---|
| 284 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 285 | { |
|---|
| 286 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 287 | if (p == (const PixelPacket *) NULL) |
|---|
| 288 | break; |
|---|
| 289 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 290 | { |
|---|
| 291 | *q++=ScaleQuantumToChar(GetBluePixelComponent(p)); |
|---|
| 292 | *q++=ScaleQuantumToChar(GetGreenPixelComponent(p)); |
|---|
| 293 | *q++=ScaleQuantumToChar(GetRedPixelComponent(p)); |
|---|
| 294 | *q++=ScaleQuantumToChar((Quantum) (GetAlphaPixelComponent(p))); |
|---|
| 295 | p++; |
|---|
| 296 | } |
|---|
| 297 | } |
|---|
| 298 | break; |
|---|
| 299 | } |
|---|
| 300 | if (LocaleCompare(map,"BGRP") == 0) |
|---|
| 301 | { |
|---|
| 302 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 303 | { |
|---|
| 304 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 305 | if (p == (const PixelPacket *) NULL) |
|---|
| 306 | break; |
|---|
| 307 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 308 | { |
|---|
| 309 | *q++=ScaleQuantumToChar(GetBluePixelComponent(p)); |
|---|
| 310 | *q++=ScaleQuantumToChar(GetGreenPixelComponent(p)); |
|---|
| 311 | *q++=ScaleQuantumToChar(GetRedPixelComponent(p)); |
|---|
| 312 | *q++=ScaleQuantumToChar((Quantum) 0); |
|---|
| 313 | p++; |
|---|
| 314 | } |
|---|
| 315 | } |
|---|
| 316 | break; |
|---|
| 317 | } |
|---|
| 318 | if (LocaleCompare(map,"I") == 0) |
|---|
| 319 | { |
|---|
| 320 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 321 | { |
|---|
| 322 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 323 | if (p == (const PixelPacket *) NULL) |
|---|
| 324 | break; |
|---|
| 325 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 326 | { |
|---|
| 327 | *q++=ScaleQuantumToChar(PixelIntensityToQuantum(p)); |
|---|
| 328 | p++; |
|---|
| 329 | } |
|---|
| 330 | } |
|---|
| 331 | break; |
|---|
| 332 | } |
|---|
| 333 | if (LocaleCompare(map,"RGB") == 0) |
|---|
| 334 | { |
|---|
| 335 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 336 | { |
|---|
| 337 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 338 | if (p == (const PixelPacket *) NULL) |
|---|
| 339 | break; |
|---|
| 340 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 341 | { |
|---|
| 342 | *q++=ScaleQuantumToChar(GetRedPixelComponent(p)); |
|---|
| 343 | *q++=ScaleQuantumToChar(GetGreenPixelComponent(p)); |
|---|
| 344 | *q++=ScaleQuantumToChar(GetBluePixelComponent(p)); |
|---|
| 345 | p++; |
|---|
| 346 | } |
|---|
| 347 | } |
|---|
| 348 | break; |
|---|
| 349 | } |
|---|
| 350 | if (LocaleCompare(map,"RGBA") == 0) |
|---|
| 351 | { |
|---|
| 352 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 353 | { |
|---|
| 354 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 355 | if (p == (const PixelPacket *) NULL) |
|---|
| 356 | break; |
|---|
| 357 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 358 | { |
|---|
| 359 | *q++=ScaleQuantumToChar(GetRedPixelComponent(p)); |
|---|
| 360 | *q++=ScaleQuantumToChar(GetGreenPixelComponent(p)); |
|---|
| 361 | *q++=ScaleQuantumToChar(GetBluePixelComponent(p)); |
|---|
| 362 | *q++=ScaleQuantumToChar((Quantum) (GetAlphaPixelComponent(p))); |
|---|
| 363 | p++; |
|---|
| 364 | } |
|---|
| 365 | } |
|---|
| 366 | break; |
|---|
| 367 | } |
|---|
| 368 | if (LocaleCompare(map,"RGBP") == 0) |
|---|
| 369 | { |
|---|
| 370 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 371 | { |
|---|
| 372 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 373 | if (p == (const PixelPacket *) NULL) |
|---|
| 374 | break; |
|---|
| 375 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 376 | { |
|---|
| 377 | *q++=ScaleQuantumToChar(GetRedPixelComponent(p)); |
|---|
| 378 | *q++=ScaleQuantumToChar(GetGreenPixelComponent(p)); |
|---|
| 379 | *q++=ScaleQuantumToChar(GetBluePixelComponent(p)); |
|---|
| 380 | *q++=ScaleQuantumToChar((Quantum) 0); |
|---|
| 381 | p++; |
|---|
| 382 | } |
|---|
| 383 | } |
|---|
| 384 | break; |
|---|
| 385 | } |
|---|
| 386 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 387 | { |
|---|
| 388 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 389 | if (p == (const PixelPacket *) NULL) |
|---|
| 390 | break; |
|---|
| 391 | indexes=GetVirtualIndexQueue(image); |
|---|
| 392 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 393 | { |
|---|
| 394 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 395 | { |
|---|
| 396 | *q=0; |
|---|
| 397 | switch (quantum_map[i]) |
|---|
| 398 | { |
|---|
| 399 | case RedQuantum: |
|---|
| 400 | case CyanQuantum: |
|---|
| 401 | { |
|---|
| 402 | *q=ScaleQuantumToChar(GetRedPixelComponent(p)); |
|---|
| 403 | break; |
|---|
| 404 | } |
|---|
| 405 | case GreenQuantum: |
|---|
| 406 | case MagentaQuantum: |
|---|
| 407 | { |
|---|
| 408 | *q=ScaleQuantumToChar(GetGreenPixelComponent(p)); |
|---|
| 409 | break; |
|---|
| 410 | } |
|---|
| 411 | case BlueQuantum: |
|---|
| 412 | case YellowQuantum: |
|---|
| 413 | { |
|---|
| 414 | *q=ScaleQuantumToChar(GetBluePixelComponent(p)); |
|---|
| 415 | break; |
|---|
| 416 | } |
|---|
| 417 | case AlphaQuantum: |
|---|
| 418 | { |
|---|
| 419 | *q=ScaleQuantumToChar((Quantum) (GetAlphaPixelComponent(p))); |
|---|
| 420 | break; |
|---|
| 421 | } |
|---|
| 422 | case OpacityQuantum: |
|---|
| 423 | { |
|---|
| 424 | *q=ScaleQuantumToChar(GetOpacityPixelComponent(p)); |
|---|
| 425 | break; |
|---|
| 426 | } |
|---|
| 427 | case BlackQuantum: |
|---|
| 428 | { |
|---|
| 429 | if (image->colorspace == CMYKColorspace) |
|---|
| 430 | *q=ScaleQuantumToChar(indexes[x]); |
|---|
| 431 | break; |
|---|
| 432 | } |
|---|
| 433 | case IndexQuantum: |
|---|
| 434 | { |
|---|
| 435 | *q=ScaleQuantumToChar(PixelIntensityToQuantum(p)); |
|---|
| 436 | break; |
|---|
| 437 | } |
|---|
| 438 | default: |
|---|
| 439 | break; |
|---|
| 440 | } |
|---|
| 441 | q++; |
|---|
| 442 | } |
|---|
| 443 | p++; |
|---|
| 444 | } |
|---|
| 445 | } |
|---|
| 446 | break; |
|---|
| 447 | } |
|---|
| 448 | case DoublePixel: |
|---|
| 449 | { |
|---|
| 450 | register double |
|---|
| 451 | *q; |
|---|
| 452 | |
|---|
| 453 | q=(double *) pixels; |
|---|
| 454 | if (LocaleCompare(map,"BGR") == 0) |
|---|
| 455 | { |
|---|
| 456 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 457 | { |
|---|
| 458 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 459 | if (p == (const PixelPacket *) NULL) |
|---|
| 460 | break; |
|---|
| 461 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 462 | { |
|---|
| 463 | *q++=(double) (QuantumScale*GetBluePixelComponent(p)); |
|---|
| 464 | *q++=(double) (QuantumScale*GetGreenPixelComponent(p)); |
|---|
| 465 | *q++=(double) (QuantumScale*GetRedPixelComponent(p)); |
|---|
| 466 | p++; |
|---|
| 467 | } |
|---|
| 468 | } |
|---|
| 469 | break; |
|---|
| 470 | } |
|---|
| 471 | if (LocaleCompare(map,"BGRA") == 0) |
|---|
| 472 | { |
|---|
| 473 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 474 | { |
|---|
| 475 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 476 | if (p == (const PixelPacket *) NULL) |
|---|
| 477 | break; |
|---|
| 478 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 479 | { |
|---|
| 480 | *q++=(double) (QuantumScale*GetBluePixelComponent(p)); |
|---|
| 481 | *q++=(double) (QuantumScale*GetGreenPixelComponent(p)); |
|---|
| 482 | *q++=(double) (QuantumScale*GetRedPixelComponent(p)); |
|---|
| 483 | *q++=(double) (QuantumScale*((Quantum) (QuantumRange- |
|---|
| 484 | GetOpacityPixelComponent(p)))); |
|---|
| 485 | p++; |
|---|
| 486 | } |
|---|
| 487 | } |
|---|
| 488 | break; |
|---|
| 489 | } |
|---|
| 490 | if (LocaleCompare(map,"BGRP") == 0) |
|---|
| 491 | { |
|---|
| 492 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 493 | { |
|---|
| 494 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 495 | if (p == (const PixelPacket *) NULL) |
|---|
| 496 | break; |
|---|
| 497 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 498 | { |
|---|
| 499 | *q++=(double) (QuantumScale*GetBluePixelComponent(p)); |
|---|
| 500 | *q++=(double) (QuantumScale*GetGreenPixelComponent(p)); |
|---|
| 501 | *q++=(double) (QuantumScale*GetRedPixelComponent(p)); |
|---|
| 502 | *q++=0.0; |
|---|
| 503 | p++; |
|---|
| 504 | } |
|---|
| 505 | } |
|---|
| 506 | break; |
|---|
| 507 | } |
|---|
| 508 | if (LocaleCompare(map,"I") == 0) |
|---|
| 509 | { |
|---|
| 510 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 511 | { |
|---|
| 512 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 513 | if (p == (const PixelPacket *) NULL) |
|---|
| 514 | break; |
|---|
| 515 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 516 | { |
|---|
| 517 | *q++=(double) (QuantumScale*PixelIntensityToQuantum(p)); |
|---|
| 518 | p++; |
|---|
| 519 | } |
|---|
| 520 | } |
|---|
| 521 | break; |
|---|
| 522 | } |
|---|
| 523 | if (LocaleCompare(map,"RGB") == 0) |
|---|
| 524 | { |
|---|
| 525 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 526 | { |
|---|
| 527 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 528 | if (p == (const PixelPacket *) NULL) |
|---|
| 529 | break; |
|---|
| 530 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 531 | { |
|---|
| 532 | *q++=(double) (QuantumScale*GetRedPixelComponent(p)); |
|---|
| 533 | *q++=(double) (QuantumScale*GetGreenPixelComponent(p)); |
|---|
| 534 | *q++=(double) (QuantumScale*GetBluePixelComponent(p)); |
|---|
| 535 | p++; |
|---|
| 536 | } |
|---|
| 537 | } |
|---|
| 538 | break; |
|---|
| 539 | } |
|---|
| 540 | if (LocaleCompare(map,"RGBA") == 0) |
|---|
| 541 | { |
|---|
| 542 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 543 | { |
|---|
| 544 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 545 | if (p == (const PixelPacket *) NULL) |
|---|
| 546 | break; |
|---|
| 547 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 548 | { |
|---|
| 549 | *q++=(double) (QuantumScale*GetRedPixelComponent(p)); |
|---|
| 550 | *q++=(double) (QuantumScale*GetGreenPixelComponent(p)); |
|---|
| 551 | *q++=(double) (QuantumScale*GetBluePixelComponent(p)); |
|---|
| 552 | *q++=(double) (QuantumScale*((Quantum) (QuantumRange- |
|---|
| 553 | GetOpacityPixelComponent(p)))); |
|---|
| 554 | p++; |
|---|
| 555 | } |
|---|
| 556 | } |
|---|
| 557 | break; |
|---|
| 558 | } |
|---|
| 559 | if (LocaleCompare(map,"RGBP") == 0) |
|---|
| 560 | { |
|---|
| 561 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 562 | { |
|---|
| 563 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 564 | if (p == (const PixelPacket *) NULL) |
|---|
| 565 | break; |
|---|
| 566 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 567 | { |
|---|
| 568 | *q++=(double) (QuantumScale*GetRedPixelComponent(p)); |
|---|
| 569 | *q++=(double) (QuantumScale*GetGreenPixelComponent(p)); |
|---|
| 570 | *q++=(double) (QuantumScale*GetBluePixelComponent(p)); |
|---|
| 571 | *q++=0.0; |
|---|
| 572 | p++; |
|---|
| 573 | } |
|---|
| 574 | } |
|---|
| 575 | break; |
|---|
| 576 | } |
|---|
| 577 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 578 | { |
|---|
| 579 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 580 | if (p == (const PixelPacket *) NULL) |
|---|
| 581 | break; |
|---|
| 582 | indexes=GetVirtualIndexQueue(image); |
|---|
| 583 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 584 | { |
|---|
| 585 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 586 | { |
|---|
| 587 | *q=0; |
|---|
| 588 | switch (quantum_map[i]) |
|---|
| 589 | { |
|---|
| 590 | case RedQuantum: |
|---|
| 591 | case CyanQuantum: |
|---|
| 592 | { |
|---|
| 593 | *q=(double) (QuantumScale*GetRedPixelComponent(p)); |
|---|
| 594 | break; |
|---|
| 595 | } |
|---|
| 596 | case GreenQuantum: |
|---|
| 597 | case MagentaQuantum: |
|---|
| 598 | { |
|---|
| 599 | *q=(double) (QuantumScale*GetGreenPixelComponent(p)); |
|---|
| 600 | break; |
|---|
| 601 | } |
|---|
| 602 | case BlueQuantum: |
|---|
| 603 | case YellowQuantum: |
|---|
| 604 | { |
|---|
| 605 | *q=(double) (QuantumScale*GetBluePixelComponent(p)); |
|---|
| 606 | break; |
|---|
| 607 | } |
|---|
| 608 | case AlphaQuantum: |
|---|
| 609 | { |
|---|
| 610 | *q=(double) (QuantumScale*((Quantum) (QuantumRange- |
|---|
| 611 | GetOpacityPixelComponent(p)))); |
|---|
| 612 | break; |
|---|
| 613 | } |
|---|
| 614 | case OpacityQuantum: |
|---|
| 615 | { |
|---|
| 616 | *q=(double) (QuantumScale*GetOpacityPixelComponent(p)); |
|---|
| 617 | break; |
|---|
| 618 | } |
|---|
| 619 | case BlackQuantum: |
|---|
| 620 | { |
|---|
| 621 | if (image->colorspace == CMYKColorspace) |
|---|
| 622 | *q=(double) (QuantumScale*indexes[x]); |
|---|
| 623 | break; |
|---|
| 624 | } |
|---|
| 625 | case IndexQuantum: |
|---|
| 626 | { |
|---|
| 627 | *q=(double) (QuantumScale*PixelIntensityToQuantum(p)); |
|---|
| 628 | break; |
|---|
| 629 | } |
|---|
| 630 | default: |
|---|
| 631 | *q=0; |
|---|
| 632 | } |
|---|
| 633 | q++; |
|---|
| 634 | } |
|---|
| 635 | p++; |
|---|
| 636 | } |
|---|
| 637 | } |
|---|
| 638 | break; |
|---|
| 639 | } |
|---|
| 640 | case FloatPixel: |
|---|
| 641 | { |
|---|
| 642 | register float |
|---|
| 643 | *q; |
|---|
| 644 | |
|---|
| 645 | q=(float *) pixels; |
|---|
| 646 | if (LocaleCompare(map,"BGR") == 0) |
|---|
| 647 | { |
|---|
| 648 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 649 | { |
|---|
| 650 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 651 | if (p == (const PixelPacket *) NULL) |
|---|
| 652 | break; |
|---|
| 653 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 654 | { |
|---|
| 655 | *q++=(float) (QuantumScale*GetBluePixelComponent(p)); |
|---|
| 656 | *q++=(float) (QuantumScale*GetGreenPixelComponent(p)); |
|---|
| 657 | *q++=(float) (QuantumScale*GetRedPixelComponent(p)); |
|---|
| 658 | p++; |
|---|
| 659 | } |
|---|
| 660 | } |
|---|
| 661 | break; |
|---|
| 662 | } |
|---|
| 663 | if (LocaleCompare(map,"BGRA") == 0) |
|---|
| 664 | { |
|---|
| 665 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 666 | { |
|---|
| 667 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 668 | if (p == (const PixelPacket *) NULL) |
|---|
| 669 | break; |
|---|
| 670 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 671 | { |
|---|
| 672 | *q++=(float) (QuantumScale*GetBluePixelComponent(p)); |
|---|
| 673 | *q++=(float) (QuantumScale*GetGreenPixelComponent(p)); |
|---|
| 674 | *q++=(float) (QuantumScale*GetRedPixelComponent(p)); |
|---|
| 675 | *q++=(float) (QuantumScale*(Quantum) (GetAlphaPixelComponent(p))); |
|---|
| 676 | p++; |
|---|
| 677 | } |
|---|
| 678 | } |
|---|
| 679 | break; |
|---|
| 680 | } |
|---|
| 681 | if (LocaleCompare(map,"BGRP") == 0) |
|---|
| 682 | { |
|---|
| 683 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 684 | { |
|---|
| 685 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 686 | if (p == (const PixelPacket *) NULL) |
|---|
| 687 | break; |
|---|
| 688 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 689 | { |
|---|
| 690 | *q++=(float) (QuantumScale*GetBluePixelComponent(p)); |
|---|
| 691 | *q++=(float) (QuantumScale*GetGreenPixelComponent(p)); |
|---|
| 692 | *q++=(float) (QuantumScale*GetRedPixelComponent(p)); |
|---|
| 693 | *q++=0.0; |
|---|
| 694 | p++; |
|---|
| 695 | } |
|---|
| 696 | } |
|---|
| 697 | break; |
|---|
| 698 | } |
|---|
| 699 | if (LocaleCompare(map,"I") == 0) |
|---|
| 700 | { |
|---|
| 701 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 702 | { |
|---|
| 703 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 704 | if (p == (const PixelPacket *) NULL) |
|---|
| 705 | break; |
|---|
| 706 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 707 | { |
|---|
| 708 | *q++=(float) (QuantumScale*PixelIntensityToQuantum(p)); |
|---|
| 709 | p++; |
|---|
| 710 | } |
|---|
| 711 | } |
|---|
| 712 | break; |
|---|
| 713 | } |
|---|
| 714 | if (LocaleCompare(map,"RGB") == 0) |
|---|
| 715 | { |
|---|
| 716 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 717 | { |
|---|
| 718 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 719 | if (p == (const PixelPacket *) NULL) |
|---|
| 720 | break; |
|---|
| 721 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 722 | { |
|---|
| 723 | *q++=(float) (QuantumScale*GetRedPixelComponent(p)); |
|---|
| 724 | *q++=(float) (QuantumScale*GetGreenPixelComponent(p)); |
|---|
| 725 | *q++=(float) (QuantumScale*GetBluePixelComponent(p)); |
|---|
| 726 | p++; |
|---|
| 727 | } |
|---|
| 728 | } |
|---|
| 729 | break; |
|---|
| 730 | } |
|---|
| 731 | if (LocaleCompare(map,"RGBA") == 0) |
|---|
| 732 | { |
|---|
| 733 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 734 | { |
|---|
| 735 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 736 | if (p == (const PixelPacket *) NULL) |
|---|
| 737 | break; |
|---|
| 738 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 739 | { |
|---|
| 740 | *q++=(float) (QuantumScale*GetRedPixelComponent(p)); |
|---|
| 741 | *q++=(float) (QuantumScale*GetGreenPixelComponent(p)); |
|---|
| 742 | *q++=(float) (QuantumScale*GetBluePixelComponent(p)); |
|---|
| 743 | *q++=(float) (QuantumScale*((Quantum) (GetAlphaPixelComponent(p)))); |
|---|
| 744 | p++; |
|---|
| 745 | } |
|---|
| 746 | } |
|---|
| 747 | break; |
|---|
| 748 | } |
|---|
| 749 | if (LocaleCompare(map,"RGBP") == 0) |
|---|
| 750 | { |
|---|
| 751 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 752 | { |
|---|
| 753 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 754 | if (p == (const PixelPacket *) NULL) |
|---|
| 755 | break; |
|---|
| 756 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 757 | { |
|---|
| 758 | *q++=(float) (QuantumScale*GetRedPixelComponent(p)); |
|---|
| 759 | *q++=(float) (QuantumScale*GetGreenPixelComponent(p)); |
|---|
| 760 | *q++=(float) (QuantumScale*GetBluePixelComponent(p)); |
|---|
| 761 | *q++=0.0; |
|---|
| 762 | p++; |
|---|
| 763 | } |
|---|
| 764 | } |
|---|
| 765 | break; |
|---|
| 766 | } |
|---|
| 767 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 768 | { |
|---|
| 769 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 770 | if (p == (const PixelPacket *) NULL) |
|---|
| 771 | break; |
|---|
| 772 | indexes=GetVirtualIndexQueue(image); |
|---|
| 773 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 774 | { |
|---|
| 775 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 776 | { |
|---|
| 777 | *q=0; |
|---|
| 778 | switch (quantum_map[i]) |
|---|
| 779 | { |
|---|
| 780 | case RedQuantum: |
|---|
| 781 | case CyanQuantum: |
|---|
| 782 | { |
|---|
| 783 | *q=(float) (QuantumScale*GetRedPixelComponent(p)); |
|---|
| 784 | break; |
|---|
| 785 | } |
|---|
| 786 | case GreenQuantum: |
|---|
| 787 | case MagentaQuantum: |
|---|
| 788 | { |
|---|
| 789 | *q=(float) (QuantumScale*GetGreenPixelComponent(p)); |
|---|
| 790 | break; |
|---|
| 791 | } |
|---|
| 792 | case BlueQuantum: |
|---|
| 793 | case YellowQuantum: |
|---|
| 794 | { |
|---|
| 795 | *q=(float) (QuantumScale*GetBluePixelComponent(p)); |
|---|
| 796 | break; |
|---|
| 797 | } |
|---|
| 798 | case AlphaQuantum: |
|---|
| 799 | { |
|---|
| 800 | *q=(float) (QuantumScale*((Quantum) (GetAlphaPixelComponent(p)))); |
|---|
| 801 | break; |
|---|
| 802 | } |
|---|
| 803 | case OpacityQuantum: |
|---|
| 804 | { |
|---|
| 805 | *q=(float) (QuantumScale*GetOpacityPixelComponent(p)); |
|---|
| 806 | break; |
|---|
| 807 | } |
|---|
| 808 | case BlackQuantum: |
|---|
| 809 | { |
|---|
| 810 | if (image->colorspace == CMYKColorspace) |
|---|
| 811 | *q=(float) (QuantumScale*indexes[x]); |
|---|
| 812 | break; |
|---|
| 813 | } |
|---|
| 814 | case IndexQuantum: |
|---|
| 815 | { |
|---|
| 816 | *q=(float) (QuantumScale*PixelIntensityToQuantum(p)); |
|---|
| 817 | break; |
|---|
| 818 | } |
|---|
| 819 | default: |
|---|
| 820 | *q=0; |
|---|
| 821 | } |
|---|
| 822 | q++; |
|---|
| 823 | } |
|---|
| 824 | p++; |
|---|
| 825 | } |
|---|
| 826 | } |
|---|
| 827 | break; |
|---|
| 828 | } |
|---|
| 829 | case IntegerPixel: |
|---|
| 830 | { |
|---|
| 831 | register unsigned int |
|---|
| 832 | *q; |
|---|
| 833 | |
|---|
| 834 | q=(unsigned int *) pixels; |
|---|
| 835 | if (LocaleCompare(map,"BGR") == 0) |
|---|
| 836 | { |
|---|
| 837 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 838 | { |
|---|
| 839 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 840 | if (p == (const PixelPacket *) NULL) |
|---|
| 841 | break; |
|---|
| 842 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 843 | { |
|---|
| 844 | *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p)); |
|---|
| 845 | *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p)); |
|---|
| 846 | *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p)); |
|---|
| 847 | p++; |
|---|
| 848 | } |
|---|
| 849 | } |
|---|
| 850 | break; |
|---|
| 851 | } |
|---|
| 852 | if (LocaleCompare(map,"BGRA") == 0) |
|---|
| 853 | { |
|---|
| 854 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 855 | { |
|---|
| 856 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 857 | if (p == (const PixelPacket *) NULL) |
|---|
| 858 | break; |
|---|
| 859 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 860 | { |
|---|
| 861 | *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p)); |
|---|
| 862 | *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p)); |
|---|
| 863 | *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p)); |
|---|
| 864 | *q++=(unsigned int) ScaleQuantumToLong((Quantum) (QuantumRange- |
|---|
| 865 | GetOpacityPixelComponent(p))); |
|---|
| 866 | p++; |
|---|
| 867 | } |
|---|
| 868 | } |
|---|
| 869 | break; |
|---|
| 870 | } |
|---|
| 871 | if (LocaleCompare(map,"BGRP") == 0) |
|---|
| 872 | { |
|---|
| 873 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 874 | { |
|---|
| 875 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 876 | if (p == (const PixelPacket *) NULL) |
|---|
| 877 | break; |
|---|
| 878 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 879 | { |
|---|
| 880 | *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p)); |
|---|
| 881 | *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p)); |
|---|
| 882 | *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p)); |
|---|
| 883 | *q++=0U; |
|---|
| 884 | p++; |
|---|
| 885 | } |
|---|
| 886 | } |
|---|
| 887 | break; |
|---|
| 888 | } |
|---|
| 889 | if (LocaleCompare(map,"I") == 0) |
|---|
| 890 | { |
|---|
| 891 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 892 | { |
|---|
| 893 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 894 | if (p == (const PixelPacket *) NULL) |
|---|
| 895 | break; |
|---|
| 896 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 897 | { |
|---|
| 898 | *q++=(unsigned int) |
|---|
| 899 | ScaleQuantumToLong(PixelIntensityToQuantum(p)); |
|---|
| 900 | p++; |
|---|
| 901 | } |
|---|
| 902 | } |
|---|
| 903 | break; |
|---|
| 904 | } |
|---|
| 905 | if (LocaleCompare(map,"RGB") == 0) |
|---|
| 906 | { |
|---|
| 907 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 908 | { |
|---|
| 909 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 910 | if (p == (const PixelPacket *) NULL) |
|---|
| 911 | break; |
|---|
| 912 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 913 | { |
|---|
| 914 | *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p)); |
|---|
| 915 | *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p)); |
|---|
| 916 | *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p)); |
|---|
| 917 | p++; |
|---|
| 918 | } |
|---|
| 919 | } |
|---|
| 920 | break; |
|---|
| 921 | } |
|---|
| 922 | if (LocaleCompare(map,"RGBA") == 0) |
|---|
| 923 | { |
|---|
| 924 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 925 | { |
|---|
| 926 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 927 | if (p == (const PixelPacket *) NULL) |
|---|
| 928 | break; |
|---|
| 929 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 930 | { |
|---|
| 931 | *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p)); |
|---|
| 932 | *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p)); |
|---|
| 933 | *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p)); |
|---|
| 934 | *q++=(unsigned int) ScaleQuantumToLong((Quantum) |
|---|
| 935 | (GetAlphaPixelComponent(p))); |
|---|
| 936 | p++; |
|---|
| 937 | } |
|---|
| 938 | } |
|---|
| 939 | break; |
|---|
| 940 | } |
|---|
| 941 | if (LocaleCompare(map,"RGBP") == 0) |
|---|
| 942 | { |
|---|
| 943 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 944 | { |
|---|
| 945 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 946 | if (p == (const PixelPacket *) NULL) |
|---|
| 947 | break; |
|---|
| 948 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 949 | { |
|---|
| 950 | *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p)); |
|---|
| 951 | *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p)); |
|---|
| 952 | *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p)); |
|---|
| 953 | *q++=0U; |
|---|
| 954 | p++; |
|---|
| 955 | } |
|---|
| 956 | } |
|---|
| 957 | break; |
|---|
| 958 | } |
|---|
| 959 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 960 | { |
|---|
| 961 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 962 | if (p == (const PixelPacket *) NULL) |
|---|
| 963 | break; |
|---|
| 964 | indexes=GetVirtualIndexQueue(image); |
|---|
| 965 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 966 | { |
|---|
| 967 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 968 | { |
|---|
| 969 | *q=0; |
|---|
| 970 | switch (quantum_map[i]) |
|---|
| 971 | { |
|---|
| 972 | case RedQuantum: |
|---|
| 973 | case CyanQuantum: |
|---|
| 974 | { |
|---|
| 975 | *q=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p)); |
|---|
| 976 | break; |
|---|
| 977 | } |
|---|
| 978 | case GreenQuantum: |
|---|
| 979 | case MagentaQuantum: |
|---|
| 980 | { |
|---|
| 981 | *q=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p)); |
|---|
| 982 | break; |
|---|
| 983 | } |
|---|
| 984 | case BlueQuantum: |
|---|
| 985 | case YellowQuantum: |
|---|
| 986 | { |
|---|
| 987 | *q=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p)); |
|---|
| 988 | break; |
|---|
| 989 | } |
|---|
| 990 | case AlphaQuantum: |
|---|
| 991 | { |
|---|
| 992 | *q=(unsigned int) ScaleQuantumToLong((Quantum) (QuantumRange- |
|---|
| 993 | GetOpacityPixelComponent(p))); |
|---|
| 994 | break; |
|---|
| 995 | } |
|---|
| 996 | case OpacityQuantum: |
|---|
| 997 | { |
|---|
| 998 | *q=(unsigned int) ScaleQuantumToLong(GetOpacityPixelComponent(p)); |
|---|
| 999 | break; |
|---|
| 1000 | } |
|---|
| 1001 | case BlackQuantum: |
|---|
| 1002 | { |
|---|
| 1003 | if (image->colorspace == CMYKColorspace) |
|---|
| 1004 | *q=(unsigned int) ScaleQuantumToLong(indexes[x]); |
|---|
| 1005 | break; |
|---|
| 1006 | } |
|---|
| 1007 | case IndexQuantum: |
|---|
| 1008 | { |
|---|
| 1009 | *q=(unsigned int) |
|---|
| 1010 | ScaleQuantumToLong(PixelIntensityToQuantum(p)); |
|---|
| 1011 | break; |
|---|
| 1012 | } |
|---|
| 1013 | default: |
|---|
| 1014 | *q=0; |
|---|
| 1015 | } |
|---|
| 1016 | q++; |
|---|
| 1017 | } |
|---|
| 1018 | p++; |
|---|
| 1019 | } |
|---|
| 1020 | } |
|---|
| 1021 | break; |
|---|
| 1022 | } |
|---|
| 1023 | case LongPixel: |
|---|
| 1024 | { |
|---|
| 1025 | register size_t |
|---|
| 1026 | *q; |
|---|
| 1027 | |
|---|
| 1028 | q=(size_t *) pixels; |
|---|
| 1029 | if (LocaleCompare(map,"BGR") == 0) |
|---|
| 1030 | { |
|---|
| 1031 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1032 | { |
|---|
| 1033 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1034 | if (p == (const PixelPacket *) NULL) |
|---|
| 1035 | break; |
|---|
| 1036 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1037 | { |
|---|
| 1038 | *q++=ScaleQuantumToLong(GetBluePixelComponent(p)); |
|---|
| 1039 | *q++=ScaleQuantumToLong(GetGreenPixelComponent(p)); |
|---|
| 1040 | *q++=ScaleQuantumToLong(GetRedPixelComponent(p)); |
|---|
| 1041 | p++; |
|---|
| 1042 | } |
|---|
| 1043 | } |
|---|
| 1044 | break; |
|---|
| 1045 | } |
|---|
| 1046 | if (LocaleCompare(map,"BGRA") == 0) |
|---|
| 1047 | { |
|---|
| 1048 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1049 | { |
|---|
| 1050 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1051 | if (p == (const PixelPacket *) NULL) |
|---|
| 1052 | break; |
|---|
| 1053 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1054 | { |
|---|
| 1055 | *q++=ScaleQuantumToLong(GetBluePixelComponent(p)); |
|---|
| 1056 | *q++=ScaleQuantumToLong(GetGreenPixelComponent(p)); |
|---|
| 1057 | *q++=ScaleQuantumToLong(GetRedPixelComponent(p)); |
|---|
| 1058 | *q++=ScaleQuantumToLong((Quantum) (GetAlphaPixelComponent(p))); |
|---|
| 1059 | p++; |
|---|
| 1060 | } |
|---|
| 1061 | } |
|---|
| 1062 | break; |
|---|
| 1063 | } |
|---|
| 1064 | if (LocaleCompare(map,"BGRP") == 0) |
|---|
| 1065 | { |
|---|
| 1066 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1067 | { |
|---|
| 1068 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1069 | if (p == (const PixelPacket *) NULL) |
|---|
| 1070 | break; |
|---|
| 1071 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1072 | { |
|---|
| 1073 | *q++=ScaleQuantumToLong(GetBluePixelComponent(p)); |
|---|
| 1074 | *q++=ScaleQuantumToLong(GetGreenPixelComponent(p)); |
|---|
| 1075 | *q++=ScaleQuantumToLong(GetRedPixelComponent(p)); |
|---|
| 1076 | *q++=0; |
|---|
| 1077 | p++; |
|---|
| 1078 | } |
|---|
| 1079 | } |
|---|
| 1080 | break; |
|---|
| 1081 | } |
|---|
| 1082 | if (LocaleCompare(map,"I") == 0) |
|---|
| 1083 | { |
|---|
| 1084 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1085 | { |
|---|
| 1086 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1087 | if (p == (const PixelPacket *) NULL) |
|---|
| 1088 | break; |
|---|
| 1089 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1090 | { |
|---|
| 1091 | *q++=ScaleQuantumToLong(PixelIntensityToQuantum(p)); |
|---|
| 1092 | p++; |
|---|
| 1093 | } |
|---|
| 1094 | } |
|---|
| 1095 | break; |
|---|
| 1096 | } |
|---|
| 1097 | if (LocaleCompare(map,"RGB") == 0) |
|---|
| 1098 | { |
|---|
| 1099 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1100 | { |
|---|
| 1101 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1102 | if (p == (const PixelPacket *) NULL) |
|---|
| 1103 | break; |
|---|
| 1104 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1105 | { |
|---|
| 1106 | *q++=ScaleQuantumToLong(GetRedPixelComponent(p)); |
|---|
| 1107 | *q++=ScaleQuantumToLong(GetGreenPixelComponent(p)); |
|---|
| 1108 | *q++=ScaleQuantumToLong(GetBluePixelComponent(p)); |
|---|
| 1109 | p++; |
|---|
| 1110 | } |
|---|
| 1111 | } |
|---|
| 1112 | break; |
|---|
| 1113 | } |
|---|
| 1114 | if (LocaleCompare(map,"RGBA") == 0) |
|---|
| 1115 | { |
|---|
| 1116 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1117 | { |
|---|
| 1118 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1119 | if (p == (const PixelPacket *) NULL) |
|---|
| 1120 | break; |
|---|
| 1121 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1122 | { |
|---|
| 1123 | *q++=ScaleQuantumToLong(GetRedPixelComponent(p)); |
|---|
| 1124 | *q++=ScaleQuantumToLong(GetGreenPixelComponent(p)); |
|---|
| 1125 | *q++=ScaleQuantumToLong(GetBluePixelComponent(p)); |
|---|
| 1126 | *q++=ScaleQuantumToLong((Quantum) (GetAlphaPixelComponent(p))); |
|---|
| 1127 | p++; |
|---|
| 1128 | } |
|---|
| 1129 | } |
|---|
| 1130 | break; |
|---|
| 1131 | } |
|---|
| 1132 | if (LocaleCompare(map,"RGBP") == 0) |
|---|
| 1133 | { |
|---|
| 1134 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1135 | { |
|---|
| 1136 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1137 | if (p == (const PixelPacket *) NULL) |
|---|
| 1138 | break; |
|---|
| 1139 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1140 | { |
|---|
| 1141 | *q++=ScaleQuantumToLong(GetRedPixelComponent(p)); |
|---|
| 1142 | *q++=ScaleQuantumToLong(GetGreenPixelComponent(p)); |
|---|
| 1143 | *q++=ScaleQuantumToLong(GetBluePixelComponent(p)); |
|---|
| 1144 | *q++=0; |
|---|
| 1145 | p++; |
|---|
| 1146 | } |
|---|
| 1147 | } |
|---|
| 1148 | break; |
|---|
| 1149 | } |
|---|
| 1150 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1151 | { |
|---|
| 1152 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1153 | if (p == (const PixelPacket *) NULL) |
|---|
| 1154 | break; |
|---|
| 1155 | indexes=GetVirtualIndexQueue(image); |
|---|
| 1156 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1157 | { |
|---|
| 1158 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 1159 | { |
|---|
| 1160 | *q=0; |
|---|
| 1161 | switch (quantum_map[i]) |
|---|
| 1162 | { |
|---|
| 1163 | case RedQuantum: |
|---|
| 1164 | case CyanQuantum: |
|---|
| 1165 | { |
|---|
| 1166 | *q=ScaleQuantumToLong(GetRedPixelComponent(p)); |
|---|
| 1167 | break; |
|---|
| 1168 | } |
|---|
| 1169 | case GreenQuantum: |
|---|
| 1170 | case MagentaQuantum: |
|---|
| 1171 | { |
|---|
| 1172 | *q=ScaleQuantumToLong(GetGreenPixelComponent(p)); |
|---|
| 1173 | break; |
|---|
| 1174 | } |
|---|
| 1175 | case BlueQuantum: |
|---|
| 1176 | case YellowQuantum: |
|---|
| 1177 | { |
|---|
| 1178 | *q=ScaleQuantumToLong(GetBluePixelComponent(p)); |
|---|
| 1179 | break; |
|---|
| 1180 | } |
|---|
| 1181 | case AlphaQuantum: |
|---|
| 1182 | { |
|---|
| 1183 | *q=ScaleQuantumToLong((Quantum) (GetAlphaPixelComponent(p))); |
|---|
| 1184 | break; |
|---|
| 1185 | } |
|---|
| 1186 | case OpacityQuantum: |
|---|
| 1187 | { |
|---|
| 1188 | *q=ScaleQuantumToLong(GetOpacityPixelComponent(p)); |
|---|
| 1189 | break; |
|---|
| 1190 | } |
|---|
| 1191 | case BlackQuantum: |
|---|
| 1192 | { |
|---|
| 1193 | if (image->colorspace == CMYKColorspace) |
|---|
| 1194 | *q=ScaleQuantumToLong(indexes[x]); |
|---|
| 1195 | break; |
|---|
| 1196 | } |
|---|
| 1197 | case IndexQuantum: |
|---|
| 1198 | { |
|---|
| 1199 | *q=ScaleQuantumToLong(PixelIntensityToQuantum(p)); |
|---|
| 1200 | break; |
|---|
| 1201 | } |
|---|
| 1202 | default: |
|---|
| 1203 | break; |
|---|
| 1204 | } |
|---|
| 1205 | q++; |
|---|
| 1206 | } |
|---|
| 1207 | p++; |
|---|
| 1208 | } |
|---|
| 1209 | } |
|---|
| 1210 | break; |
|---|
| 1211 | } |
|---|
| 1212 | case QuantumPixel: |
|---|
| 1213 | { |
|---|
| 1214 | register Quantum |
|---|
| 1215 | *q; |
|---|
| 1216 | |
|---|
| 1217 | q=(Quantum *) pixels; |
|---|
| 1218 | if (LocaleCompare(map,"BGR") == 0) |
|---|
| 1219 | { |
|---|
| 1220 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1221 | { |
|---|
| 1222 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1223 | if (p == (const PixelPacket *) NULL) |
|---|
| 1224 | break; |
|---|
| 1225 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1226 | { |
|---|
| 1227 | *q++=GetBluePixelComponent(p); |
|---|
| 1228 | *q++=GetGreenPixelComponent(p); |
|---|
| 1229 | *q++=GetRedPixelComponent(p); |
|---|
| 1230 | p++; |
|---|
| 1231 | } |
|---|
| 1232 | } |
|---|
| 1233 | break; |
|---|
| 1234 | } |
|---|
| 1235 | if (LocaleCompare(map,"BGRA") == 0) |
|---|
| 1236 | { |
|---|
| 1237 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1238 | { |
|---|
| 1239 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1240 | if (p == (const PixelPacket *) NULL) |
|---|
| 1241 | break; |
|---|
| 1242 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1243 | { |
|---|
| 1244 | *q++=GetBluePixelComponent(p); |
|---|
| 1245 | *q++=GetGreenPixelComponent(p); |
|---|
| 1246 | *q++=GetRedPixelComponent(p); |
|---|
| 1247 | *q++=(Quantum) (GetAlphaPixelComponent(p)); |
|---|
| 1248 | p++; |
|---|
| 1249 | } |
|---|
| 1250 | } |
|---|
| 1251 | break; |
|---|
| 1252 | } |
|---|
| 1253 | if (LocaleCompare(map,"BGRP") == 0) |
|---|
| 1254 | { |
|---|
| 1255 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1256 | { |
|---|
| 1257 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1258 | if (p == (const PixelPacket *) NULL) |
|---|
| 1259 | break; |
|---|
| 1260 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1261 | { |
|---|
| 1262 | *q++=GetBluePixelComponent(p); |
|---|
| 1263 | *q++=GetGreenPixelComponent(p); |
|---|
| 1264 | *q++=GetRedPixelComponent(p); |
|---|
| 1265 | *q++=(Quantum) 0; |
|---|
| 1266 | p++; |
|---|
| 1267 | } |
|---|
| 1268 | } |
|---|
| 1269 | break; |
|---|
| 1270 | } |
|---|
| 1271 | if (LocaleCompare(map,"I") == 0) |
|---|
| 1272 | { |
|---|
| 1273 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1274 | { |
|---|
| 1275 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1276 | if (p == (const PixelPacket *) NULL) |
|---|
| 1277 | break; |
|---|
| 1278 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1279 | { |
|---|
| 1280 | *q++=PixelIntensityToQuantum(p); |
|---|
| 1281 | p++; |
|---|
| 1282 | } |
|---|
| 1283 | } |
|---|
| 1284 | break; |
|---|
| 1285 | } |
|---|
| 1286 | if (LocaleCompare(map,"RGB") == 0) |
|---|
| 1287 | { |
|---|
| 1288 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1289 | { |
|---|
| 1290 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1291 | if (p == (const PixelPacket *) NULL) |
|---|
| 1292 | break; |
|---|
| 1293 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1294 | { |
|---|
| 1295 | *q++=GetRedPixelComponent(p); |
|---|
| 1296 | *q++=GetGreenPixelComponent(p); |
|---|
| 1297 | *q++=GetBluePixelComponent(p); |
|---|
| 1298 | p++; |
|---|
| 1299 | } |
|---|
| 1300 | } |
|---|
| 1301 | break; |
|---|
| 1302 | } |
|---|
| 1303 | if (LocaleCompare(map,"RGBA") == 0) |
|---|
| 1304 | { |
|---|
| 1305 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1306 | { |
|---|
| 1307 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1308 | if (p == (const PixelPacket *) NULL) |
|---|
| 1309 | break; |
|---|
| 1310 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1311 | { |
|---|
| 1312 | *q++=GetRedPixelComponent(p); |
|---|
| 1313 | *q++=GetGreenPixelComponent(p); |
|---|
| 1314 | *q++=GetBluePixelComponent(p); |
|---|
| 1315 | *q++=(Quantum) (GetAlphaPixelComponent(p)); |
|---|
| 1316 | p++; |
|---|
| 1317 | } |
|---|
| 1318 | } |
|---|
| 1319 | break; |
|---|
| 1320 | } |
|---|
| 1321 | if (LocaleCompare(map,"RGBP") == 0) |
|---|
| 1322 | { |
|---|
| 1323 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1324 | { |
|---|
| 1325 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1326 | if (p == (const PixelPacket *) NULL) |
|---|
| 1327 | break; |
|---|
| 1328 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1329 | { |
|---|
| 1330 | *q++=GetRedPixelComponent(p); |
|---|
| 1331 | *q++=GetGreenPixelComponent(p); |
|---|
| 1332 | *q++=GetBluePixelComponent(p); |
|---|
| 1333 | *q++=(Quantum) 0; |
|---|
| 1334 | p++; |
|---|
| 1335 | } |
|---|
| 1336 | } |
|---|
| 1337 | break; |
|---|
| 1338 | } |
|---|
| 1339 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1340 | { |
|---|
| 1341 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1342 | if (p == (const PixelPacket *) NULL) |
|---|
| 1343 | break; |
|---|
| 1344 | indexes=GetVirtualIndexQueue(image); |
|---|
| 1345 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1346 | { |
|---|
| 1347 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 1348 | { |
|---|
| 1349 | *q=(Quantum) 0; |
|---|
| 1350 | switch (quantum_map[i]) |
|---|
| 1351 | { |
|---|
| 1352 | case RedQuantum: |
|---|
| 1353 | case CyanQuantum: |
|---|
| 1354 | { |
|---|
| 1355 | *q=GetRedPixelComponent(p); |
|---|
| 1356 | break; |
|---|
| 1357 | } |
|---|
| 1358 | case GreenQuantum: |
|---|
| 1359 | case MagentaQuantum: |
|---|
| 1360 | { |
|---|
| 1361 | *q=GetGreenPixelComponent(p); |
|---|
| 1362 | break; |
|---|
| 1363 | } |
|---|
| 1364 | case BlueQuantum: |
|---|
| 1365 | case YellowQuantum: |
|---|
| 1366 | { |
|---|
| 1367 | *q=GetBluePixelComponent(p); |
|---|
| 1368 | break; |
|---|
| 1369 | } |
|---|
| 1370 | case AlphaQuantum: |
|---|
| 1371 | { |
|---|
| 1372 | *q=(Quantum) (GetAlphaPixelComponent(p)); |
|---|
| 1373 | break; |
|---|
| 1374 | } |
|---|
| 1375 | case OpacityQuantum: |
|---|
| 1376 | { |
|---|
| 1377 | *q=GetOpacityPixelComponent(p); |
|---|
| 1378 | break; |
|---|
| 1379 | } |
|---|
| 1380 | case BlackQuantum: |
|---|
| 1381 | { |
|---|
| 1382 | if (image->colorspace == CMYKColorspace) |
|---|
| 1383 | *q=indexes[x]; |
|---|
| 1384 | break; |
|---|
| 1385 | } |
|---|
| 1386 | case IndexQuantum: |
|---|
| 1387 | { |
|---|
| 1388 | *q=(PixelIntensityToQuantum(p)); |
|---|
| 1389 | break; |
|---|
| 1390 | } |
|---|
| 1391 | default: |
|---|
| 1392 | *q=(Quantum) 0; |
|---|
| 1393 | } |
|---|
| 1394 | q++; |
|---|
| 1395 | } |
|---|
| 1396 | p++; |
|---|
| 1397 | } |
|---|
| 1398 | } |
|---|
| 1399 | break; |
|---|
| 1400 | } |
|---|
| 1401 | case ShortPixel: |
|---|
| 1402 | { |
|---|
| 1403 | register unsigned short |
|---|
| 1404 | *q; |
|---|
| 1405 | |
|---|
| 1406 | q=(unsigned short *) pixels; |
|---|
| 1407 | if (LocaleCompare(map,"BGR") == 0) |
|---|
| 1408 | { |
|---|
| 1409 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1410 | { |
|---|
| 1411 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1412 | if (p == (const PixelPacket *) NULL) |
|---|
| 1413 | break; |
|---|
| 1414 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1415 | { |
|---|
| 1416 | *q++=ScaleQuantumToShort(GetBluePixelComponent(p)); |
|---|
| 1417 | *q++=ScaleQuantumToShort(GetGreenPixelComponent(p)); |
|---|
| 1418 | *q++=ScaleQuantumToShort(GetRedPixelComponent(p)); |
|---|
| 1419 | p++; |
|---|
| 1420 | } |
|---|
| 1421 | } |
|---|
| 1422 | break; |
|---|
| 1423 | } |
|---|
| 1424 | if (LocaleCompare(map,"BGRA") == 0) |
|---|
| 1425 | { |
|---|
| 1426 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1427 | { |
|---|
| 1428 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1429 | if (p == (const PixelPacket *) NULL) |
|---|
| 1430 | break; |
|---|
| 1431 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1432 | { |
|---|
| 1433 | *q++=ScaleQuantumToShort(GetBluePixelComponent(p)); |
|---|
| 1434 | *q++=ScaleQuantumToShort(GetGreenPixelComponent(p)); |
|---|
| 1435 | *q++=ScaleQuantumToShort(GetRedPixelComponent(p)); |
|---|
| 1436 | *q++=ScaleQuantumToShort((Quantum) (GetAlphaPixelComponent(p))); |
|---|
| 1437 | p++; |
|---|
| 1438 | } |
|---|
| 1439 | } |
|---|
| 1440 | break; |
|---|
| 1441 | } |
|---|
| 1442 | if (LocaleCompare(map,"BGRP") == 0) |
|---|
| 1443 | { |
|---|
| 1444 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1445 | { |
|---|
| 1446 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1447 | if (p == (const PixelPacket *) NULL) |
|---|
| 1448 | break; |
|---|
| 1449 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1450 | { |
|---|
| 1451 | *q++=ScaleQuantumToShort(GetBluePixelComponent(p)); |
|---|
| 1452 | *q++=ScaleQuantumToShort(GetGreenPixelComponent(p)); |
|---|
| 1453 | *q++=ScaleQuantumToShort(GetRedPixelComponent(p)); |
|---|
| 1454 | *q++=0; |
|---|
| 1455 | p++; |
|---|
| 1456 | } |
|---|
| 1457 | } |
|---|
| 1458 | break; |
|---|
| 1459 | } |
|---|
| 1460 | if (LocaleCompare(map,"I") == 0) |
|---|
| 1461 | { |
|---|
| 1462 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1463 | { |
|---|
| 1464 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1465 | if (p == (const PixelPacket *) NULL) |
|---|
| 1466 | break; |
|---|
| 1467 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1468 | { |
|---|
| 1469 | *q++=ScaleQuantumToShort(PixelIntensityToQuantum(p)); |
|---|
| 1470 | p++; |
|---|
| 1471 | } |
|---|
| 1472 | } |
|---|
| 1473 | break; |
|---|
| 1474 | } |
|---|
| 1475 | if (LocaleCompare(map,"RGB") == 0) |
|---|
| 1476 | { |
|---|
| 1477 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1478 | { |
|---|
| 1479 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1480 | if (p == (const PixelPacket *) NULL) |
|---|
| 1481 | break; |
|---|
| 1482 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1483 | { |
|---|
| 1484 | *q++=ScaleQuantumToShort(GetRedPixelComponent(p)); |
|---|
| 1485 | *q++=ScaleQuantumToShort(GetGreenPixelComponent(p)); |
|---|
| 1486 | *q++=ScaleQuantumToShort(GetBluePixelComponent(p)); |
|---|
| 1487 | p++; |
|---|
| 1488 | } |
|---|
| 1489 | } |
|---|
| 1490 | break; |
|---|
| 1491 | } |
|---|
| 1492 | if (LocaleCompare(map,"RGBA") == 0) |
|---|
| 1493 | { |
|---|
| 1494 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1495 | { |
|---|
| 1496 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1497 | if (p == (const PixelPacket *) NULL) |
|---|
| 1498 | break; |
|---|
| 1499 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1500 | { |
|---|
| 1501 | *q++=ScaleQuantumToShort(GetRedPixelComponent(p)); |
|---|
| 1502 | *q++=ScaleQuantumToShort(GetGreenPixelComponent(p)); |
|---|
| 1503 | *q++=ScaleQuantumToShort(GetBluePixelComponent(p)); |
|---|
| 1504 | *q++=ScaleQuantumToShort((Quantum) (GetAlphaPixelComponent(p))); |
|---|
| 1505 | p++; |
|---|
| 1506 | } |
|---|
| 1507 | } |
|---|
| 1508 | break; |
|---|
| 1509 | } |
|---|
| 1510 | if (LocaleCompare(map,"RGBP") == 0) |
|---|
| 1511 | { |
|---|
| 1512 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1513 | { |
|---|
| 1514 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1515 | if (p == (const PixelPacket *) NULL) |
|---|
| 1516 | break; |
|---|
| 1517 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1518 | { |
|---|
| 1519 | *q++=ScaleQuantumToShort(GetRedPixelComponent(p)); |
|---|
| 1520 | *q++=ScaleQuantumToShort(GetGreenPixelComponent(p)); |
|---|
| 1521 | *q++=ScaleQuantumToShort(GetBluePixelComponent(p)); |
|---|
| 1522 | *q++=0; |
|---|
| 1523 | p++; |
|---|
| 1524 | } |
|---|
| 1525 | } |
|---|
| 1526 | break; |
|---|
| 1527 | } |
|---|
| 1528 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1529 | { |
|---|
| 1530 | p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1531 | if (p == (const PixelPacket *) NULL) |
|---|
| 1532 | break; |
|---|
| 1533 | indexes=GetVirtualIndexQueue(image); |
|---|
| 1534 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1535 | { |
|---|
| 1536 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 1537 | { |
|---|
| 1538 | *q=0; |
|---|
| 1539 | switch (quantum_map[i]) |
|---|
| 1540 | { |
|---|
| 1541 | case RedQuantum: |
|---|
| 1542 | case CyanQuantum: |
|---|
| 1543 | { |
|---|
| 1544 | *q=ScaleQuantumToShort(GetRedPixelComponent(p)); |
|---|
| 1545 | break; |
|---|
| 1546 | } |
|---|
| 1547 | case GreenQuantum: |
|---|
| 1548 | case MagentaQuantum: |
|---|
| 1549 | { |
|---|
| 1550 | *q=ScaleQuantumToShort(GetGreenPixelComponent(p)); |
|---|
| 1551 | break; |
|---|
| 1552 | } |
|---|
| 1553 | case BlueQuantum: |
|---|
| 1554 | case YellowQuantum: |
|---|
| 1555 | { |
|---|
| 1556 | *q=ScaleQuantumToShort(GetBluePixelComponent(p)); |
|---|
| 1557 | break; |
|---|
| 1558 | } |
|---|
| 1559 | case AlphaQuantum: |
|---|
| 1560 | { |
|---|
| 1561 | *q=ScaleQuantumToShort((Quantum) (GetAlphaPixelComponent(p))); |
|---|
| 1562 | break; |
|---|
| 1563 | } |
|---|
| 1564 | case OpacityQuantum: |
|---|
| 1565 | { |
|---|
| 1566 | *q=ScaleQuantumToShort(GetOpacityPixelComponent(p)); |
|---|
| 1567 | break; |
|---|
| 1568 | } |
|---|
| 1569 | case BlackQuantum: |
|---|
| 1570 | { |
|---|
| 1571 | if (image->colorspace == CMYKColorspace) |
|---|
| 1572 | *q=ScaleQuantumToShort(indexes[x]); |
|---|
| 1573 | break; |
|---|
| 1574 | } |
|---|
| 1575 | case IndexQuantum: |
|---|
| 1576 | { |
|---|
| 1577 | *q=ScaleQuantumToShort(PixelIntensityToQuantum(p)); |
|---|
| 1578 | break; |
|---|
| 1579 | } |
|---|
| 1580 | default: |
|---|
| 1581 | break; |
|---|
| 1582 | } |
|---|
| 1583 | q++; |
|---|
| 1584 | } |
|---|
| 1585 | p++; |
|---|
| 1586 | } |
|---|
| 1587 | } |
|---|
| 1588 | break; |
|---|
| 1589 | } |
|---|
| 1590 | default: |
|---|
| 1591 | { |
|---|
| 1592 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
|---|
| 1593 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
|---|
| 1594 | "UnrecognizedPixelMap","`%s'",map); |
|---|
| 1595 | break; |
|---|
| 1596 | } |
|---|
| 1597 | } |
|---|
| 1598 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
|---|
| 1599 | return(MagickTrue); |
|---|
| 1600 | } |
|---|
| 1601 | |
|---|
| 1602 | /* |
|---|
| 1603 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 1604 | % % |
|---|
| 1605 | % % |
|---|
| 1606 | % % |
|---|
| 1607 | % G e t M a g i c k P i x e l P a c k e t % |
|---|
| 1608 | % % |
|---|
| 1609 | % % |
|---|
| 1610 | % % |
|---|
| 1611 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 1612 | % |
|---|
| 1613 | % GetMagickPixelPacket() initializes the MagickPixelPacket structure. |
|---|
| 1614 | % |
|---|
| 1615 | % The format of the GetMagickPixelPacket method is: |
|---|
| 1616 | % |
|---|
| 1617 | % GetMagickPixelPacket(const Image *image,MagickPixelPacket *pixel) |
|---|
| 1618 | % |
|---|
| 1619 | % A description of each parameter follows: |
|---|
| 1620 | % |
|---|
| 1621 | % o image: the image. |
|---|
| 1622 | % |
|---|
| 1623 | % o pixel: Specifies a pointer to a PixelPacket structure. |
|---|
| 1624 | % |
|---|
| 1625 | */ |
|---|
| 1626 | MagickExport void GetMagickPixelPacket(const Image *image, |
|---|
| 1627 | MagickPixelPacket *pixel) |
|---|
| 1628 | { |
|---|
| 1629 | pixel->storage_class=DirectClass; |
|---|
| 1630 | pixel->colorspace=RGBColorspace; |
|---|
| 1631 | pixel->matte=MagickFalse; |
|---|
| 1632 | pixel->fuzz=0.0; |
|---|
| 1633 | pixel->depth=MAGICKCORE_QUANTUM_DEPTH; |
|---|
| 1634 | pixel->red=0.0; |
|---|
| 1635 | pixel->green=0.0; |
|---|
| 1636 | pixel->blue=0.0; |
|---|
| 1637 | pixel->opacity=(MagickRealType) OpaqueOpacity; |
|---|
| 1638 | pixel->index=0.0; |
|---|
| 1639 | if (image == (const Image *) NULL) |
|---|
| 1640 | return; |
|---|
| 1641 | pixel->storage_class=image->storage_class; |
|---|
| 1642 | pixel->colorspace=image->colorspace; |
|---|
| 1643 | pixel->matte=image->matte; |
|---|
| 1644 | pixel->depth=image->depth; |
|---|
| 1645 | pixel->fuzz=image->fuzz; |
|---|
| 1646 | } |
|---|
| 1647 | |
|---|
| 1648 | /* |
|---|
| 1649 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 1650 | % % |
|---|
| 1651 | % % |
|---|
| 1652 | % % |
|---|
| 1653 | % I m p o r t I m a g e P i x e l s % |
|---|
| 1654 | % % |
|---|
| 1655 | % % |
|---|
| 1656 | % % |
|---|
| 1657 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 1658 | % |
|---|
| 1659 | % ImportImagePixels() accepts pixel data and stores in the image at the |
|---|
| 1660 | % location you specify. The method returns MagickTrue on success otherwise |
|---|
| 1661 | % MagickFalse if an error is encountered. The pixel data can be either char, |
|---|
| 1662 | % short int, int, ssize_t, float, or double in the order specified by map. |
|---|
| 1663 | % |
|---|
| 1664 | % Suppose your want to upload the first scanline of a 640x480 image from |
|---|
| 1665 | % character data in red-green-blue order: |
|---|
| 1666 | % |
|---|
| 1667 | % ImportImagePixels(image,0,0,640,1,"RGB",CharPixel,pixels); |
|---|
| 1668 | % |
|---|
| 1669 | % The format of the ImportImagePixels method is: |
|---|
| 1670 | % |
|---|
| 1671 | % MagickBooleanType ImportImagePixels(Image *image,const ssize_t x_offset, |
|---|
| 1672 | % const ssize_t y_offset,const size_t columns, |
|---|
| 1673 | % const size_t rows,const char *map,const StorageType type, |
|---|
| 1674 | % const void *pixels) |
|---|
| 1675 | % |
|---|
| 1676 | % A description of each parameter follows: |
|---|
| 1677 | % |
|---|
| 1678 | % o image: the image. |
|---|
| 1679 | % |
|---|
| 1680 | % o x_offset,y_offset,columns,rows: These values define the perimeter |
|---|
| 1681 | % of a region of pixels you want to define. |
|---|
| 1682 | % |
|---|
| 1683 | % o map: This string reflects the expected ordering of the pixel array. |
|---|
| 1684 | % It can be any combination or order of R = red, G = green, B = blue, |
|---|
| 1685 | % A = alpha (0 is transparent), O = opacity (0 is opaque), C = cyan, |
|---|
| 1686 | % Y = yellow, M = magenta, K = black, I = intensity (for grayscale), |
|---|
| 1687 | % P = pad. |
|---|
| 1688 | % |
|---|
| 1689 | % o type: Define the data type of the pixels. Float and double types are |
|---|
| 1690 | % normalized to [0..1] otherwise [0..QuantumRange]. Choose from these |
|---|
| 1691 | % types: CharPixel, ShortPixel, IntegerPixel, LongPixel, FloatPixel, or |
|---|
| 1692 | % DoublePixel. |
|---|
| 1693 | % |
|---|
| 1694 | % o pixels: This array of values contain the pixel components as defined by |
|---|
| 1695 | % map and type. You must preallocate this array where the expected |
|---|
| 1696 | % length varies depending on the values of width, height, map, and type. |
|---|
| 1697 | % |
|---|
| 1698 | */ |
|---|
| 1699 | MagickExport MagickBooleanType ImportImagePixels(Image *image, |
|---|
| 1700 | const ssize_t x_offset,const ssize_t y_offset,const size_t columns, |
|---|
| 1701 | const size_t rows,const char *map,const StorageType type, |
|---|
| 1702 | const void *pixels) |
|---|
| 1703 | { |
|---|
| 1704 | ExceptionInfo |
|---|
| 1705 | *exception; |
|---|
| 1706 | |
|---|
| 1707 | PixelPacket |
|---|
| 1708 | *q; |
|---|
| 1709 | |
|---|
| 1710 | QuantumType |
|---|
| 1711 | *quantum_map; |
|---|
| 1712 | |
|---|
| 1713 | register IndexPacket |
|---|
| 1714 | *indexes; |
|---|
| 1715 | |
|---|
| 1716 | register ssize_t |
|---|
| 1717 | i, |
|---|
| 1718 | x; |
|---|
| 1719 | |
|---|
| 1720 | size_t |
|---|
| 1721 | length; |
|---|
| 1722 | |
|---|
| 1723 | ssize_t |
|---|
| 1724 | y; |
|---|
| 1725 | |
|---|
| 1726 | /* |
|---|
| 1727 | Allocate image structure. |
|---|
| 1728 | */ |
|---|
| 1729 | assert(image != (Image *) NULL); |
|---|
| 1730 | assert(image->signature == MagickSignature); |
|---|
| 1731 | if (image->debug != MagickFalse) |
|---|
| 1732 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
|---|
| 1733 | length=strlen(map); |
|---|
| 1734 | quantum_map=(QuantumType *) AcquireQuantumMemory(length,sizeof(*quantum_map)); |
|---|
| 1735 | if (quantum_map == (QuantumType *) NULL) |
|---|
| 1736 | ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", |
|---|
| 1737 | image->filename); |
|---|
| 1738 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 1739 | { |
|---|
| 1740 | switch (map[i]) |
|---|
| 1741 | { |
|---|
| 1742 | case 'a': |
|---|
| 1743 | case 'A': |
|---|
| 1744 | { |
|---|
| 1745 | quantum_map[i]=AlphaQuantum; |
|---|
| 1746 | image->matte=MagickTrue; |
|---|
| 1747 | break; |
|---|
| 1748 | } |
|---|
| 1749 | case 'B': |
|---|
| 1750 | case 'b': |
|---|
| 1751 | { |
|---|
| 1752 | quantum_map[i]=BlueQuantum; |
|---|
| 1753 | break; |
|---|
| 1754 | } |
|---|
| 1755 | case 'C': |
|---|
| 1756 | case 'c': |
|---|
| 1757 | { |
|---|
| 1758 | quantum_map[i]=CyanQuantum; |
|---|
| 1759 | (void) SetImageColorspace(image,CMYKColorspace); |
|---|
| 1760 | break; |
|---|
| 1761 | } |
|---|
| 1762 | case 'g': |
|---|
| 1763 | case 'G': |
|---|
| 1764 | { |
|---|
| 1765 | quantum_map[i]=GreenQuantum; |
|---|
| 1766 | break; |
|---|
| 1767 | } |
|---|
| 1768 | case 'K': |
|---|
| 1769 | case 'k': |
|---|
| 1770 | { |
|---|
| 1771 | quantum_map[i]=BlackQuantum; |
|---|
| 1772 | (void) SetImageColorspace(image,CMYKColorspace); |
|---|
| 1773 | break; |
|---|
| 1774 | } |
|---|
| 1775 | case 'I': |
|---|
| 1776 | case 'i': |
|---|
| 1777 | { |
|---|
| 1778 | quantum_map[i]=IndexQuantum; |
|---|
| 1779 | break; |
|---|
| 1780 | } |
|---|
| 1781 | case 'm': |
|---|
| 1782 | case 'M': |
|---|
| 1783 | { |
|---|
| 1784 | quantum_map[i]=MagentaQuantum; |
|---|
| 1785 | (void) SetImageColorspace(image,CMYKColorspace); |
|---|
| 1786 | break; |
|---|
| 1787 | } |
|---|
| 1788 | case 'O': |
|---|
| 1789 | case 'o': |
|---|
| 1790 | { |
|---|
| 1791 | quantum_map[i]=OpacityQuantum; |
|---|
| 1792 | image->matte=MagickTrue; |
|---|
| 1793 | break; |
|---|
| 1794 | } |
|---|
| 1795 | case 'P': |
|---|
| 1796 | case 'p': |
|---|
| 1797 | { |
|---|
| 1798 | quantum_map[i]=UndefinedQuantum; |
|---|
| 1799 | break; |
|---|
| 1800 | } |
|---|
| 1801 | case 'R': |
|---|
| 1802 | case 'r': |
|---|
| 1803 | { |
|---|
| 1804 | quantum_map[i]=RedQuantum; |
|---|
| 1805 | break; |
|---|
| 1806 | } |
|---|
| 1807 | case 'Y': |
|---|
| 1808 | case 'y': |
|---|
| 1809 | { |
|---|
| 1810 | quantum_map[i]=YellowQuantum; |
|---|
| 1811 | (void) SetImageColorspace(image,CMYKColorspace); |
|---|
| 1812 | break; |
|---|
| 1813 | } |
|---|
| 1814 | default: |
|---|
| 1815 | { |
|---|
| 1816 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
|---|
| 1817 | (void) ThrowMagickException(&image->exception,GetMagickModule(), |
|---|
| 1818 | OptionError,"UnrecognizedPixelMap","`%s'",map); |
|---|
| 1819 | return(MagickFalse); |
|---|
| 1820 | } |
|---|
| 1821 | } |
|---|
| 1822 | } |
|---|
| 1823 | if (SetImageStorageClass(image,DirectClass) == MagickFalse) |
|---|
| 1824 | return(MagickFalse); |
|---|
| 1825 | /* |
|---|
| 1826 | Transfer the pixels from the pixel datarray to the image. |
|---|
| 1827 | */ |
|---|
| 1828 | exception=(&image->exception); |
|---|
| 1829 | switch (type) |
|---|
| 1830 | { |
|---|
| 1831 | case CharPixel: |
|---|
| 1832 | { |
|---|
| 1833 | register const unsigned char |
|---|
| 1834 | *p; |
|---|
| 1835 | |
|---|
| 1836 | p=(const unsigned char *) pixels; |
|---|
| 1837 | if (LocaleCompare(map,"BGR") == 0) |
|---|
| 1838 | { |
|---|
| 1839 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1840 | { |
|---|
| 1841 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1842 | if (q == (PixelPacket *) NULL) |
|---|
| 1843 | break; |
|---|
| 1844 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1845 | { |
|---|
| 1846 | q->blue=ScaleCharToQuantum(*p++); |
|---|
| 1847 | q->green=ScaleCharToQuantum(*p++); |
|---|
| 1848 | q->red=ScaleCharToQuantum(*p++); |
|---|
| 1849 | q++; |
|---|
| 1850 | } |
|---|
| 1851 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 1852 | break; |
|---|
| 1853 | } |
|---|
| 1854 | break; |
|---|
| 1855 | } |
|---|
| 1856 | if (LocaleCompare(map,"BGRA") == 0) |
|---|
| 1857 | { |
|---|
| 1858 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1859 | { |
|---|
| 1860 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1861 | if (q == (PixelPacket *) NULL) |
|---|
| 1862 | break; |
|---|
| 1863 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1864 | { |
|---|
| 1865 | q->blue=ScaleCharToQuantum(*p++); |
|---|
| 1866 | q->green=ScaleCharToQuantum(*p++); |
|---|
| 1867 | q->red=ScaleCharToQuantum(*p++); |
|---|
| 1868 | q->opacity=(Quantum) QuantumRange-ScaleCharToQuantum(*p++); |
|---|
| 1869 | q++; |
|---|
| 1870 | } |
|---|
| 1871 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 1872 | break; |
|---|
| 1873 | } |
|---|
| 1874 | break; |
|---|
| 1875 | } |
|---|
| 1876 | if (LocaleCompare(map,"BGRO") == 0) |
|---|
| 1877 | { |
|---|
| 1878 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1879 | { |
|---|
| 1880 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1881 | if (q == (PixelPacket *) NULL) |
|---|
| 1882 | break; |
|---|
| 1883 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1884 | { |
|---|
| 1885 | q->blue=ScaleCharToQuantum(*p++); |
|---|
| 1886 | q->green=ScaleCharToQuantum(*p++); |
|---|
| 1887 | q->red=ScaleCharToQuantum(*p++); |
|---|
| 1888 | q->opacity=ScaleCharToQuantum(*p++); |
|---|
| 1889 | q++; |
|---|
| 1890 | } |
|---|
| 1891 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 1892 | break; |
|---|
| 1893 | } |
|---|
| 1894 | break; |
|---|
| 1895 | } |
|---|
| 1896 | if (LocaleCompare(map,"BGRP") == 0) |
|---|
| 1897 | { |
|---|
| 1898 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1899 | { |
|---|
| 1900 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1901 | if (q == (PixelPacket *) NULL) |
|---|
| 1902 | break; |
|---|
| 1903 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1904 | { |
|---|
| 1905 | q->blue=ScaleCharToQuantum(*p++); |
|---|
| 1906 | q->green=ScaleCharToQuantum(*p++); |
|---|
| 1907 | q->red=ScaleCharToQuantum(*p++); |
|---|
| 1908 | p++; |
|---|
| 1909 | q++; |
|---|
| 1910 | } |
|---|
| 1911 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 1912 | break; |
|---|
| 1913 | } |
|---|
| 1914 | break; |
|---|
| 1915 | } |
|---|
| 1916 | if (LocaleCompare(map,"I") == 0) |
|---|
| 1917 | { |
|---|
| 1918 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1919 | { |
|---|
| 1920 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1921 | if (q == (PixelPacket *) NULL) |
|---|
| 1922 | break; |
|---|
| 1923 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1924 | { |
|---|
| 1925 | q->red=ScaleCharToQuantum(*p++); |
|---|
| 1926 | q->green=q->red; |
|---|
| 1927 | q->blue=q->red; |
|---|
| 1928 | q++; |
|---|
| 1929 | } |
|---|
| 1930 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 1931 | break; |
|---|
| 1932 | } |
|---|
| 1933 | break; |
|---|
| 1934 | } |
|---|
| 1935 | if (LocaleCompare(map,"RGB") == 0) |
|---|
| 1936 | { |
|---|
| 1937 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1938 | { |
|---|
| 1939 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1940 | if (q == (PixelPacket *) NULL) |
|---|
| 1941 | break; |
|---|
| 1942 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1943 | { |
|---|
| 1944 | q->red=ScaleCharToQuantum(*p++); |
|---|
| 1945 | q->green=ScaleCharToQuantum(*p++); |
|---|
| 1946 | q->blue=ScaleCharToQuantum(*p++); |
|---|
| 1947 | q++; |
|---|
| 1948 | } |
|---|
| 1949 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 1950 | break; |
|---|
| 1951 | } |
|---|
| 1952 | break; |
|---|
| 1953 | } |
|---|
| 1954 | if (LocaleCompare(map,"RGBA") == 0) |
|---|
| 1955 | { |
|---|
| 1956 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1957 | { |
|---|
| 1958 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1959 | if (q == (PixelPacket *) NULL) |
|---|
| 1960 | break; |
|---|
| 1961 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1962 | { |
|---|
| 1963 | q->red=ScaleCharToQuantum(*p++); |
|---|
| 1964 | q->green=ScaleCharToQuantum(*p++); |
|---|
| 1965 | q->blue=ScaleCharToQuantum(*p++); |
|---|
| 1966 | q->opacity=(Quantum) QuantumRange-ScaleCharToQuantum(*p++); |
|---|
| 1967 | q++; |
|---|
| 1968 | } |
|---|
| 1969 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 1970 | break; |
|---|
| 1971 | } |
|---|
| 1972 | break; |
|---|
| 1973 | } |
|---|
| 1974 | if (LocaleCompare(map,"RGBO") == 0) |
|---|
| 1975 | { |
|---|
| 1976 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1977 | { |
|---|
| 1978 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1979 | if (q == (PixelPacket *) NULL) |
|---|
| 1980 | break; |
|---|
| 1981 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 1982 | { |
|---|
| 1983 | q->red=ScaleCharToQuantum(*p++); |
|---|
| 1984 | q->green=ScaleCharToQuantum(*p++); |
|---|
| 1985 | q->blue=ScaleCharToQuantum(*p++); |
|---|
| 1986 | q->opacity=ScaleCharToQuantum(*p++); |
|---|
| 1987 | q++; |
|---|
| 1988 | } |
|---|
| 1989 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 1990 | break; |
|---|
| 1991 | } |
|---|
| 1992 | break; |
|---|
| 1993 | } |
|---|
| 1994 | if (LocaleCompare(map,"RGBP") == 0) |
|---|
| 1995 | { |
|---|
| 1996 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 1997 | { |
|---|
| 1998 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 1999 | if (q == (PixelPacket *) NULL) |
|---|
| 2000 | break; |
|---|
| 2001 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2002 | { |
|---|
| 2003 | q->red=ScaleCharToQuantum(*p++); |
|---|
| 2004 | q->green=ScaleCharToQuantum(*p++); |
|---|
| 2005 | q->blue=ScaleCharToQuantum(*p++); |
|---|
| 2006 | p++; |
|---|
| 2007 | q++; |
|---|
| 2008 | } |
|---|
| 2009 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2010 | break; |
|---|
| 2011 | } |
|---|
| 2012 | break; |
|---|
| 2013 | } |
|---|
| 2014 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2015 | { |
|---|
| 2016 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2017 | if (q == (PixelPacket *) NULL) |
|---|
| 2018 | break; |
|---|
| 2019 | indexes=GetAuthenticIndexQueue(image); |
|---|
| 2020 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2021 | { |
|---|
| 2022 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 2023 | { |
|---|
| 2024 | switch (quantum_map[i]) |
|---|
| 2025 | { |
|---|
| 2026 | case RedQuantum: |
|---|
| 2027 | case CyanQuantum: |
|---|
| 2028 | { |
|---|
| 2029 | q->red=ScaleCharToQuantum(*p); |
|---|
| 2030 | break; |
|---|
| 2031 | } |
|---|
| 2032 | case GreenQuantum: |
|---|
| 2033 | case MagentaQuantum: |
|---|
| 2034 | { |
|---|
| 2035 | q->green=ScaleCharToQuantum(*p); |
|---|
| 2036 | break; |
|---|
| 2037 | } |
|---|
| 2038 | case BlueQuantum: |
|---|
| 2039 | case YellowQuantum: |
|---|
| 2040 | { |
|---|
| 2041 | q->blue=ScaleCharToQuantum(*p); |
|---|
| 2042 | break; |
|---|
| 2043 | } |
|---|
| 2044 | case AlphaQuantum: |
|---|
| 2045 | { |
|---|
| 2046 | q->opacity=(Quantum) QuantumRange-ScaleCharToQuantum(*p); |
|---|
| 2047 | break; |
|---|
| 2048 | } |
|---|
| 2049 | case OpacityQuantum: |
|---|
| 2050 | { |
|---|
| 2051 | q->opacity=ScaleCharToQuantum(*p); |
|---|
| 2052 | break; |
|---|
| 2053 | } |
|---|
| 2054 | case BlackQuantum: |
|---|
| 2055 | { |
|---|
| 2056 | indexes[x]=ScaleCharToQuantum(*p); |
|---|
| 2057 | break; |
|---|
| 2058 | } |
|---|
| 2059 | case IndexQuantum: |
|---|
| 2060 | { |
|---|
| 2061 | q->red=ScaleCharToQuantum(*p); |
|---|
| 2062 | q->green=q->red; |
|---|
| 2063 | q->blue=q->red; |
|---|
| 2064 | break; |
|---|
| 2065 | } |
|---|
| 2066 | default: |
|---|
| 2067 | break; |
|---|
| 2068 | } |
|---|
| 2069 | p++; |
|---|
| 2070 | } |
|---|
| 2071 | q++; |
|---|
| 2072 | } |
|---|
| 2073 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2074 | break; |
|---|
| 2075 | } |
|---|
| 2076 | break; |
|---|
| 2077 | } |
|---|
| 2078 | case DoublePixel: |
|---|
| 2079 | { |
|---|
| 2080 | register const double |
|---|
| 2081 | *p; |
|---|
| 2082 | |
|---|
| 2083 | p=(const double *) pixels; |
|---|
| 2084 | if (LocaleCompare(map,"BGR") == 0) |
|---|
| 2085 | { |
|---|
| 2086 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2087 | { |
|---|
| 2088 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2089 | if (q == (PixelPacket *) NULL) |
|---|
| 2090 | break; |
|---|
| 2091 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2092 | { |
|---|
| 2093 | q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2094 | p++; |
|---|
| 2095 | q->green=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2096 | p++; |
|---|
| 2097 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2098 | p++; |
|---|
| 2099 | q++; |
|---|
| 2100 | } |
|---|
| 2101 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2102 | break; |
|---|
| 2103 | } |
|---|
| 2104 | break; |
|---|
| 2105 | } |
|---|
| 2106 | if (LocaleCompare(map,"BGRA") == 0) |
|---|
| 2107 | { |
|---|
| 2108 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2109 | { |
|---|
| 2110 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2111 | if (q == (PixelPacket *) NULL) |
|---|
| 2112 | break; |
|---|
| 2113 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2114 | { |
|---|
| 2115 | q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2116 | p++; |
|---|
| 2117 | q->green=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2118 | p++; |
|---|
| 2119 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2120 | p++; |
|---|
| 2121 | q->opacity=(Quantum) QuantumRange-ClampToQuantum((MagickRealType) |
|---|
| 2122 | QuantumRange*(*p)); |
|---|
| 2123 | p++; |
|---|
| 2124 | q++; |
|---|
| 2125 | } |
|---|
| 2126 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2127 | break; |
|---|
| 2128 | } |
|---|
| 2129 | break; |
|---|
| 2130 | } |
|---|
| 2131 | if (LocaleCompare(map,"BGRP") == 0) |
|---|
| 2132 | { |
|---|
| 2133 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2134 | { |
|---|
| 2135 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2136 | if (q == (PixelPacket *) NULL) |
|---|
| 2137 | break; |
|---|
| 2138 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2139 | { |
|---|
| 2140 | q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2141 | p++; |
|---|
| 2142 | q->green=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2143 | p++; |
|---|
| 2144 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2145 | p++; |
|---|
| 2146 | p++; |
|---|
| 2147 | q++; |
|---|
| 2148 | } |
|---|
| 2149 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2150 | break; |
|---|
| 2151 | } |
|---|
| 2152 | break; |
|---|
| 2153 | } |
|---|
| 2154 | if (LocaleCompare(map,"I") == 0) |
|---|
| 2155 | { |
|---|
| 2156 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2157 | { |
|---|
| 2158 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2159 | if (q == (PixelPacket *) NULL) |
|---|
| 2160 | break; |
|---|
| 2161 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2162 | { |
|---|
| 2163 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2164 | q->green=q->red; |
|---|
| 2165 | q->blue=q->red; |
|---|
| 2166 | p++; |
|---|
| 2167 | q++; |
|---|
| 2168 | } |
|---|
| 2169 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2170 | break; |
|---|
| 2171 | } |
|---|
| 2172 | break; |
|---|
| 2173 | } |
|---|
| 2174 | if (LocaleCompare(map,"RGB") == 0) |
|---|
| 2175 | { |
|---|
| 2176 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2177 | { |
|---|
| 2178 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2179 | if (q == (PixelPacket *) NULL) |
|---|
| 2180 | break; |
|---|
| 2181 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2182 | { |
|---|
| 2183 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2184 | p++; |
|---|
| 2185 | q->green=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2186 | p++; |
|---|
| 2187 | q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2188 | p++; |
|---|
| 2189 | q++; |
|---|
| 2190 | } |
|---|
| 2191 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2192 | break; |
|---|
| 2193 | } |
|---|
| 2194 | break; |
|---|
| 2195 | } |
|---|
| 2196 | if (LocaleCompare(map,"RGBA") == 0) |
|---|
| 2197 | { |
|---|
| 2198 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2199 | { |
|---|
| 2200 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2201 | if (q == (PixelPacket *) NULL) |
|---|
| 2202 | break; |
|---|
| 2203 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2204 | { |
|---|
| 2205 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2206 | p++; |
|---|
| 2207 | q->green=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2208 | p++; |
|---|
| 2209 | q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2210 | p++; |
|---|
| 2211 | q->opacity=(Quantum) QuantumRange-ClampToQuantum((MagickRealType) |
|---|
| 2212 | QuantumRange*(*p)); |
|---|
| 2213 | p++; |
|---|
| 2214 | q++; |
|---|
| 2215 | } |
|---|
| 2216 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2217 | break; |
|---|
| 2218 | } |
|---|
| 2219 | break; |
|---|
| 2220 | } |
|---|
| 2221 | if (LocaleCompare(map,"RGBP") == 0) |
|---|
| 2222 | { |
|---|
| 2223 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2224 | { |
|---|
| 2225 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2226 | if (q == (PixelPacket *) NULL) |
|---|
| 2227 | break; |
|---|
| 2228 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2229 | { |
|---|
| 2230 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2231 | p++; |
|---|
| 2232 | q->green=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2233 | p++; |
|---|
| 2234 | q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2235 | p++; |
|---|
| 2236 | q++; |
|---|
| 2237 | } |
|---|
| 2238 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2239 | break; |
|---|
| 2240 | } |
|---|
| 2241 | break; |
|---|
| 2242 | } |
|---|
| 2243 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2244 | { |
|---|
| 2245 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2246 | if (q == (PixelPacket *) NULL) |
|---|
| 2247 | break; |
|---|
| 2248 | indexes=GetAuthenticIndexQueue(image); |
|---|
| 2249 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2250 | { |
|---|
| 2251 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 2252 | { |
|---|
| 2253 | switch (quantum_map[i]) |
|---|
| 2254 | { |
|---|
| 2255 | case RedQuantum: |
|---|
| 2256 | case CyanQuantum: |
|---|
| 2257 | { |
|---|
| 2258 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2259 | break; |
|---|
| 2260 | } |
|---|
| 2261 | case GreenQuantum: |
|---|
| 2262 | case MagentaQuantum: |
|---|
| 2263 | { |
|---|
| 2264 | q->green=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2265 | break; |
|---|
| 2266 | } |
|---|
| 2267 | case BlueQuantum: |
|---|
| 2268 | case YellowQuantum: |
|---|
| 2269 | { |
|---|
| 2270 | q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2271 | break; |
|---|
| 2272 | } |
|---|
| 2273 | case AlphaQuantum: |
|---|
| 2274 | { |
|---|
| 2275 | q->opacity=(Quantum) QuantumRange-ClampToQuantum( |
|---|
| 2276 | (MagickRealType) QuantumRange*(*p)); |
|---|
| 2277 | break; |
|---|
| 2278 | } |
|---|
| 2279 | case OpacityQuantum: |
|---|
| 2280 | { |
|---|
| 2281 | q->opacity=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2282 | break; |
|---|
| 2283 | } |
|---|
| 2284 | case BlackQuantum: |
|---|
| 2285 | { |
|---|
| 2286 | indexes[x]=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2287 | break; |
|---|
| 2288 | } |
|---|
| 2289 | case IndexQuantum: |
|---|
| 2290 | { |
|---|
| 2291 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2292 | q->green=q->red; |
|---|
| 2293 | q->blue=q->red; |
|---|
| 2294 | break; |
|---|
| 2295 | } |
|---|
| 2296 | default: |
|---|
| 2297 | break; |
|---|
| 2298 | } |
|---|
| 2299 | p++; |
|---|
| 2300 | } |
|---|
| 2301 | q++; |
|---|
| 2302 | } |
|---|
| 2303 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2304 | break; |
|---|
| 2305 | } |
|---|
| 2306 | break; |
|---|
| 2307 | } |
|---|
| 2308 | case FloatPixel: |
|---|
| 2309 | { |
|---|
| 2310 | register const float |
|---|
| 2311 | *p; |
|---|
| 2312 | |
|---|
| 2313 | p=(const float *) pixels; |
|---|
| 2314 | if (LocaleCompare(map,"BGR") == 0) |
|---|
| 2315 | { |
|---|
| 2316 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2317 | { |
|---|
| 2318 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2319 | if (q == (PixelPacket *) NULL) |
|---|
| 2320 | break; |
|---|
| 2321 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2322 | { |
|---|
| 2323 | q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2324 | p++; |
|---|
| 2325 | q->green=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2326 | p++; |
|---|
| 2327 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2328 | p++; |
|---|
| 2329 | q++; |
|---|
| 2330 | } |
|---|
| 2331 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2332 | break; |
|---|
| 2333 | } |
|---|
| 2334 | break; |
|---|
| 2335 | } |
|---|
| 2336 | if (LocaleCompare(map,"BGRA") == 0) |
|---|
| 2337 | { |
|---|
| 2338 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2339 | { |
|---|
| 2340 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2341 | if (q == (PixelPacket *) NULL) |
|---|
| 2342 | break; |
|---|
| 2343 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2344 | { |
|---|
| 2345 | q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2346 | p++; |
|---|
| 2347 | q->green=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2348 | p++; |
|---|
| 2349 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2350 | p++; |
|---|
| 2351 | q->opacity=(Quantum) QuantumRange-ClampToQuantum((MagickRealType) |
|---|
| 2352 | QuantumRange*(*p)); |
|---|
| 2353 | p++; |
|---|
| 2354 | q++; |
|---|
| 2355 | } |
|---|
| 2356 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2357 | break; |
|---|
| 2358 | } |
|---|
| 2359 | break; |
|---|
| 2360 | } |
|---|
| 2361 | if (LocaleCompare(map,"BGRP") == 0) |
|---|
| 2362 | { |
|---|
| 2363 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2364 | { |
|---|
| 2365 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2366 | if (q == (PixelPacket *) NULL) |
|---|
| 2367 | break; |
|---|
| 2368 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2369 | { |
|---|
| 2370 | q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2371 | p++; |
|---|
| 2372 | q->green=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2373 | p++; |
|---|
| 2374 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2375 | p++; |
|---|
| 2376 | p++; |
|---|
| 2377 | q++; |
|---|
| 2378 | } |
|---|
| 2379 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2380 | break; |
|---|
| 2381 | } |
|---|
| 2382 | break; |
|---|
| 2383 | } |
|---|
| 2384 | if (LocaleCompare(map,"I") == 0) |
|---|
| 2385 | { |
|---|
| 2386 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2387 | { |
|---|
| 2388 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2389 | if (q == (PixelPacket *) NULL) |
|---|
| 2390 | break; |
|---|
| 2391 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2392 | { |
|---|
| 2393 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2394 | q->green=q->red; |
|---|
| 2395 | q->blue=q->red; |
|---|
| 2396 | p++; |
|---|
| 2397 | q++; |
|---|
| 2398 | } |
|---|
| 2399 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2400 | break; |
|---|
| 2401 | } |
|---|
| 2402 | break; |
|---|
| 2403 | } |
|---|
| 2404 | if (LocaleCompare(map,"RGB") == 0) |
|---|
| 2405 | { |
|---|
| 2406 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2407 | { |
|---|
| 2408 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2409 | if (q == (PixelPacket *) NULL) |
|---|
| 2410 | break; |
|---|
| 2411 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2412 | { |
|---|
| 2413 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2414 | p++; |
|---|
| 2415 | q->green=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2416 | p++; |
|---|
| 2417 | q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2418 | p++; |
|---|
| 2419 | q++; |
|---|
| 2420 | } |
|---|
| 2421 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2422 | break; |
|---|
| 2423 | } |
|---|
| 2424 | break; |
|---|
| 2425 | } |
|---|
| 2426 | if (LocaleCompare(map,"RGBA") == 0) |
|---|
| 2427 | { |
|---|
| 2428 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2429 | { |
|---|
| 2430 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2431 | if (q == (PixelPacket *) NULL) |
|---|
| 2432 | break; |
|---|
| 2433 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2434 | { |
|---|
| 2435 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2436 | p++; |
|---|
| 2437 | q->green=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2438 | p++; |
|---|
| 2439 | q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2440 | p++; |
|---|
| 2441 | q->opacity=(Quantum) QuantumRange-ClampToQuantum((MagickRealType) |
|---|
| 2442 | QuantumRange*(*p)); |
|---|
| 2443 | p++; |
|---|
| 2444 | q++; |
|---|
| 2445 | } |
|---|
| 2446 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2447 | break; |
|---|
| 2448 | } |
|---|
| 2449 | break; |
|---|
| 2450 | } |
|---|
| 2451 | if (LocaleCompare(map,"RGBP") == 0) |
|---|
| 2452 | { |
|---|
| 2453 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2454 | { |
|---|
| 2455 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2456 | if (q == (PixelPacket *) NULL) |
|---|
| 2457 | break; |
|---|
| 2458 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2459 | { |
|---|
| 2460 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2461 | p++; |
|---|
| 2462 | q->green=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2463 | p++; |
|---|
| 2464 | q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2465 | p++; |
|---|
| 2466 | q++; |
|---|
| 2467 | } |
|---|
| 2468 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2469 | break; |
|---|
| 2470 | } |
|---|
| 2471 | break; |
|---|
| 2472 | } |
|---|
| 2473 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2474 | { |
|---|
| 2475 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2476 | if (q == (PixelPacket *) NULL) |
|---|
| 2477 | break; |
|---|
| 2478 | indexes=GetAuthenticIndexQueue(image); |
|---|
| 2479 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2480 | { |
|---|
| 2481 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 2482 | { |
|---|
| 2483 | switch (quantum_map[i]) |
|---|
| 2484 | { |
|---|
| 2485 | case RedQuantum: |
|---|
| 2486 | case CyanQuantum: |
|---|
| 2487 | { |
|---|
| 2488 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2489 | break; |
|---|
| 2490 | } |
|---|
| 2491 | case GreenQuantum: |
|---|
| 2492 | case MagentaQuantum: |
|---|
| 2493 | { |
|---|
| 2494 | q->green=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2495 | break; |
|---|
| 2496 | } |
|---|
| 2497 | case BlueQuantum: |
|---|
| 2498 | case YellowQuantum: |
|---|
| 2499 | { |
|---|
| 2500 | q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2501 | break; |
|---|
| 2502 | } |
|---|
| 2503 | case AlphaQuantum: |
|---|
| 2504 | { |
|---|
| 2505 | q->opacity=(Quantum) QuantumRange-ClampToQuantum( |
|---|
| 2506 | (MagickRealType) QuantumRange*(*p)); |
|---|
| 2507 | break; |
|---|
| 2508 | } |
|---|
| 2509 | case OpacityQuantum: |
|---|
| 2510 | { |
|---|
| 2511 | q->opacity=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2512 | break; |
|---|
| 2513 | } |
|---|
| 2514 | case BlackQuantum: |
|---|
| 2515 | { |
|---|
| 2516 | indexes[x]=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2517 | break; |
|---|
| 2518 | } |
|---|
| 2519 | case IndexQuantum: |
|---|
| 2520 | { |
|---|
| 2521 | q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p)); |
|---|
| 2522 | q->green=q->red; |
|---|
| 2523 | q->blue=q->red; |
|---|
| 2524 | break; |
|---|
| 2525 | } |
|---|
| 2526 | default: |
|---|
| 2527 | break; |
|---|
| 2528 | } |
|---|
| 2529 | p++; |
|---|
| 2530 | } |
|---|
| 2531 | q++; |
|---|
| 2532 | } |
|---|
| 2533 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2534 | break; |
|---|
| 2535 | } |
|---|
| 2536 | break; |
|---|
| 2537 | } |
|---|
| 2538 | case IntegerPixel: |
|---|
| 2539 | { |
|---|
| 2540 | register const unsigned int |
|---|
| 2541 | *p; |
|---|
| 2542 | |
|---|
| 2543 | p=(const unsigned int *) pixels; |
|---|
| 2544 | if (LocaleCompare(map,"BGR") == 0) |
|---|
| 2545 | { |
|---|
| 2546 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2547 | { |
|---|
| 2548 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2549 | if (q == (PixelPacket *) NULL) |
|---|
| 2550 | break; |
|---|
| 2551 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2552 | { |
|---|
| 2553 | q->blue=ScaleLongToQuantum(*p++); |
|---|
| 2554 | q->green=ScaleLongToQuantum(*p++); |
|---|
| 2555 | q->red=ScaleLongToQuantum(*p++); |
|---|
| 2556 | q++; |
|---|
| 2557 | } |
|---|
| 2558 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2559 | break; |
|---|
| 2560 | } |
|---|
| 2561 | break; |
|---|
| 2562 | } |
|---|
| 2563 | if (LocaleCompare(map,"BGRA") == 0) |
|---|
| 2564 | { |
|---|
| 2565 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2566 | { |
|---|
| 2567 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2568 | if (q == (PixelPacket *) NULL) |
|---|
| 2569 | break; |
|---|
| 2570 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2571 | { |
|---|
| 2572 | q->blue=ScaleLongToQuantum(*p++); |
|---|
| 2573 | q->green=ScaleLongToQuantum(*p++); |
|---|
| 2574 | q->red=ScaleLongToQuantum(*p++); |
|---|
| 2575 | q->opacity=(Quantum) QuantumRange-ScaleLongToQuantum(*p++); |
|---|
| 2576 | q++; |
|---|
| 2577 | } |
|---|
| 2578 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2579 | break; |
|---|
| 2580 | } |
|---|
| 2581 | break; |
|---|
| 2582 | } |
|---|
| 2583 | if (LocaleCompare(map,"BGRP") == 0) |
|---|
| 2584 | { |
|---|
| 2585 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2586 | { |
|---|
| 2587 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2588 | if (q == (PixelPacket *) NULL) |
|---|
| 2589 | break; |
|---|
| 2590 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2591 | { |
|---|
| 2592 | q->blue=ScaleLongToQuantum(*p++); |
|---|
| 2593 | q->green=ScaleLongToQuantum(*p++); |
|---|
| 2594 | q->red=ScaleLongToQuantum(*p++); |
|---|
| 2595 | p++; |
|---|
| 2596 | q++; |
|---|
| 2597 | } |
|---|
| 2598 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2599 | break; |
|---|
| 2600 | } |
|---|
| 2601 | break; |
|---|
| 2602 | } |
|---|
| 2603 | if (LocaleCompare(map,"I") == 0) |
|---|
| 2604 | { |
|---|
| 2605 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2606 | { |
|---|
| 2607 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2608 | if (q == (PixelPacket *) NULL) |
|---|
| 2609 | break; |
|---|
| 2610 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2611 | { |
|---|
| 2612 | q->red=ScaleLongToQuantum(*p++); |
|---|
| 2613 | q->green=q->red; |
|---|
| 2614 | q->blue=q->red; |
|---|
| 2615 | q++; |
|---|
| 2616 | } |
|---|
| 2617 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2618 | break; |
|---|
| 2619 | } |
|---|
| 2620 | break; |
|---|
| 2621 | } |
|---|
| 2622 | if (LocaleCompare(map,"RGB") == 0) |
|---|
| 2623 | { |
|---|
| 2624 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2625 | { |
|---|
| 2626 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2627 | if (q == (PixelPacket *) NULL) |
|---|
| 2628 | break; |
|---|
| 2629 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2630 | { |
|---|
| 2631 | q->red=ScaleLongToQuantum(*p++); |
|---|
| 2632 | q->green=ScaleLongToQuantum(*p++); |
|---|
| 2633 | q->blue=ScaleLongToQuantum(*p++); |
|---|
| 2634 | q++; |
|---|
| 2635 | } |
|---|
| 2636 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2637 | break; |
|---|
| 2638 | } |
|---|
| 2639 | break; |
|---|
| 2640 | } |
|---|
| 2641 | if (LocaleCompare(map,"RGBA") == 0) |
|---|
| 2642 | { |
|---|
| 2643 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2644 | { |
|---|
| 2645 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2646 | if (q == (PixelPacket *) NULL) |
|---|
| 2647 | break; |
|---|
| 2648 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2649 | { |
|---|
| 2650 | q->red=ScaleLongToQuantum(*p++); |
|---|
| 2651 | q->green=ScaleLongToQuantum(*p++); |
|---|
| 2652 | q->blue=ScaleLongToQuantum(*p++); |
|---|
| 2653 | q->opacity=(Quantum) QuantumRange-ScaleLongToQuantum(*p++); |
|---|
| 2654 | q++; |
|---|
| 2655 | } |
|---|
| 2656 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2657 | break; |
|---|
| 2658 | } |
|---|
| 2659 | break; |
|---|
| 2660 | } |
|---|
| 2661 | if (LocaleCompare(map,"RGBP") == 0) |
|---|
| 2662 | { |
|---|
| 2663 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2664 | { |
|---|
| 2665 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2666 | if (q == (PixelPacket *) NULL) |
|---|
| 2667 | break; |
|---|
| 2668 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2669 | { |
|---|
| 2670 | q->red=ScaleLongToQuantum(*p++); |
|---|
| 2671 | q->green=ScaleLongToQuantum(*p++); |
|---|
| 2672 | q->blue=ScaleLongToQuantum(*p++); |
|---|
| 2673 | p++; |
|---|
| 2674 | q++; |
|---|
| 2675 | } |
|---|
| 2676 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2677 | break; |
|---|
| 2678 | } |
|---|
| 2679 | break; |
|---|
| 2680 | } |
|---|
| 2681 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2682 | { |
|---|
| 2683 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2684 | if (q == (PixelPacket *) NULL) |
|---|
| 2685 | break; |
|---|
| 2686 | indexes=GetAuthenticIndexQueue(image); |
|---|
| 2687 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2688 | { |
|---|
| 2689 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 2690 | { |
|---|
| 2691 | switch (quantum_map[i]) |
|---|
| 2692 | { |
|---|
| 2693 | case RedQuantum: |
|---|
| 2694 | case CyanQuantum: |
|---|
| 2695 | { |
|---|
| 2696 | q->red=ScaleLongToQuantum(*p); |
|---|
| 2697 | break; |
|---|
| 2698 | } |
|---|
| 2699 | case GreenQuantum: |
|---|
| 2700 | case MagentaQuantum: |
|---|
| 2701 | { |
|---|
| 2702 | q->green=ScaleLongToQuantum(*p); |
|---|
| 2703 | break; |
|---|
| 2704 | } |
|---|
| 2705 | case BlueQuantum: |
|---|
| 2706 | case YellowQuantum: |
|---|
| 2707 | { |
|---|
| 2708 | q->blue=ScaleLongToQuantum(*p); |
|---|
| 2709 | break; |
|---|
| 2710 | } |
|---|
| 2711 | case AlphaQuantum: |
|---|
| 2712 | { |
|---|
| 2713 | q->opacity=(Quantum) QuantumRange-ScaleLongToQuantum(*p); |
|---|
| 2714 | break; |
|---|
| 2715 | } |
|---|
| 2716 | case OpacityQuantum: |
|---|
| 2717 | { |
|---|
| 2718 | q->opacity=ScaleLongToQuantum(*p); |
|---|
| 2719 | break; |
|---|
| 2720 | } |
|---|
| 2721 | case BlackQuantum: |
|---|
| 2722 | { |
|---|
| 2723 | indexes[x]=ScaleLongToQuantum(*p); |
|---|
| 2724 | break; |
|---|
| 2725 | } |
|---|
| 2726 | case IndexQuantum: |
|---|
| 2727 | { |
|---|
| 2728 | q->red=ScaleLongToQuantum(*p); |
|---|
| 2729 | q->green=q->red; |
|---|
| 2730 | q->blue=q->red; |
|---|
| 2731 | break; |
|---|
| 2732 | } |
|---|
| 2733 | default: |
|---|
| 2734 | break; |
|---|
| 2735 | } |
|---|
| 2736 | p++; |
|---|
| 2737 | } |
|---|
| 2738 | q++; |
|---|
| 2739 | } |
|---|
| 2740 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2741 | break; |
|---|
| 2742 | } |
|---|
| 2743 | break; |
|---|
| 2744 | } |
|---|
| 2745 | case LongPixel: |
|---|
| 2746 | { |
|---|
| 2747 | register const unsigned int |
|---|
| 2748 | *p; |
|---|
| 2749 | |
|---|
| 2750 | p=(const unsigned int *) pixels; |
|---|
| 2751 | if (LocaleCompare(map,"BGR") == 0) |
|---|
| 2752 | { |
|---|
| 2753 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2754 | { |
|---|
| 2755 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2756 | if (q == (PixelPacket *) NULL) |
|---|
| 2757 | break; |
|---|
| 2758 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2759 | { |
|---|
| 2760 | q->blue=ScaleLongToQuantum(*p++); |
|---|
| 2761 | q->green=ScaleLongToQuantum(*p++); |
|---|
| 2762 | q->red=ScaleLongToQuantum(*p++); |
|---|
| 2763 | q++; |
|---|
| 2764 | } |
|---|
| 2765 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2766 | break; |
|---|
| 2767 | } |
|---|
| 2768 | break; |
|---|
| 2769 | } |
|---|
| 2770 | if (LocaleCompare(map,"BGRA") == 0) |
|---|
| 2771 | { |
|---|
| 2772 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2773 | { |
|---|
| 2774 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2775 | if (q == (PixelPacket *) NULL) |
|---|
| 2776 | break; |
|---|
| 2777 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2778 | { |
|---|
| 2779 | q->blue=ScaleLongToQuantum(*p++); |
|---|
| 2780 | q->green=ScaleLongToQuantum(*p++); |
|---|
| 2781 | q->red=ScaleLongToQuantum(*p++); |
|---|
| 2782 | q->opacity=(Quantum) QuantumRange-ScaleLongToQuantum(*p++); |
|---|
| 2783 | q++; |
|---|
| 2784 | } |
|---|
| 2785 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2786 | break; |
|---|
| 2787 | } |
|---|
| 2788 | break; |
|---|
| 2789 | } |
|---|
| 2790 | if (LocaleCompare(map,"BGRP") == 0) |
|---|
| 2791 | { |
|---|
| 2792 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2793 | { |
|---|
| 2794 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2795 | if (q == (PixelPacket *) NULL) |
|---|
| 2796 | break; |
|---|
| 2797 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2798 | { |
|---|
| 2799 | q->blue=ScaleLongToQuantum(*p++); |
|---|
| 2800 | q->green=ScaleLongToQuantum(*p++); |
|---|
| 2801 | q->red=ScaleLongToQuantum(*p++); |
|---|
| 2802 | p++; |
|---|
| 2803 | q++; |
|---|
| 2804 | } |
|---|
| 2805 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2806 | break; |
|---|
| 2807 | } |
|---|
| 2808 | break; |
|---|
| 2809 | } |
|---|
| 2810 | if (LocaleCompare(map,"I") == 0) |
|---|
| 2811 | { |
|---|
| 2812 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2813 | { |
|---|
| 2814 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2815 | if (q == (PixelPacket *) NULL) |
|---|
| 2816 | break; |
|---|
| 2817 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2818 | { |
|---|
| 2819 | q->red=ScaleLongToQuantum(*p++); |
|---|
| 2820 | q->green=q->red; |
|---|
| 2821 | q->blue=q->red; |
|---|
| 2822 | q++; |
|---|
| 2823 | } |
|---|
| 2824 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2825 | break; |
|---|
| 2826 | } |
|---|
| 2827 | break; |
|---|
| 2828 | } |
|---|
| 2829 | if (LocaleCompare(map,"RGB") == 0) |
|---|
| 2830 | { |
|---|
| 2831 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2832 | { |
|---|
| 2833 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2834 | if (q == (PixelPacket *) NULL) |
|---|
| 2835 | break; |
|---|
| 2836 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2837 | { |
|---|
| 2838 | q->red=ScaleLongToQuantum(*p++); |
|---|
| 2839 | q->green=ScaleLongToQuantum(*p++); |
|---|
| 2840 | q->blue=ScaleLongToQuantum(*p++); |
|---|
| 2841 | q++; |
|---|
| 2842 | } |
|---|
| 2843 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2844 | break; |
|---|
| 2845 | } |
|---|
| 2846 | break; |
|---|
| 2847 | } |
|---|
| 2848 | if (LocaleCompare(map,"RGBA") == 0) |
|---|
| 2849 | { |
|---|
| 2850 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2851 | { |
|---|
| 2852 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2853 | if (q == (PixelPacket *) NULL) |
|---|
| 2854 | break; |
|---|
| 2855 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2856 | { |
|---|
| 2857 | q->red=ScaleLongToQuantum(*p++); |
|---|
| 2858 | q->green=ScaleLongToQuantum(*p++); |
|---|
| 2859 | q->blue=ScaleLongToQuantum(*p++); |
|---|
| 2860 | q->opacity=(Quantum) QuantumRange-ScaleLongToQuantum(*p++); |
|---|
| 2861 | q++; |
|---|
| 2862 | } |
|---|
| 2863 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2864 | break; |
|---|
| 2865 | } |
|---|
| 2866 | break; |
|---|
| 2867 | } |
|---|
| 2868 | if (LocaleCompare(map,"RGBP") == 0) |
|---|
| 2869 | { |
|---|
| 2870 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2871 | { |
|---|
| 2872 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2873 | if (q == (PixelPacket *) NULL) |
|---|
| 2874 | break; |
|---|
| 2875 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2876 | { |
|---|
| 2877 | q->red=ScaleLongToQuantum(*p++); |
|---|
| 2878 | q->green=ScaleLongToQuantum(*p++); |
|---|
| 2879 | q->blue=ScaleLongToQuantum(*p++); |
|---|
| 2880 | p++; |
|---|
| 2881 | q++; |
|---|
| 2882 | } |
|---|
| 2883 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2884 | break; |
|---|
| 2885 | } |
|---|
| 2886 | break; |
|---|
| 2887 | } |
|---|
| 2888 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2889 | { |
|---|
| 2890 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2891 | if (q == (PixelPacket *) NULL) |
|---|
| 2892 | break; |
|---|
| 2893 | indexes=GetAuthenticIndexQueue(image); |
|---|
| 2894 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2895 | { |
|---|
| 2896 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 2897 | { |
|---|
| 2898 | switch (quantum_map[i]) |
|---|
| 2899 | { |
|---|
| 2900 | case RedQuantum: |
|---|
| 2901 | case CyanQuantum: |
|---|
| 2902 | { |
|---|
| 2903 | q->red=ScaleLongToQuantum(*p); |
|---|
| 2904 | break; |
|---|
| 2905 | } |
|---|
| 2906 | case GreenQuantum: |
|---|
| 2907 | case MagentaQuantum: |
|---|
| 2908 | { |
|---|
| 2909 | q->green=ScaleLongToQuantum(*p); |
|---|
| 2910 | break; |
|---|
| 2911 | } |
|---|
| 2912 | case BlueQuantum: |
|---|
| 2913 | case YellowQuantum: |
|---|
| 2914 | { |
|---|
| 2915 | q->blue=ScaleLongToQuantum(*p); |
|---|
| 2916 | break; |
|---|
| 2917 | } |
|---|
| 2918 | case AlphaQuantum: |
|---|
| 2919 | { |
|---|
| 2920 | q->opacity=(Quantum) QuantumRange-ScaleLongToQuantum(*p); |
|---|
| 2921 | break; |
|---|
| 2922 | } |
|---|
| 2923 | case OpacityQuantum: |
|---|
| 2924 | { |
|---|
| 2925 | q->opacity=ScaleLongToQuantum(*p); |
|---|
| 2926 | break; |
|---|
| 2927 | } |
|---|
| 2928 | case BlackQuantum: |
|---|
| 2929 | { |
|---|
| 2930 | indexes[x]=ScaleLongToQuantum(*p); |
|---|
| 2931 | break; |
|---|
| 2932 | } |
|---|
| 2933 | case IndexQuantum: |
|---|
| 2934 | { |
|---|
| 2935 | q->red=ScaleLongToQuantum(*p); |
|---|
| 2936 | q->green=q->red; |
|---|
| 2937 | q->blue=q->red; |
|---|
| 2938 | break; |
|---|
| 2939 | } |
|---|
| 2940 | default: |
|---|
| 2941 | break; |
|---|
| 2942 | } |
|---|
| 2943 | p++; |
|---|
| 2944 | } |
|---|
| 2945 | q++; |
|---|
| 2946 | } |
|---|
| 2947 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2948 | break; |
|---|
| 2949 | } |
|---|
| 2950 | break; |
|---|
| 2951 | } |
|---|
| 2952 | case QuantumPixel: |
|---|
| 2953 | { |
|---|
| 2954 | register const Quantum |
|---|
| 2955 | *p; |
|---|
| 2956 | |
|---|
| 2957 | p=(const Quantum *) pixels; |
|---|
| 2958 | if (LocaleCompare(map,"BGR") == 0) |
|---|
| 2959 | { |
|---|
| 2960 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2961 | { |
|---|
| 2962 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2963 | if (q == (PixelPacket *) NULL) |
|---|
| 2964 | break; |
|---|
| 2965 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2966 | { |
|---|
| 2967 | q->blue=(*p++); |
|---|
| 2968 | q->green=(*p++); |
|---|
| 2969 | q->red=(*p++); |
|---|
| 2970 | q++; |
|---|
| 2971 | } |
|---|
| 2972 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2973 | break; |
|---|
| 2974 | } |
|---|
| 2975 | break; |
|---|
| 2976 | } |
|---|
| 2977 | if (LocaleCompare(map,"BGRA") == 0) |
|---|
| 2978 | { |
|---|
| 2979 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 2980 | { |
|---|
| 2981 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 2982 | if (q == (PixelPacket *) NULL) |
|---|
| 2983 | break; |
|---|
| 2984 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 2985 | { |
|---|
| 2986 | q->blue=(*p++); |
|---|
| 2987 | q->green=(*p++); |
|---|
| 2988 | q->red=(*p++); |
|---|
| 2989 | q->opacity=(Quantum) QuantumRange-(*p++); |
|---|
| 2990 | q++; |
|---|
| 2991 | } |
|---|
| 2992 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 2993 | break; |
|---|
| 2994 | } |
|---|
| 2995 | break; |
|---|
| 2996 | } |
|---|
| 2997 | if (LocaleCompare(map,"BGRP") == 0) |
|---|
| 2998 | { |
|---|
| 2999 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 3000 | { |
|---|
| 3001 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 3002 | if (q == (PixelPacket *) NULL) |
|---|
| 3003 | break; |
|---|
| 3004 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 3005 | { |
|---|
| 3006 | q->blue=(*p++); |
|---|
| 3007 | q->green=(*p++); |
|---|
| 3008 | q->red=(*p++); |
|---|
| 3009 | p++; |
|---|
| 3010 | q++; |
|---|
| 3011 | } |
|---|
| 3012 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 3013 | break; |
|---|
| 3014 | } |
|---|
| 3015 | break; |
|---|
| 3016 | } |
|---|
| 3017 | if (LocaleCompare(map,"I") == 0) |
|---|
| 3018 | { |
|---|
| 3019 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 3020 | { |
|---|
| 3021 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 3022 | if (q == (PixelPacket *) NULL) |
|---|
| 3023 | break; |
|---|
| 3024 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 3025 | { |
|---|
| 3026 | q->red=(*p++); |
|---|
| 3027 | q->green=q->red; |
|---|
| 3028 | q->blue=q->red; |
|---|
| 3029 | q++; |
|---|
| 3030 | } |
|---|
| 3031 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 3032 | break; |
|---|
| 3033 | } |
|---|
| 3034 | break; |
|---|
| 3035 | } |
|---|
| 3036 | if (LocaleCompare(map,"RGB") == 0) |
|---|
| 3037 | { |
|---|
| 3038 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 3039 | { |
|---|
| 3040 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 3041 | if (q == (PixelPacket *) NULL) |
|---|
| 3042 | break; |
|---|
| 3043 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 3044 | { |
|---|
| 3045 | q->red=(*p++); |
|---|
| 3046 | q->green=(*p++); |
|---|
| 3047 | q->blue=(*p++); |
|---|
| 3048 | q++; |
|---|
| 3049 | } |
|---|
| 3050 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 3051 | break; |
|---|
| 3052 | } |
|---|
| 3053 | break; |
|---|
| 3054 | } |
|---|
| 3055 | if (LocaleCompare(map,"RGBA") == 0) |
|---|
| 3056 | { |
|---|
| 3057 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 3058 | { |
|---|
| 3059 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 3060 | if (q == (PixelPacket *) NULL) |
|---|
| 3061 | break; |
|---|
| 3062 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 3063 | { |
|---|
| 3064 | q->red=(*p++); |
|---|
| 3065 | q->green=(*p++); |
|---|
| 3066 | q->blue=(*p++); |
|---|
| 3067 | q->opacity=(Quantum) QuantumRange-(*p++); |
|---|
| 3068 | q++; |
|---|
| 3069 | } |
|---|
| 3070 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 3071 | break; |
|---|
| 3072 | } |
|---|
| 3073 | break; |
|---|
| 3074 | } |
|---|
| 3075 | if (LocaleCompare(map,"RGBP") == 0) |
|---|
| 3076 | { |
|---|
| 3077 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 3078 | { |
|---|
| 3079 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 3080 | if (q == (PixelPacket *) NULL) |
|---|
| 3081 | break; |
|---|
| 3082 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 3083 | { |
|---|
| 3084 | q->red=(*p++); |
|---|
| 3085 | q->green=(*p++); |
|---|
| 3086 | q->blue=(*p++); |
|---|
| 3087 | p++; |
|---|
| 3088 | q++; |
|---|
| 3089 | } |
|---|
| 3090 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 3091 | break; |
|---|
| 3092 | } |
|---|
| 3093 | break; |
|---|
| 3094 | } |
|---|
| 3095 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 3096 | { |
|---|
| 3097 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 3098 | if (q == (PixelPacket *) NULL) |
|---|
| 3099 | break; |
|---|
| 3100 | indexes=GetAuthenticIndexQueue(image); |
|---|
| 3101 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 3102 | { |
|---|
| 3103 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 3104 | { |
|---|
| 3105 | switch (quantum_map[i]) |
|---|
| 3106 | { |
|---|
| 3107 | case RedQuantum: |
|---|
| 3108 | case CyanQuantum: |
|---|
| 3109 | { |
|---|
| 3110 | q->red=(*p); |
|---|
| 3111 | break; |
|---|
| 3112 | } |
|---|
| 3113 | case GreenQuantum: |
|---|
| 3114 | case MagentaQuantum: |
|---|
| 3115 | { |
|---|
| 3116 | q->green=(*p); |
|---|
| 3117 | break; |
|---|
| 3118 | } |
|---|
| 3119 | case BlueQuantum: |
|---|
| 3120 | case YellowQuantum: |
|---|
| 3121 | { |
|---|
| 3122 | q->blue=(*p); |
|---|
| 3123 | break; |
|---|
| 3124 | } |
|---|
| 3125 | case AlphaQuantum: |
|---|
| 3126 | { |
|---|
| 3127 | q->opacity=(Quantum) QuantumRange-(*p); |
|---|
| 3128 | break; |
|---|
| 3129 | } |
|---|
| 3130 | case OpacityQuantum: |
|---|
| 3131 | { |
|---|
| 3132 | q->opacity=(*p); |
|---|
| 3133 | break; |
|---|
| 3134 | } |
|---|
| 3135 | case BlackQuantum: |
|---|
| 3136 | { |
|---|
| 3137 | indexes[x]=(*p); |
|---|
| 3138 | break; |
|---|
| 3139 | } |
|---|
| 3140 | case IndexQuantum: |
|---|
| 3141 | { |
|---|
| 3142 | q->red=(*p); |
|---|
| 3143 | q->green=q->red; |
|---|
| 3144 | q->blue=q->red; |
|---|
| 3145 | break; |
|---|
| 3146 | } |
|---|
| 3147 | default: |
|---|
| 3148 | break; |
|---|
| 3149 | } |
|---|
| 3150 | p++; |
|---|
| 3151 | } |
|---|
| 3152 | q++; |
|---|
| 3153 | } |
|---|
| 3154 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 3155 | break; |
|---|
| 3156 | } |
|---|
| 3157 | break; |
|---|
| 3158 | } |
|---|
| 3159 | case ShortPixel: |
|---|
| 3160 | { |
|---|
| 3161 | register const unsigned short |
|---|
| 3162 | *p; |
|---|
| 3163 | |
|---|
| 3164 | p=(const unsigned short *) pixels; |
|---|
| 3165 | if (LocaleCompare(map,"BGR") == 0) |
|---|
| 3166 | { |
|---|
| 3167 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 3168 | { |
|---|
| 3169 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 3170 | if (q == (PixelPacket *) NULL) |
|---|
| 3171 | break; |
|---|
| 3172 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 3173 | { |
|---|
| 3174 | q->blue=ScaleShortToQuantum(*p++); |
|---|
| 3175 | q->green=ScaleShortToQuantum(*p++); |
|---|
| 3176 | q->red=ScaleShortToQuantum(*p++); |
|---|
| 3177 | q++; |
|---|
| 3178 | } |
|---|
| 3179 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 3180 | break; |
|---|
| 3181 | } |
|---|
| 3182 | break; |
|---|
| 3183 | } |
|---|
| 3184 | if (LocaleCompare(map,"BGRA") == 0) |
|---|
| 3185 | { |
|---|
| 3186 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 3187 | { |
|---|
| 3188 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 3189 | if (q == (PixelPacket *) NULL) |
|---|
| 3190 | break; |
|---|
| 3191 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 3192 | { |
|---|
| 3193 | q->blue=ScaleShortToQuantum(*p++); |
|---|
| 3194 | q->green=ScaleShortToQuantum(*p++); |
|---|
| 3195 | q->red=ScaleShortToQuantum(*p++); |
|---|
| 3196 | q->opacity=(Quantum) QuantumRange-ScaleShortToQuantum(*p++); |
|---|
| 3197 | q++; |
|---|
| 3198 | } |
|---|
| 3199 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 3200 | break; |
|---|
| 3201 | } |
|---|
| 3202 | break; |
|---|
| 3203 | } |
|---|
| 3204 | if (LocaleCompare(map,"BGRP") == 0) |
|---|
| 3205 | { |
|---|
| 3206 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 3207 | { |
|---|
| 3208 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 3209 | if (q == (PixelPacket *) NULL) |
|---|
| 3210 | break; |
|---|
| 3211 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 3212 | { |
|---|
| 3213 | q->blue=ScaleShortToQuantum(*p++); |
|---|
| 3214 | q->green=ScaleShortToQuantum(*p++); |
|---|
| 3215 | q->red=ScaleShortToQuantum(*p++); |
|---|
| 3216 | p++; |
|---|
| 3217 | q++; |
|---|
| 3218 | } |
|---|
| 3219 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 3220 | break; |
|---|
| 3221 | } |
|---|
| 3222 | break; |
|---|
| 3223 | } |
|---|
| 3224 | if (LocaleCompare(map,"I") == 0) |
|---|
| 3225 | { |
|---|
| 3226 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 3227 | { |
|---|
| 3228 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 3229 | if (q == (PixelPacket *) NULL) |
|---|
| 3230 | break; |
|---|
| 3231 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 3232 | { |
|---|
| 3233 | q->red=ScaleShortToQuantum(*p++); |
|---|
| 3234 | q->green=q->red; |
|---|
| 3235 | q->blue=q->red; |
|---|
| 3236 | q++; |
|---|
| 3237 | } |
|---|
| 3238 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 3239 | break; |
|---|
| 3240 | } |
|---|
| 3241 | break; |
|---|
| 3242 | } |
|---|
| 3243 | if (LocaleCompare(map,"RGB") == 0) |
|---|
| 3244 | { |
|---|
| 3245 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 3246 | { |
|---|
| 3247 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 3248 | if (q == (PixelPacket *) NULL) |
|---|
| 3249 | break; |
|---|
| 3250 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 3251 | { |
|---|
| 3252 | q->red=ScaleShortToQuantum(*p++); |
|---|
| 3253 | q->green=ScaleShortToQuantum(*p++); |
|---|
| 3254 | q->blue=ScaleShortToQuantum(*p++); |
|---|
| 3255 | q++; |
|---|
| 3256 | } |
|---|
| 3257 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 3258 | break; |
|---|
| 3259 | } |
|---|
| 3260 | break; |
|---|
| 3261 | } |
|---|
| 3262 | if (LocaleCompare(map,"RGBA") == 0) |
|---|
| 3263 | { |
|---|
| 3264 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 3265 | { |
|---|
| 3266 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 3267 | if (q == (PixelPacket *) NULL) |
|---|
| 3268 | break; |
|---|
| 3269 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 3270 | { |
|---|
| 3271 | q->red=ScaleShortToQuantum(*p++); |
|---|
| 3272 | q->green=ScaleShortToQuantum(*p++); |
|---|
| 3273 | q->blue=ScaleShortToQuantum(*p++); |
|---|
| 3274 | q->opacity=(Quantum) QuantumRange-ScaleShortToQuantum(*p++); |
|---|
| 3275 | q++; |
|---|
| 3276 | } |
|---|
| 3277 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 3278 | break; |
|---|
| 3279 | } |
|---|
| 3280 | break; |
|---|
| 3281 | } |
|---|
| 3282 | if (LocaleCompare(map,"RGBP") == 0) |
|---|
| 3283 | { |
|---|
| 3284 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 3285 | { |
|---|
| 3286 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 3287 | if (q == (PixelPacket *) NULL) |
|---|
| 3288 | break; |
|---|
| 3289 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 3290 | { |
|---|
| 3291 | q->red=ScaleShortToQuantum(*p++); |
|---|
| 3292 | q->green=ScaleShortToQuantum(*p++); |
|---|
| 3293 | q->blue=ScaleShortToQuantum(*p++); |
|---|
| 3294 | p++; |
|---|
| 3295 | q++; |
|---|
| 3296 | } |
|---|
| 3297 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 3298 | break; |
|---|
| 3299 | } |
|---|
| 3300 | break; |
|---|
| 3301 | } |
|---|
| 3302 | for (y=0; y < (ssize_t) rows; y++) |
|---|
| 3303 | { |
|---|
| 3304 | q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception); |
|---|
| 3305 | if (q == (PixelPacket *) NULL) |
|---|
| 3306 | break; |
|---|
| 3307 | indexes=GetAuthenticIndexQueue(image); |
|---|
| 3308 | for (x=0; x < (ssize_t) columns; x++) |
|---|
| 3309 | { |
|---|
| 3310 | for (i=0; i < (ssize_t) length; i++) |
|---|
| 3311 | { |
|---|
| 3312 | switch (quantum_map[i]) |
|---|
| 3313 | { |
|---|
| 3314 | case RedQuantum: |
|---|
| 3315 | case CyanQuantum: |
|---|
| 3316 | { |
|---|
| 3317 | q->red=ScaleShortToQuantum(*p); |
|---|
| 3318 | break; |
|---|
| 3319 | } |
|---|
| 3320 | case GreenQuantum: |
|---|
| 3321 | case MagentaQuantum: |
|---|
| 3322 | { |
|---|
| 3323 | q->green=ScaleShortToQuantum(*p); |
|---|
| 3324 | break; |
|---|
| 3325 | } |
|---|
| 3326 | case BlueQuantum: |
|---|
| 3327 | case YellowQuantum: |
|---|
| 3328 | { |
|---|
| 3329 | q->blue=ScaleShortToQuantum(*p); |
|---|
| 3330 | break; |
|---|
| 3331 | } |
|---|
| 3332 | case AlphaQuantum: |
|---|
| 3333 | { |
|---|
| 3334 | q->opacity=(Quantum) QuantumRange-ScaleShortToQuantum(*p); |
|---|
| 3335 | break; |
|---|
| 3336 | } |
|---|
| 3337 | case OpacityQuantum: |
|---|
| 3338 | { |
|---|
| 3339 | q->opacity=ScaleShortToQuantum(*p); |
|---|
| 3340 | break; |
|---|
| 3341 | } |
|---|
| 3342 | case BlackQuantum: |
|---|
| 3343 | { |
|---|
| 3344 | indexes[x]=ScaleShortToQuantum(*p); |
|---|
| 3345 | break; |
|---|
| 3346 | } |
|---|
| 3347 | case IndexQuantum: |
|---|
| 3348 | { |
|---|
| 3349 | q->red=ScaleShortToQuantum(*p); |
|---|
| 3350 | q->green=q->red; |
|---|
| 3351 | q->blue=q->red; |
|---|
| 3352 | break; |
|---|
| 3353 | } |
|---|
| 3354 | default: |
|---|
| 3355 | break; |
|---|
| 3356 | } |
|---|
| 3357 | p++; |
|---|
| 3358 | } |
|---|
| 3359 | q++; |
|---|
| 3360 | } |
|---|
| 3361 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
|---|
| 3362 | break; |
|---|
| 3363 | } |
|---|
| 3364 | break; |
|---|
| 3365 | } |
|---|
| 3366 | default: |
|---|
| 3367 | { |
|---|
| 3368 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
|---|
| 3369 | (void) ThrowMagickException(&image->exception,GetMagickModule(), |
|---|
| 3370 | OptionError,"UnrecognizedPixelMap","`%s'",map); |
|---|
| 3371 | break; |
|---|
| 3372 | } |
|---|
| 3373 | } |
|---|
| 3374 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
|---|
| 3375 | return(MagickTrue); |
|---|
| 3376 | } |
|---|
| 3377 | |
|---|
| 3378 | /* |
|---|
| 3379 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 3380 | % % |
|---|
| 3381 | % % |
|---|
| 3382 | % % |
|---|
| 3383 | % I n t e r p o l a t e M a g i c k P i x e l P a c k e t % |
|---|
| 3384 | % % |
|---|
| 3385 | % % |
|---|
| 3386 | % % |
|---|
| 3387 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 3388 | % |
|---|
| 3389 | % InterpolateMagickPixelPacket() applies bi-linear or tri-linear interpolation |
|---|
| 3390 | % between a floating point coordinate and the pixels surrounding that |
|---|
| 3391 | % coordinate. No pixel area resampling, or scaling of the result is |
|---|
| 3392 | % performed. |
|---|
| 3393 | % |
|---|
| 3394 | % The format of the InterpolateMagickPixelPacket method is: |
|---|
| 3395 | % |
|---|
| 3396 | % MagickBooleanType InterpolateMagickPixelPacket(const Image *image, |
|---|
| 3397 | % const CacheView *image_view,const InterpolatePixelMethod method, |
|---|
| 3398 | % const double x,const double y,MagickPixelPacket *pixel, |
|---|
| 3399 | % ExceptionInfo *exception) |
|---|
| 3400 | % |
|---|
| 3401 | % A description of each parameter follows: |
|---|
| 3402 | % |
|---|
| 3403 | % o image: the image. |
|---|
| 3404 | % |
|---|
| 3405 | % o image_view: the image view. |
|---|
| 3406 | % |
|---|
| 3407 | % o method: the pixel color interpolation method. |
|---|
| 3408 | % |
|---|
| 3409 | % o x,y: A double representing the current (x,y) position of the pixel. |
|---|
| 3410 | % |
|---|
| 3411 | % o pixel: return the interpolated pixel here. |
|---|
| 3412 | % |
|---|
| 3413 | % o exception: return any errors or warnings in this structure. |
|---|
| 3414 | % |
|---|
| 3415 | */ |
|---|
| 3416 | |
|---|
| 3417 | static inline void AlphaBlendMagickPixelPacket(const Image *image, |
|---|
| 3418 | const PixelPacket *color,const IndexPacket *index,MagickPixelPacket *pixel, |
|---|
| 3419 | MagickRealType *alpha) |
|---|
| 3420 | { |
|---|
| 3421 | if (image->matte == MagickFalse) |
|---|
| 3422 | { |
|---|
| 3423 | *alpha=1.0; |
|---|
| 3424 | pixel->red=(MagickRealType) color->red; |
|---|
| 3425 | pixel->green=(MagickRealType) color->green; |
|---|
| 3426 | pixel->blue=(MagickRealType) color->blue; |
|---|
| 3427 | pixel->opacity=(MagickRealType) color->opacity; |
|---|
| 3428 | pixel->index=0.0; |
|---|
| 3429 | if (((image->colorspace == CMYKColorspace) || |
|---|
| 3430 | (image->storage_class == PseudoClass)) && |
|---|
| 3431 | (index != (const IndexPacket *) NULL)) |
|---|
| 3432 | pixel->index=(MagickRealType) *index; |
|---|
| 3433 | return; |
|---|
| 3434 | } |
|---|
| 3435 | *alpha=QuantumScale*GetAlphaPixelComponent(color); |
|---|
| 3436 | pixel->red=(MagickRealType) (*alpha*color->red); |
|---|
| 3437 | pixel->green=(MagickRealType) (*alpha*color->green); |
|---|
| 3438 | pixel->blue=(MagickRealType) (*alpha*color->blue); |
|---|
| 3439 | pixel->opacity=(MagickRealType) (*alpha*color->opacity); |
|---|
| 3440 | pixel->index=0.0; |
|---|
| 3441 | if (((image->colorspace == CMYKColorspace) || |
|---|
| 3442 | (image->storage_class == PseudoClass)) && |
|---|
| 3443 | (index != (const IndexPacket *) NULL)) |
|---|
| 3444 | pixel->index=(MagickRealType) (*alpha*(*index)); |
|---|
| 3445 | } |
|---|
| 3446 | |
|---|
| 3447 | static void BicubicInterpolate(const MagickPixelPacket *pixels,const double dx, |
|---|
| 3448 | MagickPixelPacket *pixel) |
|---|
| 3449 | { |
|---|
| 3450 | MagickRealType |
|---|
| 3451 | dx2, |
|---|
| 3452 | p, |
|---|
| 3453 | q, |
|---|
| 3454 | r, |
|---|
| 3455 | s; |
|---|
| 3456 | |
|---|
| 3457 | dx2=dx*dx; |
|---|
| 3458 | p=(pixels[3].red-pixels[2].red)-(pixels[0].red-pixels[1].red); |
|---|
| 3459 | q=(pixels[0].red-pixels[1].red)-p; |
|---|
| 3460 | r=pixels[2].red-pixels[0].red; |
|---|
| 3461 | s=pixels[1].red; |
|---|
| 3462 | pixel->red=(dx*dx2*p)+(dx2*q)+(dx*r)+s; |
|---|
| 3463 | p=(pixels[3].green-pixels[2].green)-(pixels[0].green-pixels[1].green); |
|---|
| 3464 | q=(pixels[0].green-pixels[1].green)-p; |
|---|
| 3465 | r=pixels[2].green-pixels[0].green; |
|---|
| 3466 | s=pixels[1].green; |
|---|
| 3467 | pixel->green=(dx*dx2*p)+(dx2*q)+(dx*r)+s; |
|---|
| 3468 | p=(pixels[3].blue-pixels[2].blue)-(pixels[0].blue-pixels[1].blue); |
|---|
| 3469 | q=(pixels[0].blue-pixels[1].blue)-p; |
|---|
| 3470 | r=pixels[2].blue-pixels[0].blue; |
|---|
| 3471 | s=pixels[1].blue; |
|---|
| 3472 | pixel->blue=(dx*dx2*p)+(dx2*q)+(dx*r)+s; |
|---|
| 3473 | p=(pixels[3].opacity-pixels[2].opacity)-(pixels[0].opacity-pixels[1].opacity); |
|---|
| 3474 | q=(pixels[0].opacity-pixels[1].opacity)-p; |
|---|
| 3475 | r=pixels[2].opacity-pixels[0].opacity; |
|---|
| 3476 | s=pixels[1].opacity; |
|---|
| 3477 | pixel->opacity=(dx*dx2*p)+(dx2*q)+(dx*r)+s; |
|---|
| 3478 | if (pixel->colorspace == CMYKColorspace) |
|---|
| 3479 | { |
|---|
| 3480 | p=(pixels[3].index-pixels[2].index)-(pixels[0].index-pixels[1].index); |
|---|
| 3481 | q=(pixels[0].index-pixels[1].index)-p; |
|---|
| 3482 | r=pixels[2].index-pixels[0].index; |
|---|
| 3483 | s=pixels[1].index; |
|---|
| 3484 | pixel->index=(dx*dx2*p)+(dx2*q)+(dx*r)+s; |
|---|
| 3485 | } |
|---|
| 3486 | } |
|---|
| 3487 | |
|---|
| 3488 | static inline double MagickMax(const MagickRealType x,const MagickRealType y) |
|---|
| 3489 | { |
|---|
| 3490 | if (x > y) |
|---|
| 3491 | return(x); |
|---|
| 3492 | return(y); |
|---|
| 3493 | } |
|---|
| 3494 | |
|---|
| 3495 | static inline MagickRealType CubicWeightingFunction(const MagickRealType x) |
|---|
| 3496 | { |
|---|
| 3497 | MagickRealType |
|---|
| 3498 | alpha, |
|---|
| 3499 | gamma; |
|---|
| 3500 | |
|---|
| 3501 | alpha=MagickMax(x+2.0,0.0); |
|---|
| 3502 | gamma=1.0*alpha*alpha*alpha; |
|---|
| 3503 | alpha=MagickMax(x+1.0,0.0); |
|---|
| 3504 | gamma-=4.0*alpha*alpha*alpha; |
|---|
| 3505 | alpha=MagickMax(x+0.0,0.0); |
|---|
| 3506 | gamma+=6.0*alpha*alpha*alpha; |
|---|
| 3507 | alpha=MagickMax(x-1.0,0.0); |
|---|
| 3508 | gamma-=4.0*alpha*alpha*alpha; |
|---|
| 3509 | return(gamma/6.0); |
|---|
| 3510 | } |
|---|
| 3511 | |
|---|
| 3512 | static inline double MeshInterpolate(const PointInfo *delta,const double p, |
|---|
| 3513 | const double x,const double y) |
|---|
| 3514 | { |
|---|
| 3515 | return(delta->x*x+delta->y*y+(1.0-delta->x-delta->y)*p); |
|---|
| 3516 | } |
|---|
| 3517 | |
|---|
| 3518 | static inline ssize_t NearestNeighbor(const MagickRealType x) |
|---|
| 3519 | { |
|---|
| 3520 | if (x >= 0.0) |
|---|
| 3521 | return((ssize_t) (x+0.5)); |
|---|
| 3522 | return((ssize_t) (x-0.5)); |
|---|
| 3523 | } |
|---|
| 3524 | |
|---|
| 3525 | MagickExport MagickBooleanType InterpolateMagickPixelPacket(const Image *image, |
|---|
| 3526 | const CacheView *image_view,const InterpolatePixelMethod method, |
|---|
| 3527 | const double x,const double y,MagickPixelPacket *pixel, |
|---|
| 3528 | ExceptionInfo *exception) |
|---|
| 3529 | { |
|---|
| 3530 | MagickBooleanType |
|---|
| 3531 | status; |
|---|
| 3532 | |
|---|
| 3533 | MagickPixelPacket |
|---|
| 3534 | pixels[16]; |
|---|
| 3535 | |
|---|
| 3536 | MagickRealType |
|---|
| 3537 | alpha[16], |
|---|
| 3538 | gamma; |
|---|
| 3539 | |
|---|
| 3540 | register const IndexPacket |
|---|
| 3541 | *indexes; |
|---|
| 3542 | |
|---|
| 3543 | register const PixelPacket |
|---|
| 3544 | *p; |
|---|
| 3545 | |
|---|
| 3546 | register ssize_t |
|---|
| 3547 | i; |
|---|
| 3548 | |
|---|
| 3549 | ssize_t |
|---|
| 3550 | x_offset, |
|---|
| 3551 | y_offset; |
|---|
| 3552 | |
|---|
| 3553 | assert(image != (Image *) NULL); |
|---|
| 3554 | assert(image->signature == MagickSignature); |
|---|
| 3555 | assert(image_view != (CacheView *) NULL); |
|---|
| 3556 | status=MagickTrue; |
|---|
| 3557 | x_offset=(ssize_t) floor(x); |
|---|
| 3558 | y_offset=(ssize_t) floor(y); |
|---|
| 3559 | switch (method == UndefinedInterpolatePixel ? image->interpolate : method) |
|---|
| 3560 | { |
|---|
| 3561 | case AverageInterpolatePixel: |
|---|
| 3562 | { |
|---|
| 3563 | p=GetCacheViewVirtualPixels(image_view,x_offset-1,y_offset-1,4,4, |
|---|
| 3564 | exception); |
|---|
| 3565 | if (p == (const PixelPacket *) NULL) |
|---|
| 3566 | { |
|---|
| 3567 | status=MagickFalse; |
|---|
| 3568 | break; |
|---|
| 3569 | } |
|---|
| 3570 | indexes=GetCacheViewVirtualIndexQueue(image_view); |
|---|
| 3571 | AlphaBlendMagickPixelPacket(image,p+0,indexes+0,pixels+0,alpha+0); |
|---|
| 3572 | AlphaBlendMagickPixelPacket(image,p+1,indexes+1,pixels+1,alpha+1); |
|---|
| 3573 | AlphaBlendMagickPixelPacket(image,p+2,indexes+2,pixels+2,alpha+2); |
|---|
| 3574 | AlphaBlendMagickPixelPacket(image,p+3,indexes+3,pixels+3,alpha+3); |
|---|
| 3575 | AlphaBlendMagickPixelPacket(image,p+4,indexes+4,pixels+4,alpha+4); |
|---|
| 3576 | AlphaBlendMagickPixelPacket(image,p+5,indexes+5,pixels+5,alpha+5); |
|---|
| 3577 | AlphaBlendMagickPixelPacket(image,p+6,indexes+6,pixels+6,alpha+6); |
|---|
| 3578 | AlphaBlendMagickPixelPacket(image,p+7,indexes+7,pixels+7,alpha+7); |
|---|
| 3579 | AlphaBlendMagickPixelPacket(image,p+8,indexes+8,pixels+8,alpha+8); |
|---|
| 3580 | AlphaBlendMagickPixelPacket(image,p+9,indexes+9,pixels+9,alpha+9); |
|---|
| 3581 | AlphaBlendMagickPixelPacket(image,p+10,indexes+10,pixels+10,alpha+10); |
|---|
| 3582 | AlphaBlendMagickPixelPacket(image,p+11,indexes+11,pixels+11,alpha+11); |
|---|
| 3583 | AlphaBlendMagickPixelPacket(image,p+12,indexes+12,pixels+12,alpha+12); |
|---|
| 3584 | AlphaBlendMagickPixelPacket(image,p+13,indexes+13,pixels+13,alpha+13); |
|---|
| 3585 | AlphaBlendMagickPixelPacket(image,p+14,indexes+14,pixels+14,alpha+14); |
|---|
| 3586 | AlphaBlendMagickPixelPacket(image,p+15,indexes+15,pixels+15,alpha+15); |
|---|
| 3587 | pixel->red=0.0; |
|---|
| 3588 | pixel->green=0.0; |
|---|
| 3589 | pixel->blue=0.0; |
|---|
| 3590 | pixel->opacity=0.0; |
|---|
| 3591 | pixel->index=0.0; |
|---|
| 3592 | for (i=0; i < 16L; i++) |
|---|
| 3593 | { |
|---|
| 3594 | gamma=1.0/(fabs((double) alpha[i]) <= MagickEpsilon ? 1.0 : alpha[i]); |
|---|
| 3595 | pixel->red+=gamma*0.0625*pixels[i].red; |
|---|
| 3596 | pixel->green+=gamma*0.0625*pixels[i].green; |
|---|
| 3597 | pixel->blue+=gamma*0.0625*pixels[i].blue; |
|---|
| 3598 | pixel->opacity+=0.0625*pixels[i].opacity; |
|---|
| 3599 | if (image->colorspace == CMYKColorspace) |
|---|
| 3600 | pixel->index+=gamma*0.0625*pixels[i].index; |
|---|
| 3601 | } |
|---|
| 3602 | break; |
|---|
| 3603 | } |
|---|
| 3604 | case BicubicInterpolatePixel: |
|---|
| 3605 | { |
|---|
| 3606 | MagickPixelPacket |
|---|
| 3607 | u[4]; |
|---|
| 3608 | |
|---|
| 3609 | PointInfo |
|---|
| 3610 | delta; |
|---|
| 3611 | |
|---|
| 3612 | p=GetCacheViewVirtualPixels(image_view,x_offset-1,y_offset-1,4,4, |
|---|
| 3613 | exception); |
|---|
| 3614 | if (p == (const PixelPacket *) NULL) |
|---|
| 3615 | { |
|---|
| 3616 | status=MagickFalse; |
|---|
| 3617 | break; |
|---|
| 3618 | } |
|---|
| 3619 | indexes=GetCacheViewVirtualIndexQueue(image_view); |
|---|
| 3620 | AlphaBlendMagickPixelPacket(image,p+0,indexes+0,pixels+0,alpha+0); |
|---|
| 3621 | AlphaBlendMagickPixelPacket(image,p+1,indexes+1,pixels+1,alpha+1); |
|---|
| 3622 | AlphaBlendMagickPixelPacket(image,p+2,indexes+2,pixels+2,alpha+2); |
|---|
| 3623 | AlphaBlendMagickPixelPacket(image,p+3,indexes+3,pixels+3,alpha+3); |
|---|
| 3624 | AlphaBlendMagickPixelPacket(image,p+4,indexes+4,pixels+4,alpha+4); |
|---|
| 3625 | AlphaBlendMagickPixelPacket(image,p+5,indexes+5,pixels+5,alpha+5); |
|---|
| 3626 | AlphaBlendMagickPixelPacket(image,p+6,indexes+6,pixels+6,alpha+6); |
|---|
| 3627 | AlphaBlendMagickPixelPacket(image,p+7,indexes+7,pixels+7,alpha+7); |
|---|
| 3628 | AlphaBlendMagickPixelPacket(image,p+8,indexes+8,pixels+8,alpha+8); |
|---|
| 3629 | AlphaBlendMagickPixelPacket(image,p+9,indexes+9,pixels+9,alpha+9); |
|---|
| 3630 | AlphaBlendMagickPixelPacket(image,p+10,indexes+10,pixels+10,alpha+10); |
|---|
| 3631 | AlphaBlendMagickPixelPacket(image,p+11,indexes+11,pixels+11,alpha+11); |
|---|
| 3632 | AlphaBlendMagickPixelPacket(image,p+12,indexes+12,pixels+12,alpha+12); |
|---|
| 3633 | AlphaBlendMagickPixelPacket(image,p+13,indexes+13,pixels+13,alpha+13); |
|---|
| 3634 | AlphaBlendMagickPixelPacket(image,p+14,indexes+14,pixels+14,alpha+14); |
|---|
| 3635 | AlphaBlendMagickPixelPacket(image,p+15,indexes+15,pixels+15,alpha+15); |
|---|
| 3636 | delta.x=x-x_offset; |
|---|
| 3637 | delta.y=y-y_offset; |
|---|
| 3638 | for (i=0; i < 4L; i++) |
|---|
| 3639 | BicubicInterpolate(pixels+4*i,delta.x,u+i); |
|---|
| 3640 | BicubicInterpolate(u,delta.y,pixel); |
|---|
| 3641 | break; |
|---|
| 3642 | } |
|---|
| 3643 | case BilinearInterpolatePixel: |
|---|
| 3644 | default: |
|---|
| 3645 | { |
|---|
| 3646 | PointInfo |
|---|
| 3647 | delta, |
|---|
| 3648 | epsilon; |
|---|
| 3649 | |
|---|
| 3650 | p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset,2,2,exception); |
|---|
| 3651 | if (p == (const PixelPacket *) NULL) |
|---|
| 3652 | { |
|---|
| 3653 | status=MagickFalse; |
|---|
| 3654 | break; |
|---|
| 3655 | } |
|---|
| 3656 | indexes=GetCacheViewVirtualIndexQueue(image_view); |
|---|
| 3657 | AlphaBlendMagickPixelPacket(image,p+0,indexes+0,pixels+0,alpha+0); |
|---|
| 3658 | AlphaBlendMagickPixelPacket(image,p+1,indexes+1,pixels+1,alpha+1); |
|---|
| 3659 | AlphaBlendMagickPixelPacket(image,p+2,indexes+2,pixels+2,alpha+2); |
|---|
| 3660 | AlphaBlendMagickPixelPacket(image,p+3,indexes+3,pixels+3,alpha+3); |
|---|
| 3661 | delta.x=x-x_offset; |
|---|
| 3662 | delta.y=y-y_offset; |
|---|
| 3663 | epsilon.x=1.0-delta.x; |
|---|
| 3664 | epsilon.y=1.0-delta.y; |
|---|
| 3665 | gamma=((epsilon.y*(epsilon.x*alpha[0]+delta.x*alpha[1])+delta.y* |
|---|
| 3666 | (epsilon.x*alpha[2]+delta.x*alpha[3]))); |
|---|
| 3667 | gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); |
|---|
| 3668 | pixel->red=gamma*(epsilon.y*(epsilon.x*pixels[0].red+delta.x* |
|---|
| 3669 | pixels[1].red)+delta.y*(epsilon.x*pixels[2].red+delta.x*pixels[3].red)); |
|---|
| 3670 | pixel->green=gamma*(epsilon.y*(epsilon.x*pixels[0].green+delta.x* |
|---|
| 3671 | pixels[1].green)+delta.y*(epsilon.x*pixels[2].green+delta.x* |
|---|
| 3672 | pixels[3].green)); |
|---|
| 3673 | pixel->blue=gamma*(epsilon.y*(epsilon.x*pixels[0].blue+delta.x* |
|---|
| 3674 | pixels[1].blue)+delta.y*(epsilon.x*pixels[2].blue+delta.x* |
|---|
| 3675 | pixels[3].blue)); |
|---|
| 3676 | pixel->opacity=(epsilon.y*(epsilon.x*pixels[0].opacity+delta.x* |
|---|
| 3677 | pixels[1].opacity)+delta.y*(epsilon.x*pixels[2].opacity+delta.x* |
|---|
| 3678 | pixels[3].opacity)); |
|---|
| 3679 | if (image->colorspace == CMYKColorspace) |
|---|
| 3680 | pixel->index=gamma*(epsilon.y*(epsilon.x*pixels[0].index+delta.x* |
|---|
| 3681 | pixels[1].index)+delta.y*(epsilon.x*pixels[2].index+delta.x* |
|---|
| 3682 | pixels[3].index)); |
|---|
| 3683 | break; |
|---|
| 3684 | } |
|---|
| 3685 | case FilterInterpolatePixel: |
|---|
| 3686 | { |
|---|
| 3687 | CacheView |
|---|
| 3688 | *filter_view; |
|---|
| 3689 | |
|---|
| 3690 | Image |
|---|
| 3691 | *excerpt_image, |
|---|
| 3692 | *filter_image; |
|---|
| 3693 | |
|---|
| 3694 | RectangleInfo |
|---|
| 3695 | geometry; |
|---|
| 3696 | |
|---|
| 3697 | geometry.width=4L; |
|---|
| 3698 | geometry.height=4L; |
|---|
| 3699 | geometry.x=x_offset-1; |
|---|
| 3700 | geometry.y=y_offset-1; |
|---|
| 3701 | excerpt_image=ExcerptImage(image,&geometry,exception); |
|---|
| 3702 | if (excerpt_image == (Image *) NULL) |
|---|
| 3703 | { |
|---|
| 3704 | status=MagickFalse; |
|---|
| 3705 | break; |
|---|
| 3706 | } |
|---|
| 3707 | filter_image=ResizeImage(excerpt_image,1,1,image->filter,image->blur, |
|---|
| 3708 | exception); |
|---|
| 3709 | excerpt_image=DestroyImage(excerpt_image); |
|---|
| 3710 | if (filter_image == (Image *) NULL) |
|---|
| 3711 | break; |
|---|
| 3712 | filter_view=AcquireCacheView(filter_image); |
|---|
| 3713 | p=GetCacheViewVirtualPixels(filter_view,0,0,1,1,exception); |
|---|
| 3714 | if (p != (const PixelPacket *) NULL) |
|---|
| 3715 | { |
|---|
| 3716 | indexes=GetVirtualIndexQueue(filter_image); |
|---|
| 3717 | SetMagickPixelPacket(image,p,indexes,pixel); |
|---|
| 3718 | } |
|---|
| 3719 | filter_view=DestroyCacheView(filter_view); |
|---|
| 3720 | filter_image=DestroyImage(filter_image); |
|---|
| 3721 | break; |
|---|
| 3722 | } |
|---|
| 3723 | case IntegerInterpolatePixel: |
|---|
| 3724 | { |
|---|
| 3725 | p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset,1,1,exception); |
|---|
| 3726 | if (p == (const PixelPacket *) NULL) |
|---|
| 3727 | { |
|---|
| 3728 | status=MagickFalse; |
|---|
| 3729 | break; |
|---|
| 3730 | } |
|---|
| 3731 | indexes=GetCacheViewVirtualIndexQueue(image_view); |
|---|
| 3732 | SetMagickPixelPacket(image,p,indexes,pixel); |
|---|
| 3733 | break; |
|---|
| 3734 | } |
|---|
| 3735 | case MeshInterpolatePixel: |
|---|
| 3736 | { |
|---|
| 3737 | PointInfo |
|---|
| 3738 | delta, |
|---|
| 3739 | luminance; |
|---|
| 3740 | |
|---|
| 3741 | p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset,2,2, |
|---|
| 3742 | exception); |
|---|
| 3743 | if (p == (const PixelPacket *) NULL) |
|---|
| 3744 | { |
|---|
| 3745 | status=MagickFalse; |
|---|
| 3746 | break; |
|---|
| 3747 | } |
|---|
| 3748 | indexes=GetCacheViewVirtualIndexQueue(image_view); |
|---|
| 3749 | AlphaBlendMagickPixelPacket(image,p+0,indexes+0,pixels+0,alpha+0); |
|---|
| 3750 | AlphaBlendMagickPixelPacket(image,p+1,indexes+1,pixels+1,alpha+1); |
|---|
| 3751 | AlphaBlendMagickPixelPacket(image,p+2,indexes+2,pixels+2,alpha+2); |
|---|
| 3752 | AlphaBlendMagickPixelPacket(image,p+3,indexes+3,pixels+3,alpha+3); |
|---|
| 3753 | delta.x=x-x_offset; |
|---|
| 3754 | delta.y=y-y_offset; |
|---|
| 3755 | luminance.x=MagickPixelLuminance(pixels+0)-MagickPixelLuminance(pixels+3); |
|---|
| 3756 | luminance.y=MagickPixelLuminance(pixels+1)-MagickPixelLuminance(pixels+2); |
|---|
| 3757 | if (fabs(luminance.x) < fabs(luminance.y)) |
|---|
| 3758 | { |
|---|
| 3759 | /* |
|---|
| 3760 | Diagonal 0-3 NW-SE. |
|---|
| 3761 | */ |
|---|
| 3762 | if (delta.x <= delta.y) |
|---|
| 3763 | { |
|---|
| 3764 | /* |
|---|
| 3765 | Bottom-left triangle (pixel:2, diagonal: 0-3). |
|---|
| 3766 | */ |
|---|
| 3767 | delta.y=1.0-delta.y; |
|---|
| 3768 | gamma=MeshInterpolate(&delta,alpha[2],alpha[3],alpha[0]); |
|---|
| 3769 | gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); |
|---|
| 3770 | pixel->red=gamma*MeshInterpolate(&delta,pixels[2].red, |
|---|
| 3771 | pixels[3].red,pixels[0].red); |
|---|
| 3772 | pixel->green=gamma*MeshInterpolate(&delta,pixels[2].green, |
|---|
| 3773 | pixels[3].green,pixels[0].green); |
|---|
| 3774 | pixel->blue=gamma*MeshInterpolate(&delta,pixels[2].blue, |
|---|
| 3775 | pixels[3].blue,pixels[0].blue); |
|---|
| 3776 | pixel->opacity=gamma*MeshInterpolate(&delta,pixels[2].opacity, |
|---|
| 3777 | pixels[3].opacity,pixels[0].opacity); |
|---|
| 3778 | if (image->colorspace == CMYKColorspace) |
|---|
| 3779 | pixel->index=gamma*MeshInterpolate(&delta,pixels[2].index, |
|---|
| 3780 | pixels[3].index,pixels[0].index); |
|---|
| 3781 | } |
|---|
| 3782 | else |
|---|
| 3783 | { |
|---|
| 3784 | /* |
|---|
| 3785 | Top-right triangle (pixel:1, diagonal: 0-3). |
|---|
| 3786 | */ |
|---|
| 3787 | delta.x=1.0-delta.x; |
|---|
| 3788 | gamma=MeshInterpolate(&delta,alpha[1],alpha[0],alpha[3]); |
|---|
| 3789 | gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); |
|---|
| 3790 | pixel->red=gamma*MeshInterpolate(&delta,pixels[1].red, |
|---|
| 3791 | pixels[0].red,pixels[3].red); |
|---|
| 3792 | pixel->green=gamma*MeshInterpolate(&delta,pixels[1].green, |
|---|
| 3793 | pixels[0].green,pixels[3].green); |
|---|
| 3794 | pixel->blue=gamma*MeshInterpolate(&delta,pixels[1].blue, |
|---|
| 3795 | pixels[0].blue,pixels[3].blue); |
|---|
| 3796 | pixel->opacity=gamma*MeshInterpolate(&delta,pixels[1].opacity, |
|---|
| 3797 | pixels[0].opacity,pixels[3].opacity); |
|---|
| 3798 | if (image->colorspace == CMYKColorspace) |
|---|
| 3799 | pixel->index=gamma*MeshInterpolate(&delta,pixels[1].index, |
|---|
| 3800 | pixels[0].index,pixels[3].index); |
|---|
| 3801 | } |
|---|
| 3802 | } |
|---|
| 3803 | else |
|---|
| 3804 | { |
|---|
| 3805 | /* |
|---|
| 3806 | Diagonal 1-2 NE-SW. |
|---|
| 3807 | */ |
|---|
| 3808 | if (delta.x <= (1.0-delta.y)) |
|---|
| 3809 | { |
|---|
| 3810 | /* |
|---|
| 3811 | Top-left triangle (pixel 0, diagonal: 1-2). |
|---|
| 3812 | */ |
|---|
| 3813 | gamma=MeshInterpolate(&delta,alpha[0],alpha[1],alpha[2]); |
|---|
| 3814 | gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); |
|---|
| 3815 | pixel->red=gamma*MeshInterpolate(&delta,pixels[0].red, |
|---|
| 3816 | pixels[1].red,pixels[2].red); |
|---|
| 3817 | pixel->green=gamma*MeshInterpolate(&delta,pixels[0].green, |
|---|
| 3818 | pixels[1].green,pixels[2].green); |
|---|
| 3819 | pixel->blue=gamma*MeshInterpolate(&delta,pixels[0].blue, |
|---|
| 3820 | pixels[1].blue,pixels[2].blue); |
|---|
| 3821 | pixel->opacity=gamma*MeshInterpolate(&delta,pixels[0].opacity, |
|---|
| 3822 | pixels[1].opacity,pixels[2].opacity); |
|---|
| 3823 | if (image->colorspace == CMYKColorspace) |
|---|
| 3824 | pixel->index=gamma*MeshInterpolate(&delta,pixels[0].index, |
|---|
| 3825 | pixels[1].index,pixels[2].index); |
|---|
| 3826 | } |
|---|
| 3827 | else |
|---|
| 3828 | { |
|---|
| 3829 | /* |
|---|
| 3830 | Bottom-right triangle (pixel: 3, diagonal: 1-2). |
|---|
| 3831 | */ |
|---|
| 3832 | delta.x=1.0-delta.x; |
|---|
| 3833 | delta.y=1.0-delta.y; |
|---|
| 3834 | gamma=MeshInterpolate(&delta,alpha[3],alpha[2],alpha[1]); |
|---|
| 3835 | gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); |
|---|
| 3836 | pixel->red=gamma*MeshInterpolate(&delta,pixels[3].red, |
|---|
| 3837 | pixels[2].red,pixels[1].red); |
|---|
| 3838 | pixel->green=gamma*MeshInterpolate(&delta,pixels[3].green, |
|---|
| 3839 | pixels[2].green,pixels[1].green); |
|---|
| 3840 | pixel->blue=gamma*MeshInterpolate(&delta,pixels[3].blue, |
|---|
| 3841 | pixels[2].blue,pixels[1].blue); |
|---|
| 3842 | pixel->opacity=gamma*MeshInterpolate(&delta,pixels[3].opacity, |
|---|
| 3843 | pixels[2].opacity,pixels[1].opacity); |
|---|
| 3844 | if (image->colorspace == CMYKColorspace) |
|---|
| 3845 | pixel->index=gamma*MeshInterpolate(&delta,pixels[3].index, |
|---|
| 3846 | pixels[2].index,pixels[1].index); |
|---|
| 3847 | } |
|---|
| 3848 | } |
|---|
| 3849 | break; |
|---|
| 3850 | } |
|---|
| 3851 | case NearestNeighborInterpolatePixel: |
|---|
| 3852 | { |
|---|
| 3853 | p=GetCacheViewVirtualPixels(image_view,NearestNeighbor(x), |
|---|
| 3854 | NearestNeighbor(y),1,1,exception); |
|---|
| 3855 | if (p == (const PixelPacket *) NULL) |
|---|
| 3856 | { |
|---|
| 3857 | status=MagickFalse; |
|---|
| 3858 | break; |
|---|
| 3859 | } |
|---|
| 3860 | indexes=GetCacheViewVirtualIndexQueue(image_view); |
|---|
| 3861 | SetMagickPixelPacket(image,p,indexes,pixel); |
|---|
| 3862 | break; |
|---|
| 3863 | } |
|---|
| 3864 | case SplineInterpolatePixel: |
|---|
| 3865 | { |
|---|
| 3866 | MagickRealType |
|---|
| 3867 | dx, |
|---|
| 3868 | dy; |
|---|
| 3869 | |
|---|
| 3870 | PointInfo |
|---|
| 3871 | delta; |
|---|
| 3872 | |
|---|
| 3873 | ssize_t |
|---|
| 3874 | j, |
|---|
| 3875 | n; |
|---|
| 3876 | |
|---|
| 3877 | p=GetCacheViewVirtualPixels(image_view,x_offset-1,y_offset-1,4,4, |
|---|
| 3878 | exception); |
|---|
| 3879 | if (p == (const PixelPacket *) NULL) |
|---|
| 3880 | { |
|---|
| 3881 | status=MagickFalse; |
|---|
| 3882 | break; |
|---|
| 3883 | } |
|---|
| 3884 | indexes=GetCacheViewVirtualIndexQueue(image_view); |
|---|
| 3885 | AlphaBlendMagickPixelPacket(image,p+0,indexes+0,pixels+0,alpha+0); |
|---|
| 3886 | AlphaBlendMagickPixelPacket(image,p+1,indexes+1,pixels+1,alpha+1); |
|---|
| 3887 | AlphaBlendMagickPixelPacket(image,p+2,indexes+2,pixels+2,alpha+2); |
|---|
| 3888 | AlphaBlendMagickPixelPacket(image,p+3,indexes+3,pixels+3,alpha+3); |
|---|
| 3889 | AlphaBlendMagickPixelPacket(image,p+4,indexes+4,pixels+4,alpha+4); |
|---|
| 3890 | AlphaBlendMagickPixelPacket(image,p+5,indexes+5,pixels+5,alpha+5); |
|---|
| 3891 | AlphaBlendMagickPixelPacket(image,p+6,indexes+6,pixels+6,alpha+6); |
|---|
| 3892 | AlphaBlendMagickPixelPacket(image,p+7,indexes+7,pixels+7,alpha+7); |
|---|
| 3893 | AlphaBlendMagickPixelPacket(image,p+8,indexes+8,pixels+8,alpha+8); |
|---|
| 3894 | AlphaBlendMagickPixelPacket(image,p+9,indexes+9,pixels+9,alpha+9); |
|---|
| 3895 | AlphaBlendMagickPixelPacket(image,p+10,indexes+10,pixels+10,alpha+10); |
|---|
| 3896 | AlphaBlendMagickPixelPacket(image,p+11,indexes+11,pixels+11,alpha+11); |
|---|
| 3897 | AlphaBlendMagickPixelPacket(image,p+12,indexes+12,pixels+12,alpha+12); |
|---|
| 3898 | AlphaBlendMagickPixelPacket(image,p+13,indexes+13,pixels+13,alpha+13); |
|---|
| 3899 | AlphaBlendMagickPixelPacket(image,p+14,indexes+14,pixels+14,alpha+14); |
|---|
| 3900 | AlphaBlendMagickPixelPacket(image,p+15,indexes+15,pixels+15,alpha+15); |
|---|
| 3901 | pixel->red=0.0; |
|---|
| 3902 | pixel->green=0.0; |
|---|
| 3903 | pixel->blue=0.0; |
|---|
| 3904 | pixel->opacity=0.0; |
|---|
| 3905 | pixel->index=0.0; |
|---|
| 3906 | delta.x=x-x_offset; |
|---|
| 3907 | delta.y=y-y_offset; |
|---|
| 3908 | n=0; |
|---|
| 3909 | for (i=(-1); i < 3L; i++) |
|---|
| 3910 | { |
|---|
| 3911 | dy=CubicWeightingFunction((MagickRealType) i-delta.y); |
|---|
| 3912 | for (j=(-1); j < 3L; j++) |
|---|
| 3913 | { |
|---|
| 3914 | dx=CubicWeightingFunction(delta.x-(MagickRealType) j); |
|---|
| 3915 | gamma=1.0/(fabs((double) alpha[n]) <= MagickEpsilon ? 1.0 : alpha[n]); |
|---|
| 3916 | pixel->red+=gamma*dx*dy*pixels[n].red; |
|---|
| 3917 | pixel->green+=gamma*dx*dy*pixels[n].green; |
|---|
| 3918 | pixel->blue+=gamma*dx*dy*pixels[n].blue; |
|---|
| 3919 | pixel->opacity+=dx*dy*pixels[n].opacity; |
|---|
| 3920 | if (image->colorspace == CMYKColorspace) |
|---|
| 3921 | pixel->index+=gamma*dx*dy*pixels[n].index; |
|---|
| 3922 | n++; |
|---|
| 3923 | } |
|---|
| 3924 | } |
|---|
| 3925 | break; |
|---|
| 3926 | } |
|---|
| 3927 | } |
|---|
| 3928 | return(status); |
|---|
| 3929 | } |
|---|