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