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