MagickCore  7.0.3
decorate.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % DDDD EEEEE CCCC OOO RRRR AAA TTTTT EEEEE %
7 % D D E C O O R R A A T E %
8 % D D EEE C O O RRRR AAAAA T EEE %
9 % D D E C O O R R A A T E %
10 % DDDD EEEEE CCCC OOO R R A A T EEEEE %
11 % %
12 % %
13 % MagickCore Image Decoration Methods %
14 % %
15 % Software Design %
16 % Cristy %
17 % July 1992 %
18 % %
19 % %
20 % Copyright 1999-2019 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
22 % %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
25 % %
26 % https://imagemagick.org/script/license.php %
27 % %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
33 % %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 %
37 %
38 */
39 
40 /*
41  Include declarations.
42 */
43 #include "MagickCore/studio.h"
44 #include "MagickCore/cache-view.h"
47 #include "MagickCore/composite.h"
48 #include "MagickCore/decorate.h"
49 #include "MagickCore/exception.h"
51 #include "MagickCore/image.h"
52 #include "MagickCore/memory_.h"
53 #include "MagickCore/monitor.h"
56 #include "MagickCore/quantum.h"
58 #include "MagickCore/resource_.h"
60 #include "MagickCore/transform.h"
61 
62 /*
63  Define declarations.
64 */
65 #define AccentuateModulate ScaleCharToQuantum(80)
66 #define HighlightModulate ScaleCharToQuantum(125)
67 #define ShadowModulate ScaleCharToQuantum(135)
68 #define DepthModulate ScaleCharToQuantum(185)
69 #define TroughModulate ScaleCharToQuantum(110)
70 
71 /*
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 % %
74 % %
75 % %
76 % B o r d e r I m a g e %
77 % %
78 % %
79 % %
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 %
82 % BorderImage() surrounds the image with a border of the color defined by
83 % the bordercolor member of the image structure. The width and height
84 % of the border are defined by the corresponding members of the border_info
85 % structure.
86 %
87 % The format of the BorderImage method is:
88 %
89 % Image *BorderImage(const Image *image,const RectangleInfo *border_info,
90 % const CompositeOperator compose,ExceptionInfo *exception)
91 %
92 % A description of each parameter follows:
93 %
94 % o image: the image.
95 %
96 % o border_info: define the width and height of the border.
97 %
98 % o compose: the composite operator.
99 %
100 % o exception: return any errors or warnings in this structure.
101 %
102 */
104  const RectangleInfo *border_info,const CompositeOperator compose,
105  ExceptionInfo *exception)
106 {
107  Image
108  *border_image,
109  *clone_image;
110 
111  FrameInfo
112  frame_info;
113 
114  assert(image != (const Image *) NULL);
115  assert(image->signature == MagickCoreSignature);
116  if (image->debug != MagickFalse)
117  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
118  assert(border_info != (RectangleInfo *) NULL);
119  frame_info.width=image->columns+(border_info->width << 1);
120  frame_info.height=image->rows+(border_info->height << 1);
121  frame_info.x=(ssize_t) border_info->width;
122  frame_info.y=(ssize_t) border_info->height;
123  frame_info.inner_bevel=0;
124  frame_info.outer_bevel=0;
125  clone_image=CloneImage(image,0,0,MagickTrue,exception);
126  if (clone_image == (Image *) NULL)
127  return((Image *) NULL);
128  clone_image->matte_color=image->border_color;
129  border_image=FrameImage(clone_image,&frame_info,compose,exception);
130  clone_image=DestroyImage(clone_image);
131  if (border_image != (Image *) NULL)
132  border_image->matte_color=image->matte_color;
133  return(border_image);
134 }
135 
136 /*
137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138 % %
139 % %
140 % %
141 % F r a m e I m a g e %
142 % %
143 % %
144 % %
145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146 %
147 % FrameImage() adds a simulated three-dimensional border around the image.
148 % The color of the border is defined by the matte_color member of image.
149 % Members width and height of frame_info specify the border width of the
150 % vertical and horizontal sides of the frame. Members inner and outer
151 % indicate the width of the inner and outer shadows of the frame.
152 %
153 % The format of the FrameImage method is:
154 %
155 % Image *FrameImage(const Image *image,const FrameInfo *frame_info,
156 % const CompositeOperator compose,ExceptionInfo *exception)
157 %
158 % A description of each parameter follows:
159 %
160 % o image: the image.
161 %
162 % o frame_info: Define the width and height of the frame and its bevels.
163 %
164 % o compose: the composite operator.
165 %
166 % o exception: return any errors or warnings in this structure.
167 %
168 */
169 MagickExport Image *FrameImage(const Image *image,const FrameInfo *frame_info,
170  const CompositeOperator compose,ExceptionInfo *exception)
171 {
172 #define FrameImageTag "Frame/Image"
173 
174  CacheView
175  *image_view,
176  *frame_view;
177 
178  Image
179  *frame_image;
180 
182  status;
183 
185  progress;
186 
187  PixelInfo
188  accentuate,
189  highlight,
190  matte,
191  shadow,
192  trough;
193 
194  register ssize_t
195  x;
196 
197  size_t
198  bevel_width,
199  height,
200  width;
201 
202  ssize_t
203  y;
204 
205  /*
206  Check frame geometry.
207  */
208  assert(image != (Image *) NULL);
209  assert(image->signature == MagickCoreSignature);
210  if (image->debug != MagickFalse)
211  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
212  assert(frame_info != (FrameInfo *) NULL);
213  if ((frame_info->outer_bevel < 0) || (frame_info->inner_bevel < 0))
214  ThrowImageException(OptionError,"FrameIsLessThanImageSize");
215  bevel_width=(size_t) (frame_info->outer_bevel+frame_info->inner_bevel);
216  x=(ssize_t) frame_info->width-frame_info->x-bevel_width;
217  y=(ssize_t) frame_info->height-frame_info->y-bevel_width;
218  if ((x < (ssize_t) image->columns) || (y < (ssize_t) image->rows))
219  ThrowImageException(OptionError,"FrameIsLessThanImageSize");
220  /*
221  Initialize framed image attributes.
222  */
223  frame_image=CloneImage(image,frame_info->width,frame_info->height,MagickTrue,
224  exception);
225  if (frame_image == (Image *) NULL)
226  return((Image *) NULL);
227  if (SetImageStorageClass(frame_image,DirectClass,exception) == MagickFalse)
228  {
229  frame_image=DestroyImage(frame_image);
230  return((Image *) NULL);
231  }
232  if ((IsPixelInfoGray(&frame_image->border_color) == MagickFalse) &&
233  (IsGrayColorspace(frame_image->colorspace) != MagickFalse))
234  (void) SetImageColorspace(frame_image,sRGBColorspace,exception);
235  if ((frame_image->matte_color.alpha_trait != UndefinedPixelTrait) &&
236  (frame_image->alpha_trait == UndefinedPixelTrait))
237  (void) SetImageAlpha(frame_image,OpaqueAlpha,exception);
238  frame_image->page=image->page;
239  if ((image->page.width != 0) && (image->page.height != 0))
240  {
241  frame_image->page.width+=frame_image->columns-image->columns;
242  frame_image->page.height+=frame_image->rows-image->rows;
243  }
244  /*
245  Initialize 3D effects color.
246  */
247  matte=image->matte_color;
248  accentuate=matte;
249  accentuate.red=(double) (QuantumScale*((QuantumRange-
251  accentuate.green=(double) (QuantumScale*((QuantumRange-
253  accentuate.blue=(double) (QuantumScale*((QuantumRange-
255  accentuate.black=(double) (QuantumScale*((QuantumRange-
257  accentuate.alpha=matte.alpha;
258  highlight=matte;
259  highlight.red=(double) (QuantumScale*((QuantumRange-
261  highlight.green=(double) (QuantumScale*((QuantumRange-
263  highlight.blue=(double) (QuantumScale*((QuantumRange-
265  highlight.black=(double) (QuantumScale*((QuantumRange-
267  highlight.alpha=matte.alpha;
268  shadow=matte;
269  shadow.red=QuantumScale*matte.red*ShadowModulate;
270  shadow.green=QuantumScale*matte.green*ShadowModulate;
271  shadow.blue=QuantumScale*matte.blue*ShadowModulate;
272  shadow.black=QuantumScale*matte.black*ShadowModulate;
273  shadow.alpha=matte.alpha;
274  trough=matte;
275  trough.red=QuantumScale*matte.red*TroughModulate;
276  trough.green=QuantumScale*matte.green*TroughModulate;
277  trough.blue=QuantumScale*matte.blue*TroughModulate;
278  trough.black=QuantumScale*matte.black*TroughModulate;
279  trough.alpha=matte.alpha;
280  status=MagickTrue;
281  progress=0;
282  image_view=AcquireVirtualCacheView(image,exception);
283  frame_view=AcquireAuthenticCacheView(frame_image,exception);
284  height=(size_t) (frame_info->outer_bevel+(frame_info->y-bevel_width)+
285  frame_info->inner_bevel);
286  if (height != 0)
287  {
288  register ssize_t
289  x;
290 
291  register Quantum
292  *magick_restrict q;
293 
294  /*
295  Draw top of ornamental border.
296  */
297  q=QueueCacheViewAuthenticPixels(frame_view,0,0,frame_image->columns,
298  height,exception);
299  if (q != (Quantum *) NULL)
300  {
301  /*
302  Draw top of ornamental border.
303  */
304  for (y=0; y < (ssize_t) frame_info->outer_bevel; y++)
305  {
306  for (x=0; x < (ssize_t) (frame_image->columns-y); x++)
307  {
308  if (x < y)
309  SetPixelViaPixelInfo(frame_image,&highlight,q);
310  else
311  SetPixelViaPixelInfo(frame_image,&accentuate,q);
312  q+=GetPixelChannels(frame_image);
313  }
314  for ( ; x < (ssize_t) frame_image->columns; x++)
315  {
316  SetPixelViaPixelInfo(frame_image,&shadow,q);
317  q+=GetPixelChannels(frame_image);
318  }
319  }
320  for (y=0; y < (ssize_t) (frame_info->y-bevel_width); y++)
321  {
322  for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
323  {
324  SetPixelViaPixelInfo(frame_image,&highlight,q);
325  q+=GetPixelChannels(frame_image);
326  }
327  width=frame_image->columns-2*frame_info->outer_bevel;
328  for (x=0; x < (ssize_t) width; x++)
329  {
330  SetPixelViaPixelInfo(frame_image,&matte,q);
331  q+=GetPixelChannels(frame_image);
332  }
333  for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
334  {
335  SetPixelViaPixelInfo(frame_image,&shadow,q);
336  q+=GetPixelChannels(frame_image);
337  }
338  }
339  for (y=0; y < (ssize_t) frame_info->inner_bevel; y++)
340  {
341  for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
342  {
343  SetPixelViaPixelInfo(frame_image,&highlight,q);
344  q+=GetPixelChannels(frame_image);
345  }
346  for (x=0; x < (ssize_t) (frame_info->x-bevel_width); x++)
347  {
348  SetPixelViaPixelInfo(frame_image,&matte,q);
349  q+=GetPixelChannels(frame_image);
350  }
351  width=image->columns+((size_t) frame_info->inner_bevel << 1)-
352  y;
353  for (x=0; x < (ssize_t) width; x++)
354  {
355  if (x < y)
356  SetPixelViaPixelInfo(frame_image,&shadow,q);
357  else
358  SetPixelViaPixelInfo(frame_image,&trough,q);
359  q+=GetPixelChannels(frame_image);
360  }
361  for ( ; x < (ssize_t) (image->columns+2*frame_info->inner_bevel); x++)
362  {
363  SetPixelViaPixelInfo(frame_image,&highlight,q);
364  q+=GetPixelChannels(frame_image);
365  }
366  width=frame_info->width-frame_info->x-image->columns-bevel_width;
367  for (x=0; x < (ssize_t) width; x++)
368  {
369  SetPixelViaPixelInfo(frame_image,&matte,q);
370  q+=GetPixelChannels(frame_image);
371  }
372  for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
373  {
374  SetPixelViaPixelInfo(frame_image,&shadow,q);
375  q+=GetPixelChannels(frame_image);
376  }
377  }
378  (void) SyncCacheViewAuthenticPixels(frame_view,exception);
379  }
380  }
381  /*
382  Draw sides of ornamental border.
383  */
384 #if defined(MAGICKCORE_OPENMP_SUPPORT)
385  #pragma omp parallel for schedule(static) shared(progress,status) \
386  magick_number_threads(image,frame_image,image->rows,1)
387 #endif
388  for (y=0; y < (ssize_t) image->rows; y++)
389  {
390  register ssize_t
391  x;
392 
393  register Quantum
394  *magick_restrict q;
395 
396  size_t
397  width;
398 
399  /*
400  Initialize scanline with matte color.
401  */
402  if (status == MagickFalse)
403  continue;
404  q=QueueCacheViewAuthenticPixels(frame_view,0,frame_info->y+y,
405  frame_image->columns,1,exception);
406  if (q == (Quantum *) NULL)
407  {
408  status=MagickFalse;
409  continue;
410  }
411  for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
412  {
413  SetPixelViaPixelInfo(frame_image,&highlight,q);
414  q+=GetPixelChannels(frame_image);
415  }
416  for (x=0; x < (ssize_t) (frame_info->x-bevel_width); x++)
417  {
418  SetPixelViaPixelInfo(frame_image,&matte,q);
419  q+=GetPixelChannels(frame_image);
420  }
421  for (x=0; x < (ssize_t) frame_info->inner_bevel; x++)
422  {
423  SetPixelViaPixelInfo(frame_image,&shadow,q);
424  q+=GetPixelChannels(frame_image);
425  }
426  /*
427  Set frame interior pixels.
428  */
429  for (x=0; x < (ssize_t) image->columns; x++)
430  {
431  SetPixelViaPixelInfo(frame_image,&frame_image->border_color,q);
432  q+=GetPixelChannels(frame_image);
433  }
434  for (x=0; x < (ssize_t) frame_info->inner_bevel; x++)
435  {
436  SetPixelViaPixelInfo(frame_image,&highlight,q);
437  q+=GetPixelChannels(frame_image);
438  }
439  width=frame_info->width-frame_info->x-image->columns-bevel_width;
440  for (x=0; x < (ssize_t) width; x++)
441  {
442  SetPixelViaPixelInfo(frame_image,&matte,q);
443  q+=GetPixelChannels(frame_image);
444  }
445  for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
446  {
447  SetPixelViaPixelInfo(frame_image,&shadow,q);
448  q+=GetPixelChannels(frame_image);
449  }
450  if (SyncCacheViewAuthenticPixels(frame_view,exception) == MagickFalse)
451  status=MagickFalse;
452  if (image->progress_monitor != (MagickProgressMonitor) NULL)
453  {
455  proceed;
456 
457 #if defined(MAGICKCORE_OPENMP_SUPPORT)
458  #pragma omp atomic
459 #endif
460  progress++;
461  proceed=SetImageProgress(image,FrameImageTag,progress,image->rows);
462  if (proceed == MagickFalse)
463  status=MagickFalse;
464  }
465  }
466  height=(size_t) (frame_info->inner_bevel+frame_info->height-
467  frame_info->y-image->rows-bevel_width+frame_info->outer_bevel);
468  if (height != 0)
469  {
470  register ssize_t
471  x;
472 
473  register Quantum
474  *magick_restrict q;
475 
476  /*
477  Draw bottom of ornamental border.
478  */
479  q=QueueCacheViewAuthenticPixels(frame_view,0,(ssize_t) (frame_image->rows-
480  height),frame_image->columns,height,exception);
481  if (q != (Quantum *) NULL)
482  {
483  /*
484  Draw bottom of ornamental border.
485  */
486  for (y=frame_info->inner_bevel-1; y >= 0; y--)
487  {
488  for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
489  {
490  SetPixelViaPixelInfo(frame_image,&highlight,q);
491  q+=GetPixelChannels(frame_image);
492  }
493  for (x=0; x < (ssize_t) (frame_info->x-bevel_width); x++)
494  {
495  SetPixelViaPixelInfo(frame_image,&matte,q);
496  q+=GetPixelChannels(frame_image);
497  }
498  for (x=0; x < y; x++)
499  {
500  SetPixelViaPixelInfo(frame_image,&shadow,q);
501  q+=GetPixelChannels(frame_image);
502  }
503  for ( ; x < (ssize_t) (image->columns+2*frame_info->inner_bevel); x++)
504  {
505  if (x >= (ssize_t) (image->columns+2*frame_info->inner_bevel-y))
506  SetPixelViaPixelInfo(frame_image,&highlight,q);
507  else
508  SetPixelViaPixelInfo(frame_image,&accentuate,q);
509  q+=GetPixelChannels(frame_image);
510  }
511  width=frame_info->width-frame_info->x-image->columns-bevel_width;
512  for (x=0; x < (ssize_t) width; x++)
513  {
514  SetPixelViaPixelInfo(frame_image,&matte,q);
515  q+=GetPixelChannels(frame_image);
516  }
517  for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
518  {
519  SetPixelViaPixelInfo(frame_image,&shadow,q);
520  q+=GetPixelChannels(frame_image);
521  }
522  }
523  height=frame_info->height-frame_info->y-image->rows-bevel_width;
524  for (y=0; y < (ssize_t) height; y++)
525  {
526  for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
527  {
528  SetPixelViaPixelInfo(frame_image,&highlight,q);
529  q+=GetPixelChannels(frame_image);
530  }
531  width=frame_image->columns-2*frame_info->outer_bevel;
532  for (x=0; x < (ssize_t) width; x++)
533  {
534  SetPixelViaPixelInfo(frame_image,&matte,q);
535  q+=GetPixelChannels(frame_image);
536  }
537  for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
538  {
539  SetPixelViaPixelInfo(frame_image,&shadow,q);
540  q+=GetPixelChannels(frame_image);
541  }
542  }
543  for (y=frame_info->outer_bevel-1; y >= 0; y--)
544  {
545  for (x=0; x < y; x++)
546  {
547  SetPixelViaPixelInfo(frame_image,&highlight,q);
548  q+=GetPixelChannels(frame_image);
549  }
550  for ( ; x < (ssize_t) frame_image->columns; x++)
551  {
552  if (x >= (ssize_t) (frame_image->columns-y))
553  SetPixelViaPixelInfo(frame_image,&shadow,q);
554  else
555  SetPixelViaPixelInfo(frame_image,&trough,q);
556  q+=GetPixelChannels(frame_image);
557  }
558  }
559  (void) SyncCacheViewAuthenticPixels(frame_view,exception);
560  }
561  }
562  frame_view=DestroyCacheView(frame_view);
563  image_view=DestroyCacheView(image_view);
564  x=(ssize_t) (frame_info->outer_bevel+(frame_info->x-bevel_width)+
565  frame_info->inner_bevel);
566  y=(ssize_t) (frame_info->outer_bevel+(frame_info->y-bevel_width)+
567  frame_info->inner_bevel);
568  if (status != MagickFalse)
569  status=CompositeImage(frame_image,image,compose,MagickTrue,x,y,
570  exception);
571  if (status == MagickFalse)
572  frame_image=DestroyImage(frame_image);
573  return(frame_image);
574 }
575 
576 /*
577 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578 % %
579 % %
580 % %
581 % R a i s e I m a g e %
582 % %
583 % %
584 % %
585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
586 %
587 % RaiseImage() creates a simulated three-dimensional button-like effect
588 % by lightening and darkening the edges of the image. Members width and
589 % height of raise_info define the width of the vertical and horizontal
590 % edge of the effect.
591 %
592 % The format of the RaiseImage method is:
593 %
594 % MagickBooleanType RaiseImage(const Image *image,
595 % const RectangleInfo *raise_info,const MagickBooleanType raise,
596 % ExceptionInfo *exception)
597 %
598 % A description of each parameter follows:
599 %
600 % o image: the image.
601 %
602 % o raise_info: Define the width and height of the raise area.
603 %
604 % o raise: A value other than zero creates a 3-D raise effect,
605 % otherwise it has a lowered effect.
606 %
607 % o exception: return any errors or warnings in this structure.
608 %
609 */
611  const RectangleInfo *raise_info,const MagickBooleanType raise,
612  ExceptionInfo *exception)
613 {
614 #define AccentuateFactor ScaleCharToQuantum(135)
615 #define HighlightFactor ScaleCharToQuantum(190)
616 #define ShadowFactor ScaleCharToQuantum(190)
617 #define RaiseImageTag "Raise/Image"
618 #define TroughFactor ScaleCharToQuantum(135)
619 
620  CacheView
621  *image_view;
622 
624  status;
625 
627  progress;
628 
629  Quantum
630  foreground,
631  background;
632 
633  ssize_t
634  y;
635 
636  assert(image != (Image *) NULL);
637  assert(image->signature == MagickCoreSignature);
638  if (image->debug != MagickFalse)
639  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
640  assert(raise_info != (RectangleInfo *) NULL);
641  if ((image->columns <= (raise_info->width << 1)) ||
642  (image->rows <= (raise_info->height << 1)))
643  ThrowBinaryException(OptionError,"ImageSizeMustExceedBevelWidth",
644  image->filename);
645  foreground=QuantumRange;
646  background=(Quantum) 0;
647  if (raise == MagickFalse)
648  {
649  foreground=(Quantum) 0;
650  background=QuantumRange;
651  }
652  if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
653  return(MagickFalse);
654  /*
655  Raise image.
656  */
657  status=MagickTrue;
658  progress=0;
659  image_view=AcquireAuthenticCacheView(image,exception);
660 #if defined(MAGICKCORE_OPENMP_SUPPORT)
661  #pragma omp parallel for schedule(static) shared(progress,status) \
662  magick_number_threads(image,image,raise_info->height,1)
663 #endif
664  for (y=0; y < (ssize_t) raise_info->height; y++)
665  {
666  register ssize_t
667  i,
668  x;
669 
670  register Quantum
671  *magick_restrict q;
672 
673  if (status == MagickFalse)
674  continue;
675  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
676  if (q == (Quantum *) NULL)
677  {
678  status=MagickFalse;
679  continue;
680  }
681  for (x=0; x < y; x++)
682  {
683  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
684  {
685  PixelChannel channel = GetPixelChannelChannel(image,i);
686  PixelTrait traits = GetPixelChannelTraits(image,channel);
687  if ((traits & UpdatePixelTrait) == 0)
688  continue;
689  q[i]=ClampToQuantum(QuantumScale*((double) q[i]*HighlightFactor+(double)
690  foreground*(QuantumRange-HighlightFactor)));
691  }
692  q+=GetPixelChannels(image);
693  }
694  for ( ; x < (ssize_t) (image->columns-y); x++)
695  {
696  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
697  {
698  PixelChannel channel = GetPixelChannelChannel(image,i);
699  PixelTrait traits = GetPixelChannelTraits(image,channel);
700  if ((traits & UpdatePixelTrait) == 0)
701  continue;
702  q[i]=ClampToQuantum(QuantumScale*((double) q[i]*AccentuateFactor+
703  (double) foreground*(QuantumRange-AccentuateFactor)));
704  }
705  q+=GetPixelChannels(image);
706  }
707  for ( ; x < (ssize_t) image->columns; x++)
708  {
709  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
710  {
711  PixelChannel channel = GetPixelChannelChannel(image,i);
712  PixelTrait traits = GetPixelChannelTraits(image,channel);
713  if ((traits & UpdatePixelTrait) == 0)
714  continue;
715  q[i]=ClampToQuantum(QuantumScale*((double) q[i]*ShadowFactor+(double)
716  background*(QuantumRange-ShadowFactor)));
717  }
718  q+=GetPixelChannels(image);
719  }
720  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
721  status=MagickFalse;
722  if (image->progress_monitor != (MagickProgressMonitor) NULL)
723  {
725  proceed;
726 
727 #if defined(MAGICKCORE_OPENMP_SUPPORT)
728  #pragma omp atomic
729 #endif
730  progress++;
731  proceed=SetImageProgress(image,RaiseImageTag,progress,image->rows);
732  if (proceed == MagickFalse)
733  status=MagickFalse;
734  }
735  }
736 #if defined(MAGICKCORE_OPENMP_SUPPORT)
737  #pragma omp parallel for schedule(static) shared(progress,status) \
738  magick_number_threads(image,image,image->rows-2*raise_info->height,1)
739 #endif
740  for (y=(ssize_t) raise_info->height; y < (ssize_t) (image->rows-raise_info->height); y++)
741  {
742  register ssize_t
743  i,
744  x;
745 
746  register Quantum
747  *magick_restrict q;
748 
749  if (status == MagickFalse)
750  continue;
751  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
752  if (q == (Quantum *) NULL)
753  {
754  status=MagickFalse;
755  continue;
756  }
757  for (x=0; x < (ssize_t) raise_info->width; x++)
758  {
759  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
760  {
761  PixelChannel channel = GetPixelChannelChannel(image,i);
762  PixelTrait traits = GetPixelChannelTraits(image,channel);
763  if ((traits & UpdatePixelTrait) == 0)
764  continue;
765  q[i]=ClampToQuantum(QuantumScale*((double) q[i]*HighlightFactor+(double)
766  foreground*(QuantumRange-HighlightFactor)));
767  }
768  q+=GetPixelChannels(image);
769  }
770  for ( ; x < (ssize_t) (image->columns-raise_info->width); x++)
771  q+=GetPixelChannels(image);
772  for ( ; x < (ssize_t) image->columns; x++)
773  {
774  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
775  {
776  PixelChannel channel = GetPixelChannelChannel(image,i);
777  PixelTrait traits = GetPixelChannelTraits(image,channel);
778  if ((traits & UpdatePixelTrait) == 0)
779  continue;
780  q[i]=ClampToQuantum(QuantumScale*((double) q[i]*ShadowFactor+(double)
781  background*(QuantumRange-ShadowFactor)));
782  }
783  q+=GetPixelChannels(image);
784  }
785  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
786  status=MagickFalse;
787  if (image->progress_monitor != (MagickProgressMonitor) NULL)
788  {
790  proceed;
791 
792 #if defined(MAGICKCORE_OPENMP_SUPPORT)
793  #pragma omp atomic
794 #endif
795  progress++;
796  proceed=SetImageProgress(image,RaiseImageTag,progress,image->rows);
797  if (proceed == MagickFalse)
798  status=MagickFalse;
799  }
800  }
801 #if defined(MAGICKCORE_OPENMP_SUPPORT)
802  #pragma omp parallel for schedule(static) shared(progress,status) \
803  magick_number_threads(image,image,image->rows-raise_info->height,1)
804 #endif
805  for (y=(ssize_t) (image->rows-raise_info->height); y < (ssize_t) image->rows; y++)
806  {
807  register ssize_t
808  i,
809  x;
810 
811  register Quantum
812  *magick_restrict q;
813 
814  if (status == MagickFalse)
815  continue;
816  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
817  if (q == (Quantum *) NULL)
818  {
819  status=MagickFalse;
820  continue;
821  }
822  for (x=0; x < (ssize_t) (image->rows-y); x++)
823  {
824  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
825  {
826  PixelChannel channel = GetPixelChannelChannel(image,i);
827  PixelTrait traits = GetPixelChannelTraits(image,channel);
828  if ((traits & UpdatePixelTrait) == 0)
829  continue;
830  q[i]=ClampToQuantum(QuantumScale*((double) q[i]*HighlightFactor+(double)
831  foreground*(QuantumRange-HighlightFactor)));
832  }
833  q+=GetPixelChannels(image);
834  }
835  for ( ; x < (ssize_t) (image->columns-(image->rows-y)); x++)
836  {
837  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
838  {
839  PixelChannel channel = GetPixelChannelChannel(image,i);
840  PixelTrait traits = GetPixelChannelTraits(image,channel);
841  if ((traits & UpdatePixelTrait) == 0)
842  continue;
843  q[i]=ClampToQuantum(QuantumScale*((double) q[i]*TroughFactor+
844  (double) background*(QuantumRange-TroughFactor)));
845  }
846  q+=GetPixelChannels(image);
847  }
848  for ( ; x < (ssize_t) image->columns; x++)
849  {
850  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
851  {
852  PixelChannel channel = GetPixelChannelChannel(image,i);
853  PixelTrait traits = GetPixelChannelTraits(image,channel);
854  if ((traits & UpdatePixelTrait) == 0)
855  continue;
856  q[i]=ClampToQuantum(QuantumScale*((double) q[i]*ShadowFactor+(double)
857  background*(QuantumRange-ShadowFactor)));
858  }
859  q+=GetPixelChannels(image);
860  }
861  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
862  status=MagickFalse;
863  if (image->progress_monitor != (MagickProgressMonitor) NULL)
864  {
866  proceed;
867 
868 #if defined(MAGICKCORE_OPENMP_SUPPORT)
869  #pragma omp atomic
870 #endif
871  progress++;
872  proceed=SetImageProgress(image,RaiseImageTag,progress,image->rows);
873  if (proceed == MagickFalse)
874  status=MagickFalse;
875  }
876  }
877  image_view=DestroyCacheView(image_view);
878  return(status);
879 }
size_t rows
Definition: image.h:172
#define magick_restrict
Definition: MagickCore.h:41
PixelInfo matte_color
Definition: image.h:357
MagickExport CacheView * DestroyCacheView(CacheView *cache_view)
Definition: cache-view.c:252
#define FrameImageTag
MagickExport Image * FrameImage(const Image *image, const FrameInfo *frame_info, const CompositeOperator compose, ExceptionInfo *exception)
Definition: decorate.c:169
MagickProgressMonitor progress_monitor
Definition: image.h:303
PixelTrait alpha_trait
Definition: pixel.h:179
#define RaiseImageTag
MagickExport MagickBooleanType RaiseImage(Image *image, const RectangleInfo *raise_info, const MagickBooleanType raise, ExceptionInfo *exception)
Definition: decorate.c:610
PixelInfo border_color
Definition: image.h:179
#define OpaqueAlpha
Definition: image.h:25
ssize_t outer_bevel
Definition: decorate.h:34
MagickRealType red
Definition: pixel.h:191
MagickExport MagickBooleanType SetImageAlpha(Image *image, const Quantum alpha, ExceptionInfo *exception)
Definition: image.c:2339
static PixelTrait GetPixelChannelTraits(const Image *magick_restrict image, const PixelChannel channel)
static void SetPixelViaPixelInfo(const Image *magick_restrict image, const PixelInfo *magick_restrict pixel_info, Quantum *magick_restrict pixel)
static MagickBooleanType IsGrayColorspace(const ColorspaceType colorspace)
#define ShadowFactor
MagickRealType alpha
Definition: pixel.h:191
MagickExport MagickBooleanType CompositeImage(Image *image, const Image *composite, const CompositeOperator compose, const MagickBooleanType clip_to_self, const ssize_t x_offset, const ssize_t y_offset, ExceptionInfo *exception)
Definition: composite.c:528
size_t width
Definition: geometry.h:130
#define ThrowBinaryException(severity, tag, context)
Definition: log.h:52
ssize_t MagickOffsetType
Definition: magick-type.h:129
Definition: image.h:151
#define AccentuateModulate
Definition: decorate.c:65
#define MagickCoreSignature
MagickExport Quantum * GetCacheViewAuthenticPixels(CacheView *cache_view, const ssize_t x, const ssize_t y, const size_t columns, const size_t rows, ExceptionInfo *exception)
Definition: cache-view.c:299
MagickBooleanType
Definition: magick-type.h:158
RectangleInfo page
Definition: image.h:212
ssize_t y
Definition: decorate.h:34
PixelTrait alpha_trait
Definition: image.h:280
MagickRealType blue
Definition: pixel.h:191
MagickExport Quantum * QueueCacheViewAuthenticPixels(CacheView *cache_view, const ssize_t x, const ssize_t y, const size_t columns, const size_t rows, ExceptionInfo *exception)
Definition: cache-view.c:977
#define TroughModulate
Definition: decorate.c:69
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition: log.c:1399
size_t signature
Definition: image.h:354
#define QuantumScale
Definition: magick-type.h:115
size_t columns
Definition: image.h:172
size_t height
Definition: geometry.h:130
MagickExport MagickBooleanType SetImageStorageClass(Image *image, const ClassType storage_class, ExceptionInfo *exception)
Definition: image.c:2617
ssize_t x
Definition: decorate.h:34
PixelChannel
Definition: pixel.h:67
static size_t GetPixelChannels(const Image *magick_restrict image)
char filename[MagickPathExtent]
Definition: image.h:319
#define GetMagickModule()
Definition: log.h:28
#define ThrowImageException(severity, tag)
static Quantum ClampToQuantum(const MagickRealType value)
Definition: quantum.h:84
static PixelChannel GetPixelChannelChannel(const Image *magick_restrict image, const ssize_t offset)
MagickExport CacheView * AcquireVirtualCacheView(const Image *image, ExceptionInfo *exception)
Definition: cache-view.c:149
#define HighlightModulate
Definition: decorate.c:66
ssize_t inner_bevel
Definition: decorate.h:34
unsigned short Quantum
Definition: magick-type.h:82
static MagickBooleanType IsPixelInfoGray(const PixelInfo *magick_restrict pixel)
MagickExport Image * BorderImage(const Image *image, const RectangleInfo *border_info, const CompositeOperator compose, ExceptionInfo *exception)
Definition: decorate.c:103
MagickExport MagickBooleanType SetImageColorspace(Image *image, const ColorspaceType colorspace, ExceptionInfo *exception)
Definition: colorspace.c:1135
MagickRealType black
Definition: pixel.h:191
size_t height
Definition: decorate.h:30
size_t width
Definition: decorate.h:30
MagickRealType green
Definition: pixel.h:191
MagickBooleanType(* MagickProgressMonitor)(const char *, const MagickOffsetType, const MagickSizeType, void *)
Definition: monitor.h:26
#define TroughFactor
#define AccentuateFactor
CompositeOperator
Definition: composite.h:25
#define MagickExport
MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *magick_restrict cache_view, ExceptionInfo *exception)
Definition: cache-view.c:1100
MagickExport CacheView * AcquireAuthenticCacheView(const Image *image, ExceptionInfo *exception)
Definition: cache-view.c:112
#define ShadowModulate
Definition: decorate.c:67
PixelTrait
Definition: pixel.h:135
MagickExport Image * DestroyImage(Image *image)
Definition: image.c:1181
MagickExport Image * CloneImage(const Image *image, const size_t columns, const size_t rows, const MagickBooleanType detach, ExceptionInfo *exception)
Definition: image.c:796
ColorspaceType colorspace
Definition: image.h:157
#define HighlightFactor
#define QuantumRange
Definition: magick-type.h:83
MagickExport MagickBooleanType SetImageProgress(const Image *image, const char *tag, const MagickOffsetType offset, const MagickSizeType extent)
Definition: monitor.c:136
MagickBooleanType debug
Definition: image.h:334