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