root / ImageMagick / trunk / wand / pixel-iterator.c
| Revision 12610, 37.6 kB (checked in by cristy, 5 days ago) |
|---|
| Line | Â |
|---|---|
| 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 4 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 5 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 6 | %Â Â Â Â Â Â Â Â Â Â Â PPPPÂ Â IIIIIÂ XÂ Â XÂ EEEEEÂ LÂ Â Â Â Â Â Â Â Â Â Â Â Â % |
| 7 | %Â Â Â Â Â Â Â Â Â Â Â PÂ Â PÂ Â IÂ Â Â X XÂ Â EÂ Â Â LÂ Â Â Â Â Â Â Â Â Â Â Â Â % |
| 8 | %Â Â Â Â Â Â Â Â Â Â Â PPPPÂ Â Â IÂ Â Â XÂ Â EEEÂ Â LÂ Â Â Â Â Â Â Â Â Â Â Â Â % |
| 9 | %Â Â Â Â Â Â Â Â Â Â Â PÂ Â Â Â IÂ Â Â X XÂ Â EÂ Â Â LÂ Â Â Â Â Â Â Â Â Â Â Â Â % |
| 10 | %Â Â Â Â Â Â Â Â Â Â Â PÂ Â Â IIIIIÂ XÂ Â XÂ EEEEEÂ LLLLLÂ Â Â Â Â Â Â Â Â Â Â % |
| 11 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 12 | %Â Â Â Â Â Â IIIIIÂ TTTTT EEEEEÂ RRRRÂ Â AAAÂ Â TTTTTÂ Â OOOÂ Â RRRRÂ Â Â Â Â Â Â % |
| 13 | %Â Â Â Â Â Â Â IÂ Â Â TÂ Â EÂ Â Â RÂ Â RÂ AÂ Â AÂ Â TÂ Â OÂ Â OÂ RÂ Â RÂ Â Â Â Â Â % |
| 14 | %Â Â Â Â Â Â Â IÂ Â Â TÂ Â EEEÂ Â RRRRÂ Â AAAAAÂ Â TÂ Â OÂ Â OÂ RRRRÂ Â Â Â Â Â Â % |
| 15 | %Â Â Â Â Â Â Â IÂ Â Â TÂ Â EÂ Â Â R RÂ Â AÂ Â AÂ Â TÂ Â OÂ Â OÂ R RÂ Â Â Â Â Â Â % |
| 16 | %Â Â Â Â Â Â IIIIIÂ Â TÂ Â EEEEEÂ RÂ RÂ Â AÂ Â AÂ Â TÂ Â Â OOOÂ Â RÂ RÂ Â Â Â Â Â Â % |
| 17 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 18 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 19 | %          ImageMagick Image Pixel Iterator Methods         % |
| 20 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 21 | %               Software Design                % |
| 22 | %                John Cristy                 % |
| 23 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â March 2003Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 24 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 25 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 26 | % Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization   % |
| 27 | % dedicated to making software imaging solutions freely available.      % |
| 28 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 29 | % You may not use this file except in compliance with the License. You may % |
| 30 | % obtain a copy of the License at                      % |
| 31 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 32 | %  http://www.imagemagick.org/script/license.php              % |
| 33 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 34 | % Unless required by applicable law or agreed to in writing, software    % |
| 35 | % distributed under the License is distributed on an "AS IS" BASIS,     % |
| 36 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  % |
| 37 | % See the License for the specific language governing permissions and    % |
| 38 | % limitations under the License.                       % |
| 39 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 40 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 41 | % |
| 42 | % |
| 43 | % |
| 44 | */ |
| 45 | |
| 46 | /* |
| 47 | Â Include declarations. |
| 48 | */ |
| 49 | #include "wand/studio.h" |
| 50 | #include "wand/MagickWand.h" |
| 51 | #include "wand/magick-wand-private.h" |
| 52 | #include "wand/pixel-iterator.h" |
| 53 | #include "wand/pixel-wand.h" |
| 54 | #include "wand/wand.h" |
| 55 | |
| 56 | /* |
| 57 | Â Define declarations. |
| 58 | */ |
| 59 | #define PixelIteratorId "PixelIterator" |
| 60 | |
| 61 | /* |
| 62 | Â Typedef declarations. |
| 63 | */ |
| 64 | struct _PixelIterator |
| 65 | { |
| 66 |  unsigned long |
| 67 | Â Â id; |
| 68 | |
| 69 | Â char |
| 70 | Â Â name[MaxTextExtent]; |
| 71 | |
| 72 | Â ExceptionInfo |
| 73 | Â Â *exception; |
| 74 | |
| 75 | Â ViewInfo |
| 76 | Â Â *view; |
| 77 | |
| 78 | Â RectangleInfo |
| 79 | Â Â region; |
| 80 | |
| 81 | Â MagickBooleanType |
| 82 | Â Â active; |
| 83 | |
| 84 | Â long |
| 85 | Â Â y; |
| 86 | |
| 87 | Â PixelWand |
| 88 | Â Â **pixel_wands; |
| 89 | |
| 90 | Â MagickBooleanType |
| 91 | Â Â debug; |
| 92 | |
| 93 |  unsigned long |
| 94 | Â Â signature; |
| 95 | }; |
| 96 | |
| 97 | /* |
| 98 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 99 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 100 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 101 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 102 | %  C l e a r P i x e l I t e r a t o r                    % |
| 103 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 104 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 105 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 106 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 107 | % |
| 108 | %Â ClearPixelIterator() clear resources associated with a PixelIterator. |
| 109 | % |
| 110 | %Â The format of the ClearPixelIterator method is: |
| 111 | % |
| 112 | %Â Â Â PixelIterator *ClearPixelIterator(PixelIterator *iterator) |
| 113 | % |
| 114 | %Â A description of each parameter follows: |
| 115 | % |
| 116 | %Â Â o iterator: the pixel iterator. |
| 117 | % |
| 118 | */ |
| 119 | WandExport void ClearPixelIterator(PixelIterator *iterator) |
| 120 | { |
| 121 |  assert(iterator != (const PixelIterator *) NULL); |
| 122 | Â assert(iterator->signature == WandSignature); |
| 123 |  if (iterator->debug != MagickFalse) |
| 124 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 125 | Â iterator->pixel_wands=DestroyPixelWands(iterator->pixel_wands, |
| 126 | Â Â iterator->region.width); |
| 127 | Â ClearMagickException(iterator->exception); |
| 128 | Â iterator->pixel_wands=NewPixelWands(iterator->region.width); |
| 129 | Â iterator->active=MagickFalse; |
| 130 | Â iterator->y=0; |
| 131 | Â iterator->debug=IsEventLogging(); |
| 132 | } |
| 133 | |
| 134 | /* |
| 135 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 136 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 137 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 138 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 139 | %  C l o n e P i x e l I t e r a t o r                    % |
| 140 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 141 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 142 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 143 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 144 | % |
| 145 | %Â ClonePixelIterator() makes an exact copy of the specified iterator. |
| 146 | % |
| 147 | %Â The format of the ClonePixelIterator method is: |
| 148 | % |
| 149 | %Â Â Â PixelIterator *ClonePixelIterator(const PixelIterator *iterator) |
| 150 | % |
| 151 | %Â A description of each parameter follows: |
| 152 | % |
| 153 | %Â Â o iterator: the magick iterator. |
| 154 | % |
| 155 | */ |
| 156 | WandExport PixelIterator *ClonePixelIterator(const PixelIterator *iterator) |
| 157 | { |
| 158 | Â PixelIterator |
| 159 | Â Â *clone_iterator; |
| 160 | |
| 161 | Â assert(iterator != (PixelIterator *) NULL); |
| 162 | Â assert(iterator->signature == WandSignature); |
| 163 |  if (iterator->debug != MagickFalse) |
| 164 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 165 | Â clone_iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*clone_iterator)); |
| 166 |  if (clone_iterator == (PixelIterator *) NULL) |
| 167 | Â Â ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 168 | Â Â Â iterator->name); |
| 169 | Â (void) ResetMagickMemory(clone_iterator,0,sizeof(*clone_iterator)); |
| 170 | Â clone_iterator->id=AcquireWandId(); |
| 171 | Â (void) FormatMagickString(clone_iterator->name,MaxTextExtent,"%s-%lu", |
| 172 | Â Â PixelIteratorId,clone_iterator->id); |
| 173 | Â clone_iterator->exception=AcquireExceptionInfo(); |
| 174 | Â InheritException(clone_iterator->exception,iterator->exception); |
| 175 | Â clone_iterator->view=CloneCacheView(iterator->view); |
| 176 | Â clone_iterator->region=iterator->region; |
| 177 | Â clone_iterator->active=iterator->active; |
| 178 | Â clone_iterator->y=iterator->y; |
| 179 |  clone_iterator->pixel_wands=ClonePixelWands((const PixelWand **) |
| 180 | Â Â iterator->pixel_wands,iterator->region.width); |
| 181 | Â clone_iterator->debug=iterator->debug; |
| 182 |  if (clone_iterator->debug != MagickFalse) |
| 183 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s", |
| 184 | Â Â Â clone_iterator->name); |
| 185 | Â clone_iterator->signature=WandSignature; |
| 186 | Â return(clone_iterator); |
| 187 | } |
| 188 | |
| 189 | /* |
| 190 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 191 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 192 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 193 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 194 | %  D e s t r o y P i x e l I t e r a t o r                  % |
| 195 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 196 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 197 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 198 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 199 | % |
| 200 | %Â DestroyPixelIterator() deallocates resources associated with a PixelIterator. |
| 201 | % |
| 202 | %Â The format of the DestroyPixelIterator method is: |
| 203 | % |
| 204 | %Â Â Â PixelIterator *DestroyPixelIterator(PixelIterator *iterator) |
| 205 | % |
| 206 | %Â A description of each parameter follows: |
| 207 | % |
| 208 | %Â Â o iterator: the pixel iterator. |
| 209 | % |
| 210 | */ |
| 211 | WandExport PixelIterator *DestroyPixelIterator(PixelIterator *iterator) |
| 212 | { |
| 213 |  assert(iterator != (const PixelIterator *) NULL); |
| 214 | Â assert(iterator->signature == WandSignature); |
| 215 |  if (iterator->debug != MagickFalse) |
| 216 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 217 | Â iterator->view=DestroyCacheView(iterator->view); |
| 218 | Â iterator->pixel_wands=DestroyPixelWands(iterator->pixel_wands, |
| 219 | Â Â iterator->region.width); |
| 220 | Â iterator->exception=DestroyExceptionInfo(iterator->exception); |
| 221 | Â iterator->signature=(~WandSignature); |
| 222 | Â RelinquishWandId(iterator->id); |
| 223 | Â iterator=(PixelIterator *) RelinquishMagickMemory(iterator); |
| 224 | Â return(iterator); |
| 225 | } |
| 226 | |
| 227 | /* |
| 228 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 229 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 230 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 231 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 232 | %  I s P i x e l I t e r a t o r                       % |
| 233 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 234 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 235 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 236 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 237 | % |
| 238 | %Â IsPixelIterator() returns MagickTrue if the iterator is verified as a pixel |
| 239 | %Â iterator. |
| 240 | % |
| 241 | %Â The format of the IsPixelIterator method is: |
| 242 | % |
| 243 | %Â Â Â MagickBooleanType IsPixelIterator(const PixelIterator *iterator) |
| 244 | % |
| 245 | %Â A description of each parameter follows: |
| 246 | % |
| 247 | %Â Â o iterator: the magick iterator. |
| 248 | % |
| 249 | */ |
| 250 | WandExport MagickBooleanType IsPixelIterator(const PixelIterator *iterator) |
| 251 | { |
| 252 | Â size_t |
| 253 | Â Â length; |
| 254 | |
| 255 |  if (iterator == (const PixelIterator *) NULL) |
| 256 | Â Â return(MagickFalse); |
| 257 |  if (iterator->signature != WandSignature) |
| 258 | Â Â return(MagickFalse); |
| 259 | Â length=strlen(PixelIteratorId); |
| 260 |  if (LocaleNCompare(iterator->name,PixelIteratorId,length) != 0) |
| 261 | Â Â return(MagickFalse); |
| 262 | Â return(MagickTrue); |
| 263 | } |
| 264 | |
| 265 | /* |
| 266 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 267 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 268 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 269 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 270 | %  N e w P i x e l I t e r a t o r                      % |
| 271 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 272 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 273 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 274 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 275 | % |
| 276 | %Â NewPixelIterator() returns a new pixel iterator. |
| 277 | % |
| 278 | %Â The format of the NewPixelIterator method is: |
| 279 | % |
| 280 | %Â Â Â PixelIterator NewPixelIterator(MagickWand *wand) |
| 281 | % |
| 282 | %Â A description of each parameter follows: |
| 283 | % |
| 284 | %Â Â o wand: the magick wand. |
| 285 | % |
| 286 | */ |
| 287 | WandExport PixelIterator *NewPixelIterator(MagickWand *wand) |
| 288 | { |
| 289 |  const char |
| 290 | Â Â *quantum; |
| 291 | |
| 292 | Â Image |
| 293 | Â Â *image; |
| 294 | |
| 295 | Â PixelIterator |
| 296 | Â Â *iterator; |
| 297 | |
| 298 |  unsigned long |
| 299 | Â Â depth; |
| 300 | |
| 301 | Â ViewInfo |
| 302 | Â Â *view; |
| 303 | |
| 304 | Â depth=MAGICKCORE_QUANTUM_DEPTH; |
| 305 | Â quantum=GetMagickQuantumDepth(&depth); |
| 306 |  if (depth != MAGICKCORE_QUANTUM_DEPTH) |
| 307 | Â Â ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); |
| 308 | Â assert(wand != (MagickWand *) NULL); |
| 309 | Â image=GetImageFromMagickWand(wand); |
| 310 |  if (image == (Image *) NULL) |
| 311 | Â Â return((PixelIterator *) NULL); |
| 312 | Â view=AcquireCacheView(image); |
| 313 |  if (view == (ViewInfo *) NULL) |
| 314 | Â Â return((PixelIterator *) NULL); |
| 315 | Â iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator)); |
| 316 |  if (iterator == (PixelIterator *) NULL) |
| 317 | Â Â ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 318 | Â Â Â strerror(errno)); |
| 319 | Â (void) ResetMagickMemory(iterator,0,sizeof(*iterator)); |
| 320 | Â iterator->id=AcquireWandId(); |
| 321 | Â (void) FormatMagickString(iterator->name,MaxTextExtent,"%s-%lu", |
| 322 | Â Â PixelIteratorId,iterator->id); |
| 323 | Â iterator->exception=AcquireExceptionInfo(); |
| 324 | Â iterator->view=view; |
| 325 | Â SetGeometry(image,&iterator->region); |
| 326 | Â iterator->region.width=image->columns; |
| 327 | Â iterator->region.height=image->rows; |
| 328 | Â iterator->region.x=0; |
| 329 | Â iterator->region.y=0; |
| 330 | Â iterator->pixel_wands=NewPixelWands(iterator->region.width); |
| 331 | Â iterator->y=0; |
| 332 | Â iterator->debug=IsEventLogging(); |
| 333 |  if (iterator->debug != MagickFalse) |
| 334 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 335 | Â iterator->signature=WandSignature; |
| 336 | Â return(iterator); |
| 337 | } |
| 338 | |
| 339 | /* |
| 340 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 341 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 342 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 343 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 344 | %  P i x e l C l e a r I t e r a t o r E x c e p t i o n           % |
| 345 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 346 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 347 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 348 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 349 | % |
| 350 | %Â PixelClearIteratorException() clear any exceptions associated with the |
| 351 | %Â iterator. |
| 352 | % |
| 353 | %Â The format of the PixelClearIteratorException method is: |
| 354 | % |
| 355 | %Â Â Â MagickBooleanType PixelClearIteratorException(PixelIterator *wand) |
| 356 | % |
| 357 | %Â A description of each parameter follows: |
| 358 | % |
| 359 | %Â Â o wand: the pixel wand. |
| 360 | % |
| 361 | */ |
| 362 | WandExport MagickBooleanType PixelClearIteratorException( |
| 363 | Â PixelIterator *iterator) |
| 364 | { |
| 365 | Â assert(iterator != (PixelIterator *) NULL); |
| 366 | Â assert(iterator->signature == WandSignature); |
| 367 |  if (iterator->debug != MagickFalse) |
| 368 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 369 | Â ClearMagickException(iterator->exception); |
| 370 | Â return(MagickTrue); |
| 371 | } |
| 372 | |
| 373 | /* |
| 374 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 375 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 376 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 377 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 378 | %  N e w P i x e l R e g i o n I t e r a t o r                % |
| 379 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 380 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 381 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 382 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 383 | % |
| 384 | %Â NewPixelRegionIterator() returns a new pixel iterator. |
| 385 | % |
| 386 | %Â The format of the NewPixelRegionIterator method is: |
| 387 | % |
| 388 | %Â Â Â PixelIterator NewPixelRegionIterator(MagickWand *wand,const long x, |
| 389 | %Â Â Â Â const long y,const unsigned long columns,const unsigned long rows, |
| 390 | %Â Â Â Â const MagickBooleanType modify) |
| 391 | % |
| 392 | %Â A description of each parameter follows: |
| 393 | % |
| 394 | %Â Â o wand: the magick wand. |
| 395 | % |
| 396 | %Â Â o x,y,columns,rows:Â These values define the perimeter of a region of |
| 397 | %Â Â Â pixels. |
| 398 | % |
| 399 | */ |
| 400 | WandExport PixelIterator *NewPixelRegionIterator(MagickWand *wand,const long x, |
| 401 |  const long y,const unsigned long columns,const unsigned long rows) |
| 402 | { |
| 403 |  const char |
| 404 | Â Â *quantum; |
| 405 | |
| 406 | Â Image |
| 407 | Â Â *image; |
| 408 | |
| 409 | Â PixelIterator |
| 410 | Â Â *iterator; |
| 411 | |
| 412 |  unsigned long |
| 413 | Â Â depth; |
| 414 | |
| 415 | Â ViewInfo |
| 416 | Â Â *view; |
| 417 | |
| 418 | Â assert(wand != (MagickWand *) NULL); |
| 419 | Â depth=MAGICKCORE_QUANTUM_DEPTH; |
| 420 | Â quantum=GetMagickQuantumDepth(&depth); |
| 421 |  if (depth != MAGICKCORE_QUANTUM_DEPTH) |
| 422 | Â Â ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); |
| 423 |  if ((columns == 0) || (rows == 0)) |
| 424 | Â Â ThrowWandFatalException(WandError,"ZeroRegionSize",quantum); |
| 425 | Â image=GetImageFromMagickWand(wand); |
| 426 |  if (image == (Image *) NULL) |
| 427 | Â Â return((PixelIterator *) NULL); |
| 428 | Â view=AcquireCacheView(image); |
| 429 |  if (view == (ViewInfo *) NULL) |
| 430 | Â Â return((PixelIterator *) NULL); |
| 431 | Â iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator)); |
| 432 |  if (iterator == (PixelIterator *) NULL) |
| 433 | Â Â ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 434 | Â Â Â wand->name); |
| 435 | Â (void) ResetMagickMemory(iterator,0,sizeof(*iterator)); |
| 436 | Â iterator->id=AcquireWandId(); |
| 437 | Â (void) FormatMagickString(iterator->name,MaxTextExtent,"%s-%lu", |
| 438 | Â Â PixelIteratorId,iterator->id); |
| 439 | Â iterator->exception=AcquireExceptionInfo(); |
| 440 | Â iterator->view=view; |
| 441 | Â SetGeometry(image,&iterator->region); |
| 442 | Â iterator->region.width=columns; |
| 443 | Â iterator->region.height=rows; |
| 444 | Â iterator->region.x=x; |
| 445 | Â iterator->region.y=y; |
| 446 | Â iterator->pixel_wands=NewPixelWands(iterator->region.width); |
| 447 | Â iterator->y=0; |
| 448 | Â iterator->debug=IsEventLogging(); |
| 449 |  if (iterator->debug != MagickFalse) |
| 450 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 451 | Â iterator->signature=WandSignature; |
| 452 | Â return(iterator); |
| 453 | } |
| 454 | |
| 455 | /* |
| 456 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 457 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 458 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 459 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 460 | %  P i x e l G e t C u r r e n t I t e r a t o r R o w            % |
| 461 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 462 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 463 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 464 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 465 | % |
| 466 | %Â PixelGetCurrentIteratorRow() returns the current row as an array of pixel |
| 467 | %Â wands from the pixel iterator. |
| 468 | % |
| 469 | %Â The format of the PixelGetCurrentIteratorRow method is: |
| 470 | % |
| 471 | %Â Â Â PixelWand **PixelGetCurrentIteratorRow(PixelIterator *iterator, |
| 472 | %Â Â Â Â unsigned long *number_wands) |
| 473 | % |
| 474 | %Â A description of each parameter follows: |
| 475 | % |
| 476 | %Â Â o iterator: the pixel iterator. |
| 477 | % |
| 478 | %Â Â o number_wands: the number of pixel wands. |
| 479 | % |
| 480 | */ |
| 481 | WandExport PixelWand **PixelGetCurrentIteratorRow(PixelIterator *iterator, |
| 482 |  unsigned long *number_wands) |
| 483 | { |
| 484 |  register const IndexPacket |
| 485 | Â Â *indexes; |
| 486 | |
| 487 |  register const PixelPacket |
| 488 | Â Â *p; |
| 489 | |
| 490 |  register long |
| 491 | Â Â x; |
| 492 | |
| 493 | Â assert(iterator != (PixelIterator *) NULL); |
| 494 | Â assert(iterator->signature == WandSignature); |
| 495 |  if (iterator->debug != MagickFalse) |
| 496 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 497 | Â *number_wands=0; |
| 498 | Â iterator->active=MagickTrue; |
| 499 | Â p=AcquireCacheViewPixels(iterator->view,iterator->region.x,iterator->region.y+ |
| 500 | Â Â iterator->y,iterator->region.width,1,iterator->exception); |
| 501 |  if (p == (const PixelPacket *) NULL) |
| 502 | Â Â return((PixelWand **) NULL); |
| 503 | Â indexes=AcquireCacheViewIndexes(iterator->view); |
| 504 |  for (x=0; x < (long) iterator->region.width; x++) |
| 505 | Â { |
| 506 | Â Â PixelSetQuantumColor(iterator->pixel_wands[x],p); |
| 507 |   if (GetCacheViewColorspace(iterator->view) == CMYKColorspace) |
| 508 | Â Â Â PixelSetBlackQuantum(iterator->pixel_wands[x],indexes[x]); |
| 509 | Â Â else |
| 510 |    if (GetCacheViewStorageClass(iterator->view) == PseudoClass) |
| 511 | Â Â Â Â PixelSetIndex(iterator->pixel_wands[x],indexes[x]); |
| 512 | Â Â p++; |
| 513 | Â } |
| 514 | Â *number_wands=iterator->region.width; |
| 515 | Â return(iterator->pixel_wands); |
| 516 | } |
| 517 | |
| 518 | /* |
| 519 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 520 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 521 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 522 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 523 | %  P i x e l G e t I t e r a t o r E x c e p t i o n             % |
| 524 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 525 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 526 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 527 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 528 | % |
| 529 | %Â PixelGetIteratorException() returns the severity, reason, and description of |
| 530 | %Â any error that occurs when using other methods in this API. |
| 531 | % |
| 532 | %Â The format of the PixelGetIteratorException method is: |
| 533 | % |
| 534 | %Â Â Â char *PixelGetIteratorException(const Pixeliterator *iterator, |
| 535 | %Â Â Â Â ExceptionType *severity) |
| 536 | % |
| 537 | %Â A description of each parameter follows: |
| 538 | % |
| 539 | %Â Â o iterator: the pixel iterator. |
| 540 | % |
| 541 | %Â Â o severity: the severity of the error is returned here. |
| 542 | % |
| 543 | */ |
| 544 | WandExport char *PixelGetIteratorException(const PixelIterator *iterator, |
| 545 | Â ExceptionType *severity) |
| 546 | { |
| 547 | Â char |
| 548 | Â Â *description; |
| 549 | |
| 550 |  assert(iterator != (const PixelIterator *) NULL); |
| 551 | Â assert(iterator->signature == WandSignature); |
| 552 |  if (iterator->debug != MagickFalse) |
| 553 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 554 | Â assert(severity != (ExceptionType *) NULL); |
| 555 | Â *severity=iterator->exception->severity; |
| 556 |  description=(char *) AcquireQuantumMemory(2UL*MaxTextExtent, |
| 557 | Â Â sizeof(*description)); |
| 558 |  if (description == (char *) NULL) |
| 559 | Â Â ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 560 | Â Â Â iterator->name); |
| 561 | Â *description='\0'; |
| 562 |  if (iterator->exception->reason != (char *) NULL) |
| 563 | Â Â (void) CopyMagickString(description,GetLocaleExceptionMessage( |
| 564 | Â Â Â iterator->exception->severity,iterator->exception->reason),MaxTextExtent); |
| 565 |  if (iterator->exception->description != (char *) NULL) |
| 566 | Â Â { |
| 567 | Â Â Â (void) ConcatenateMagickString(description," (",MaxTextExtent); |
| 568 | Â Â Â (void) ConcatenateMagickString(description,GetLocaleExceptionMessage( |
| 569 | Â Â Â Â iterator->exception->severity,iterator->exception->description), |
| 570 | Â Â Â Â MaxTextExtent); |
| 571 | Â Â Â (void) ConcatenateMagickString(description,")",MaxTextExtent); |
| 572 | Â Â } |
| 573 | Â return(description); |
| 574 | } |
| 575 | |
| 576 | /* |
| 577 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 578 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 579 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 580 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 581 | %  P i x e l G e t E x c e p t i o n T y p e                 % |
| 582 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 583 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 584 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 585 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 586 | % |
| 587 | %Â PixelGetIteratorExceptionType() the exception type associated with the wand. |
| 588 | %Â If no exception has occurred, UndefinedExceptionType is returned. |
| 589 | % |
| 590 | %Â The format of the PixelGetIteratorExceptionType method is: |
| 591 | % |
| 592 | %Â Â Â ExceptionType PixelGetIteratorExceptionType(const PixelWand *wand) |
| 593 | % |
| 594 | %Â A description of each parameter follows: |
| 595 | % |
| 596 | %Â Â o wand: the magick wand. |
| 597 | % |
| 598 | */ |
| 599 | WandExport ExceptionType PixelGetIteratorExceptionType( |
| 600 |  const PixelIterator *wand) |
| 601 | { |
| 602 |  assert(wand != (const PixelIterator *) NULL); |
| 603 | Â assert(wand->signature == WandSignature); |
| 604 |  if (wand->debug != MagickFalse) |
| 605 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 606 | Â return(wand->exception->severity); |
| 607 | } |
| 608 | |
| 609 | /* |
| 610 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 611 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 612 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 613 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 614 | %  P i x e l G e t I t e r a t o r R o w                   % |
| 615 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 616 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 617 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 618 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 619 | % |
| 620 | %Â PixelGetIteratorRow() returns the current pixel iterator row. |
| 621 | % |
| 622 | %Â The format of the PixelGetIteratorRow method is: |
| 623 | % |
| 624 | %Â Â Â MagickBooleanType PixelGetIteratorRow(PixelIterator *iterator) |
| 625 | % |
| 626 | %Â A description of each parameter follows: |
| 627 | % |
| 628 | %Â Â o iterator: the pixel iterator. |
| 629 | % |
| 630 | */ |
| 631 | WandExport long PixelGetIteratorRow(PixelIterator *iterator) |
| 632 | { |
| 633 |  assert(iterator != (const PixelIterator *) NULL); |
| 634 | Â assert(iterator->signature == WandSignature); |
| 635 |  if (iterator->debug != MagickFalse) |
| 636 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 637 | Â return(iterator->y); |
| 638 | } |
| 639 | |
| 640 | /* |
| 641 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 642 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 643 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 644 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 645 | %  P i x e l G e t N e x t I t e r a t o r R o w               % |
| 646 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 647 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 648 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 649 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 650 | % |
| 651 | %Â PixelGetNextIteratorRow() returns the next row as an array of pixel wands |
| 652 | %Â from the pixel iterator. |
| 653 | % |
| 654 | %Â The format of the PixelGetNextIteratorRow method is: |
| 655 | % |
| 656 | %Â Â Â PixelWand **PixelGetNextIteratorRow(PixelIterator *iterator, |
| 657 | %Â Â Â Â unsigned long *number_wands) |
| 658 | % |
| 659 | %Â A description of each parameter follows: |
| 660 | % |
| 661 | %Â Â o iterator: the pixel iterator. |
| 662 | % |
| 663 | %Â Â o number_wands: the number of pixel wands. |
| 664 | % |
| 665 | */ |
| 666 | WandExport PixelWand **PixelGetNextIteratorRow(PixelIterator *iterator, |
| 667 |  unsigned long *number_wands) |
| 668 | { |
| 669 |  register const IndexPacket |
| 670 | Â Â *indexes; |
| 671 | |
| 672 |  register const PixelPacket |
| 673 | Â Â *p; |
| 674 | |
| 675 |  register long |
| 676 | Â Â x; |
| 677 | |
| 678 | Â assert(iterator != (PixelIterator *) NULL); |
| 679 | Â assert(iterator->signature == WandSignature); |
| 680 |  if (iterator->debug != MagickFalse) |
| 681 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 682 | Â *number_wands=0; |
| 683 |  if (iterator->active != MagickFalse) |
| 684 | Â Â iterator->y++; |
| 685 |  if (PixelSetIteratorRow(iterator,iterator->y) == MagickFalse) |
| 686 | Â Â return((PixelWand **) NULL); |
| 687 | Â p=AcquireCacheViewPixels(iterator->view,iterator->region.x,iterator->region.y+ |
| 688 | Â Â iterator->y,iterator->region.width,1,iterator->exception); |
| 689 |  if (p == (const PixelPacket *) NULL) |
| 690 | Â Â return((PixelWand **) NULL); |
| 691 | Â indexes=AcquireCacheViewIndexes(iterator->view); |
| 692 |  for (x=0; x < (long) iterator->region.width; x++) |
| 693 | Â { |
| 694 | Â Â PixelSetQuantumColor(iterator->pixel_wands[x],p); |
| 695 |   if (GetCacheViewColorspace(iterator->view) == CMYKColorspace) |
| 696 | Â Â Â PixelSetBlackQuantum(iterator->pixel_wands[x],indexes[x]); |
| 697 | Â Â else |
| 698 |    if (GetCacheViewStorageClass(iterator->view) == PseudoClass) |
| 699 | Â Â Â Â PixelSetIndex(iterator->pixel_wands[x],indexes[x]); |
| 700 | Â Â p++; |
| 701 | Â } |
| 702 | Â *number_wands=iterator->region.width; |
| 703 | Â return(iterator->pixel_wands); |
| 704 | } |
| 705 | |
| 706 | /* |
| 707 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 708 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 709 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 710 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 711 | %  P i x e l G e t P r e v i o u s I t e r a t o r R o w           % |
| 712 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 713 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 714 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 715 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 716 | % |
| 717 | %Â PixelGetPreviousIteratorRow() returns the previous row as an array of pixel |
| 718 | %Â wands from the pixel iterator. |
| 719 | % |
| 720 | %Â The format of the PixelGetPreviousIteratorRow method is: |
| 721 | % |
| 722 | %Â Â Â PixelWand **PixelGetPreviousIteratorRow(PixelIterator *iterator, |
| 723 | %Â Â Â Â unsigned long *number_wands) |
| 724 | % |
| 725 | %Â A description of each parameter follows: |
| 726 | % |
| 727 | %Â Â o iterator: the pixel iterator. |
| 728 | % |
| 729 | %Â Â o number_wands: the number of pixel wands. |
| 730 | % |
| 731 | */ |
| 732 | |
| 733 | WandExport PixelWand **PixelGetPreviousRow(PixelIterator *iterator) |
| 734 | { |
| 735 |  unsigned long |
| 736 | Â Â number_wands; |
| 737 | |
| 738 | Â return(PixelGetPreviousIteratorRow(iterator,&number_wands)); |
| 739 | } |
| 740 | |
| 741 | WandExport PixelWand **PixelGetPreviousIteratorRow(PixelIterator *iterator, |
| 742 |  unsigned long *number_wands) |
| 743 | { |
| 744 |  register const IndexPacket |
| 745 | Â Â *indexes; |
| 746 | |
| 747 |  register const PixelPacket |
| 748 | Â Â *p; |
| 749 | |
| 750 |  register long |
| 751 | Â Â x; |
| 752 | |
| 753 | Â assert(iterator != (PixelIterator *) NULL); |
| 754 | Â assert(iterator->signature == WandSignature); |
| 755 |  if (iterator->debug != MagickFalse) |
| 756 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 757 | Â *number_wands=0; |
| 758 |  if (iterator->active != MagickFalse) |
| 759 | Â Â iterator->y--; |
| 760 |  if (PixelSetIteratorRow(iterator,iterator->y) == MagickFalse) |
| 761 | Â Â return((PixelWand **) NULL); |
| 762 | Â p=AcquireCacheViewPixels(iterator->view,iterator->region.x,iterator->region.y+ |
| 763 | Â Â iterator->y,iterator->region.width,1,iterator->exception); |
| 764 |  if (p == (const PixelPacket *) NULL) |
| 765 | Â Â return((PixelWand **) NULL); |
| 766 | Â indexes=AcquireCacheViewIndexes(iterator->view); |
| 767 |  for (x=0; x < (long) iterator->region.width; x++) |
| 768 | Â { |
| 769 | Â Â PixelSetQuantumColor(iterator->pixel_wands[x],p); |
| 770 |   if (GetCacheViewColorspace(iterator->view) == CMYKColorspace) |
| 771 | Â Â Â PixelSetBlackQuantum(iterator->pixel_wands[x],indexes[x]); |
| 772 | Â Â else |
| 773 |    if (GetCacheViewStorageClass(iterator->view) == PseudoClass) |
| 774 | Â Â Â Â PixelSetIndex(iterator->pixel_wands[x],indexes[x]); |
| 775 | Â Â p++; |
| 776 | Â } |
| 777 | Â *number_wands=iterator->region.width; |
| 778 | Â return(iterator->pixel_wands); |
| 779 | } |
| 780 | |
| 781 | /* |
| 782 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 783 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 784 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 785 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 786 | %  P i x e l R e s e t I t e r a t o r                    % |
| 787 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 788 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 789 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 790 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 791 | % |
| 792 | % PixelResetIterator() resets the pixel iterator. Use it in conjunction |
| 793 | %Â with PixelGetNextIteratorRow() to iterate over all the pixels in a pixel |
| 794 | %Â container. |
| 795 | % |
| 796 | %Â The format of the PixelResetIterator method is: |
| 797 | % |
| 798 | %Â Â Â void PixelResetIterator(PixelIterator *iterator) |
| 799 | % |
| 800 | %Â A description of each parameter follows: |
| 801 | % |
| 802 | %Â Â o iterator: the pixel iterator. |
| 803 | % |
| 804 | */ |
| 805 | WandExport void PixelResetIterator(PixelIterator *iterator) |
| 806 | { |
| 807 | Â assert(iterator != (PixelIterator *) NULL); |
| 808 | Â assert(iterator->signature == WandSignature); |
| 809 |  if (iterator->debug != MagickFalse) |
| 810 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 811 | Â iterator->active=MagickFalse; |
| 812 | Â iterator->y=0; |
| 813 | } |
| 814 | |
| 815 | /* |
| 816 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 817 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 818 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 819 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 820 | %  P i x e l S e t F i r s t I t e r a t o r R o w              % |
| 821 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 822 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 823 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 824 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 825 | % |
| 826 | %Â PixelSetFirstIteratorRow() sets the pixel iterator to the first pixel row. |
| 827 | % |
| 828 | %Â The format of the PixelSetFirstIteratorRow method is: |
| 829 | % |
| 830 | %Â Â Â void PixelSetFirstIteratorRow(PixelIterator *iterator) |
| 831 | % |
| 832 | %Â A description of each parameter follows: |
| 833 | % |
| 834 | %Â Â o iterator: the magick iterator. |
| 835 | % |
| 836 | */ |
| 837 | WandExport void PixelSetFirstIteratorRow(PixelIterator *iterator) |
| 838 | { |
| 839 | Â assert(iterator != (PixelIterator *) NULL); |
| 840 | Â assert(iterator->signature == WandSignature); |
| 841 |  if (iterator->debug != MagickFalse) |
| 842 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 843 | Â iterator->active=MagickFalse; |
| 844 | Â iterator->y=iterator->region.y; |
| 845 | } |
| 846 | |
| 847 | /* |
| 848 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 849 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 850 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 851 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 852 | %  P i x e l S e t I t e r a t o r R o w                   % |
| 853 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 854 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 855 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 856 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 857 | % |
| 858 | %Â PixelSetIteratorRow() set the pixel iterator row. |
| 859 | % |
| 860 | %Â The format of the PixelSetIteratorRow method is: |
| 861 | % |
| 862 | %Â Â Â MagickBooleanType PixelSetIteratorRow(PixelIterator *iterator, |
| 863 | %Â Â Â Â const long row) |
| 864 | % |
| 865 | %Â A description of each parameter follows: |
| 866 | % |
| 867 | %Â Â o iterator: the pixel iterator. |
| 868 | % |
| 869 | */ |
| 870 | WandExport MagickBooleanType PixelSetIteratorRow(PixelIterator *iterator, |
| 871 |  const long row) |
| 872 | { |
| 873 |  assert(iterator != (const PixelIterator *) NULL); |
| 874 | Â assert(iterator->signature == WandSignature); |
| 875 |  if (iterator->debug != MagickFalse) |
| 876 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 877 |  if ((row < 0) || (row >= (long) iterator->region.height)) |
| 878 | Â Â return(MagickFalse); |
| 879 | Â iterator->active=MagickTrue; |
| 880 | Â iterator->y=row; |
| 881 | Â return(MagickTrue); |
| 882 | } |
| 883 | |
| 884 | /* |
| 885 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 886 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 887 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 888 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 889 | %  P i x e l S e t L a s t I t e r a t o r R o w               % |
| 890 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 891 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 892 | %Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â % |
| 893 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 894 | % |
| 895 | %Â PixelSetLastIteratorRow() sets the pixel iterator to the last pixel row. |
| 896 | % |
| 897 | %Â The format of the PixelSetLastIteratorRow method is: |
| 898 | % |
| 899 | %Â Â Â void PixelSetLastIteratorRow(PixelIterator *iterator) |
| 900 | % |
| 901 | %Â A description of each parameter follows: |
| 902 | % |
| 903 | %Â Â o iterator: the magick iterator. |
| 904 | % |
| 905 | */ |
| 906 | WandExport void PixelSetLastIteratorRow(PixelIterator *iterator) |
| 907 | { |
| 908 | Â assert(iterator != (PixelIterator *) NULL); |
| 909 | Â assert(iterator->signature == WandSignature); |
| 910 |  if (iterator->debug != MagickFalse) |
| 911 | Â Â (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); |
| 912 | Â iterator->active=MagickFalse; |
| 913 | Â iterator->y=(long) iterator->region.height-1; |
| 914 | } |
| 915 | |
| 916 | /* |
| 917 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 918 | %Â Â Â Â Â Â Â |
