| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
#include "MagickCore/studio.h" |
| 43 |
#include "MagickCore/attribute.h" |
| 44 |
#include "MagickCore/property.h" |
| 45 |
#include "MagickCore/blob.h" |
| 46 |
#include "MagickCore/blob-private.h" |
| 47 |
#include "MagickCore/cache.h" |
| 48 |
#include "MagickCore/color.h" |
| 49 |
#include "MagickCore/color-private.h" |
| 50 |
#include "MagickCore/colormap.h" |
| 51 |
#include "MagickCore/colorspace.h" |
| 52 |
#include "MagickCore/colorspace-private.h" |
| 53 |
#include "MagickCore/constitute.h" |
| 54 |
#include "MagickCore/exception.h" |
| 55 |
#include "MagickCore/exception-private.h" |
| 56 |
#include "MagickCore/geometry.h" |
| 57 |
#include "MagickCore/image.h" |
| 58 |
#include "MagickCore/image-private.h" |
| 59 |
#include "MagickCore/list.h" |
| 60 |
#include "MagickCore/magick.h" |
| 61 |
#include "MagickCore/memory_.h" |
| 62 |
#include "MagickCore/module.h" |
| 63 |
#include "MagickCore/monitor.h" |
| 64 |
#include "MagickCore/monitor-private.h" |
| 65 |
#include "MagickCore/option.h" |
| 66 |
#include "MagickCore/pixel.h" |
| 67 |
#include "MagickCore/pixel-accessor.h" |
| 68 |
#include "MagickCore/property.h" |
| 69 |
#include "MagickCore/quantum-private.h" |
| 70 |
#include "MagickCore/static.h" |
| 71 |
#include "MagickCore/string_.h" |
| 72 |
#include "coders/coders-private.h" |
| 73 |
#if defined(MAGICKCORE_FPX_DELEGATE) |
| 74 |
#if !defined(vms) && !defined(MAGICKCORE_WINDOWS_SUPPORT) |
| 75 |
#include <fpxlib.h> |
| 76 |
#else |
| 77 |
#include "Fpxlib.h" |
| 78 |
#endif |
| 79 |
#endif |
| 80 |
|
| 81 |
#if defined(MAGICKCORE_FPX_DELEGATE) |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
static MagickBooleanType |
| 86 |
WriteFPXImage(const ImageInfo *,Image *,ExceptionInfo *); |
| 87 |
#endif |
| 88 |
|
| 89 |
#if defined(MAGICKCORE_FPX_DELEGATE) |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
static void FPXRelinquishSummaryInfo(FPXSummaryInformation *summary_info) |
| 118 |
{ |
| 119 |
if (summary_info->title_valid) |
| 120 |
(void) FPX_DeleteFPXStr(&summary_info->title); |
| 121 |
if (summary_info->subject_valid) |
| 122 |
(void) FPX_DeleteFPXStr(&summary_info->subject); |
| 123 |
if (summary_info->author_valid) |
| 124 |
(void) FPX_DeleteFPXStr(&summary_info->author); |
| 125 |
if (summary_info->keywords_valid) |
| 126 |
(void) FPX_DeleteFPXStr(&summary_info->keywords); |
| 127 |
if (summary_info->comments_valid) |
| 128 |
(void) FPX_DeleteFPXStr(&summary_info->comments); |
| 129 |
if (summary_info->OLEtemplate_valid) |
| 130 |
(void) FPX_DeleteFPXStr(&summary_info->OLEtemplate); |
| 131 |
if (summary_info->last_author_valid) |
| 132 |
(void) FPX_DeleteFPXStr(&summary_info->last_author); |
| 133 |
if (summary_info->rev_number_valid) |
| 134 |
(void) FPX_DeleteFPXStr(&summary_info->rev_number); |
| 135 |
if (summary_info->appname_valid) |
| 136 |
(void) FPX_DeleteFPXStr(&summary_info->appname); |
| 137 |
} |
| 138 |
|
| 139 |
static Image *ReadFPXImage(const ImageInfo *image_info,ExceptionInfo *exception) |
| 140 |
{ |
| 141 |
const char |
| 142 |
*option; |
| 143 |
|
| 144 |
FPXColorspace |
| 145 |
colorspace; |
| 146 |
|
| 147 |
FPXImageComponentDesc |
| 148 |
*alpha_component, |
| 149 |
*blue_component, |
| 150 |
*green_component, |
| 151 |
*red_component; |
| 152 |
|
| 153 |
FPXImageDesc |
| 154 |
fpx_info; |
| 155 |
|
| 156 |
FPXImageHandle |
| 157 |
*flashpix; |
| 158 |
|
| 159 |
FPXStatus |
| 160 |
fpx_status; |
| 161 |
|
| 162 |
FPXSummaryInformation |
| 163 |
summary_info; |
| 164 |
|
| 165 |
Image |
| 166 |
*image; |
| 167 |
|
| 168 |
MagickBooleanType |
| 169 |
status; |
| 170 |
|
| 171 |
Quantum |
| 172 |
index; |
| 173 |
|
| 174 |
ssize_t |
| 175 |
i, |
| 176 |
x; |
| 177 |
|
| 178 |
Quantum |
| 179 |
*q; |
| 180 |
|
| 181 |
unsigned char |
| 182 |
*a, |
| 183 |
*b, |
| 184 |
*g, |
| 185 |
*r; |
| 186 |
|
| 187 |
size_t |
| 188 |
memory_limit; |
| 189 |
|
| 190 |
ssize_t |
| 191 |
y; |
| 192 |
|
| 193 |
unsigned char |
| 194 |
*pixels; |
| 195 |
|
| 196 |
unsigned int |
| 197 |
height, |
| 198 |
tile_width, |
| 199 |
tile_height, |
| 200 |
width; |
| 201 |
|
| 202 |
size_t |
| 203 |
scene; |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
assert(image_info != (const ImageInfo *) NULL); |
| 209 |
assert(image_info->signature == MagickCoreSignature); |
| 210 |
assert(exception != (ExceptionInfo *) NULL); |
| 211 |
assert(exception->signature == MagickCoreSignature); |
| 212 |
if (IsEventLogging() != MagickFalse) |
| 213 |
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 214 |
image_info->filename); |
| 215 |
image=AcquireImage(image_info,exception); |
| 216 |
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); |
| 217 |
if (status == MagickFalse) |
| 218 |
{ |
| 219 |
image=DestroyImageList(image); |
| 220 |
return((Image *) NULL); |
| 221 |
} |
| 222 |
(void) CloseBlob(image); |
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
(void) memset(&summary_info,0,sizeof(summary_info)); |
| 227 |
fpx_status=FPX_InitSystem(); |
| 228 |
if (fpx_status != FPX_OK) |
| 229 |
ThrowReaderException(CoderError,"UnableToInitializeFPXLibrary"); |
| 230 |
memory_limit=20000000; |
| 231 |
fpx_status=FPX_SetToolkitMemoryLimit(&memory_limit); |
| 232 |
if (fpx_status != FPX_OK) |
| 233 |
{ |
| 234 |
FPXRelinquishSummaryInfo(&summary_info); |
| 235 |
FPX_ClearSystem(); |
| 236 |
ThrowReaderException(CoderError,"UnableToInitializeFPXLibrary"); |
| 237 |
} |
| 238 |
tile_width=64; |
| 239 |
tile_height=64; |
| 240 |
flashpix=(FPXImageHandle *) NULL; |
| 241 |
fpx_status=FPX_OpenImageByFilename(image->filename,(char *) NULL,&width, |
| 242 |
&height,&tile_width,&tile_height,&colorspace,&flashpix); |
| 243 |
if (fpx_status == FPX_LOW_MEMORY_ERROR) |
| 244 |
{ |
| 245 |
FPXRelinquishSummaryInfo(&summary_info); |
| 246 |
FPX_ClearSystem(); |
| 247 |
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); |
| 248 |
} |
| 249 |
if (fpx_status != FPX_OK) |
| 250 |
{ |
| 251 |
FPX_ClearSystem(); |
| 252 |
ThrowFileException(exception,FileOpenError,"UnableToOpenFile", |
| 253 |
image->filename); |
| 254 |
image=DestroyImageList(image); |
| 255 |
return((Image *) NULL); |
| 256 |
} |
| 257 |
if (colorspace.numberOfComponents == 0) |
| 258 |
{ |
| 259 |
FPXRelinquishSummaryInfo(&summary_info); |
| 260 |
FPX_ClearSystem(); |
| 261 |
ThrowReaderException(CorruptImageError,"ImageTypeNotSupported"); |
| 262 |
} |
| 263 |
option=GetImageOption(image_info,"fpx:view"); |
| 264 |
if (option == (const char *) NULL) |
| 265 |
{ |
| 266 |
float |
| 267 |
aspect_ratio; |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
aspect_ratio=(float) width/height; |
| 273 |
fpx_status=FPX_GetImageResultAspectRatio(flashpix,&aspect_ratio); |
| 274 |
if (fpx_status != FPX_OK) |
| 275 |
ThrowReaderException(DelegateError,"UnableToReadAspectRatio"); |
| 276 |
if (width != (size_t) floor((aspect_ratio*height)+0.5)) |
| 277 |
Swap(width,height); |
| 278 |
} |
| 279 |
fpx_status=FPX_GetSummaryInformation(flashpix,&summary_info); |
| 280 |
if (fpx_status != FPX_OK) |
| 281 |
{ |
| 282 |
FPXRelinquishSummaryInfo(&summary_info); |
| 283 |
FPX_ClearSystem(); |
| 284 |
ThrowReaderException(DelegateError,"UnableToReadSummaryInfo"); |
| 285 |
} |
| 286 |
if (summary_info.title_valid) |
| 287 |
if ((summary_info.title.length != 0) && |
| 288 |
(summary_info.title.ptr != (unsigned char *) NULL)) |
| 289 |
{ |
| 290 |
char |
| 291 |
*label; |
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
label=(char *) NULL; |
| 297 |
if (~summary_info.title.length >= (MagickPathExtent-1)) |
| 298 |
label=(char *) AcquireQuantumMemory(summary_info.title.length+ |
| 299 |
MagickPathExtent,sizeof(*label)); |
| 300 |
if (label == (char *) NULL) |
| 301 |
{ |
| 302 |
FPXRelinquishSummaryInfo(&summary_info); |
| 303 |
FPX_ClearSystem(); |
| 304 |
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); |
| 305 |
} |
| 306 |
(void) CopyMagickString(label,(char *) summary_info.title.ptr, |
| 307 |
summary_info.title.length+1); |
| 308 |
(void) SetImageProperty(image,"label",label,exception); |
| 309 |
label=DestroyString(label); |
| 310 |
} |
| 311 |
if (summary_info.comments_valid) |
| 312 |
if ((summary_info.comments.length != 0) && |
| 313 |
(summary_info.comments.ptr != (unsigned char *) NULL)) |
| 314 |
{ |
| 315 |
char |
| 316 |
*comments; |
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
comments=(char *) NULL; |
| 322 |
if (~summary_info.comments.length >= (MagickPathExtent-1)) |
| 323 |
comments=(char *) AcquireQuantumMemory(summary_info.comments.length+ |
| 324 |
MagickPathExtent,sizeof(*comments)); |
| 325 |
if (comments == (char *) NULL) |
| 326 |
{ |
| 327 |
FPXRelinquishSummaryInfo(&summary_info); |
| 328 |
FPX_ClearSystem(); |
| 329 |
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); |
| 330 |
} |
| 331 |
(void) CopyMagickString(comments,(char *) summary_info.comments.ptr, |
| 332 |
summary_info.comments.length+1); |
| 333 |
(void) SetImageProperty(image,"comment",comments,exception); |
| 334 |
comments=DestroyString(comments); |
| 335 |
} |
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
for (i=1; ; i++) |
| 340 |
if (((width >> i) < tile_width) || ((height >> i) < tile_height)) |
| 341 |
break; |
| 342 |
scene=(size_t) i; |
| 343 |
if (image_info->number_scenes != 0) |
| 344 |
while (scene > image_info->scene) |
| 345 |
{ |
| 346 |
width>>=1; |
| 347 |
height>>=1; |
| 348 |
scene--; |
| 349 |
} |
| 350 |
if (image_info->size != (char *) NULL) |
| 351 |
while ((width > image->columns) || (height > image->rows)) |
| 352 |
{ |
| 353 |
width>>=1; |
| 354 |
height>>=1; |
| 355 |
if (scene != 0) |
| 356 |
scene--; |
| 357 |
} |
| 358 |
image->depth=8; |
| 359 |
image->columns=width; |
| 360 |
image->rows=height; |
| 361 |
if ((colorspace.numberOfComponents % 2) == 0) |
| 362 |
image->alpha_trait=BlendPixelTrait; |
| 363 |
if (colorspace.numberOfComponents == 1) |
| 364 |
{ |
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
if (AcquireImageColormap(image,MaxColormapSize,exception) == MagickFalse) |
| 369 |
{ |
| 370 |
FPXRelinquishSummaryInfo(&summary_info); |
| 371 |
FPX_ClearSystem(); |
| 372 |
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); |
| 373 |
} |
| 374 |
} |
| 375 |
if (image_info->ping != MagickFalse) |
| 376 |
{ |
| 377 |
(void) FPX_CloseImage(flashpix); |
| 378 |
FPXRelinquishSummaryInfo(&summary_info); |
| 379 |
FPX_ClearSystem(); |
| 380 |
return(GetFirstImageInList(image)); |
| 381 |
} |
| 382 |
status=SetImageExtent(image,image->columns,image->rows,exception); |
| 383 |
if (status == MagickFalse) |
| 384 |
return(DestroyImageList(image)); |
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
pixels=(unsigned char *) AcquireQuantumMemory(image->columns,(tile_height+1)* |
| 389 |
(size_t) colorspace.numberOfComponents*sizeof(*pixels)); |
| 390 |
if (pixels == (unsigned char *) NULL) |
| 391 |
{ |
| 392 |
FPXRelinquishSummaryInfo(&summary_info); |
| 393 |
FPX_ClearSystem(); |
| 394 |
(void) FPX_CloseImage(flashpix); |
| 395 |
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); |
| 396 |
} |
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
fpx_info.numberOfComponents=(unsigned int) colorspace.numberOfComponents; |
| 401 |
for (i=0; i < 4; i++) |
| 402 |
{ |
| 403 |
fpx_info.components[i].myColorType.myDataType=DATA_TYPE_UNSIGNED_BYTE; |
| 404 |
fpx_info.components[i].horzSubSampFactor=1; |
| 405 |
fpx_info.components[i].vertSubSampFactor=1; |
| 406 |
fpx_info.components[i].columnStride=(int) fpx_info.numberOfComponents; |
| 407 |
fpx_info.components[i].lineStride=(image->columns* |
| 408 |
(size_t) fpx_info.components[i].columnStride); |
| 409 |
fpx_info.components[i].theData=pixels+i; |
| 410 |
} |
| 411 |
fpx_info.components[0].myColorType.myColor=fpx_info.numberOfComponents > 2 ? |
| 412 |
NIFRGB_R : MONOCHROME; |
| 413 |
red_component=(&fpx_info.components[0]); |
| 414 |
fpx_info.components[1].myColorType.myColor=fpx_info.numberOfComponents > 2 ? |
| 415 |
NIFRGB_G : ALPHA; |
| 416 |
green_component=(&fpx_info.components[1]); |
| 417 |
fpx_info.components[2].myColorType.myColor=NIFRGB_B; |
| 418 |
blue_component=(&fpx_info.components[2]); |
| 419 |
fpx_info.components[3].myColorType.myColor=ALPHA; |
| 420 |
alpha_component=(&fpx_info.components[fpx_info.numberOfComponents-1]); |
| 421 |
FPX_SetResampleMethod(FPX_LINEAR_INTERPOLATION); |
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
for (y=0; y < (ssize_t) image->rows; y++) |
| 426 |
{ |
| 427 |
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); |
| 428 |
if (q == (Quantum *) NULL) |
| 429 |
break; |
| 430 |
if ((y % tile_height) == 0) |
| 431 |
{ |
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
if (option != (const char *) NULL) |
| 436 |
fpx_status=FPX_ReadImageRectangle(flashpix,0,y,image->columns,y+ |
| 437 |
tile_height-1,scene,&fpx_info); |
| 438 |
else |
| 439 |
fpx_status=FPX_ReadImageTransformRectangle(flashpix,0.0F, |
| 440 |
(float) y/image->rows,(float) image->columns/image->rows, |
| 441 |
(float) (y+tile_height-1)/image->rows,(int) image->columns, |
| 442 |
(int) tile_height,&fpx_info); |
| 443 |
if (fpx_status == FPX_LOW_MEMORY_ERROR) |
| 444 |
{ |
| 445 |
pixels=(unsigned char *) RelinquishMagickMemory(pixels); |
| 446 |
(void) FPX_CloseImage(flashpix); |
| 447 |
FPXRelinquishSummaryInfo(&summary_info); |
| 448 |
FPX_ClearSystem(); |
| 449 |
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); |
| 450 |
} |
| 451 |
} |
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
r=red_component->theData+(y % tile_height)*red_component->lineStride; |
| 456 |
g=green_component->theData+(y % tile_height)*green_component->lineStride; |
| 457 |
b=blue_component->theData+(y % tile_height)*blue_component->lineStride; |
| 458 |
a=alpha_component->theData+(y % tile_height)*alpha_component->lineStride; |
| 459 |
for (x=0; x < (ssize_t) image->columns; x++) |
| 460 |
{ |
| 461 |
if (fpx_info.numberOfComponents > 2) |
| 462 |
{ |
| 463 |
SetPixelRed(image,ScaleCharToQuantum(*r),q); |
| 464 |
SetPixelGreen(image,ScaleCharToQuantum(*g),q); |
| 465 |
SetPixelBlue(image,ScaleCharToQuantum(*b),q); |
| 466 |
} |
| 467 |
else |
| 468 |
{ |
| 469 |
index=ScaleCharToQuantum(*r); |
| 470 |
SetPixelIndex(image,index,q); |
| 471 |
SetPixelRed(image,index,q); |
| 472 |
SetPixelGreen(image,index,q); |
| 473 |
SetPixelBlue(image,index,q); |
| 474 |
} |
| 475 |
SetPixelAlpha(image,OpaqueAlpha,q); |
| 476 |
if (image->alpha_trait != UndefinedPixelTrait) |
| 477 |
SetPixelAlpha(image,ScaleCharToQuantum(*a),q); |
| 478 |
q+=(ptrdiff_t) GetPixelChannels(image); |
| 479 |
r+=(ptrdiff_t) red_component->columnStride; |
| 480 |
g+=green_component->columnStride; |
| 481 |
b+=blue_component->columnStride; |
| 482 |
a+=alpha_component->columnStride; |
| 483 |
} |
| 484 |
if (SyncAuthenticPixels(image,exception) == MagickFalse) |
| 485 |
break; |
| 486 |
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, |
| 487 |
image->rows); |
| 488 |
if (status == MagickFalse) |
| 489 |
break; |
| 490 |
} |
| 491 |
pixels=(unsigned char *) RelinquishMagickMemory(pixels); |
| 492 |
(void) FPX_CloseImage(flashpix); |
| 493 |
FPXRelinquishSummaryInfo(&summary_info); |
| 494 |
FPX_ClearSystem(); |
| 495 |
return(GetFirstImageInList(image)); |
| 496 |
} |
| 497 |
#endif |
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
ModuleExport size_t RegisterFPXImage(void) |
| 523 |
{ |
| 524 |
MagickInfo |
| 525 |
*entry; |
| 526 |
|
| 527 |
entry=AcquireMagickInfo("FPX","FPX","FlashPix Format"); |
| 528 |
#if defined(MAGICKCORE_FPX_DELEGATE) |
| 529 |
entry->decoder=(DecodeImageHandler *) ReadFPXImage; |
| 530 |
entry->encoder=(EncodeImageHandler *) WriteFPXImage; |
| 531 |
#endif |
| 532 |
entry->flags^=CoderAdjoinFlag; |
| 533 |
entry->flags^=CoderBlobSupportFlag; |
| 534 |
(void) RegisterMagickInfo(entry); |
| 535 |
return(MagickImageCoderSignature); |
| 536 |
} |
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
ModuleExport void UnregisterFPXImage(void) |
| 558 |
{ |
| 559 |
(void) UnregisterMagickInfo("FPX"); |
| 560 |
} |
| 561 |
|
| 562 |
#if defined(MAGICKCORE_FPX_DELEGATE) |
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
static void ColorTwistMultiply(FPXColorTwistMatrix first, |
| 593 |
FPXColorTwistMatrix second,FPXColorTwistMatrix *color_twist) |
| 594 |
{ |
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
assert(color_twist != (FPXColorTwistMatrix *) NULL); |
| 599 |
color_twist->byy=(first.byy*second.byy)+(first.byc1*second.bc1y)+ |
| 600 |
(first.byc2*second.bc2y)+(first.dummy1_zero*second.dummy4_zero); |
| 601 |
color_twist->byc1=(first.byy*second.byc1)+(first.byc1*second.bc1c1)+ |
| 602 |
(first.byc2*second.bc2c1)+(first.dummy1_zero*second.dummy5_zero); |
| 603 |
color_twist->byc2=(first.byy*second.byc2)+(first.byc1*second.bc1c2)+ |
| 604 |
(first.byc2*second.bc2c2)+(first.dummy1_zero*second.dummy6_zero); |
| 605 |
color_twist->dummy1_zero=(first.byy*second.dummy1_zero)+ |
| 606 |
(first.byc1*second.dummy2_zero)+(first.byc2*second.dummy3_zero)+ |
| 607 |
(first.dummy1_zero*second.dummy7_one); |
| 608 |
color_twist->bc1y=(first.bc1y*second.byy)+(first.bc1c1*second.bc1y)+ |
| 609 |
(first.bc1c2*second.bc2y)+(first.dummy2_zero*second.dummy4_zero); |
| 610 |
color_twist->bc1c1=(first.bc1y*second.byc1)+(first.bc1c1*second.bc1c1)+ |
| 611 |
(first.bc1c2*second.bc2c1)+(first.dummy2_zero*second.dummy5_zero); |
| 612 |
color_twist->bc1c2=(first.bc1y*second.byc2)+(first.bc1c1*second.bc1c2)+ |
| 613 |
(first.bc1c2*second.bc2c2)+(first.dummy2_zero*second.dummy6_zero); |
| 614 |
color_twist->dummy2_zero=(first.bc1y*second.dummy1_zero)+ |
| 615 |
(first.bc1c1*second.dummy2_zero)+(first.bc1c2*second.dummy3_zero)+ |
| 616 |
(first.dummy2_zero*second.dummy7_one); |
| 617 |
color_twist->bc2y=(first.bc2y*second.byy)+(first.bc2c1*second.bc1y)+ |
| 618 |
(first.bc2c2*second.bc2y)+(first.dummy3_zero*second.dummy4_zero); |
| 619 |
color_twist->bc2c1=(first.bc2y*second.byc1)+(first.bc2c1*second.bc1c1)+ |
| 620 |
(first.bc2c2*second.bc2c1)+(first.dummy3_zero*second.dummy5_zero); |
| 621 |
color_twist->bc2c2=(first.bc2y*second.byc2)+(first.bc2c1*second.bc1c2)+ |
| 622 |
(first.bc2c2*second.bc2c2)+(first.dummy3_zero*second.dummy6_zero); |
| 623 |
color_twist->dummy3_zero=(first.bc2y*second.dummy1_zero)+ |
| 624 |
(first.bc2c1*second.dummy2_zero)+(first.bc2c2*second.dummy3_zero)+ |
| 625 |
(first.dummy3_zero*second.dummy7_one); |
| 626 |
color_twist->dummy4_zero=(first.dummy4_zero*second.byy)+ |
| 627 |
(first.dummy5_zero*second.bc1y)+(first.dummy6_zero*second.bc2y)+ |
| 628 |
(first.dummy7_one*second.dummy4_zero); |
| 629 |
color_twist->dummy5_zero=(first.dummy4_zero*second.byc1)+ |
| 630 |
(first.dummy5_zero*second.bc1c1)+(first.dummy6_zero*second.bc2c1)+ |
| 631 |
(first.dummy7_one*second.dummy5_zero); |
| 632 |
color_twist->dummy6_zero=(first.dummy4_zero*second.byc2)+ |
| 633 |
(first.dummy5_zero*second.bc1c2)+(first.dummy6_zero*second.bc2c2)+ |
| 634 |
(first.dummy7_one*second.dummy6_zero); |
| 635 |
color_twist->dummy7_one=(first.dummy4_zero*second.dummy1_zero)+ |
| 636 |
(first.dummy5_zero*second.dummy2_zero)+ |
| 637 |
(first.dummy6_zero*second.dummy3_zero)+(first.dummy7_one*second.dummy7_one); |
| 638 |
} |
| 639 |
|
| 640 |
static void SetBrightness(double brightness,FPXColorTwistMatrix *color_twist) |
| 641 |
{ |
| 642 |
FPXColorTwistMatrix |
| 643 |
effect, |
| 644 |
result; |
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
assert(color_twist != (FPXColorTwistMatrix *) NULL); |
| 650 |
brightness=sqrt((double) brightness); |
| 651 |
effect.byy=brightness; |
| 652 |
effect.byc1=0.0; |
| 653 |
effect.byc2=0.0; |
| 654 |
effect.dummy1_zero=0.0; |
| 655 |
effect.bc1y=0.0; |
| 656 |
effect.bc1c1=brightness; |
| 657 |
effect.bc1c2=0.0; |
| 658 |
effect.dummy2_zero=0.0; |
| 659 |
effect.bc2y=0.0; |
| 660 |
effect.bc2c1=0.0; |
| 661 |
effect.bc2c2=brightness; |
| 662 |
effect.dummy3_zero=0.0; |
| 663 |
effect.dummy4_zero=0.0; |
| 664 |
effect.dummy5_zero=0.0; |
| 665 |
effect.dummy6_zero=0.0; |
| 666 |
effect.dummy7_one=1.0; |
| 667 |
ColorTwistMultiply(*color_twist,effect,&result); |
| 668 |
*color_twist=result; |
| 669 |
} |
| 670 |
|
| 671 |
static void SetColorBalance(double red,double green,double blue, |
| 672 |
FPXColorTwistMatrix *color_twist) |
| 673 |
{ |
| 674 |
FPXColorTwistMatrix |
| 675 |
blue_effect, |
| 676 |
green_effect, |
| 677 |
result, |
| 678 |
rgb_effect, |
| 679 |
rg_effect, |
| 680 |
red_effect; |
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
assert(color_twist != (FPXColorTwistMatrix *) NULL); |
| 686 |
red=sqrt((double) red)-1.0; |
| 687 |
green=sqrt((double) green)-1.0; |
| 688 |
blue=sqrt((double) blue)-1.0; |
| 689 |
red_effect.byy=1.0; |
| 690 |
red_effect.byc1=0.0; |
| 691 |
red_effect.byc2=0.299*red; |
| 692 |
red_effect.dummy1_zero=0.0; |
| 693 |
red_effect.bc1y=(-0.299)*red; |
| 694 |
red_effect.bc1c1=1.0-0.299*red; |
| 695 |
red_effect.bc1c2=(-0.299)*red; |
| 696 |
red_effect.dummy2_zero=0.0; |
| 697 |
red_effect.bc2y=0.701*red; |
| 698 |
red_effect.bc2c1=0.0; |
| 699 |
red_effect.bc2c2=1.0+0.402*red; |
| 700 |
red_effect.dummy3_zero=0.0; |
| 701 |
red_effect.dummy4_zero=0.0; |
| 702 |
red_effect.dummy5_zero=0.0; |
| 703 |
red_effect.dummy6_zero=0.0; |
| 704 |
red_effect.dummy7_one=1.0; |
| 705 |
green_effect.byy=1.0; |
| 706 |
green_effect.byc1=(-0.114)*green; |
| 707 |
green_effect.byc2=(-0.299)*green; |
| 708 |
green_effect.dummy1_zero=0.0; |
| 709 |
green_effect.bc1y=(-0.587)*green; |
| 710 |
green_effect.bc1c1=1.0-0.473*green; |
| 711 |
green_effect.bc1c2=0.299*green; |
| 712 |
green_effect.dummy2_zero=0.0; |
| 713 |
green_effect.bc2y=(-0.587)*green; |
| 714 |
green_effect.bc2c1=0.114*green; |
| 715 |
green_effect.bc2c2=1.0-0.288*green; |
| 716 |
green_effect.dummy3_zero=0.0; |
| 717 |
green_effect.dummy4_zero=0.0; |
| 718 |
green_effect.dummy5_zero=0.0; |
| 719 |
green_effect.dummy6_zero=0.0; |
| 720 |
green_effect.dummy7_one=1.0; |
| 721 |
blue_effect.byy=1.0; |
| 722 |
blue_effect.byc1=0.114*blue; |
| 723 |
blue_effect.byc2=0.0; |
| 724 |
blue_effect.dummy1_zero=0.0; |
| 725 |
blue_effect.bc1y=0.886*blue; |
| 726 |
blue_effect.bc1c1=1.0+0.772*blue; |
| 727 |
blue_effect.bc1c2=0.0; |
| 728 |
blue_effect.dummy2_zero=0.0; |
| 729 |
blue_effect.bc2y=(-0.114)*blue; |
| 730 |
blue_effect.bc2c1=(-0.114)*blue; |
| 731 |
blue_effect.bc2c2=1.0-0.114*blue; |
| 732 |
blue_effect.dummy3_zero=0.0; |
| 733 |
blue_effect.dummy4_zero=0.0; |
| 734 |
blue_effect.dummy5_zero=0.0; |
| 735 |
blue_effect.dummy6_zero=0.0; |
| 736 |
blue_effect.dummy7_one=1.0; |
| 737 |
ColorTwistMultiply(red_effect,green_effect,&rg_effect); |
| 738 |
ColorTwistMultiply(rg_effect,blue_effect,&rgb_effect); |
| 739 |
ColorTwistMultiply(*color_twist,rgb_effect,&result); |
| 740 |
*color_twist=result; |
| 741 |
} |
| 742 |
|
| 743 |
static void SetSaturation(double saturation,FPXColorTwistMatrix *color_twist) |
| 744 |
{ |
| 745 |
FPXColorTwistMatrix |
| 746 |
effect, |
| 747 |
result; |
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
assert(color_twist != (FPXColorTwistMatrix *) NULL); |
| 753 |
effect.byy=1.0; |
| 754 |
effect.byc1=0.0; |
| 755 |
effect.byc2=0.0; |
| 756 |
effect.dummy1_zero=0.0; |
| 757 |
effect.bc1y=0.0; |
| 758 |
effect.bc1c1=saturation; |
| 759 |
effect.bc1c2=0.0; |
| 760 |
effect.dummy2_zero=0.0; |
| 761 |
effect.bc2y=0.0; |
| 762 |
effect.bc2c1=0.0; |
| 763 |
effect.bc2c2=saturation; |
| 764 |
effect.dummy3_zero=0.0; |
| 765 |
effect.dummy4_zero=0.0; |
| 766 |
effect.dummy5_zero=0.0; |
| 767 |
effect.dummy6_zero=0.0; |
| 768 |
effect.dummy7_one=1.0; |
| 769 |
ColorTwistMultiply(*color_twist,effect,&result); |
| 770 |
*color_twist=result; |
| 771 |
} |
| 772 |
|
| 773 |
static MagickBooleanType WriteFPXImage(const ImageInfo *image_info,Image *image, |
| 774 |
ExceptionInfo *exception) |
| 775 |
{ |
| 776 |
FPXBackground |
| 777 |
background_color; |
| 778 |
|
| 779 |
FPXColorspace |
| 780 |
colorspace = |
| 781 |
{ |
| 782 |
TRUE, 4, |
| 783 |
{ |
| 784 |
{ NIFRGB_R, DATA_TYPE_UNSIGNED_BYTE }, |
| 785 |
{ NIFRGB_G, DATA_TYPE_UNSIGNED_BYTE }, |
| 786 |
{ NIFRGB_B, DATA_TYPE_UNSIGNED_BYTE }, |
| 787 |
{ ALPHA, DATA_TYPE_UNSIGNED_BYTE } |
| 788 |
} |
| 789 |
}; |
| 790 |
|
| 791 |
const char |
| 792 |
*comment, |
| 793 |
*label, |
| 794 |
*option; |
| 795 |
|
| 796 |
const Quantum |
| 797 |
*p; |
| 798 |
|
| 799 |
FPXCompressionOption |
| 800 |
compression; |
| 801 |
|
| 802 |
FPXImageDesc |
| 803 |
fpx_info; |
| 804 |
|
| 805 |
FPXImageHandle |
| 806 |
*flashpix; |
| 807 |
|
| 808 |
FPXStatus |
| 809 |
fpx_status; |
| 810 |
|
| 811 |
FPXSummaryInformation |
| 812 |
summary_info; |
| 813 |
|
| 814 |
MagickBooleanType |
| 815 |
status; |
| 816 |
|
| 817 |
QuantumInfo |
| 818 |
*quantum_info; |
| 819 |
|
| 820 |
QuantumType |
| 821 |
quantum_type; |
| 822 |
|
| 823 |
ssize_t |
| 824 |
i; |
| 825 |
|
| 826 |
size_t |
| 827 |
length, |
| 828 |
memory_limit; |
| 829 |
|
| 830 |
ssize_t |
| 831 |
y; |
| 832 |
|
| 833 |
unsigned char |
| 834 |
*pixels; |
| 835 |
|
| 836 |
unsigned int |
| 837 |
tile_height, |
| 838 |
tile_width; |
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
assert(image_info != (const ImageInfo *) NULL); |
| 844 |
assert(image_info->signature == MagickCoreSignature); |
| 845 |
assert(image != (Image *) NULL); |
| 846 |
assert(image->signature == MagickCoreSignature); |
| 847 |
assert(exception != (ExceptionInfo *) NULL); |
| 848 |
assert(exception->signature == MagickCoreSignature); |
| 849 |
if (IsEventLogging() != MagickFalse) |
| 850 |
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 851 |
status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); |
| 852 |
if (status == MagickFalse) |
| 853 |
return(status); |
| 854 |
if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) |
| 855 |
(void) TransformImageColorspace(image,sRGBColorspace,exception); |
| 856 |
(void) CloseBlob(image); |
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
image->depth=8; |
| 861 |
memory_limit=20000000; |
| 862 |
fpx_status=FPX_SetToolkitMemoryLimit(&memory_limit); |
| 863 |
if (fpx_status != FPX_OK) |
| 864 |
ThrowWriterException(DelegateError,"UnableToInitializeFPXLibrary"); |
| 865 |
tile_width=64; |
| 866 |
tile_height=64; |
| 867 |
colorspace.numberOfComponents=3; |
| 868 |
if (image->alpha_trait != UndefinedPixelTrait) |
| 869 |
colorspace.numberOfComponents=4; |
| 870 |
if ((image_info->type != TrueColorType) && |
| 871 |
(IdentifyImageCoderGray(image,exception) != MagickFalse)) |
| 872 |
{ |
| 873 |
colorspace.numberOfComponents=1; |
| 874 |
colorspace.theComponents[0].myColor=MONOCHROME; |
| 875 |
} |
| 876 |
background_color.color1_value=0; |
| 877 |
background_color.color2_value=0; |
| 878 |
background_color.color3_value=0; |
| 879 |
background_color.color4_value=0; |
| 880 |
compression=NONE; |
| 881 |
if (image->compression == JPEGCompression) |
| 882 |
compression=JPEG_UNSPECIFIED; |
| 883 |
if (image_info->compression == JPEGCompression) |
| 884 |
compression=JPEG_UNSPECIFIED; |
| 885 |
fpx_status=FPX_CreateImageByFilename(image->filename,image->columns, |
| 886 |
image->rows,tile_width,tile_height,colorspace,background_color,compression, |
| 887 |
&flashpix); |
| 888 |
if (fpx_status != FPX_OK) |
| 889 |
return(status); |
| 890 |
if (compression == JPEG_UNSPECIFIED) |
| 891 |
{ |
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
fpx_status=FPX_SetJPEGCompression(flashpix,(unsigned short) |
| 896 |
image->quality == UndefinedCompressionQuality ? 75 : image->quality); |
| 897 |
if (fpx_status != FPX_OK) |
| 898 |
ThrowWriterException(DelegateError,"UnableToSetJPEGLevel"); |
| 899 |
} |
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
(void) memset(&summary_info,0,sizeof(summary_info)); |
| 904 |
label=GetImageProperty(image,"label",exception); |
| 905 |
if (label != (const char *) NULL) |
| 906 |
{ |
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
summary_info.title_valid=MagickTrue; |
| 911 |
length=strlen(label); |
| 912 |
summary_info.title.length=length; |
| 913 |
if (~length >= (MagickPathExtent-1)) |
| 914 |
summary_info.title.ptr=(unsigned char *) AcquireQuantumMemory( |
| 915 |
length+MagickPathExtent,sizeof(*summary_info.title.ptr)); |
| 916 |
if (summary_info.title.ptr == (unsigned char *) NULL) |
| 917 |
ThrowWriterException(DelegateError,"UnableToSetImageTitle"); |
| 918 |
(void) CopyMagickString((char *) summary_info.title.ptr,label, |
| 919 |
MagickPathExtent); |
| 920 |
} |
| 921 |
comment=GetImageProperty(image,"comment",exception); |
| 922 |
if (comment != (const char *) NULL) |
| 923 |
{ |
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
summary_info.comments_valid=MagickTrue; |
| 928 |
summary_info.comments.ptr=(unsigned char *) AcquireString(comment); |
| 929 |
summary_info.comments.length=strlen(comment); |
| 930 |
} |
| 931 |
fpx_status=FPX_SetSummaryInformation(flashpix,&summary_info); |
| 932 |
if (fpx_status != FPX_OK) |
| 933 |
ThrowWriterException(DelegateError,"UnableToSetSummaryInfo"); |
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
quantum_info=AcquireQuantumInfo(image_info,image); |
| 938 |
if (quantum_info == (QuantumInfo *) NULL) |
| 939 |
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); |
| 940 |
pixels=(unsigned char *) GetQuantumPixels(quantum_info); |
| 941 |
fpx_info.numberOfComponents=(unsigned int) colorspace.numberOfComponents; |
| 942 |
for (i=0; i < (ssize_t) fpx_info.numberOfComponents; i++) |
| 943 |
{ |
| 944 |
fpx_info.components[i].myColorType.myDataType=DATA_TYPE_UNSIGNED_BYTE; |
| 945 |
fpx_info.components[i].horzSubSampFactor=1; |
| 946 |
fpx_info.components[i].vertSubSampFactor=1; |
| 947 |
fpx_info.components[i].columnStride=(int) fpx_info.numberOfComponents; |
| 948 |
fpx_info.components[i].lineStride=image->columns* |
| 949 |
(size_t) fpx_info.components[i].columnStride; |
| 950 |
fpx_info.components[i].theData=pixels+i; |
| 951 |
} |
| 952 |
fpx_info.components[0].myColorType.myColor=fpx_info.numberOfComponents != 1 ? |
| 953 |
NIFRGB_R : MONOCHROME; |
| 954 |
fpx_info.components[1].myColorType.myColor=NIFRGB_G; |
| 955 |
fpx_info.components[2].myColorType.myColor=NIFRGB_B; |
| 956 |
fpx_info.components[3].myColorType.myColor=ALPHA; |
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
quantum_type=RGBQuantum; |
| 961 |
if (image->alpha_trait != UndefinedPixelTrait) |
| 962 |
quantum_type=RGBAQuantum; |
| 963 |
if (fpx_info.numberOfComponents == 1) |
| 964 |
quantum_type=GrayQuantum; |
| 965 |
for (y=0; y < (ssize_t) image->rows; y++) |
| 966 |
{ |
| 967 |
p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
| 968 |
if (p == (const Quantum *) NULL) |
| 969 |
break; |
| 970 |
length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
| 971 |
quantum_type,pixels,exception); |
| 972 |
fpx_status=FPX_WriteImageLine(flashpix,&fpx_info); |
| 973 |
if (fpx_status != FPX_OK) |
| 974 |
break; |
| 975 |
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, |
| 976 |
image->rows); |
| 977 |
if (status == MagickFalse) |
| 978 |
break; |
| 979 |
} |
| 980 |
quantum_info=DestroyQuantumInfo(quantum_info); |
| 981 |
option=GetImageOption(image_info,"fpx:view"); |
| 982 |
if (option != (const char *) NULL) |
| 983 |
{ |
| 984 |
FPXAffineMatrix |
| 985 |
affine; |
| 986 |
|
| 987 |
FPXColorTwistMatrix |
| 988 |
color_twist; |
| 989 |
|
| 990 |
FPXContrastAdjustment |
| 991 |
contrast; |
| 992 |
|
| 993 |
FPXFilteringValue |
| 994 |
sharpen; |
| 995 |
|
| 996 |
FPXResultAspectRatio |
| 997 |
aspect_ratio; |
| 998 |
|
| 999 |
FPXROI |
| 1000 |
view_rect; |
| 1001 |
|
| 1002 |
MagickBooleanType |
| 1003 |
affine_valid, |
| 1004 |
aspect_ratio_valid, |
| 1005 |
color_twist_valid, |
| 1006 |
contrast_valid, |
| 1007 |
sharpen_valid, |
| 1008 |
view_rect_valid; |
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
contrast=1.0; |
| 1014 |
contrast_valid=MagickTrue; |
| 1015 |
color_twist.byy=1.0; |
| 1016 |
color_twist.byc1=0.0; |
| 1017 |
color_twist.byc2=0.0; |
| 1018 |
color_twist.dummy1_zero=0.0; |
| 1019 |
color_twist.bc1y=0.0; |
| 1020 |
color_twist.bc1c1=1.0; |
| 1021 |
color_twist.bc1c2=0.0; |
| 1022 |
color_twist.dummy2_zero=0.0; |
| 1023 |
color_twist.bc2y=0.0; |
| 1024 |
color_twist.bc2c1=0.0; |
| 1025 |
color_twist.bc2c2=1.0; |
| 1026 |
color_twist.dummy3_zero=0.0; |
| 1027 |
color_twist.dummy4_zero=0.0; |
| 1028 |
color_twist.dummy5_zero=0.0; |
| 1029 |
color_twist.dummy6_zero=0.0; |
| 1030 |
color_twist.dummy7_one=1.0; |
| 1031 |
color_twist_valid=MagickTrue; |
| 1032 |
sharpen=0.0; |
| 1033 |
sharpen_valid=MagickTrue; |
| 1034 |
aspect_ratio=(double) image->columns/image->rows; |
| 1035 |
aspect_ratio_valid=MagickTrue; |
| 1036 |
view_rect.left=(float) 0.1; |
| 1037 |
view_rect.width=aspect_ratio-0.2; |
| 1038 |
view_rect.top=(float) 0.1; |
| 1039 |
view_rect.height=(float) 0.8; |
| 1040 |
view_rect_valid=MagickTrue; |
| 1041 |
affine.a11=1.0; |
| 1042 |
affine.a12=0.0; |
| 1043 |
affine.a13=0.0; |
| 1044 |
affine.a14=0.0; |
| 1045 |
affine.a21=0.0; |
| 1046 |
affine.a22=1.0; |
| 1047 |
affine.a23=0.0; |
| 1048 |
affine.a24=0.0; |
| 1049 |
affine.a31=0.0; |
| 1050 |
affine.a32=0.0; |
| 1051 |
affine.a33=1.0; |
| 1052 |
affine.a34=0.0; |
| 1053 |
affine.a41=0.0; |
| 1054 |
affine.a42=0.0; |
| 1055 |
affine.a43=0.0; |
| 1056 |
affine.a44=1.0; |
| 1057 |
affine_valid=MagickTrue; |
| 1058 |
if (0) |
| 1059 |
{ |
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
SetBrightness(0.5,&color_twist); |
| 1064 |
SetSaturation(0.5,&color_twist); |
| 1065 |
SetColorBalance(0.5,1.0,1.0,&color_twist); |
| 1066 |
color_twist_valid=MagickTrue; |
| 1067 |
} |
| 1068 |
if (affine_valid != MagickFalse) |
| 1069 |
{ |
| 1070 |
fpx_status=FPX_SetImageAffineMatrix(flashpix,&affine); |
| 1071 |
if (fpx_status != FPX_OK) |
| 1072 |
ThrowWriterException(DelegateError,"UnableToSetAffineMatrix"); |
| 1073 |
} |
| 1074 |
if (aspect_ratio_valid != MagickFalse) |
| 1075 |
{ |
| 1076 |
fpx_status=FPX_SetImageResultAspectRatio(flashpix,&aspect_ratio); |
| 1077 |
if (fpx_status != FPX_OK) |
| 1078 |
ThrowWriterException(DelegateError,"UnableToSetAspectRatio"); |
| 1079 |
} |
| 1080 |
if (color_twist_valid != MagickFalse) |
| 1081 |
{ |
| 1082 |
fpx_status=FPX_SetImageColorTwistMatrix(flashpix,&color_twist); |
| 1083 |
if (fpx_status != FPX_OK) |
| 1084 |
ThrowWriterException(DelegateError,"UnableToSetColorTwist"); |
| 1085 |
} |
| 1086 |
if (contrast_valid != MagickFalse) |
| 1087 |
{ |
| 1088 |
fpx_status=FPX_SetImageContrastAdjustment(flashpix,&contrast); |
| 1089 |
if (fpx_status != FPX_OK) |
| 1090 |
ThrowWriterException(DelegateError,"UnableToSetContrast"); |
| 1091 |
} |
| 1092 |
if (sharpen_valid != MagickFalse) |
| 1093 |
{ |
| 1094 |
fpx_status=FPX_SetImageFilteringValue(flashpix,&sharpen); |
| 1095 |
if (fpx_status != FPX_OK) |
| 1096 |
ThrowWriterException(DelegateError,"UnableToSetFilteringValue"); |
| 1097 |
} |
| 1098 |
if (view_rect_valid != MagickFalse) |
| 1099 |
{ |
| 1100 |
fpx_status=FPX_SetImageROI(flashpix,&view_rect); |
| 1101 |
if (fpx_status != FPX_OK) |
| 1102 |
ThrowWriterException(DelegateError,"UnableToSetRegionOfInterest"); |
| 1103 |
} |
| 1104 |
} |
| 1105 |
(void) FPX_CloseImage(flashpix); |
| 1106 |
FPXRelinquishSummaryInfo(&summary_info); |
| 1107 |
FPX_ClearSystem(); |
| 1108 |
return(MagickTrue); |
| 1109 |
} |
| 1110 |
#endif |