| 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 | |
|---|
| 43 | #include "magick/studio.h" |
|---|
| 44 | #include "magick/cache-view.h" |
|---|
| 45 | #include "magick/color-private.h" |
|---|
| 46 | #include "magick/colorspace-private.h" |
|---|
| 47 | #include "magick/composite.h" |
|---|
| 48 | #include "magick/decorate.h" |
|---|
| 49 | #include "magick/exception.h" |
|---|
| 50 | #include "magick/exception-private.h" |
|---|
| 51 | #include "magick/image.h" |
|---|
| 52 | #include "magick/memory_.h" |
|---|
| 53 | #include "magick/monitor.h" |
|---|
| 54 | #include "magick/monitor-private.h" |
|---|
| 55 | #include "magick/pixel-private.h" |
|---|
| 56 | #include "magick/quantum.h" |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | #define AccentuateModulate ScaleCharToQuantum(80) |
|---|
| 62 | #define HighlightModulate ScaleCharToQuantum(125) |
|---|
| 63 | #define ShadowModulate ScaleCharToQuantum(135) |
|---|
| 64 | #define DepthModulate ScaleCharToQuantum(185) |
|---|
| 65 | #define TroughModulate ScaleCharToQuantum(110) |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | MagickExport Image *BorderImage(const Image *image, |
|---|
| 98 | const RectangleInfo *border_info,ExceptionInfo *exception) |
|---|
| 99 | { |
|---|
| 100 | Image |
|---|
| 101 | *border_image, |
|---|
| 102 | *clone_image; |
|---|
| 103 | |
|---|
| 104 | FrameInfo |
|---|
| 105 | frame_info; |
|---|
| 106 | |
|---|
| 107 | assert(image != (const Image *) NULL); |
|---|
| 108 | assert(image->signature == MagickSignature); |
|---|
| 109 | if (image->debug != MagickFalse) |
|---|
| 110 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
|---|
| 111 | assert(border_info != (RectangleInfo *) NULL); |
|---|
| 112 | frame_info.width=image->columns+(border_info->width << 1); |
|---|
| 113 | frame_info.height=image->rows+(border_info->height << 1); |
|---|
| 114 | frame_info.x=(long) border_info->width; |
|---|
| 115 | frame_info.y=(long) border_info->height; |
|---|
| 116 | frame_info.inner_bevel=0; |
|---|
| 117 | frame_info.outer_bevel=0; |
|---|
| 118 | clone_image=CloneImage(image,0,0,MagickTrue,exception); |
|---|
| 119 | if (clone_image == (Image *) NULL) |
|---|
| 120 | return((Image *) NULL); |
|---|
| 121 | clone_image->matte_color=image->border_color; |
|---|
| 122 | border_image=FrameImage(clone_image,&frame_info,exception); |
|---|
| 123 | clone_image=DestroyImage(clone_image); |
|---|
| 124 | if (border_image != (Image *) NULL) |
|---|
| 125 | border_image->matte_color=image->matte_color; |
|---|
| 126 | return(border_image); |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | MagickExport Image *FrameImage(const Image *image,const FrameInfo *frame_info, |
|---|
| 161 | ExceptionInfo *exception) |
|---|
| 162 | { |
|---|
| 163 | #define FrameImageTag "Frame/Image" |
|---|
| 164 | |
|---|
| 165 | Image |
|---|
| 166 | *frame_image; |
|---|
| 167 | |
|---|
| 168 | long |
|---|
| 169 | progress, |
|---|
| 170 | y; |
|---|
| 171 | |
|---|
| 172 | MagickBooleanType |
|---|
| 173 | status; |
|---|
| 174 | |
|---|
| 175 | MagickPixelPacket |
|---|
| 176 | accentuate, |
|---|
| 177 | border, |
|---|
| 178 | highlight, |
|---|
| 179 | interior, |
|---|
| 180 | matte, |
|---|
| 181 | shadow, |
|---|
| 182 | trough; |
|---|
| 183 | |
|---|
| 184 | register IndexPacket |
|---|
| 185 | *frame_indexes; |
|---|
| 186 | |
|---|
| 187 | register long |
|---|
| 188 | x; |
|---|
| 189 | |
|---|
| 190 | register PixelPacket |
|---|
| 191 | *q; |
|---|
| 192 | |
|---|
| 193 | unsigned long |
|---|
| 194 | bevel_width, |
|---|
| 195 | height, |
|---|
| 196 | width; |
|---|
| 197 | |
|---|
| 198 | ViewInfo |
|---|
| 199 | *frame_view; |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | assert(image != (Image *) NULL); |
|---|
| 205 | assert(image->signature == MagickSignature); |
|---|
| 206 | if (image->debug != MagickFalse) |
|---|
| 207 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
|---|
| 208 | assert(frame_info != (FrameInfo *) NULL); |
|---|
| 209 | bevel_width=(unsigned long) (frame_info->outer_bevel+frame_info->inner_bevel); |
|---|
| 210 | width=frame_info->width-frame_info->x-bevel_width; |
|---|
| 211 | height=frame_info->height-frame_info->y-bevel_width; |
|---|
| 212 | if ((width < image->columns) || (height < image->rows)) |
|---|
| 213 | ThrowImageException(OptionError,"FrameIsLessThanImageSize"); |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | frame_image=CloneImage(image,frame_info->width,frame_info->height,MagickTrue, |
|---|
| 218 | exception); |
|---|
| 219 | if (frame_image == (Image *) NULL) |
|---|
| 220 | return((Image *) NULL); |
|---|
| 221 | if (SetImageStorageClass(frame_image,DirectClass) == MagickFalse) |
|---|
| 222 | { |
|---|
| 223 | InheritException(exception,&frame_image->exception); |
|---|
| 224 | frame_image=DestroyImage(frame_image); |
|---|
| 225 | return((Image *) NULL); |
|---|
| 226 | } |
|---|
| 227 | if (frame_image->matte_color.opacity != OpaqueOpacity) |
|---|
| 228 | frame_image->matte=MagickTrue; |
|---|
| 229 | frame_image->page=image->page; |
|---|
| 230 | if ((image->page.width != 0) && (image->page.height != 0)) |
|---|
| 231 | { |
|---|
| 232 | frame_image->page.width+=frame_image->columns-image->columns; |
|---|
| 233 | frame_image->page.height+=frame_image->rows-image->rows; |
|---|
| 234 | } |
|---|
| 235 | |
|---|
| 236 | |
|---|
| 237 | |
|---|
| 238 | GetMagickPixelPacket(frame_image,&interior); |
|---|
| 239 | SetMagickPixelPacket(frame_image,&image->border_color,(IndexPacket *) NULL, |
|---|
| 240 | &interior); |
|---|
| 241 | GetMagickPixelPacket(frame_image,&matte); |
|---|
| 242 | matte.colorspace=RGBColorspace; |
|---|
| 243 | SetMagickPixelPacket(frame_image,&image->matte_color,(IndexPacket *) NULL, |
|---|
| 244 | &matte); |
|---|
| 245 | GetMagickPixelPacket(frame_image,&border); |
|---|
| 246 | border.colorspace=RGBColorspace; |
|---|
| 247 | SetMagickPixelPacket(frame_image,&image->border_color,(IndexPacket *) NULL, |
|---|
| 248 | &border); |
|---|
| 249 | GetMagickPixelPacket(frame_image,&accentuate); |
|---|
| 250 | accentuate.red=(MagickRealType) (QuantumScale*((QuantumRange- |
|---|
| 251 | AccentuateModulate)*matte.red+(QuantumRange*AccentuateModulate))); |
|---|
| 252 | accentuate.green=(MagickRealType) (QuantumScale*((QuantumRange- |
|---|
| 253 | AccentuateModulate)*matte.green+(QuantumRange*AccentuateModulate))); |
|---|
| 254 | accentuate.blue=(MagickRealType) (QuantumScale*((QuantumRange- |
|---|
| 255 | AccentuateModulate)*matte.blue+(QuantumRange*AccentuateModulate))); |
|---|
| 256 | accentuate.opacity=matte.opacity; |
|---|
| 257 | GetMagickPixelPacket(frame_image,&highlight); |
|---|
| 258 | highlight.red=(MagickRealType) (QuantumScale*((QuantumRange- |
|---|
| 259 | HighlightModulate)*matte.red+(QuantumRange*HighlightModulate))); |
|---|
| 260 | highlight.green=(MagickRealType) (QuantumScale*((QuantumRange- |
|---|
| 261 | HighlightModulate)*matte.green+(QuantumRange*HighlightModulate))); |
|---|
| 262 | highlight.blue=(MagickRealType) (QuantumScale*((QuantumRange- |
|---|
| 263 | HighlightModulate)*matte.blue+(QuantumRange*HighlightModulate))); |
|---|
| 264 | highlight.opacity=matte.opacity; |
|---|
| 265 | GetMagickPixelPacket(frame_image,&shadow); |
|---|
| 266 | shadow.red=QuantumScale*matte.red*ShadowModulate; |
|---|
| 267 | shadow.green=QuantumScale*matte.green*ShadowModulate; |
|---|
| 268 | shadow.blue=QuantumScale*matte.blue*ShadowModulate; |
|---|
| 269 | shadow.opacity=matte.opacity; |
|---|
| 270 | GetMagickPixelPacket(frame_image,&trough); |
|---|
| 271 | trough.red=QuantumScale*matte.red*TroughModulate; |
|---|
| 272 | trough.green=QuantumScale*matte.green*TroughModulate; |
|---|
| 273 | trough.blue=QuantumScale*matte.blue*TroughModulate; |
|---|
| 274 | trough.opacity=matte.opacity; |
|---|
| 275 | if (image->colorspace == CMYKColorspace) |
|---|
| 276 | { |
|---|
| 277 | ConvertRGBToCMYK(&interior); |
|---|
| 278 | ConvertRGBToCMYK(&matte); |
|---|
| 279 | ConvertRGBToCMYK(&border); |
|---|
| 280 | ConvertRGBToCMYK(&accentuate); |
|---|
| 281 | ConvertRGBToCMYK(&highlight); |
|---|
| 282 | ConvertRGBToCMYK(&shadow); |
|---|
| 283 | ConvertRGBToCMYK(&trough); |
|---|
| 284 | } |
|---|
| 285 | height=(unsigned long) (frame_info->outer_bevel+(frame_info->y-bevel_width)+ |
|---|
| 286 | frame_info->inner_bevel); |
|---|
| 287 | frame_view=AcquireCacheView(frame_image); |
|---|
| 288 | progress=0; |
|---|
| 289 | q=SetCacheViewPixels(frame_view,0,0,frame_image->columns,height); |
|---|
| 290 | frame_indexes=GetCacheViewIndexes(frame_view); |
|---|
| 291 | if (q != (PixelPacket *) NULL) |
|---|
| 292 | { |
|---|
| 293 | |
|---|
| 294 | |
|---|
| 295 | |
|---|
| 296 | for (y=0; y < (long) frame_info->outer_bevel; y++) |
|---|
| 297 | { |
|---|
| 298 | for (x=0; x < (long) (frame_image->columns-y); x++) |
|---|
| 299 | { |
|---|
| 300 | if (x < y) |
|---|
| 301 | SetPixelPacket(frame_image,&highlight,q,frame_indexes); |
|---|
| 302 | else |
|---|
| 303 | SetPixelPacket(frame_image,&accentuate,q,frame_indexes); |
|---|
| 304 | q++; |
|---|
| 305 | frame_indexes++; |
|---|
| 306 | } |
|---|
| 307 | for ( ; x < (long) frame_image->columns; x++) |
|---|
| 308 | { |
|---|
| 309 | SetPixelPacket(frame_image,&shadow,q,frame_indexes); |
|---|
| 310 | q++; |
|---|
| 311 | frame_indexes++; |
|---|
| 312 | } |
|---|
| 313 | } |
|---|
| 314 | for (y=0; y < (long) (frame_info->y-bevel_width); y++) |
|---|
| 315 | { |
|---|
| 316 | for (x=0; x < (long) frame_info->outer_bevel; x++) |
|---|
| 317 | { |
|---|
| 318 | SetPixelPacket(frame_image,&highlight,q,frame_indexes); |
|---|
| 319 | q++; |
|---|
| 320 | frame_indexes++; |
|---|
| 321 | } |
|---|
| 322 | width=frame_image->columns-2*frame_info->outer_bevel; |
|---|
| 323 | for (x=0; x < (long) width; x++) |
|---|
| 324 | { |
|---|
| 325 | SetPixelPacket(frame_image,&matte,q,frame_indexes); |
|---|
| 326 | q++; |
|---|
| 327 | frame_indexes++; |
|---|
| 328 | } |
|---|
| 329 | for (x=0; x < (long) frame_info->outer_bevel; x++) |
|---|
| 330 | { |
|---|
| 331 | SetPixelPacket(frame_image,&shadow,q,frame_indexes); |
|---|
| 332 | q++; |
|---|
| 333 | frame_indexes++; |
|---|
| 334 | } |
|---|
| 335 | } |
|---|
| 336 | for (y=0; y < (long) frame_info->inner_bevel; y++) |
|---|
| 337 | { |
|---|
| 338 | for (x=0; x < (long) frame_info->outer_bevel; x++) |
|---|
| 339 | { |
|---|
| 340 | SetPixelPacket(frame_image,&highlight,q,frame_indexes); |
|---|
| 341 | q++; |
|---|
| 342 | frame_indexes++; |
|---|
| 343 | } |
|---|
| 344 | for (x=0; x < (long) (frame_info->x-bevel_width); x++) |
|---|
| 345 | { |
|---|
| 346 | SetPixelPacket(frame_image,&matte,q,frame_indexes); |
|---|
| 347 | q++; |
|---|
| 348 | frame_indexes++; |
|---|
| 349 | } |
|---|
| 350 | width=image->columns+((unsigned long) frame_info->inner_bevel << 1)-y; |
|---|
| 351 | for (x=0; x < (long) width; x++) |
|---|
| 352 | { |
|---|
| 353 | if (x < y) |
|---|
| 354 | SetPixelPacket(frame_image,&shadow,q,frame_indexes); |
|---|
| 355 | else |
|---|
| 356 | SetPixelPacket(frame_image,&trough,q,frame_indexes); |
|---|
| 357 | q++; |
|---|
| 358 | frame_indexes++; |
|---|
| 359 | } |
|---|
| 360 | for ( ; x < (long) (image->columns+2*frame_info->inner_bevel); x++) |
|---|
| 361 | { |
|---|
| 362 | SetPixelPacket(frame_image,&highlight,q,frame_indexes); |
|---|
| 363 | q++; |
|---|
| 364 | frame_indexes++; |
|---|
| 365 | } |
|---|
| 366 | width=frame_info->width-frame_info->x-image->columns-bevel_width; |
|---|
| 367 | for (x=0; x < (long) width; x++) |
|---|
| 368 | { |
|---|
| 369 | SetPixelPacket(frame_image,&matte,q,frame_indexes); |
|---|
| 370 | q++; |
|---|
| 371 | frame_indexes++; |
|---|
| 372 | } |
|---|
| 373 | for (x=0; x < (long) frame_info->outer_bevel; x++) |
|---|
| 374 | { |
|---|
| 375 | SetPixelPacket(frame_image,&shadow,q,frame_indexes); |
|---|
| 376 | q++; |
|---|
| 377 | frame_indexes++; |
|---|
| 378 | } |
|---|
| 379 | } |
|---|
| 380 | (void) SyncCacheView(frame_view); |
|---|
| 381 | } |
|---|
| 382 | |
|---|
| 383 | |
|---|
| 384 | |
|---|
| 385 | for (y=0; y < (long) image->rows; y++) |
|---|
| 386 | { |
|---|
| 387 | |
|---|
| 388 | |
|---|
| 389 | |
|---|
| 390 | q=SetCacheViewPixels(frame_view,0,frame_info->y+y,frame_image->columns,1); |
|---|
| 391 | if (q == (PixelPacket *) NULL) |
|---|
| 392 | break; |
|---|
| 393 | frame_indexes=GetCacheViewIndexes(frame_view); |
|---|
| 394 | for (x=0; x < (long) frame_info->outer_bevel; x++) |
|---|
| 395 | { |
|---|
| 396 | SetPixelPacket(frame_image,&highlight,q,frame_indexes); |
|---|
| 397 | q++; |
|---|
| 398 | frame_indexes++; |
|---|
| 399 | } |
|---|
| 400 | for (x=0; x < (long) (frame_info->x-bevel_width); x++) |
|---|
| 401 | { |
|---|
| 402 | SetPixelPacket(frame_image,&matte,q,frame_indexes); |
|---|
| 403 | q++; |
|---|
| 404 | frame_indexes++; |
|---|
| 405 | } |
|---|
| 406 | for (x=0; x < (long) frame_info->inner_bevel; x++) |
|---|
| 407 | { |
|---|
| 408 | SetPixelPacket(frame_image,&shadow,q,frame_indexes); |
|---|
| 409 | q++; |
|---|
| 410 | frame_indexes++; |
|---|
| 411 | } |
|---|
| 412 | |
|---|
| 413 | |
|---|
| 414 | |
|---|
| 415 | for (x=0; x < (long) image->columns; x++) |
|---|
| 416 | { |
|---|
| 417 | SetPixelPacket(frame_image,&interior,q,frame_indexes); |
|---|
| 418 | q++; |
|---|
| 419 | frame_indexes++; |
|---|
| 420 | } |
|---|
| 421 | for (x=0; x < (long) frame_info->inner_bevel; x++) |
|---|
| 422 | { |
|---|
| 423 | SetPixelPacket(frame_image,&highlight,q,frame_indexes); |
|---|
| 424 | q++; |
|---|
| 425 | frame_indexes++; |
|---|
| 426 | } |
|---|
| 427 | width=frame_info->width-frame_info->x-image->columns-bevel_width; |
|---|
| 428 | for (x=0; x < (long) width; x++) |
|---|
| 429 | { |
|---|
| 430 | SetPixelPacket(frame_image,&matte,q,frame_indexes); |
|---|
| 431 | q++; |
|---|
| 432 | frame_indexes++; |
|---|
| 433 | } |
|---|
| 434 | for (x=0; x < (long) frame_info->outer_bevel; x++) |
|---|
| 435 | { |
|---|
| 436 | SetPixelPacket(frame_image,&shadow,q,frame_indexes); |
|---|
| 437 | q++; |
|---|
| 438 | frame_indexes++; |
|---|
| 439 | } |
|---|
| 440 | if (SyncCacheView(frame_view) == MagickFalse) |
|---|
| 441 | break; |
|---|
| 442 | if (image->progress_monitor != (MagickProgressMonitor) NULL) |
|---|
| 443 | { |
|---|
| 444 | MagickBooleanType |
|---|
| 445 | proceed; |
|---|
| 446 | |
|---|
| 447 | proceed=SetImageProgress(image,FrameImageTag,progress++,image->rows); |
|---|
| 448 | if (proceed == MagickFalse) |
|---|
| 449 | status=MagickFalse; |
|---|
| 450 | } |
|---|
| 451 | } |
|---|
| 452 | height=(unsigned long) (frame_info->inner_bevel+frame_info->height- |
|---|
| 453 | frame_info->y-image->rows-bevel_width+frame_info->outer_bevel); |
|---|
| 454 | q=SetCacheViewPixels(frame_view,0,(long) (frame_image->rows-height), |
|---|
| 455 | frame_image->columns,height); |
|---|
| 456 | if (q != (PixelPacket *) NULL) |
|---|
| 457 | { |
|---|
| 458 | |
|---|
| 459 | |
|---|
| 460 | |
|---|
| 461 | frame_indexes=GetIndexes(frame_image); |
|---|
| 462 | for (y=frame_info->inner_bevel-1; y >= 0; y--) |
|---|
| 463 | { |
|---|
| 464 | for (x=0; x < (long) frame_info->outer_bevel; x++) |
|---|
| 465 | { |
|---|
| 466 | SetPixelPacket(frame_image,&highlight,q,frame_indexes); |
|---|
| 467 | q++; |
|---|
| 468 | frame_indexes++; |
|---|
| 469 | } |
|---|
| 470 | for (x=0; x < (long) (frame_info->x-bevel_width); x++) |
|---|
| 471 | { |
|---|
| 472 | SetPixelPacket(frame_image,&matte,q,frame_indexes); |
|---|
| 473 | q++; |
|---|
| 474 | frame_indexes++; |
|---|
| 475 | } |
|---|
| 476 | for (x=0; x < y; x++) |
|---|
| 477 | { |
|---|
| 478 | SetPixelPacket(frame_image,&shadow,q,frame_indexes); |
|---|
| 479 | q++; |
|---|
| 480 | frame_indexes++; |
|---|
| 481 | } |
|---|
| 482 | for ( ; x < (long) (image->columns+2*frame_info->inner_bevel); x++) |
|---|
| 483 | { |
|---|
| 484 | if (x >= (long) (image->columns+2*frame_info->inner_bevel-y)) |
|---|
| 485 | SetPixelPacket(frame_image,&highlight,q,frame_indexes); |
|---|
| 486 | else |
|---|
| 487 | SetPixelPacket(frame_image,&accentuate,q,frame_indexes); |
|---|
| 488 | q++; |
|---|
| 489 | frame_indexes++; |
|---|
| 490 | } |
|---|
| 491 | width=frame_info->width-frame_info->x-image->columns-bevel_width; |
|---|
| 492 | for (x=0; x < (long) width; x++) |
|---|
| 493 | { |
|---|
| 494 | SetPixelPacket(frame_image,&matte,q,frame_indexes); |
|---|
| 495 | q++; |
|---|
| 496 | frame_indexes++; |
|---|
| 497 | } |
|---|
| 498 | for (x=0; x < (long) frame_info->outer_bevel; x++) |
|---|
| 499 | { |
|---|
| 500 | SetPixelPacket(frame_image,&shadow,q,frame_indexes); |
|---|
| 501 | q++; |
|---|
| 502 | frame_indexes++; |
|---|
| 503 | } |
|---|
| 504 | } |
|---|
| 505 | height=frame_info->height-frame_info->y-image->rows-bevel_width; |
|---|
| 506 | for (y=0; y < (long) height; y++) |
|---|
| 507 | { |
|---|
| 508 | for (x=0; x < (long) frame_info->outer_bevel; x++) |
|---|
| 509 | { |
|---|
| 510 | SetPixelPacket(frame_image,&highlight,q,frame_indexes); |
|---|
| 511 | q++; |
|---|
| 512 | frame_indexes++; |
|---|
| 513 | } |
|---|
| 514 | width=frame_image->columns-2*frame_info->outer_bevel; |
|---|
| 515 | for (x=0; x < (long) width; x++) |
|---|
| 516 | { |
|---|
| 517 | SetPixelPacket(frame_image,&matte,q,frame_indexes); |
|---|
| 518 | q++; |
|---|
| 519 | frame_indexes++; |
|---|
| 520 | } |
|---|
| 521 | for (x=0; x < (long) frame_info->outer_bevel; x++) |
|---|
| 522 | { |
|---|
| 523 | SetPixelPacket(frame_image,&shadow,q,frame_indexes); |
|---|
| 524 | q++; |
|---|
| 525 | frame_indexes++; |
|---|
| 526 | } |
|---|
| 527 | } |
|---|
| 528 | for (y=frame_info->outer_bevel-1; y >= 0; y--) |
|---|
| 529 | { |
|---|
| 530 | for (x=0; x < y; x++) |
|---|
| 531 | { |
|---|
| 532 | SetPixelPacket(frame_image,&highlight,q,frame_indexes); |
|---|
| 533 | q++; |
|---|
| 534 | frame_indexes++; |
|---|
| 535 | } |
|---|
| 536 | for ( ; x < (long) frame_image->columns; x++) |
|---|
| 537 | { |
|---|
| 538 | if (x >= (long) (frame_image->columns-y)) |
|---|
| 539 | SetPixelPacket(frame_image,&shadow,q,frame_indexes); |
|---|
| 540 | else |
|---|
| 541 | SetPixelPacket(frame_image,&trough,q,frame_indexes); |
|---|
| 542 | q++; |
|---|
| 543 | frame_indexes++; |
|---|
| 544 | } |
|---|
| 545 | } |
|---|
| 546 | (void) SyncCacheView(frame_view); |
|---|
| 547 | } |
|---|
| 548 | frame_view=DestroyCacheView(frame_view); |
|---|
| 549 | x=(long) (frame_info->outer_bevel+(frame_info->x-bevel_width)+ |
|---|
| 550 | frame_info->inner_bevel); |
|---|
| 551 | y=(long) (frame_info->outer_bevel+(frame_info->y-bevel_width)+ |
|---|
| 552 | frame_info->inner_bevel); |
|---|
| 553 | (void) CompositeImage(frame_image,image->compose,image,x,y); |
|---|
| 554 | return(frame_image); |
|---|
| 555 | } |
|---|
| 556 | |
|---|
| 557 | |
|---|
| 558 | |
|---|
| 559 | |
|---|
| 560 | |
|---|
| 561 | |
|---|
| 562 | |
|---|
| 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 | MagickExport MagickBooleanType RaiseImage(Image *image, |
|---|
| 589 | const RectangleInfo *raise_info,const MagickBooleanType raise) |
|---|
| 590 | { |
|---|
| 591 | #define AccentuateFactor ScaleCharToQuantum(135) |
|---|
| 592 | #define HighlightFactor ScaleCharToQuantum(190) |
|---|
| 593 | #define ShadowFactor ScaleCharToQuantum(190) |
|---|
| 594 | #define RaiseImageTag "Raise/Image" |
|---|
| 595 | #define TroughFactor ScaleCharToQuantum(135) |
|---|
| 596 | |
|---|
| 597 | long |
|---|
| 598 | progress; |
|---|
| 599 | |
|---|
| 600 | MagickBooleanType |
|---|
| 601 | status; |
|---|
| 602 | |
|---|
| 603 | Quantum |
|---|
| 604 | foreground, |
|---|
| 605 | background; |
|---|
| 606 | |
|---|
| 607 | long |
|---|
| 608 | y; |
|---|
| 609 | |
|---|
| 610 | ViewInfo |
|---|
| 611 | *image_view; |
|---|
| 612 | |
|---|
| 613 | assert(image != (Image *) NULL); |
|---|
| 614 | assert(image->signature == MagickSignature); |
|---|
| 615 | if (image->debug != MagickFalse) |
|---|
| 616 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
|---|
| 617 | assert(raise_info != (RectangleInfo *) NULL); |
|---|
| 618 | if ((image->columns <= (raise_info->width << 1)) || |
|---|
| 619 | (image->rows <= (raise_info->height << 1))) |
|---|
| 620 | ThrowBinaryException(OptionError,"ImageSizeMustExceedBevelWidth", |
|---|
| 621 | image->filename); |
|---|
| 622 | foreground=(Quantum) QuantumRange; |
|---|
| 623 | background=(Quantum) 0; |
|---|
| 624 | if (raise == MagickFalse) |
|---|
| 625 | { |
|---|
| 626 | foreground=(Quantum) 0; |
|---|
| 627 | background=(Quantum) QuantumRange; |
|---|
| 628 | } |
|---|
| 629 | if (SetImageStorageClass(image,DirectClass) == MagickFalse) |
|---|
| 630 | return(MagickFalse); |
|---|
| 631 | |
|---|
| 632 | |
|---|
| 633 | |
|---|
| 634 | status=MagickTrue; |
|---|
| 635 | progress=0; |
|---|
| 636 | image_view=AcquireCacheView(image); |
|---|
| 637 | for (y=0; y < (long) raise_info->height; y++) |
|---|
| 638 | { |
|---|
| 639 | register long |
|---|
| 640 | x; |
|---|
| 641 | |
|---|
| 642 | register PixelPacket |
|---|
| 643 | *q; |
|---|
| 644 | |
|---|
| 645 | if (status == MagickFalse) |
|---|
| 646 | continue; |
|---|
| 647 | q=GetCacheViewPixels(image_view,0,y,image->columns,1); |
|---|
| 648 | if (q == (PixelPacket *) NULL) |
|---|
| 649 | { |
|---|
| 650 | status=MagickFalse; |
|---|
| 651 | continue; |
|---|
| 652 | } |
|---|
| 653 | for (x=0; x < y; x++) |
|---|
| 654 | { |
|---|
| 655 | q->red=RoundToQuantum(QuantumScale*((MagickRealType) q->red* |
|---|
| 656 | HighlightFactor+(MagickRealType) foreground*(QuantumRange- |
|---|
| 657 | HighlightFactor))); |
|---|
| 658 | q->green=RoundToQuantum(QuantumScale*((MagickRealType) q->green* |
|---|
| 659 | HighlightFactor+(MagickRealType) foreground*(QuantumRange- |
|---|
| 660 | HighlightFactor))); |
|---|
| 661 | q->blue=RoundToQuantum(QuantumScale*((MagickRealType) q->blue* |
|---|
| 662 | HighlightFactor+(MagickRealType) foreground*(QuantumRange- |
|---|
| 663 | HighlightFactor))); |
|---|
| 664 | q++; |
|---|
| 665 | } |
|---|
| 666 | for ( ; x < (long) (image->columns-y); x++) |
|---|
| 667 | { |
|---|
| 668 | q->red=RoundToQuantum(QuantumScale*((MagickRealType) q->red* |
|---|
| 669 | AccentuateFactor+(MagickRealType) foreground*(QuantumRange- |
|---|
| 670 | AccentuateFactor))); |
|---|
| 671 | q->green=RoundToQuantum(QuantumScale*((MagickRealType) q->green* |
|---|
| 672 | AccentuateFactor+(MagickRealType) foreground*(QuantumRange- |
|---|
| 673 | AccentuateFactor))); |
|---|
| 674 | q->blue=RoundToQuantum(QuantumScale*((MagickRealType) q->blue* |
|---|
| 675 | AccentuateFactor+(MagickRealType) foreground*(QuantumRange- |
|---|
| 676 | AccentuateFactor))); |
|---|
| 677 | q++; |
|---|
| 678 | } |
|---|
| 679 | for ( ; x < (long) image->columns; x++) |
|---|
| 680 | { |
|---|
| 681 | q->red=RoundToQuantum(QuantumScale*((MagickRealType) q->red*ShadowFactor+ |
|---|
| 682 | (MagickRealType) background*(QuantumRange-ShadowFactor))); |
|---|
| 683 | q->green=RoundToQuantum(QuantumScale*((MagickRealType) q->green* |
|---|
| 684 | ShadowFactor+(MagickRealType) background*(QuantumRange-ShadowFactor))); |
|---|
| 685 | q->blue=RoundToQuantum(QuantumScale*((MagickRealType) q->blue* |
|---|
| 686 | ShadowFactor+(MagickRealType) background*(QuantumRange-ShadowFactor))); |
|---|
| 687 | q++; |
|---|
| 688 | } |
|---|
| 689 | if (SyncCacheView(image_view) == MagickFalse) |
|---|
| 690 | status=MagickFalse; |
|---|
| 691 | if (image->progress_monitor != (MagickProgressMonitor) NULL) |
|---|
| 692 | { |
|---|
| 693 | MagickBooleanType |
|---|
| 694 | proceed; |
|---|
| 695 | |
|---|
| 696 | proceed=SetImageProgress(image,RaiseImageTag,progress++,image->rows); |
|---|
| 697 | if (proceed == MagickFalse) |
|---|
| 698 | status=MagickFalse; |
|---|
| 699 | } |
|---|
| 700 | } |
|---|
| 701 | for ( ; y < (long) (image->rows-raise_info->height); y++) |
|---|
| 702 | { |
|---|
| 703 | register long |
|---|
| 704 | x; |
|---|
| 705 | |
|---|
| 706 | register PixelPacket |
|---|
| 707 | *q; |
|---|
| 708 | |
|---|
| 709 | if (status == MagickFalse) |
|---|
| 710 | continue; |
|---|
| 711 | q=GetCacheViewPixels(image_view,0,y,image->columns,1); |
|---|
| 712 | if (q == (PixelPacket *) NULL) |
|---|
| 713 | { |
|---|
| 714 | status=MagickFalse; |
|---|
| 715 | continue; |
|---|
| 716 | } |
|---|
| 717 | for (x=0; x < (long) raise_info->width; x++) |
|---|
| 718 | { |
|---|
| 719 | q->red=RoundToQuantum(QuantumScale*((MagickRealType) q->red* |
|---|
| 720 | HighlightFactor+(MagickRealType) foreground*(QuantumRange- |
|---|
| 721 | HighlightFactor))); |
|---|
| 722 | q->green=RoundToQuantum(QuantumScale*((MagickRealType) q->green* |
|---|
| 723 | HighlightFactor+(MagickRealType) foreground*(QuantumRange- |
|---|
| 724 | HighlightFactor))); |
|---|
| 725 | q->blue=RoundToQuantum(QuantumScale*((MagickRealType) q->blue* |
|---|
| 726 | HighlightFactor+(MagickRealType) foreground*(QuantumRange- |
|---|
| 727 | HighlightFactor))); |
|---|
| 728 | q++; |
|---|
| 729 | } |
|---|
| 730 | for ( ; x < (long) (image->columns-raise_info->width); x++) |
|---|
| 731 | q++; |
|---|
| 732 | for ( ; x < (long) image->columns; x++) |
|---|
| 733 | { |
|---|
| 734 | q->red=RoundToQuantum(QuantumScale*((MagickRealType) q->red*ShadowFactor+ |
|---|
| 735 | (MagickRealType) background*(QuantumRange-ShadowFactor))); |
|---|
| 736 | q->green=RoundToQuantum(QuantumScale*((MagickRealType) q->green* |
|---|
| 737 | ShadowFactor+(MagickRealType) background*(QuantumRange-ShadowFactor))); |
|---|
| 738 | q->blue=RoundToQuantum(QuantumScale*((MagickRealType) q->blue* |
|---|
| 739 | ShadowFactor+(MagickRealType) background*(QuantumRange-ShadowFactor))); |
|---|
| 740 | q++; |
|---|
| 741 | } |
|---|
| 742 | if (SyncCacheView(image_view) == MagickFalse) |
|---|
| 743 | status=MagickFalse; |
|---|
| 744 | if (image->progress_monitor != (MagickProgressMonitor) NULL) |
|---|
| 745 | { |
|---|
| 746 | MagickBooleanType |
|---|
| 747 | proceed; |
|---|
| 748 | |
|---|
| 749 | proceed=SetImageProgress(image,RaiseImageTag,progress++,image->rows); |
|---|
| 750 | if (proceed == MagickFalse) |
|---|
| 751 | status=MagickFalse; |
|---|
| 752 | } |
|---|
| 753 | } |
|---|
| 754 | for ( ; y < (long) image->rows; y++) |
|---|
| 755 | { |
|---|
| 756 | register long |
|---|
| 757 | x; |
|---|
| 758 | |
|---|
| 759 | register PixelPacket |
|---|
| 760 | *q; |
|---|
| 761 | |
|---|
| 762 | if (status == MagickFalse) |
|---|
| 763 | continue; |
|---|
| 764 | q=GetCacheViewPixels(image_view,0,y,image->columns,1); |
|---|
| 765 | if (q == (PixelPacket *) NULL) |
|---|
| 766 | { |
|---|
| 767 | status=MagickFalse; |
|---|
| 768 | continue; |
|---|
| 769 | } |
|---|
| 770 | for (x=0; x < (long) (image->rows-y); x++) |
|---|
| 771 | { |
|---|
| 772 | q->red=RoundToQuantum(QuantumScale*((MagickRealType) q->red* |
|---|
| 773 | HighlightFactor+(MagickRealType) foreground*(QuantumRange- |
|---|
| 774 | HighlightFactor))); |
|---|
| 775 | q->green=RoundToQuantum(QuantumScale*((MagickRealType) q->green* |
|---|
| 776 | HighlightFactor+(MagickRealType) foreground*(QuantumRange- |
|---|
| 777 | HighlightFactor))); |
|---|
| 778 | q->blue=RoundToQuantum(QuantumScale*((MagickRealType) q->blue* |
|---|
| 779 | HighlightFactor+(MagickRealType) foreground*(QuantumRange- |
|---|
| 780 | HighlightFactor))); |
|---|
| 781 | q++; |
|---|
| 782 | } |
|---|
| 783 | for ( ; x < (long) (image->columns-(image->rows-y)); x++) |
|---|
| 784 | { |
|---|
| 785 | q->red=RoundToQuantum(QuantumScale*((MagickRealType) q->red*TroughFactor+ |
|---|
| 786 | (MagickRealType) background*(QuantumRange-TroughFactor))); |
|---|
| 787 | q->green=RoundToQuantum(QuantumScale*((MagickRealType) q->green* |
|---|
| 788 | TroughFactor+(MagickRealType) background*(QuantumRange-TroughFactor))); |
|---|
| 789 | q->blue=RoundToQuantum(QuantumScale*((MagickRealType) q->blue* |
|---|
| 790 | TroughFactor+(MagickRealType) background*(QuantumRange-TroughFactor))); |
|---|
| 791 | q++; |
|---|
| 792 | } |
|---|
| 793 | for ( ; x < (long) image->columns; x++) |
|---|
| 794 | { |
|---|
| 795 | q->red=RoundToQuantum(QuantumScale*((MagickRealType) q->red*ShadowFactor+ |
|---|
| 796 | (MagickRealType) background*(QuantumRange-ShadowFactor))); |
|---|
| 797 | q->green=RoundToQuantum(QuantumScale*((MagickRealType) q->green* |
|---|
| 798 | ShadowFactor+(MagickRealType) background*(QuantumRange-ShadowFactor))); |
|---|
| 799 | q->blue=RoundToQuantum(QuantumScale*((MagickRealType) q->blue* |
|---|
| 800 | ShadowFactor+(MagickRealType) background*(QuantumRange-ShadowFactor))); |
|---|
| 801 | q++; |
|---|
| 802 | } |
|---|
| 803 | if (SyncCacheView(image_view) == MagickFalse) |
|---|
| 804 | status=MagickFalse; |
|---|
| 805 | if (image->progress_monitor != (MagickProgressMonitor) NULL) |
|---|
| 806 | { |
|---|
| 807 | MagickBooleanType |
|---|
| 808 | proceed; |
|---|
| 809 | |
|---|
| 810 | proceed=SetImageProgress(image,RaiseImageTag,progress++,image->rows); |
|---|
| 811 | if (proceed == MagickFalse) |
|---|
| 812 | status=MagickFalse; |
|---|
| 813 | } |
|---|
| 814 | } |
|---|
| 815 | image_view=DestroyCacheView(image_view); |
|---|
| 816 | return(status); |
|---|
| 817 | } |
|---|