cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
cristy | 5873947 | 2010-06-26 20:27:18 +0000 | [diff] [blame] | 5 | % W W AAA N N DDDD % |
| 6 | % W W A A NN N D D % |
| 7 | % W W W AAAAA N N N D D % |
| 8 | % WW WW A A N NN D D % |
| 9 | % W W A A N N DDDD % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 10 | % % |
| 11 | % V V IIIII EEEEE W W % |
| 12 | % V V I E W W % |
| 13 | % V V I EEE W W W % |
| 14 | % V V I E WW WW % |
| 15 | % V IIIII EEEEE W W % |
| 16 | % % |
| 17 | % % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 18 | % MagickWand Wand View Methods % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 19 | % % |
| 20 | % Software Design % |
| 21 | % John Cristy % |
| 22 | % March 2003 % |
| 23 | % % |
| 24 | % % |
cristy | 7e41fe8 | 2010-12-04 23:12:08 +0000 | [diff] [blame] | 25 | % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 26 | % dedicated to making software imaging solutions freely available. % |
| 27 | % % |
| 28 | % You may not use this file except in compliance with the License. You may % |
| 29 | % obtain a copy of the License at % |
| 30 | % % |
| 31 | % http://www.imagemagick.org/script/license.php % |
| 32 | % % |
| 33 | % Unless required by applicable law or agreed to in writing, software % |
| 34 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 35 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 36 | % See the License for the specific language governing permissions and % |
| 37 | % limitations under the License. % |
| 38 | % % |
| 39 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 40 | % |
| 41 | % |
| 42 | % |
| 43 | */ |
| 44 | |
| 45 | /* |
| 46 | Include declarations. |
| 47 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 48 | #include "MagickWand/studio.h" |
| 49 | #include "MagickWand/MagickWand.h" |
| 50 | #include "MagickWand/magick-wand-private.h" |
| 51 | #include "MagickWand/wand.h" |
| 52 | #include "MagickCore/monitor-private.h" |
| 53 | #include "MagickCore/thread-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 54 | /* |
| 55 | Define declarations. |
| 56 | */ |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 57 | #define WandViewId "WandView" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 58 | |
| 59 | /* |
| 60 | Typedef declarations. |
| 61 | */ |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 62 | struct _WandView |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 63 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 64 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 65 | id; |
| 66 | |
| 67 | char |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 68 | name[MaxTextExtent], |
| 69 | *description; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 70 | |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 71 | RectangleInfo |
| 72 | extent; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 73 | |
| 74 | MagickWand |
| 75 | *wand; |
| 76 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 77 | Image |
| 78 | *image; |
| 79 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 80 | CacheView |
| 81 | *view; |
| 82 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 83 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 84 | number_threads; |
| 85 | |
| 86 | PixelWand |
| 87 | ***pixel_wands; |
| 88 | |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 89 | ExceptionInfo |
| 90 | *exception; |
| 91 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 92 | MagickBooleanType |
| 93 | debug; |
| 94 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 95 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 96 | signature; |
| 97 | }; |
| 98 | |
| 99 | /* |
| 100 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 101 | % % |
| 102 | % % |
| 103 | % % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 104 | % C l o n e W a n d V i e w % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 105 | % % |
| 106 | % % |
| 107 | % % |
| 108 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 109 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 110 | % CloneWandView() makes a copy of the specified wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 111 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 112 | % The format of the CloneWandView method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 113 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 114 | % WandView *CloneWandView(const WandView *wand_view) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 115 | % |
| 116 | % A description of each parameter follows: |
| 117 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 118 | % o wand_view: the wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 119 | % |
| 120 | */ |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 121 | WandExport WandView *CloneWandView(const WandView *wand_view) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 122 | { |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 123 | WandView |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 124 | *clone_view; |
| 125 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 126 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 127 | i; |
| 128 | |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 129 | assert(wand_view != (WandView *) NULL); |
| 130 | assert(wand_view->signature == WandSignature); |
| 131 | if (wand_view->debug != MagickFalse) |
| 132 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand_view->name); |
cristy | 73bd4a5 | 2010-10-05 11:24:23 +0000 | [diff] [blame] | 133 | clone_view=(WandView *) AcquireMagickMemory(sizeof(*clone_view)); |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 134 | if (clone_view == (WandView *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 135 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 136 | wand_view->name); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 137 | (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view)); |
| 138 | clone_view->id=AcquireWandId(); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 139 | (void) FormatLocaleString(clone_view->name,MaxTextExtent,"%s-%.20g", |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 140 | WandViewId,(double) clone_view->id); |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 141 | clone_view->description=ConstantString(wand_view->description); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 142 | clone_view->image=CloneImage(wand_view->image,0,0,MagickTrue, |
| 143 | wand_view->exception); |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 144 | clone_view->view=CloneCacheView(wand_view->view); |
| 145 | clone_view->extent=wand_view->extent; |
| 146 | clone_view->number_threads=wand_view->number_threads; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 147 | clone_view->exception=AcquireExceptionInfo(); |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 148 | InheritException(clone_view->exception,wand_view->exception); |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 149 | for (i=0; i < (ssize_t) wand_view->number_threads; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 150 | clone_view->pixel_wands[i]=ClonePixelWands((const PixelWand **) |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 151 | wand_view->pixel_wands[i],wand_view->extent.width); |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 152 | clone_view->debug=wand_view->debug; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 153 | if (clone_view->debug != MagickFalse) |
| 154 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",clone_view->name); |
| 155 | clone_view->signature=WandSignature; |
| 156 | return(clone_view); |
| 157 | } |
| 158 | |
| 159 | /* |
| 160 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 161 | % % |
| 162 | % % |
| 163 | % % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 164 | % D e s t r o y W a n d V i e w % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 165 | % % |
| 166 | % % |
| 167 | % % |
| 168 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 169 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 170 | % DestroyWandView() deallocates memory associated with a wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 171 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 172 | % The format of the DestroyWandView method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 173 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 174 | % WandView *DestroyWandView(WandView *wand_view) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 175 | % |
| 176 | % A description of each parameter follows: |
| 177 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 178 | % o wand_view: the wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 179 | % |
| 180 | */ |
| 181 | |
| 182 | static PixelWand ***DestroyPixelsThreadSet(PixelWand ***pixel_wands, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 183 | const size_t number_wands,const size_t number_threads) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 184 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 185 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 186 | i; |
| 187 | |
| 188 | assert(pixel_wands != (PixelWand ***) NULL); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 189 | for (i=0; i < (ssize_t) number_threads; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 190 | if (pixel_wands[i] != (PixelWand **) NULL) |
| 191 | pixel_wands[i]=DestroyPixelWands(pixel_wands[i],number_wands); |
cristy | b41ee10 | 2010-10-04 16:46:15 +0000 | [diff] [blame] | 192 | pixel_wands=(PixelWand ***) RelinquishMagickMemory(pixel_wands); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 193 | return(pixel_wands); |
| 194 | } |
| 195 | |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 196 | WandExport WandView *DestroyWandView(WandView *wand_view) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 197 | { |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 198 | assert(wand_view != (WandView *) NULL); |
| 199 | assert(wand_view->signature == WandSignature); |
| 200 | wand_view->pixel_wands=DestroyPixelsThreadSet(wand_view->pixel_wands, |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 201 | wand_view->extent.width,wand_view->number_threads); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 202 | wand_view->image=DestroyImage(wand_view->image); |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 203 | wand_view->view=DestroyCacheView(wand_view->view); |
| 204 | wand_view->exception=DestroyExceptionInfo(wand_view->exception); |
| 205 | wand_view->signature=(~WandSignature); |
| 206 | RelinquishWandId(wand_view->id); |
| 207 | wand_view=(WandView *) RelinquishMagickMemory(wand_view); |
| 208 | return(wand_view); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | /* |
| 212 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 213 | % % |
| 214 | % % |
| 215 | % % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 216 | % D u p l e x T r a n s f e r W a n d V i e w I t e r a t o r % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 217 | % % |
| 218 | % % |
| 219 | % % |
| 220 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 221 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 222 | % DuplexTransferWandViewIterator() iterates over three wand views in |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 223 | % parallel and calls your transfer method for each scanline of the view. The |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 224 | % source and duplex pixel extent is not confined to the image canvas-- that is |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 225 | % you can include negative offsets or widths or heights that exceed the image |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 226 | % dimension. However, the destination wand view is confined to the image |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 227 | % canvas-- that is no negative offsets or widths or heights that exceed the |
| 228 | % image dimension are permitted. |
| 229 | % |
cristy | d6dfc0d | 2010-06-27 19:30:49 +0000 | [diff] [blame] | 230 | % The callback signature is: |
| 231 | % |
| 232 | % MagickBooleanType DuplexTransferImageViewMethod(const WandView *source, |
| 233 | % const WandView *duplex,WandView *destination,const ssize_t y, |
| 234 | % const int thread_id,void *context) |
| 235 | % |
cristy | 5873947 | 2010-06-26 20:27:18 +0000 | [diff] [blame] | 236 | % Use this pragma if the view is not single threaded: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 237 | % |
| 238 | % #pragma omp critical |
| 239 | % |
| 240 | % to define a section of code in your callback transfer method that must be |
| 241 | % executed by a single thread at a time. |
| 242 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 243 | % The format of the DuplexTransferWandViewIterator method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 244 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 245 | % MagickBooleanType DuplexTransferWandViewIterator(WandView *source, |
| 246 | % WandView *duplex,WandView *destination, |
| 247 | % DuplexTransferWandViewMethod transfer,void *context) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 248 | % |
| 249 | % A description of each parameter follows: |
| 250 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 251 | % o source: the source wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 252 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 253 | % o duplex: the duplex wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 254 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 255 | % o destination: the destination wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 256 | % |
| 257 | % o transfer: the transfer callback method. |
| 258 | % |
| 259 | % o context: the user defined context. |
| 260 | % |
| 261 | */ |
cristy | 5873947 | 2010-06-26 20:27:18 +0000 | [diff] [blame] | 262 | WandExport MagickBooleanType DuplexTransferWandViewIterator(WandView *source, |
| 263 | WandView *duplex,WandView *destination,DuplexTransferWandViewMethod transfer, |
| 264 | void *context) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 265 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 266 | ExceptionInfo |
| 267 | *exception; |
| 268 | |
| 269 | Image |
| 270 | *destination_image, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 271 | *source_image; |
| 272 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 273 | MagickBooleanType |
| 274 | status; |
| 275 | |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 276 | MagickOffsetType |
| 277 | progress; |
| 278 | |
| 279 | ssize_t |
| 280 | y; |
| 281 | |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 282 | assert(source != (WandView *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 283 | assert(source->signature == WandSignature); |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 284 | if (transfer == (DuplexTransferWandViewMethod) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 285 | return(MagickFalse); |
| 286 | source_image=source->wand->images; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 287 | destination_image=destination->wand->images; |
cristy | 874276b | 2011-08-05 19:29:22 +0000 | [diff] [blame] | 288 | exception=destination->exception; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 289 | if (SetImageStorageClass(destination_image,DirectClass,exception) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 290 | return(MagickFalse); |
| 291 | status=MagickTrue; |
| 292 | progress=0; |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 293 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 09d8117 | 2010-10-21 16:15:05 +0000 | [diff] [blame] | 294 | #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 295 | #endif |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 296 | for (y=source->extent.y; y < (ssize_t) source->extent.height; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 297 | { |
cristy | 83e6d2a | 2010-09-17 17:35:13 +0000 | [diff] [blame] | 298 | const int |
| 299 | id = GetOpenMPThreadId(); |
cristy | ad74005 | 2010-07-03 01:38:03 +0000 | [diff] [blame] | 300 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 301 | MagickBooleanType |
| 302 | sync; |
| 303 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 304 | register const Quantum |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 305 | *restrict duplex_pixels, |
| 306 | *restrict pixels; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 307 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 308 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 309 | x; |
| 310 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 311 | register Quantum |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 312 | *restrict destination_pixels; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 313 | |
| 314 | if (status == MagickFalse) |
| 315 | continue; |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 316 | pixels=GetCacheViewVirtualPixels(source->view,source->extent.x,y, |
| 317 | source->extent.width,1,source->exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 318 | if (pixels == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 319 | { |
| 320 | status=MagickFalse; |
| 321 | continue; |
| 322 | } |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 323 | for (x=0; x < (ssize_t) source->extent.width; x++) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 324 | { |
| 325 | PixelSetQuantumPixel(source->image,pixels,source->pixel_wands[id][x]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 326 | pixels+=GetPixelChannels(source->image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 327 | } |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 328 | duplex_pixels=GetCacheViewVirtualPixels(duplex->view,duplex->extent.x,y, |
| 329 | duplex->extent.width,1,duplex->exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 330 | if (duplex_pixels == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 331 | { |
| 332 | status=MagickFalse; |
| 333 | continue; |
| 334 | } |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 335 | for (x=0; x < (ssize_t) duplex->extent.width; x++) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 336 | { |
| 337 | PixelSetQuantumPixel(duplex->image,duplex_pixels, |
| 338 | duplex->pixel_wands[id][x]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 339 | duplex_pixels+=GetPixelChannels(duplex->image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 340 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 341 | destination_pixels=GetCacheViewAuthenticPixels(destination->view, |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 342 | destination->extent.x,y,destination->extent.width,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 343 | if (destination_pixels == (Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 344 | { |
| 345 | status=MagickFalse; |
| 346 | continue; |
| 347 | } |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 348 | for (x=0; x < (ssize_t) destination->extent.width; x++) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 349 | { |
| 350 | PixelSetQuantumPixel(destination->image,destination_pixels, |
| 351 | destination->pixel_wands[id][x]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 352 | destination_pixels+=GetPixelChannels(destination->image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 353 | } |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 354 | if (transfer(source,duplex,destination,y,id,context) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 355 | status=MagickFalse; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 356 | destination_pixels=GetCacheViewAuthenticPixels(destination->view, |
| 357 | destination->extent.x,y,destination->extent.width,1,exception); |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 358 | for (x=0; x < (ssize_t) destination->extent.width; x++) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 359 | { |
| 360 | PixelGetQuantumPixel(destination->image,destination->pixel_wands[id][x], |
| 361 | destination_pixels); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 362 | destination_pixels+=GetPixelChannels(destination->image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 363 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 364 | sync=SyncCacheViewAuthenticPixels(destination->view,exception); |
| 365 | if (sync == MagickFalse) |
| 366 | { |
| 367 | InheritException(destination->exception,GetCacheViewException( |
| 368 | source->view)); |
| 369 | status=MagickFalse; |
| 370 | } |
| 371 | if (source_image->progress_monitor != (MagickProgressMonitor) NULL) |
| 372 | { |
| 373 | MagickBooleanType |
| 374 | proceed; |
| 375 | |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 376 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 377 | #pragma omp critical (MagickWand_DuplexTransferWandViewIterator) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 378 | #endif |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 379 | proceed=SetImageProgress(source_image,source->description,progress++, |
| 380 | source->extent.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 381 | if (proceed == MagickFalse) |
| 382 | status=MagickFalse; |
| 383 | } |
| 384 | } |
| 385 | return(status); |
| 386 | } |
| 387 | |
| 388 | /* |
| 389 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 390 | % % |
| 391 | % % |
| 392 | % % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 393 | % G e t W a n d V i e w E x c e p t i o n % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 394 | % % |
| 395 | % % |
| 396 | % % |
| 397 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 398 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 399 | % GetWandViewException() returns the severity, reason, and description of any |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 400 | % error that occurs when utilizing a wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 401 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 402 | % The format of the GetWandViewException method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 403 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 404 | % char *GetWandViewException(const PixelWand *wand_view, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 405 | % ExceptionType *severity) |
| 406 | % |
| 407 | % A description of each parameter follows: |
| 408 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 409 | % o wand_view: the pixel wand_view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 410 | % |
| 411 | % o severity: the severity of the error is returned here. |
| 412 | % |
| 413 | */ |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 414 | WandExport char *GetWandViewException(const WandView *wand_view, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 415 | ExceptionType *severity) |
| 416 | { |
| 417 | char |
| 418 | *description; |
| 419 | |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 420 | assert(wand_view != (const WandView *) NULL); |
| 421 | assert(wand_view->signature == WandSignature); |
| 422 | if (wand_view->debug != MagickFalse) |
| 423 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand_view->name); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 424 | assert(severity != (ExceptionType *) NULL); |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 425 | *severity=wand_view->exception->severity; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 426 | description=(char *) AcquireQuantumMemory(2UL*MaxTextExtent, |
| 427 | sizeof(*description)); |
| 428 | if (description == (char *) NULL) |
| 429 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 430 | wand_view->name); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 431 | *description='\0'; |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 432 | if (wand_view->exception->reason != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 433 | (void) CopyMagickString(description,GetLocaleExceptionMessage( |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 434 | wand_view->exception->severity,wand_view->exception->reason), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 435 | MaxTextExtent); |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 436 | if (wand_view->exception->description != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 437 | { |
| 438 | (void) ConcatenateMagickString(description," (",MaxTextExtent); |
| 439 | (void) ConcatenateMagickString(description,GetLocaleExceptionMessage( |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 440 | wand_view->exception->severity,wand_view->exception->description), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 441 | MaxTextExtent); |
| 442 | (void) ConcatenateMagickString(description,")",MaxTextExtent); |
| 443 | } |
| 444 | return(description); |
| 445 | } |
| 446 | |
| 447 | /* |
| 448 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 449 | % % |
| 450 | % % |
| 451 | % % |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 452 | % G e t W a n d V i e w E x t e n t % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 453 | % % |
| 454 | % % |
| 455 | % % |
| 456 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 457 | % |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 458 | % GetWandViewExtent() returns the wand view extent. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 459 | % |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 460 | % The format of the GetWandViewExtent method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 461 | % |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 462 | % RectangleInfo GetWandViewExtent(const WandView *wand_view) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 463 | % |
| 464 | % A description of each parameter follows: |
| 465 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 466 | % o wand_view: the wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 467 | % |
| 468 | */ |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 469 | WandExport RectangleInfo GetWandViewExtent(const WandView *wand_view) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 470 | { |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 471 | assert(wand_view != (WandView *) NULL); |
| 472 | assert(wand_view->signature == WandSignature); |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 473 | return(wand_view->extent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | /* |
| 477 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 478 | % % |
| 479 | % % |
| 480 | % % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 481 | % G e t W a n d V i e w I t e r a t o r % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 482 | % % |
| 483 | % % |
| 484 | % % |
| 485 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 486 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 487 | % GetWandViewIterator() iterates over the wand view in parallel and calls |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 488 | % your get method for each scanline of the view. The pixel extent is |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 489 | % not confined to the image canvas-- that is you can include negative offsets |
| 490 | % or widths or heights that exceed the image dimension. Any updates to |
| 491 | % the pixels in your callback are ignored. |
| 492 | % |
cristy | d6dfc0d | 2010-06-27 19:30:49 +0000 | [diff] [blame] | 493 | % The callback signature is: |
| 494 | % |
| 495 | % MagickBooleanType GetImageViewMethod(const WandView *source, |
| 496 | % const ssize_t y,const int thread_id,void *context) |
| 497 | % |
cristy | 5873947 | 2010-06-26 20:27:18 +0000 | [diff] [blame] | 498 | % Use this pragma if the view is not single threaded: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 499 | % |
| 500 | % #pragma omp critical |
| 501 | % |
| 502 | % to define a section of code in your callback get method that must be |
| 503 | % executed by a single thread at a time. |
| 504 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 505 | % The format of the GetWandViewIterator method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 506 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 507 | % MagickBooleanType GetWandViewIterator(WandView *source, |
| 508 | % GetWandViewMethod get,void *context) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 509 | % |
| 510 | % A description of each parameter follows: |
| 511 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 512 | % o source: the source wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 513 | % |
| 514 | % o get: the get callback method. |
| 515 | % |
| 516 | % o context: the user defined context. |
| 517 | % |
| 518 | */ |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 519 | WandExport MagickBooleanType GetWandViewIterator(WandView *source, |
| 520 | GetWandViewMethod get,void *context) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 521 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 522 | Image |
| 523 | *source_image; |
| 524 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 525 | MagickBooleanType |
| 526 | status; |
| 527 | |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 528 | MagickOffsetType |
| 529 | progress; |
| 530 | |
| 531 | ssize_t |
| 532 | y; |
| 533 | |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 534 | assert(source != (WandView *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 535 | assert(source->signature == WandSignature); |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 536 | if (get == (GetWandViewMethod) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 537 | return(MagickFalse); |
| 538 | source_image=source->wand->images; |
| 539 | status=MagickTrue; |
| 540 | progress=0; |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 541 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 09d8117 | 2010-10-21 16:15:05 +0000 | [diff] [blame] | 542 | #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 543 | #endif |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 544 | for (y=source->extent.y; y < (ssize_t) source->extent.height; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 545 | { |
cristy | 83e6d2a | 2010-09-17 17:35:13 +0000 | [diff] [blame] | 546 | const int |
| 547 | id = GetOpenMPThreadId(); |
cristy | ad74005 | 2010-07-03 01:38:03 +0000 | [diff] [blame] | 548 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 549 | register const Quantum |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 550 | *pixels; |
| 551 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 552 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 553 | x; |
| 554 | |
| 555 | if (status == MagickFalse) |
| 556 | continue; |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 557 | pixels=GetCacheViewVirtualPixels(source->view,source->extent.x,y, |
| 558 | source->extent.width,1,source->exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 559 | if (pixels == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 560 | { |
| 561 | status=MagickFalse; |
| 562 | continue; |
| 563 | } |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 564 | for (x=0; x < (ssize_t) source->extent.width; x++) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 565 | { |
| 566 | PixelSetQuantumPixel(source->image,pixels,source->pixel_wands[id][x]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 567 | pixels+=GetPixelChannels(source->image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 568 | } |
cristy | d6dfc0d | 2010-06-27 19:30:49 +0000 | [diff] [blame] | 569 | if (get(source,y,id,context) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 570 | status=MagickFalse; |
| 571 | if (source_image->progress_monitor != (MagickProgressMonitor) NULL) |
| 572 | { |
| 573 | MagickBooleanType |
| 574 | proceed; |
| 575 | |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 576 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 577 | #pragma omp critical (MagickWand_GetWandViewIterator) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 578 | #endif |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 579 | proceed=SetImageProgress(source_image,source->description,progress++, |
| 580 | source->extent.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 581 | if (proceed == MagickFalse) |
| 582 | status=MagickFalse; |
| 583 | } |
| 584 | } |
| 585 | return(status); |
| 586 | } |
| 587 | |
| 588 | /* |
| 589 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 590 | % % |
| 591 | % % |
| 592 | % % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 593 | % G e t W a n d V i e w P i x e l s % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 594 | % % |
| 595 | % % |
| 596 | % % |
| 597 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 598 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 599 | % GetWandViewPixels() returns the wand view pixel_wands. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 600 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 601 | % The format of the GetWandViewPixels method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 602 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 603 | % PixelWand *GetWandViewPixels(const WandView *wand_view) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 604 | % |
| 605 | % A description of each parameter follows: |
| 606 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 607 | % o wand_view: the wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 608 | % |
| 609 | */ |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 610 | WandExport PixelWand **GetWandViewPixels(const WandView *wand_view) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 611 | { |
cristy | 83e6d2a | 2010-09-17 17:35:13 +0000 | [diff] [blame] | 612 | const int |
| 613 | id = GetOpenMPThreadId(); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 614 | |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 615 | assert(wand_view != (WandView *) NULL); |
| 616 | assert(wand_view->signature == WandSignature); |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 617 | return(wand_view->pixel_wands[id]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | /* |
| 621 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 622 | % % |
| 623 | % % |
| 624 | % % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 625 | % G e t W a n d V i e w W a n d % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 626 | % % |
| 627 | % % |
| 628 | % % |
| 629 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 630 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 631 | % GetWandViewWand() returns the magick wand associated with the wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 632 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 633 | % The format of the GetWandViewWand method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 634 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 635 | % MagickWand *GetWandViewWand(const WandView *wand_view) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 636 | % |
| 637 | % A description of each parameter follows: |
| 638 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 639 | % o wand_view: the wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 640 | % |
| 641 | */ |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 642 | WandExport MagickWand *GetWandViewWand(const WandView *wand_view) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 643 | { |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 644 | assert(wand_view != (WandView *) NULL); |
| 645 | assert(wand_view->signature == WandSignature); |
| 646 | return(wand_view->wand); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | /* |
| 650 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 651 | % % |
| 652 | % % |
| 653 | % % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 654 | % I s W a n d V i e w % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 655 | % % |
| 656 | % % |
| 657 | % % |
| 658 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 659 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 660 | % IsWandView() returns MagickTrue if the the parameter is verified as a wand |
| 661 | % view object. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 662 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 663 | % The format of the IsWandView method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 664 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 665 | % MagickBooleanType IsWandView(const WandView *wand_view) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 666 | % |
| 667 | % A description of each parameter follows: |
| 668 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 669 | % o wand_view: the wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 670 | % |
| 671 | */ |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 672 | WandExport MagickBooleanType IsWandView(const WandView *wand_view) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 673 | { |
| 674 | size_t |
| 675 | length; |
| 676 | |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 677 | if (wand_view == (const WandView *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 678 | return(MagickFalse); |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 679 | if (wand_view->signature != WandSignature) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 680 | return(MagickFalse); |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 681 | length=strlen(WandViewId); |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 682 | if (LocaleNCompare(wand_view->name,WandViewId,length) != 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 683 | return(MagickFalse); |
| 684 | return(MagickTrue); |
| 685 | } |
| 686 | |
| 687 | /* |
| 688 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 689 | % % |
| 690 | % % |
| 691 | % % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 692 | % N e w W a n d V i e w % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 693 | % % |
| 694 | % % |
| 695 | % % |
| 696 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 697 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 698 | % NewWandView() returns a wand view required for all other methods in the |
| 699 | % Wand View API. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 700 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 701 | % The format of the NewWandView method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 702 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 703 | % WandView *NewWandView(MagickWand *wand) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 704 | % |
| 705 | % A description of each parameter follows: |
| 706 | % |
| 707 | % o wand: the wand. |
| 708 | % |
| 709 | */ |
| 710 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 711 | static PixelWand ***AcquirePixelsThreadSet(const size_t number_wands, |
| 712 | const size_t number_threads) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 713 | { |
| 714 | PixelWand |
| 715 | ***pixel_wands; |
| 716 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 717 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 718 | i; |
| 719 | |
cristy | b41ee10 | 2010-10-04 16:46:15 +0000 | [diff] [blame] | 720 | pixel_wands=(PixelWand ***) AcquireQuantumMemory(number_threads, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 721 | sizeof(*pixel_wands)); |
| 722 | if (pixel_wands == (PixelWand ***) NULL) |
| 723 | return((PixelWand ***) NULL); |
| 724 | (void) ResetMagickMemory(pixel_wands,0,number_threads*sizeof(*pixel_wands)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 725 | for (i=0; i < (ssize_t) number_threads; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 726 | { |
| 727 | pixel_wands[i]=NewPixelWands(number_wands); |
| 728 | if (pixel_wands[i] == (PixelWand **) NULL) |
| 729 | return(DestroyPixelsThreadSet(pixel_wands,number_wands,number_threads)); |
| 730 | } |
| 731 | return(pixel_wands); |
| 732 | } |
| 733 | |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 734 | WandExport WandView *NewWandView(MagickWand *wand) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 735 | { |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 736 | WandView |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 737 | *wand_view; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 738 | |
| 739 | assert(wand != (MagickWand *) NULL); |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 740 | assert(wand->signature == WandSignature); |
cristy | 73bd4a5 | 2010-10-05 11:24:23 +0000 | [diff] [blame] | 741 | wand_view=(WandView *) AcquireMagickMemory(sizeof(*wand_view)); |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 742 | if (wand_view == (WandView *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 743 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 744 | GetExceptionMessage(errno)); |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 745 | (void) ResetMagickMemory(wand_view,0,sizeof(*wand_view)); |
| 746 | wand_view->id=AcquireWandId(); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 747 | (void) FormatLocaleString(wand_view->name,MaxTextExtent,"%s-%.20g", |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 748 | WandViewId,(double) wand_view->id); |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 749 | wand_view->description=ConstantString("WandView"); |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 750 | wand_view->wand=wand; |
| 751 | wand_view->view=AcquireCacheView(wand_view->wand->images); |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 752 | wand_view->extent.width=wand->images->columns; |
| 753 | wand_view->extent.height=wand->images->rows; |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 754 | wand_view->number_threads=GetOpenMPMaximumThreads(); |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 755 | wand_view->pixel_wands=AcquirePixelsThreadSet(wand_view->extent.width, |
| 756 | wand_view->number_threads); |
| 757 | wand_view->exception=AcquireExceptionInfo(); |
| 758 | if (wand_view->pixel_wands == (PixelWand ***) NULL) |
| 759 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 760 | GetExceptionMessage(errno)); |
| 761 | wand_view->debug=IsEventLogging(); |
| 762 | wand_view->signature=WandSignature; |
| 763 | return(wand_view); |
| 764 | } |
| 765 | |
| 766 | /* |
| 767 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 768 | % % |
| 769 | % % |
| 770 | % % |
| 771 | % N e w W a n d V i e w E x t e n t % |
| 772 | % % |
| 773 | % % |
| 774 | % % |
| 775 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 776 | % |
| 777 | % NewWandViewExtent() returns a wand view required for all other methods |
| 778 | % in the Wand View API. |
| 779 | % |
| 780 | % The format of the NewWandViewExtent method is: |
| 781 | % |
| 782 | % WandView *NewWandViewExtent(MagickWand *wand,const ssize_t x, |
| 783 | % const ssize_t y,const size_t width,const size_t height) |
| 784 | % |
| 785 | % A description of each parameter follows: |
| 786 | % |
| 787 | % o wand: the magick wand. |
| 788 | % |
| 789 | % o x,y,columns,rows: These values define the perimeter of a extent of |
| 790 | % pixel_wands view. |
| 791 | % |
| 792 | */ |
| 793 | WandExport WandView *NewWandViewExtent(MagickWand *wand,const ssize_t x, |
| 794 | const ssize_t y,const size_t width,const size_t height) |
| 795 | { |
| 796 | WandView |
| 797 | *wand_view; |
| 798 | |
| 799 | assert(wand != (MagickWand *) NULL); |
| 800 | assert(wand->signature == WandSignature); |
cristy | 73bd4a5 | 2010-10-05 11:24:23 +0000 | [diff] [blame] | 801 | wand_view=(WandView *) AcquireMagickMemory(sizeof(*wand_view)); |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 802 | if (wand_view == (WandView *) NULL) |
| 803 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 804 | GetExceptionMessage(errno)); |
| 805 | (void) ResetMagickMemory(wand_view,0,sizeof(*wand_view)); |
| 806 | wand_view->id=AcquireWandId(); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 807 | (void) FormatLocaleString(wand_view->name,MaxTextExtent,"%s-%.20g", |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 808 | WandViewId,(double) wand_view->id); |
| 809 | wand_view->description=ConstantString("WandView"); |
| 810 | wand_view->view=AcquireCacheView(wand_view->wand->images); |
| 811 | wand_view->wand=wand; |
| 812 | wand_view->extent.width=width; |
| 813 | wand_view->extent.height=height; |
| 814 | wand_view->extent.x=x; |
| 815 | wand_view->extent.y=y; |
| 816 | wand_view->number_threads=GetOpenMPMaximumThreads(); |
| 817 | wand_view->exception=AcquireExceptionInfo(); |
| 818 | wand_view->pixel_wands=AcquirePixelsThreadSet(wand_view->extent.width, |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 819 | wand_view->number_threads); |
| 820 | if (wand_view->pixel_wands == (PixelWand ***) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 821 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 822 | GetExceptionMessage(errno)); |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 823 | wand_view->debug=IsEventLogging(); |
| 824 | wand_view->signature=WandSignature; |
| 825 | return(wand_view); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 826 | } |
| 827 | |
| 828 | /* |
| 829 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 830 | % % |
| 831 | % % |
| 832 | % % |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 833 | % S e t W a n d V i e w D e s c r i p t i o n % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 834 | % % |
| 835 | % % |
| 836 | % % |
| 837 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 838 | % |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 839 | % SetWandViewDescription() associates a description with an image view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 840 | % |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 841 | % The format of the SetWandViewDescription method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 842 | % |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 843 | % void SetWandViewDescription(WandView *image_view,const char *description) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 844 | % |
| 845 | % A description of each parameter follows: |
| 846 | % |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 847 | % o wand_view: the wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 848 | % |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 849 | % o description: the wand view description. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 850 | % |
| 851 | */ |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 852 | MagickExport void SetWandViewDescription(WandView *wand_view, |
| 853 | const char *description) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 854 | { |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 855 | assert(wand_view != (WandView *) NULL); |
| 856 | assert(wand_view->signature == WandSignature); |
| 857 | wand_view->description=ConstantString(description); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 858 | } |
| 859 | |
| 860 | /* |
| 861 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 862 | % % |
| 863 | % % |
| 864 | % % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 865 | % S e t W a n d V i e w I t e r a t o r % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 866 | % % |
| 867 | % % |
| 868 | % % |
| 869 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 870 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 871 | % SetWandViewIterator() iterates over the wand view in parallel and calls |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 872 | % your set method for each scanline of the view. The pixel extent is |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 873 | % confined to the image canvas-- that is no negative offsets or widths or |
| 874 | % heights that exceed the image dimension. The pixels are initiallly |
| 875 | % undefined and any settings you make in the callback method are automagically |
| 876 | % synced back to your image. |
| 877 | % |
cristy | d6dfc0d | 2010-06-27 19:30:49 +0000 | [diff] [blame] | 878 | % The callback signature is: |
| 879 | % |
| 880 | % MagickBooleanType SetImageViewMethod(ImageView *destination, |
| 881 | % const ssize_t y,const int thread_id,void *context) |
| 882 | % |
cristy | 5873947 | 2010-06-26 20:27:18 +0000 | [diff] [blame] | 883 | % Use this pragma if the view is not single threaded: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 884 | % |
| 885 | % #pragma omp critical |
| 886 | % |
| 887 | % to define a section of code in your callback set method that must be |
| 888 | % executed by a single thread at a time. |
| 889 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 890 | % The format of the SetWandViewIterator method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 891 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 892 | % MagickBooleanType SetWandViewIterator(WandView *destination, |
| 893 | % SetWandViewMethod set,void *context) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 894 | % |
| 895 | % A description of each parameter follows: |
| 896 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 897 | % o destination: the wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 898 | % |
| 899 | % o set: the set callback method. |
| 900 | % |
| 901 | % o context: the user defined context. |
| 902 | % |
| 903 | */ |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 904 | WandExport MagickBooleanType SetWandViewIterator(WandView *destination, |
| 905 | SetWandViewMethod set,void *context) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 906 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 907 | ExceptionInfo |
| 908 | *exception; |
| 909 | |
| 910 | Image |
| 911 | *destination_image; |
| 912 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 913 | MagickBooleanType |
| 914 | status; |
| 915 | |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 916 | MagickOffsetType |
| 917 | progress; |
| 918 | |
| 919 | ssize_t |
| 920 | y; |
| 921 | |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 922 | assert(destination != (WandView *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 923 | assert(destination->signature == WandSignature); |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 924 | if (set == (SetWandViewMethod) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 925 | return(MagickFalse); |
| 926 | destination_image=destination->wand->images; |
cristy | 874276b | 2011-08-05 19:29:22 +0000 | [diff] [blame] | 927 | exception=destination->exception; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 928 | if (SetImageStorageClass(destination_image,DirectClass,exception) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 929 | return(MagickFalse); |
| 930 | status=MagickTrue; |
| 931 | progress=0; |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 932 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 09d8117 | 2010-10-21 16:15:05 +0000 | [diff] [blame] | 933 | #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(destination->number_threads) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 934 | #endif |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 935 | for (y=destination->extent.y; y < (ssize_t) destination->extent.height; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 936 | { |
cristy | 83e6d2a | 2010-09-17 17:35:13 +0000 | [diff] [blame] | 937 | const int |
| 938 | id = GetOpenMPThreadId(); |
cristy | ad74005 | 2010-07-03 01:38:03 +0000 | [diff] [blame] | 939 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 940 | MagickBooleanType |
| 941 | sync; |
| 942 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 943 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 944 | x; |
| 945 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 946 | register Quantum |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 947 | *restrict pixels; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 948 | |
| 949 | if (status == MagickFalse) |
| 950 | continue; |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 951 | pixels=GetCacheViewAuthenticPixels(destination->view,destination->extent.x, |
| 952 | y,destination->extent.width,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 953 | if (pixels == (Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 954 | { |
| 955 | InheritException(destination->exception,GetCacheViewException( |
| 956 | destination->view)); |
| 957 | status=MagickFalse; |
| 958 | continue; |
| 959 | } |
cristy | d6dfc0d | 2010-06-27 19:30:49 +0000 | [diff] [blame] | 960 | if (set(destination,y,id,context) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 961 | status=MagickFalse; |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 962 | for (x=0; x < (ssize_t) destination->extent.width; x++) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 963 | { |
| 964 | PixelGetQuantumPixel(destination->image,destination->pixel_wands[id][x], |
| 965 | pixels); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 966 | pixels+=GetPixelChannels(destination->image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 967 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 968 | sync=SyncCacheViewAuthenticPixels(destination->view,exception); |
| 969 | if (sync == MagickFalse) |
| 970 | { |
| 971 | InheritException(destination->exception,GetCacheViewException( |
| 972 | destination->view)); |
| 973 | status=MagickFalse; |
| 974 | } |
| 975 | if (destination_image->progress_monitor != (MagickProgressMonitor) NULL) |
| 976 | { |
| 977 | MagickBooleanType |
| 978 | proceed; |
| 979 | |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 980 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 981 | #pragma omp critical (MagickWand_SetWandViewIterator) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 982 | #endif |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 983 | proceed=SetImageProgress(destination_image,destination->description, |
| 984 | progress++,destination->extent.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 985 | if (proceed == MagickFalse) |
| 986 | status=MagickFalse; |
| 987 | } |
| 988 | } |
| 989 | return(status); |
| 990 | } |
| 991 | |
| 992 | /* |
| 993 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 994 | % % |
| 995 | % % |
| 996 | % % |
cristy | 09d8117 | 2010-10-21 16:15:05 +0000 | [diff] [blame] | 997 | % S e t W a n d V i e w T h r e a d s % |
| 998 | % % |
| 999 | % % |
| 1000 | % % |
| 1001 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1002 | % |
| 1003 | % SetWandViewThreads() sets the number of threads in a thread team. |
| 1004 | % |
| 1005 | % The format of the SetWandViewDescription method is: |
| 1006 | % |
| 1007 | % void SetWandViewThreads(WandView *image_view, |
| 1008 | % const size_t number_threads) |
| 1009 | % |
| 1010 | % A description of each parameter follows: |
| 1011 | % |
| 1012 | % o image_view: the image view. |
| 1013 | % |
| 1014 | % o number_threads: the number of threads in a thread team. |
| 1015 | % |
| 1016 | */ |
| 1017 | MagickExport void SetWandViewThreads(WandView *image_view, |
| 1018 | const size_t number_threads) |
| 1019 | { |
| 1020 | assert(image_view != (WandView *) NULL); |
| 1021 | assert(image_view->signature == MagickSignature); |
| 1022 | image_view->number_threads=number_threads; |
| 1023 | if (number_threads > GetOpenMPMaximumThreads()) |
| 1024 | image_view->number_threads=GetOpenMPMaximumThreads(); |
| 1025 | } |
| 1026 | |
| 1027 | /* |
| 1028 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1029 | % % |
| 1030 | % % |
| 1031 | % % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 1032 | % T r a n s f e r W a n d V i e w I t e r a t o r % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1033 | % % |
| 1034 | % % |
| 1035 | % % |
| 1036 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1037 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 1038 | % TransferWandViewIterator() iterates over two wand views in parallel and |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1039 | % calls your transfer method for each scanline of the view. The source pixel |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1040 | % extent is not confined to the image canvas-- that is you can include |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1041 | % negative offsets or widths or heights that exceed the image dimension. |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 1042 | % However, the destination wand view is confined to the image canvas-- that |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1043 | % is no negative offsets or widths or heights that exceed the image dimension |
| 1044 | % are permitted. |
| 1045 | % |
cristy | d6dfc0d | 2010-06-27 19:30:49 +0000 | [diff] [blame] | 1046 | % The callback signature is: |
| 1047 | % |
| 1048 | % MagickBooleanType TransferImageViewMethod(const WandView *source, |
| 1049 | % WandView *destination,const ssize_t y,const int thread_id, |
| 1050 | % void *context) |
| 1051 | % |
cristy | 5873947 | 2010-06-26 20:27:18 +0000 | [diff] [blame] | 1052 | % Use this pragma if the view is not single threaded: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1053 | % |
| 1054 | % #pragma omp critical |
| 1055 | % |
| 1056 | % to define a section of code in your callback transfer method that must be |
| 1057 | % executed by a single thread at a time. |
| 1058 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 1059 | % The format of the TransferWandViewIterator method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1060 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 1061 | % MagickBooleanType TransferWandViewIterator(WandView *source, |
| 1062 | % WandView *destination,TransferWandViewMethod transfer,void *context) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1063 | % |
| 1064 | % A description of each parameter follows: |
| 1065 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 1066 | % o source: the source wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1067 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 1068 | % o destination: the destination wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1069 | % |
| 1070 | % o transfer: the transfer callback method. |
| 1071 | % |
| 1072 | % o context: the user defined context. |
| 1073 | % |
| 1074 | */ |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 1075 | WandExport MagickBooleanType TransferWandViewIterator(WandView *source, |
| 1076 | WandView *destination,TransferWandViewMethod transfer,void *context) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1077 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1078 | ExceptionInfo |
| 1079 | *exception; |
| 1080 | |
| 1081 | Image |
| 1082 | *destination_image, |
| 1083 | *source_image; |
| 1084 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1085 | MagickBooleanType |
| 1086 | status; |
| 1087 | |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 1088 | MagickOffsetType |
| 1089 | progress; |
| 1090 | |
| 1091 | ssize_t |
| 1092 | y; |
| 1093 | |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 1094 | assert(source != (WandView *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1095 | assert(source->signature == WandSignature); |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 1096 | if (transfer == (TransferWandViewMethod) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1097 | return(MagickFalse); |
| 1098 | source_image=source->wand->images; |
| 1099 | destination_image=destination->wand->images; |
cristy | 874276b | 2011-08-05 19:29:22 +0000 | [diff] [blame] | 1100 | exception=destination->exception; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 1101 | if (SetImageStorageClass(destination_image,DirectClass,exception) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1102 | return(MagickFalse); |
| 1103 | status=MagickTrue; |
| 1104 | progress=0; |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 1105 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 09d8117 | 2010-10-21 16:15:05 +0000 | [diff] [blame] | 1106 | #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1107 | #endif |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1108 | for (y=source->extent.y; y < (ssize_t) source->extent.height; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1109 | { |
cristy | 83e6d2a | 2010-09-17 17:35:13 +0000 | [diff] [blame] | 1110 | const int |
| 1111 | id = GetOpenMPThreadId(); |
cristy | ad74005 | 2010-07-03 01:38:03 +0000 | [diff] [blame] | 1112 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1113 | MagickBooleanType |
| 1114 | sync; |
| 1115 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1116 | register const Quantum |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 1117 | *restrict pixels; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1118 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1119 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1120 | x; |
| 1121 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1122 | register Quantum |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 1123 | *restrict destination_pixels; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1124 | |
| 1125 | if (status == MagickFalse) |
| 1126 | continue; |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1127 | pixels=GetCacheViewVirtualPixels(source->view,source->extent.x,y, |
| 1128 | source->extent.width,1,source->exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1129 | if (pixels == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1130 | { |
| 1131 | status=MagickFalse; |
| 1132 | continue; |
| 1133 | } |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1134 | for (x=0; x < (ssize_t) source->extent.width; x++) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1135 | { |
| 1136 | PixelSetQuantumPixel(source->image,pixels,source->pixel_wands[id][x]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1137 | pixels+=GetPixelChannels(source->image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1138 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1139 | destination_pixels=GetCacheViewAuthenticPixels(destination->view, |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1140 | destination->extent.x,y,destination->extent.width,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1141 | if (destination_pixels == (Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1142 | { |
| 1143 | status=MagickFalse; |
| 1144 | continue; |
| 1145 | } |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1146 | for (x=0; x < (ssize_t) destination->extent.width; x++) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1147 | { |
| 1148 | PixelSetQuantumPixel(destination->image,destination_pixels, |
| 1149 | destination->pixel_wands[id][x]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1150 | destination_pixels+=GetPixelChannels(destination->image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1151 | } |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1152 | if (transfer(source,destination,y,id,context) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1153 | status=MagickFalse; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1154 | destination_pixels=GetCacheViewAuthenticPixels(destination->view, |
| 1155 | destination->extent.x,y,destination->extent.width,1,exception); |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1156 | for (x=0; x < (ssize_t) destination->extent.width; x++) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1157 | { |
| 1158 | PixelGetQuantumPixel(destination->image,destination->pixel_wands[id][x], |
| 1159 | destination_pixels); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1160 | destination_pixels+=GetPixelChannels(destination->image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1161 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1162 | sync=SyncCacheViewAuthenticPixels(destination->view,exception); |
| 1163 | if (sync == MagickFalse) |
| 1164 | { |
| 1165 | InheritException(destination->exception,GetCacheViewException( |
| 1166 | source->view)); |
| 1167 | status=MagickFalse; |
| 1168 | } |
| 1169 | if (source_image->progress_monitor != (MagickProgressMonitor) NULL) |
| 1170 | { |
| 1171 | MagickBooleanType |
| 1172 | proceed; |
| 1173 | |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 1174 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 1175 | #pragma omp critical (MagickWand_TransferWandViewIterator) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1176 | #endif |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1177 | proceed=SetImageProgress(source_image,source->description,progress++, |
| 1178 | source->extent.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1179 | if (proceed == MagickFalse) |
| 1180 | status=MagickFalse; |
| 1181 | } |
| 1182 | } |
| 1183 | return(status); |
| 1184 | } |
| 1185 | |
| 1186 | /* |
| 1187 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1188 | % % |
| 1189 | % % |
| 1190 | % % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 1191 | % U p d a t e W a n d V i e w I t e r a t o r % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1192 | % % |
| 1193 | % % |
| 1194 | % % |
| 1195 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1196 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 1197 | % UpdateWandViewIterator() iterates over the wand view in parallel and calls |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1198 | % your update method for each scanline of the view. The pixel extent is |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1199 | % confined to the image canvas-- that is no negative offsets or widths or |
| 1200 | % heights that exceed the image dimension are permitted. Updates to pixels |
| 1201 | % in your callback are automagically synced back to the image. |
| 1202 | % |
cristy | d6dfc0d | 2010-06-27 19:30:49 +0000 | [diff] [blame] | 1203 | % The callback signature is: |
| 1204 | % |
| 1205 | % MagickBooleanType UpdateImageViewMethod(WandView *source,const ssize_t y, |
| 1206 | % const int thread_id,void *context) |
| 1207 | % |
cristy | 5873947 | 2010-06-26 20:27:18 +0000 | [diff] [blame] | 1208 | % Use this pragma if the view is not single threaded: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1209 | % |
| 1210 | % #pragma omp critical |
| 1211 | % |
| 1212 | % to define a section of code in your callback update method that must be |
| 1213 | % executed by a single thread at a time. |
| 1214 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 1215 | % The format of the UpdateWandViewIterator method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1216 | % |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 1217 | % MagickBooleanType UpdateWandViewIterator(WandView *source, |
| 1218 | % UpdateWandViewMethod update,void *context) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1219 | % |
| 1220 | % A description of each parameter follows: |
| 1221 | % |
cristy | 73b7d4c | 2010-06-27 00:31:00 +0000 | [diff] [blame] | 1222 | % o source: the source wand view. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1223 | % |
| 1224 | % o update: the update callback method. |
| 1225 | % |
| 1226 | % o context: the user defined context. |
| 1227 | % |
| 1228 | */ |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 1229 | WandExport MagickBooleanType UpdateWandViewIterator(WandView *source, |
| 1230 | UpdateWandViewMethod update,void *context) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1231 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1232 | ExceptionInfo |
| 1233 | *exception; |
| 1234 | |
| 1235 | Image |
| 1236 | *source_image; |
| 1237 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1238 | MagickBooleanType |
| 1239 | status; |
| 1240 | |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 1241 | MagickOffsetType |
| 1242 | progress; |
| 1243 | |
| 1244 | ssize_t |
| 1245 | y; |
| 1246 | |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 1247 | assert(source != (WandView *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1248 | assert(source->signature == WandSignature); |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 1249 | if (update == (UpdateWandViewMethod) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1250 | return(MagickFalse); |
| 1251 | source_image=source->wand->images; |
cristy | 874276b | 2011-08-05 19:29:22 +0000 | [diff] [blame] | 1252 | exception=source->exception; |
cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 1253 | if (SetImageStorageClass(source_image,DirectClass,exception) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1254 | return(MagickFalse); |
| 1255 | status=MagickTrue; |
| 1256 | progress=0; |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 1257 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 09d8117 | 2010-10-21 16:15:05 +0000 | [diff] [blame] | 1258 | #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1259 | #endif |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1260 | for (y=source->extent.y; y < (ssize_t) source->extent.height; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1261 | { |
cristy | 83e6d2a | 2010-09-17 17:35:13 +0000 | [diff] [blame] | 1262 | const int |
| 1263 | id = GetOpenMPThreadId(); |
cristy | ad74005 | 2010-07-03 01:38:03 +0000 | [diff] [blame] | 1264 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1265 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1266 | x; |
| 1267 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1268 | register Quantum |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 1269 | *restrict pixels; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1270 | |
| 1271 | if (status == MagickFalse) |
| 1272 | continue; |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1273 | pixels=GetCacheViewAuthenticPixels(source->view,source->extent.x,y, |
| 1274 | source->extent.width,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1275 | if (pixels == (Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1276 | { |
| 1277 | InheritException(source->exception,GetCacheViewException( |
| 1278 | source->view)); |
| 1279 | status=MagickFalse; |
| 1280 | continue; |
| 1281 | } |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1282 | for (x=0; x < (ssize_t) source->extent.width; x++) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1283 | { |
| 1284 | PixelSetQuantumPixel(source->image,pixels,source->pixel_wands[id][x]); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1285 | pixels+=GetPixelChannels(source->image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1286 | } |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1287 | if (update(source,y,id,context) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1288 | status=MagickFalse; |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1289 | for (x=0; x < (ssize_t) source->extent.width; x++) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1290 | { |
| 1291 | PixelGetQuantumPixel(source->image,source->pixel_wands[id][x],pixels); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1292 | pixels+=GetPixelChannels(source->image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1293 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1294 | if (SyncCacheViewAuthenticPixels(source->view,exception) == MagickFalse) |
| 1295 | { |
| 1296 | InheritException(source->exception,GetCacheViewException(source->view)); |
| 1297 | status=MagickFalse; |
| 1298 | } |
| 1299 | if (source_image->progress_monitor != (MagickProgressMonitor) NULL) |
| 1300 | { |
| 1301 | MagickBooleanType |
| 1302 | proceed; |
| 1303 | |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 1304 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 7eb1b7a | 2010-06-26 15:47:49 +0000 | [diff] [blame] | 1305 | #pragma omp critical (MagickWand_UpdateWandViewIterator) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1306 | #endif |
cristy | c3ebda2 | 2010-06-27 17:11:57 +0000 | [diff] [blame] | 1307 | proceed=SetImageProgress(source_image,source->description,progress++, |
| 1308 | source->extent.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1309 | if (proceed == MagickFalse) |
| 1310 | status=MagickFalse; |
| 1311 | } |
| 1312 | } |
| 1313 | return(status); |
| 1314 | } |