/src/graphicsmagick/magick/decorate.c
Line | Count | Source |
1 | | /* |
2 | | % Copyright (C) 2003-2019 GraphicsMagick Group |
3 | | % Copyright (C) 2002 ImageMagick Studio |
4 | | % Copyright 1991-1999 E. I. du Pont de Nemours and Company |
5 | | % |
6 | | % This program is covered by multiple licenses, which are described in |
7 | | % Copyright.txt. You should have received a copy of Copyright.txt with this |
8 | | % package; otherwise see http://www.graphicsmagick.org/www/Copyright.html. |
9 | | % |
10 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
11 | | % % |
12 | | % % |
13 | | % % |
14 | | % DDDD EEEEE CCCC OOO RRRR AAA TTTTT EEEEE % |
15 | | % D D E C O O R R A A T E % |
16 | | % D D EEE C O O RRRR AAAAA T EEE % |
17 | | % D D E C O O R R A A T E % |
18 | | % DDDD EEEEE CCCC OOO R R A A T EEEEE % |
19 | | % % |
20 | | % % |
21 | | % GraphicsMagick Image Decoration Methods % |
22 | | % % |
23 | | % % |
24 | | % Software Design % |
25 | | % John Cristy % |
26 | | % July 1992 % |
27 | | % % |
28 | | % % |
29 | | % % |
30 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
31 | | % |
32 | | % |
33 | | % |
34 | | */ |
35 | | |
36 | | /* |
37 | | Include declarations. |
38 | | */ |
39 | | #include "magick/studio.h" |
40 | | #include "magick/color.h" |
41 | | #include "magick/decorate.h" |
42 | | #include "magick/pixel_cache.h" |
43 | | #include "magick/monitor.h" |
44 | | |
45 | | /* |
46 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
47 | | % % |
48 | | % % |
49 | | % % |
50 | | % B o r d e r I m a g e % |
51 | | % % |
52 | | % % |
53 | | % % |
54 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
55 | | % |
56 | | % BorderImage() surrounds the image with a border of the color defined by |
57 | | % the bordercolor member of the image structure. The width and height |
58 | | % of the border are defined by the corresponding members of the border_info |
59 | | % structure. |
60 | | % |
61 | | % The format of the BorderImage method is: |
62 | | % |
63 | | % Image *BorderImage(const Image *image,const RectangleInfo *border_info, |
64 | | % ExceptionInfo *exception) |
65 | | % |
66 | | % A description of each parameter follows: |
67 | | % |
68 | | % o image: The image. |
69 | | % |
70 | | % o border_info: Define the width and height of the border. |
71 | | % |
72 | | % o exception: Return any errors or warnings in this structure. |
73 | | % |
74 | | % |
75 | | */ |
76 | | MagickExport Image *BorderImage(const Image *image, |
77 | | const RectangleInfo *border_info,ExceptionInfo *exception) |
78 | 705 | { |
79 | 705 | Image |
80 | 705 | *border_image, |
81 | 705 | *clone_image; |
82 | | |
83 | 705 | FrameInfo |
84 | 705 | frame_info; |
85 | | |
86 | 705 | assert(image != (const Image *) NULL); |
87 | 705 | assert(image->signature == MagickSignature); |
88 | 705 | assert(border_info != (RectangleInfo *) NULL); |
89 | 705 | frame_info.width=image->columns+(border_info->width << 1); |
90 | 705 | frame_info.height=image->rows+(border_info->height << 1); |
91 | 705 | frame_info.x=(long) border_info->width; |
92 | 705 | frame_info.y=(long) border_info->height; |
93 | 705 | frame_info.inner_bevel=0; |
94 | 705 | frame_info.outer_bevel=0; |
95 | 705 | clone_image=CloneImage(image,0,0,True,exception); |
96 | 705 | if (clone_image == (Image *) NULL) |
97 | 0 | return((Image *) NULL); |
98 | 705 | clone_image->matte_color=image->border_color; |
99 | 705 | border_image=FrameImage(clone_image,&frame_info,exception); |
100 | 705 | DestroyImage(clone_image); |
101 | 705 | if (border_image != (Image *) NULL) |
102 | 705 | border_image->matte_color=image->matte_color; |
103 | 705 | return(border_image); |
104 | 705 | } |
105 | | |
106 | | /* |
107 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
108 | | % % |
109 | | % % |
110 | | % % |
111 | | % F r a m e I m a g e % |
112 | | % % |
113 | | % % |
114 | | % % |
115 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
116 | | % |
117 | | % FrameImage() adds a simulated three-dimensional border around the image. |
118 | | % The color of the border is defined by the matte_color member of image. |
119 | | % Members width and height of frame_info specify the border width of the |
120 | | % vertical and horizontal sides of the frame. Members inner and outer |
121 | | % indicate the width of the inner and outer shadows of the frame. |
122 | | % |
123 | | % The format of the FrameImage method is: |
124 | | % |
125 | | % Image *FrameImage(const Image *image,const FrameInfo *frame_info, |
126 | | % ExceptionInfo *exception) |
127 | | % |
128 | | % A description of each parameter follows: |
129 | | % |
130 | | % o image: The image. |
131 | | % |
132 | | % o frame_info: Define the width and height of the frame and its bevels. |
133 | | % |
134 | | % o exception: Return any errors or warnings in this structure. |
135 | | % |
136 | | % |
137 | | */ |
138 | | MagickExport Image *FrameImage(const Image *image,const FrameInfo *frame_info, |
139 | | ExceptionInfo *exception) |
140 | 705 | { |
141 | 705 | #define FrameImageText "[%s] Frame: %lux%lu%+ld%+ld bevel inner %ld outer %ld..." |
142 | | |
143 | 705 | Image |
144 | 705 | *frame_image; |
145 | | |
146 | 705 | unsigned long |
147 | 705 | row_count=0; |
148 | | |
149 | 705 | MagickBool |
150 | 705 | monitor_active; |
151 | | |
152 | 705 | long |
153 | 705 | height, |
154 | 705 | width, |
155 | 705 | y; |
156 | | |
157 | 705 | register const PixelPacket |
158 | 705 | * restrict p; |
159 | | |
160 | 705 | register long |
161 | 705 | x; |
162 | | |
163 | 705 | register PixelPacket |
164 | 705 | * restrict q; |
165 | | |
166 | 705 | PixelPacket |
167 | 705 | accentuate, |
168 | 705 | highlight, |
169 | 705 | matte, |
170 | 705 | shadow, |
171 | 705 | trough; |
172 | | |
173 | 705 | unsigned long |
174 | 705 | bevel_width; |
175 | | |
176 | 705 | unsigned int |
177 | 705 | is_grayscale; |
178 | | |
179 | 705 | MagickPassFail |
180 | 705 | status=MagickPass; |
181 | | |
182 | | /* |
183 | | Check frame geometry. |
184 | | */ |
185 | 705 | assert(image != (Image *) NULL); |
186 | 705 | assert(image->signature == MagickSignature); |
187 | 705 | assert(frame_info != (FrameInfo *) NULL); |
188 | 705 | is_grayscale=image->is_grayscale; |
189 | 705 | if ((frame_info->outer_bevel < 0) || (frame_info->inner_bevel < 0)) |
190 | 0 | ThrowImageException3(OptionError,UnableToFrameImage, |
191 | 705 | BevelWidthIsNegative); |
192 | 705 | bevel_width=frame_info->outer_bevel+frame_info->inner_bevel; |
193 | 705 | width=(long) (frame_info->width-frame_info->x-bevel_width); |
194 | 705 | height=(long) (frame_info->height-frame_info->y-bevel_width); |
195 | 705 | if ((width < (long) image->columns) || (height < (long) image->rows)) |
196 | 0 | ThrowImageException3(OptionError,UnableToFrameImage, |
197 | 705 | FrameIsLessThanImageSize); |
198 | | /* |
199 | | Allocate image |
200 | | */ |
201 | 705 | frame_image= |
202 | 705 | CloneImage(image,frame_info->width,frame_info->height,True,exception); |
203 | 705 | if (frame_image == (Image *) NULL) |
204 | 0 | return(False); |
205 | | |
206 | 705 | monitor_active=MagickMonitorActive(); |
207 | | |
208 | | /* |
209 | | Set image type. |
210 | | */ |
211 | 705 | (void) SetImageType(frame_image,frame_image->matte_color.opacity != |
212 | 705 | OpaqueOpacity ? TrueColorMatteType : TrueColorType); |
213 | | |
214 | | /* |
215 | | Initialize 3D effects color. |
216 | | */ |
217 | 705 | matte=image->matte_color; |
218 | 705 | if (!IsGray(image->matte_color)) |
219 | 0 | is_grayscale=False; |
220 | 705 | accentuate.red=(Quantum) ((((double) MaxRGB-AccentuateModulate)*matte.red+ |
221 | 705 | ((double) MaxRGB*AccentuateModulate))/MaxRGB+0.5); |
222 | 705 | accentuate.green=(Quantum) ((((double) MaxRGB-AccentuateModulate)*matte.green+ |
223 | 705 | ((double) MaxRGB*AccentuateModulate))/MaxRGB+0.5); |
224 | 705 | accentuate.blue=(Quantum) ((((double) MaxRGB-AccentuateModulate)*matte.blue+ |
225 | 705 | ((double) MaxRGB*AccentuateModulate))/MaxRGB+0.5); |
226 | 705 | accentuate.opacity=(Quantum) ((((double) MaxRGB-AccentuateModulate)* |
227 | 705 | matte.opacity+((double) MaxRGB*AccentuateModulate))/MaxRGB+0.5); |
228 | 705 | highlight.red=(Quantum) ((((double) MaxRGB-HighlightModulate)*matte.red+ |
229 | 705 | ((double) MaxRGB*HighlightModulate))/MaxRGB+0.5); |
230 | 705 | highlight.green=(Quantum) ((((double) MaxRGB-HighlightModulate)*matte.green+ |
231 | 705 | ((double) MaxRGB*HighlightModulate))/MaxRGB+0.5); |
232 | 705 | highlight.blue=(Quantum) ((((double) MaxRGB-HighlightModulate)*matte.blue+ |
233 | 705 | ((double) MaxRGB*HighlightModulate))/MaxRGB+0.5); |
234 | 705 | highlight.opacity=(Quantum) ((((double) MaxRGB-HighlightModulate)* |
235 | 705 | matte.opacity+((double) MaxRGB*HighlightModulate))/MaxRGB+0.5); |
236 | 705 | shadow.red=(Quantum) (((double) matte.red*ShadowModulate)/MaxRGB+0.5); |
237 | 705 | shadow.green=(Quantum) (((double) matte.green*ShadowModulate)/MaxRGB+0.5); |
238 | 705 | shadow.blue=(Quantum) (((double) matte.blue*ShadowModulate)/MaxRGB+0.5); |
239 | 705 | shadow.opacity=(Quantum) (((double) matte.opacity*ShadowModulate)/MaxRGB+0.5); |
240 | 705 | trough.red=(Quantum) (((double) matte.red*TroughModulate)/MaxRGB+0.5); |
241 | 705 | trough.green=(Quantum) (((double) matte.green*TroughModulate)/MaxRGB+0.5); |
242 | 705 | trough.blue=(Quantum) (((double) matte.blue*TroughModulate)/MaxRGB+0.5); |
243 | 705 | trough.opacity=(Quantum) (((double) matte.opacity*TroughModulate)/MaxRGB+0.5); |
244 | | /* |
245 | | Draw top of ornamental border. |
246 | | */ |
247 | 705 | height=(long) (frame_info->outer_bevel+(frame_info->y-bevel_width)+ |
248 | 705 | frame_info->inner_bevel); |
249 | 705 | if (height > 0) |
250 | 705 | { |
251 | 705 | q=SetImagePixelsEx(frame_image,0,0,frame_image->columns,height,exception); |
252 | 705 | if (q != (PixelPacket *) NULL) |
253 | 696 | { |
254 | 696 | for (y=0; y < frame_info->outer_bevel; y++) |
255 | 0 | { |
256 | 0 | for (x=0; x < (long) (frame_image->columns-y); x++) |
257 | 0 | if (x < y) |
258 | 0 | *q++=highlight; |
259 | 0 | else |
260 | 0 | *q++=accentuate; |
261 | 0 | for ( ; x < (long) frame_image->columns; x++) |
262 | 0 | *q++=shadow; |
263 | 0 | } |
264 | 71.9k | for (y=0; y < (long) (frame_info->y-bevel_width); y++) |
265 | 71.2k | { |
266 | 71.2k | for (x=0; x < frame_info->outer_bevel; x++) |
267 | 0 | *q++=highlight; |
268 | 71.2k | width=(long) (frame_image->columns-2*frame_info->outer_bevel); |
269 | 52.9M | for (x=0; x < (long) width; x++) |
270 | 52.9M | *q++=matte; |
271 | 71.2k | for (x=0; x < frame_info->outer_bevel; x++) |
272 | 0 | *q++=shadow; |
273 | 71.2k | } |
274 | 696 | for (y=0; y < frame_info->inner_bevel; y++) |
275 | 0 | { |
276 | 0 | for (x=0; x < frame_info->outer_bevel; x++) |
277 | 0 | *q++=highlight; |
278 | 0 | for (x=0; x < (long) (frame_info->x-bevel_width); x++) |
279 | 0 | *q++=matte; |
280 | 0 | width=(long) (image->columns+(frame_info->inner_bevel << 1)-y); |
281 | 0 | for (x=0; x < width; x++) |
282 | 0 | if (x < y) |
283 | 0 | *q++=shadow; |
284 | 0 | else |
285 | 0 | *q++=trough; |
286 | 0 | for ( ; x < (long) (image->columns+(frame_info->inner_bevel << 1)); x++) |
287 | 0 | *q++=highlight; |
288 | 0 | width=(long) |
289 | 0 | (frame_info->width-frame_info->x-image->columns-bevel_width); |
290 | 0 | for (x=0; x < width; x++) |
291 | 0 | *q++=matte; |
292 | 0 | for (x=0; x < frame_info->outer_bevel; x++) |
293 | 0 | *q++=shadow; |
294 | 0 | } |
295 | 696 | (void) SyncImagePixelsEx(frame_image,exception); |
296 | 696 | } |
297 | 705 | } |
298 | | /* |
299 | | Draw sides of ornamental border. |
300 | | */ |
301 | | #if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP) |
302 | | # if defined(TUNE_OPENMP) |
303 | | # pragma omp parallel for schedule(runtime) shared(row_count, status) private (p, q, width, x) |
304 | | # else |
305 | | # pragma omp parallel for schedule(static,8) shared(row_count, status) private (p, q, width, x) |
306 | | # endif |
307 | | #endif |
308 | 91.9k | for (y=0; y < (long) image->rows; y++) |
309 | 91.2k | { |
310 | 91.2k | MagickBool |
311 | 91.2k | thread_status; |
312 | | |
313 | 91.2k | thread_status=status; |
314 | 91.2k | if (thread_status == MagickFail) |
315 | 3.84k | continue; |
316 | | |
317 | | /* |
318 | | Initialize scanline with border color. |
319 | | */ |
320 | 87.3k | p=AcquireImagePixels(image,0,y,image->columns,1,exception); |
321 | 87.3k | q=SetImagePixelsEx(frame_image,0,frame_info->y+y,frame_image->columns,1,exception); |
322 | 87.3k | if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL)) |
323 | 9 | thread_status=MagickFail; |
324 | | |
325 | 87.3k | if (thread_status != MagickFail) |
326 | 87.3k | { |
327 | 87.3k | for (x=0; x < frame_info->outer_bevel; x++) |
328 | 0 | *q++=highlight; |
329 | 17.5M | for (x=0; x < (long) (frame_info->x-bevel_width); x++) |
330 | 17.4M | *q++=matte; |
331 | 87.3k | for (x=0; x < frame_info->inner_bevel; x++) |
332 | 0 | *q++=shadow; |
333 | | /* |
334 | | Transfer scanline. |
335 | | */ |
336 | 87.3k | (void) memcpy(q,p,image->columns*sizeof(PixelPacket)); |
337 | 87.3k | q+=image->columns; |
338 | 87.3k | for (x=0; x < frame_info->inner_bevel; x++) |
339 | 0 | *q++=highlight; |
340 | 87.3k | width=(long) (frame_info->width-frame_info->x-image->columns-bevel_width); |
341 | 17.5M | for (x=0; x < width; x++) |
342 | 17.4M | *q++=matte; |
343 | 87.3k | for (x=0; x < frame_info->outer_bevel; x++) |
344 | 0 | *q++=shadow; |
345 | 87.3k | if (!SyncImagePixelsEx(frame_image,exception)) |
346 | 0 | thread_status=MagickFail; |
347 | 87.3k | } |
348 | | |
349 | 87.3k | if (monitor_active) |
350 | 0 | { |
351 | 0 | unsigned long |
352 | 0 | thread_row_count; |
353 | |
|
354 | | #if defined(HAVE_OPENMP) |
355 | | # pragma omp atomic |
356 | | #endif |
357 | 0 | row_count++; |
358 | | #if defined(HAVE_OPENMP) |
359 | | # pragma omp flush (row_count) |
360 | | #endif |
361 | 0 | thread_row_count=row_count; |
362 | 0 | if (QuantumTick(thread_row_count,image->rows)) |
363 | 0 | if (!MagickMonitorFormatted(thread_row_count,image->rows,exception, |
364 | 0 | FrameImageText,image->filename, |
365 | 0 | frame_info->width,frame_info->height, |
366 | 0 | frame_info->x, |
367 | 0 | frame_info->y, |
368 | 0 | frame_info->inner_bevel, |
369 | 0 | frame_info->outer_bevel)) |
370 | 0 | thread_status=MagickFail; |
371 | 0 | } |
372 | | |
373 | 87.3k | if (thread_status == MagickFail) |
374 | 9 | { |
375 | 9 | status=MagickFail; |
376 | | #if defined(HAVE_OPENMP) |
377 | | # pragma omp flush (status) |
378 | | #endif |
379 | 9 | } |
380 | 87.3k | } |
381 | | /* |
382 | | Draw bottom of ornamental border. |
383 | | */ |
384 | 705 | height=(long) (frame_info->inner_bevel+frame_info->height-frame_info->y- |
385 | 705 | image->rows-bevel_width+frame_info->outer_bevel); |
386 | 705 | if (height > 0) |
387 | 705 | { |
388 | 705 | q=SetImagePixelsEx(frame_image,0,(long) (frame_image->rows-height), |
389 | 705 | frame_image->columns,height,exception); |
390 | 705 | if (q == (PixelPacket *) NULL) |
391 | 9 | return(frame_image); |
392 | 696 | for (y=frame_info->inner_bevel-1; y >= 0; y--) |
393 | 0 | { |
394 | 0 | for (x=0; x < frame_info->outer_bevel; x++) |
395 | 0 | *q++=highlight; |
396 | 0 | for (x=0; x < (long) (frame_info->x-bevel_width); x++) |
397 | 0 | *q++=matte; |
398 | 0 | for (x=0; x < y; x++) |
399 | 0 | *q++=shadow; |
400 | 0 | for ( ; x < (long) (image->columns+(frame_info->inner_bevel << 1)); x++) |
401 | 0 | if (x >= (long) (image->columns+(frame_info->inner_bevel << 1)-y)) |
402 | 0 | *q++=highlight; |
403 | 0 | else |
404 | 0 | *q++=accentuate; |
405 | 0 | width=(long) (frame_info->width-frame_info->x-image->columns-bevel_width); |
406 | 0 | for (x=0; x < (long) width; x++) |
407 | 0 | *q++=matte; |
408 | 0 | for (x=0; x < frame_info->outer_bevel; x++) |
409 | 0 | *q++=shadow; |
410 | 0 | } |
411 | 696 | height=(long) (frame_info->height-frame_info->y-image->rows-bevel_width); |
412 | 71.9k | for (y=0; y < height; y++) |
413 | 71.2k | { |
414 | 71.2k | for (x=0; x < frame_info->outer_bevel; x++) |
415 | 0 | *q++=highlight; |
416 | 52.9M | for (x=0; x < (long) (frame_image->columns-2*frame_info->outer_bevel); x++) |
417 | 52.9M | *q++=matte; |
418 | 71.2k | for (x=0; x < frame_info->outer_bevel; x++) |
419 | 0 | *q++=shadow; |
420 | 71.2k | } |
421 | 696 | for (y=frame_info->outer_bevel-1; y >= 0; y--) |
422 | 0 | { |
423 | 0 | for (x=0; x < y; x++) |
424 | 0 | *q++=highlight; |
425 | 0 | for ( ; x < (long) frame_image->columns; x++) |
426 | 0 | if (x >= (long) (frame_image->columns-y)) |
427 | 0 | *q++=shadow; |
428 | 0 | else |
429 | 0 | *q++=trough; |
430 | 0 | } |
431 | 696 | (void) SyncImagePixelsEx(frame_image,exception); |
432 | 696 | } |
433 | | |
434 | 696 | frame_image->is_grayscale=is_grayscale; |
435 | 696 | return(frame_image); |
436 | 705 | } |
437 | | |
438 | | /* |
439 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
440 | | % % |
441 | | % % |
442 | | % % |
443 | | % R a i s e I m a g e % |
444 | | % % |
445 | | % % |
446 | | % % |
447 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
448 | | % |
449 | | % RaiseImage() creates a simulated three-dimensional button-like effect |
450 | | % by lightening and darkening the edges of the image. Members width and |
451 | | % height of raise_info define the width of the vertical and horizontal |
452 | | % edge of the effect. |
453 | | % |
454 | | % The format of the RaiseImage method is: |
455 | | % |
456 | | % unsigned int RaiseImage(Image *image,const RectangleInfo *raise_info, |
457 | | % const int raise_flag) |
458 | | % |
459 | | % A description of each parameter follows: |
460 | | % |
461 | | % o image: The image. |
462 | | % |
463 | | % o raise_info: Define the width and height of the raise area. |
464 | | % |
465 | | % o raise_flag: A value other than zero creates a 3-D raise effect, |
466 | | % otherwise it has a lowered effect. |
467 | | % |
468 | | % |
469 | | */ |
470 | 0 | #define AccentuateFactor (double) ScaleCharToQuantum(135) |
471 | 0 | #define HighlightFactor (double) ScaleCharToQuantum(190) |
472 | 0 | #define ShadowFactor (double) ScaleCharToQuantum(190) |
473 | 0 | #define RaiseImageText "[%s] Raise..." |
474 | 0 | #define TroughFactor (double) ScaleCharToQuantum(135) |
475 | | |
476 | | MagickExport MagickPassFail |
477 | | RaiseImage(Image *image,const RectangleInfo *raise_info,const int raise_flag) |
478 | 0 | { |
479 | 0 | unsigned long |
480 | 0 | row_count=0; |
481 | |
|
482 | 0 | MagickBool |
483 | 0 | monitor_active; |
484 | |
|
485 | 0 | double |
486 | 0 | foreground, |
487 | 0 | background; |
488 | |
|
489 | 0 | long |
490 | 0 | y; |
491 | |
|
492 | 0 | register long |
493 | 0 | x; |
494 | |
|
495 | 0 | unsigned int |
496 | 0 | is_grayscale; |
497 | |
|
498 | 0 | register PixelPacket |
499 | 0 | * restrict q; |
500 | |
|
501 | 0 | MagickPassFail |
502 | 0 | status=MagickPass; |
503 | |
|
504 | 0 | assert(image != (Image *) NULL); |
505 | 0 | assert(image->signature == MagickSignature); |
506 | 0 | assert(raise_info != (RectangleInfo *) NULL); |
507 | 0 | is_grayscale=image->is_grayscale; |
508 | 0 | if ((image->columns <= (raise_info->width << 1)) || |
509 | 0 | (image->rows <= (raise_info->height << 1))) |
510 | 0 | ThrowBinaryException3(OptionError,UnableToRaiseImage, |
511 | 0 | ImageSizeMustExceedBevelWidth); |
512 | |
|
513 | 0 | foreground=MaxRGBDouble; |
514 | 0 | background=0.0; |
515 | 0 | if (!raise_flag) |
516 | 0 | { |
517 | 0 | foreground=0.0; |
518 | 0 | background=MaxRGBDouble; |
519 | 0 | } |
520 | 0 | (void) SetImageType(image,TrueColorType); |
521 | |
|
522 | 0 | monitor_active=MagickMonitorActive(); |
523 | |
|
524 | | #if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP) |
525 | | # if defined(TUNE_OPENMP) |
526 | | # pragma omp parallel for schedule(runtime) shared(row_count, status) private (q, x) |
527 | | # else |
528 | | # pragma omp parallel for schedule(static,4) shared(row_count, status) private (q, x) |
529 | | # endif |
530 | | #endif |
531 | 0 | for ( y=0; y < (long) image->rows; y++) |
532 | 0 | { |
533 | 0 | MagickBool |
534 | 0 | thread_status; |
535 | |
|
536 | 0 | thread_status=status; |
537 | 0 | if (thread_status == MagickFail) |
538 | 0 | continue; |
539 | | |
540 | 0 | q=GetImagePixelsEx(image,0,y,image->columns,1,&image->exception); |
541 | 0 | if (q == (PixelPacket *) NULL) |
542 | 0 | thread_status=MagickFail; |
543 | |
|
544 | 0 | if (thread_status != MagickFail) |
545 | 0 | { |
546 | 0 | if (y < (long) raise_info->height) |
547 | 0 | { |
548 | 0 | for (x=0; x < y; x++) |
549 | 0 | { |
550 | 0 | q[x].red=(Quantum) ((q[x].red*HighlightFactor+ |
551 | 0 | foreground*(MaxRGBDouble-HighlightFactor))/MaxRGBDouble); |
552 | 0 | q[x].green=(Quantum) ((q[x].green*HighlightFactor+ |
553 | 0 | foreground*(MaxRGBDouble-HighlightFactor))/MaxRGBDouble); |
554 | 0 | q[x].blue=(Quantum) ((q[x].blue*HighlightFactor+ |
555 | 0 | foreground*(MaxRGBDouble-HighlightFactor))/MaxRGBDouble); |
556 | 0 | } |
557 | 0 | for ( ; x < (long) (image->columns-y); x++) |
558 | 0 | { |
559 | 0 | q[x].red=(Quantum) ((q[x].red*AccentuateFactor+ |
560 | 0 | foreground*(MaxRGBDouble-AccentuateFactor))/MaxRGBDouble); |
561 | 0 | q[x].green=(Quantum) ((q[x].green*AccentuateFactor+ |
562 | 0 | foreground*(MaxRGBDouble-AccentuateFactor))/MaxRGBDouble); |
563 | 0 | q[x].blue=(Quantum) ((q[x].blue*AccentuateFactor+ |
564 | 0 | foreground*(MaxRGBDouble-AccentuateFactor))/MaxRGBDouble); |
565 | 0 | } |
566 | 0 | for ( ; x < (long) image->columns; x++) |
567 | 0 | { |
568 | 0 | q[x].red=(Quantum) ((q[x].red*ShadowFactor+ |
569 | 0 | background*(MaxRGBDouble-ShadowFactor))/MaxRGBDouble); |
570 | 0 | q[x].green=(Quantum) ((q[x].green*ShadowFactor+ |
571 | 0 | background*(MaxRGBDouble-ShadowFactor))/MaxRGBDouble); |
572 | 0 | q[x].blue=(Quantum) ((q[x].blue*ShadowFactor+ |
573 | 0 | background*(MaxRGBDouble-ShadowFactor))/MaxRGBDouble); |
574 | 0 | } |
575 | 0 | } |
576 | 0 | else if (y < (long) (image->rows-raise_info->height)) |
577 | 0 | { |
578 | 0 | for (x=0; x < (long) raise_info->width; x++) |
579 | 0 | { |
580 | 0 | q[x].red=(Quantum) ((q[x].red*HighlightFactor+ |
581 | 0 | foreground*(MaxRGBDouble-HighlightFactor))/MaxRGBDouble); |
582 | 0 | q[x].green=(Quantum) ((q[x].green*HighlightFactor+ |
583 | 0 | foreground*(MaxRGBDouble-HighlightFactor))/MaxRGBDouble); |
584 | 0 | q[x].blue=(Quantum) ((q[x].blue*HighlightFactor+ |
585 | 0 | foreground*(MaxRGBDouble-HighlightFactor))/MaxRGBDouble); |
586 | 0 | } |
587 | 0 | for ( ; x < (long) (image->columns-raise_info->width); x++); |
588 | 0 | for ( ; x < (long) image->columns; x++) |
589 | 0 | { |
590 | 0 | q[x].red=(Quantum) ((q[x].red*ShadowFactor+ |
591 | 0 | background*(MaxRGBDouble-ShadowFactor))/MaxRGBDouble); |
592 | 0 | q[x].green=(Quantum) ((q[x].green*ShadowFactor+ |
593 | 0 | background*(MaxRGBDouble-ShadowFactor))/MaxRGBDouble); |
594 | 0 | q[x].blue=(Quantum) ((q[x].blue*ShadowFactor+ |
595 | 0 | background*(MaxRGBDouble-ShadowFactor))/MaxRGBDouble); |
596 | 0 | } |
597 | 0 | } |
598 | 0 | else |
599 | 0 | { |
600 | 0 | for (x=0; x < (long) (image->rows-y); x++) |
601 | 0 | { |
602 | 0 | q[x].red=(Quantum) ((q[x].red*HighlightFactor+ |
603 | 0 | foreground*(MaxRGBDouble-HighlightFactor))/MaxRGBDouble+0.5); |
604 | 0 | q[x].green=(Quantum) ((q[x].green*HighlightFactor+ |
605 | 0 | foreground*(MaxRGBDouble-HighlightFactor))/MaxRGBDouble+0.5); |
606 | 0 | q[x].blue=(Quantum) ((q[x].blue*HighlightFactor+ |
607 | 0 | foreground*(MaxRGBDouble-HighlightFactor))/MaxRGBDouble+0.5); |
608 | 0 | } |
609 | 0 | for ( ; x < (long) (image->columns-(image->rows-y)); x++) |
610 | 0 | { |
611 | 0 | q[x].red=(Quantum) ((q[x].red*TroughFactor+ |
612 | 0 | background*(MaxRGBDouble-TroughFactor))/MaxRGBDouble+0.5); |
613 | 0 | q[x].green=(Quantum) ((q[x].green*TroughFactor+ |
614 | 0 | background*(MaxRGBDouble-TroughFactor))/MaxRGBDouble+0.5); |
615 | 0 | q[x].blue=(Quantum) ((q[x].blue*TroughFactor+ |
616 | 0 | background*(MaxRGBDouble-TroughFactor))/MaxRGBDouble+0.5); |
617 | 0 | } |
618 | 0 | for ( ; x < (long) image->columns; x++) |
619 | 0 | { |
620 | 0 | q[x].red=(Quantum) ((q[x].red*ShadowFactor+ |
621 | 0 | background*(MaxRGBDouble-ShadowFactor))/MaxRGBDouble+0.5); |
622 | 0 | q[x].green=(Quantum) ((q[x].green*ShadowFactor+ |
623 | 0 | background*(MaxRGBDouble-ShadowFactor))/MaxRGBDouble+0.5); |
624 | 0 | q[x].blue=(Quantum) ((q[x].blue*ShadowFactor+ |
625 | 0 | background*(MaxRGBDouble-ShadowFactor))/MaxRGBDouble+0.5); |
626 | 0 | } |
627 | 0 | } |
628 | 0 | if (!SyncImagePixelsEx(image,&image->exception)) |
629 | 0 | thread_status=MagickFail; |
630 | 0 | } |
631 | |
|
632 | 0 | if (monitor_active) |
633 | 0 | { |
634 | 0 | unsigned long |
635 | 0 | thread_row_count; |
636 | |
|
637 | | #if defined(HAVE_OPENMP) |
638 | | # pragma omp atomic |
639 | | #endif |
640 | 0 | row_count++; |
641 | | #if defined(HAVE_OPENMP) |
642 | | # pragma omp flush (row_count) |
643 | | #endif |
644 | 0 | thread_row_count=row_count; |
645 | 0 | if (QuantumTick(thread_row_count,image->rows)) |
646 | 0 | if (!MagickMonitorFormatted(thread_row_count,image->rows,&image->exception, |
647 | 0 | RaiseImageText,image->filename)) |
648 | 0 | thread_status=MagickFail; |
649 | 0 | } |
650 | |
|
651 | 0 | if (thread_status == MagickFail) |
652 | 0 | { |
653 | 0 | status=MagickFail; |
654 | | #if defined(HAVE_OPENMP) |
655 | | # pragma omp flush (status) |
656 | | #endif |
657 | 0 | } |
658 | 0 | } |
659 | |
|
660 | 0 | image->is_grayscale=is_grayscale; |
661 | 0 | return(status); |
662 | 0 | } |