2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % PPPP IIIII X X EEEEE L %
10 % P IIIII X X EEEEE LLLLL %
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 %
19 % ImageMagick Image Pixel Iterator Methods %
26 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
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. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 #include "MagickWand/studio.h"
50 #include "MagickWand/MagickWand.h"
51 #include "MagickWand/magick-wand-private.h"
52 #include "MagickWand/pixel-iterator.h"
53 #include "MagickWand/pixel-wand.h"
54 #include "MagickWand/wand.h"
59 #define PixelIteratorId "PixelIterator"
85 active; /* user has been given pixel data */
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105 % C l e a r P i x e l I t e r a t o r %
109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111 % ClearPixelIterator() clear resources associated with a PixelIterator.
113 % The format of the ClearPixelIterator method is:
115 % PixelIterator *ClearPixelIterator(PixelIterator *iterator)
117 % A description of each parameter follows:
119 % o iterator: the pixel iterator.
122 WandExport void ClearPixelIterator(PixelIterator *iterator)
124 assert(iterator != (const PixelIterator *) NULL);
125 assert(iterator->signature == WandSignature);
126 if (iterator->debug != MagickFalse)
127 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
128 iterator->pixel_wands=DestroyPixelWands(iterator->pixel_wands,
129 iterator->region.width);
130 ClearMagickException(iterator->exception);
131 iterator->pixel_wands=NewPixelWands(iterator->region.width);
132 iterator->active=MagickFalse;
134 iterator->debug=IsEventLogging();
138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
142 % C l o n e P i x e l I t e r a t o r %
146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148 % ClonePixelIterator() makes an exact copy of the specified iterator.
150 % The format of the ClonePixelIterator method is:
152 % PixelIterator *ClonePixelIterator(const PixelIterator *iterator)
154 % A description of each parameter follows:
156 % o iterator: the magick iterator.
159 WandExport PixelIterator *ClonePixelIterator(const PixelIterator *iterator)
164 assert(iterator != (PixelIterator *) NULL);
165 assert(iterator->signature == WandSignature);
166 if (iterator->debug != MagickFalse)
167 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
168 clone_iterator=(PixelIterator *) AcquireMagickMemory(
169 sizeof(*clone_iterator));
170 if (clone_iterator == (PixelIterator *) NULL)
171 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
173 (void) ResetMagickMemory(clone_iterator,0,sizeof(*clone_iterator));
174 clone_iterator->id=AcquireWandId();
175 (void) FormatLocaleString(clone_iterator->name,MaxTextExtent,"%s-%.20g",
176 PixelIteratorId,(double) clone_iterator->id);
177 clone_iterator->exception=AcquireExceptionInfo();
178 InheritException(clone_iterator->exception,iterator->exception);
179 clone_iterator->image=CloneImage(iterator->image,0,0,MagickTrue,
180 iterator->exception);
181 clone_iterator->view=CloneCacheView(iterator->view);
182 clone_iterator->region=iterator->region;
183 clone_iterator->active=iterator->active;
184 clone_iterator->y=iterator->y;
185 clone_iterator->pixel_wands=ClonePixelWands((const PixelWand **)
186 iterator->pixel_wands,iterator->region.width);
187 clone_iterator->debug=iterator->debug;
188 if (clone_iterator->debug != MagickFalse)
189 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",
190 clone_iterator->name);
191 clone_iterator->signature=WandSignature;
192 return(clone_iterator);
196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
200 % D e s t r o y P i x e l I t e r a t o r %
204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206 % DestroyPixelIterator() deallocates resources associated with a PixelIterator.
208 % The format of the DestroyPixelIterator method is:
210 % PixelIterator *DestroyPixelIterator(PixelIterator *iterator)
212 % A description of each parameter follows:
214 % o iterator: the pixel iterator.
217 WandExport PixelIterator *DestroyPixelIterator(PixelIterator *iterator)
219 assert(iterator != (const PixelIterator *) NULL);
220 assert(iterator->signature == WandSignature);
221 if (iterator->debug != MagickFalse)
222 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
223 iterator->image=DestroyImage(iterator->image);
224 iterator->view=DestroyCacheView(iterator->view);
225 iterator->pixel_wands=DestroyPixelWands(iterator->pixel_wands,
226 iterator->region.width);
227 iterator->exception=DestroyExceptionInfo(iterator->exception);
228 iterator->signature=(~WandSignature);
229 RelinquishWandId(iterator->id);
230 iterator=(PixelIterator *) RelinquishMagickMemory(iterator);
235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
239 % I s P i x e l I t e r a t o r %
243 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
245 % IsPixelIterator() returns MagickTrue if the iterator is verified as a pixel
248 % The format of the IsPixelIterator method is:
250 % MagickBooleanType IsPixelIterator(const PixelIterator *iterator)
252 % A description of each parameter follows:
254 % o iterator: the magick iterator.
257 WandExport MagickBooleanType IsPixelIterator(const PixelIterator *iterator)
262 if (iterator == (const PixelIterator *) NULL)
264 if (iterator->signature != WandSignature)
266 length=strlen(PixelIteratorId);
267 if (LocaleNCompare(iterator->name,PixelIteratorId,length) != 0)
273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
277 % N e w P i x e l I t e r a t o r %
281 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
283 % NewPixelIterator() returns a new pixel iterator.
285 % The format of the NewPixelIterator method is:
287 % PixelIterator *NewPixelIterator(MagickWand *wand)
289 % A description of each parameter follows:
291 % o wand: the magick wand.
294 WandExport PixelIterator *NewPixelIterator(MagickWand *wand)
311 depth=MAGICKCORE_QUANTUM_DEPTH;
312 quantum=GetMagickQuantumDepth(&depth);
313 if (depth != MAGICKCORE_QUANTUM_DEPTH)
314 ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum);
315 assert(wand != (MagickWand *) NULL);
316 image=GetImageFromMagickWand(wand);
317 if (image == (Image *) NULL)
318 return((PixelIterator *) NULL);
319 view=AcquireCacheView(image);
320 if (view == (CacheView *) NULL)
321 return((PixelIterator *) NULL);
322 iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator));
323 if (iterator == (PixelIterator *) NULL)
324 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
325 GetExceptionMessage(errno));
326 (void) ResetMagickMemory(iterator,0,sizeof(*iterator));
327 iterator->id=AcquireWandId();
328 (void) FormatLocaleString(iterator->name,MaxTextExtent,"%s-%.20g",
329 PixelIteratorId,(double) iterator->id);
330 iterator->exception=AcquireExceptionInfo();
331 iterator->image=CloneImage(image,0,0,MagickTrue,iterator->exception);
333 SetGeometry(image,&iterator->region);
334 iterator->region.width=image->columns;
335 iterator->region.height=image->rows;
336 iterator->region.x=0;
337 iterator->region.y=0;
338 iterator->pixel_wands=NewPixelWands(iterator->region.width);
340 iterator->debug=IsEventLogging();
341 if (iterator->debug != MagickFalse)
342 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
343 iterator->signature=WandSignature;
348 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
352 % 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 %
356 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
358 % PixelClearIteratorException() clear any exceptions associated with the
361 % The format of the PixelClearIteratorException method is:
363 % MagickBooleanType PixelClearIteratorException(PixelIterator *wand)
365 % A description of each parameter follows:
367 % o wand: the pixel wand.
370 WandExport MagickBooleanType PixelClearIteratorException(
371 PixelIterator *iterator)
373 assert(iterator != (PixelIterator *) NULL);
374 assert(iterator->signature == WandSignature);
375 if (iterator->debug != MagickFalse)
376 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
377 ClearMagickException(iterator->exception);
382 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
386 % N e w P i x e l R e g i o n I t e r a t o r %
390 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
392 % NewPixelRegionIterator() returns a new pixel iterator.
394 % The format of the NewPixelRegionIterator method is:
396 % PixelIterator NewPixelRegionIterator(MagickWand *wand,const ssize_t x,
397 % const ssize_t y,const size_t width,const size_t height)
399 % A description of each parameter follows:
401 % o wand: the magick wand.
403 % o x,y,columns,rows: These values define the perimeter of a region of
407 WandExport PixelIterator *NewPixelRegionIterator(MagickWand *wand,
408 const ssize_t x,const ssize_t y,const size_t width,const size_t height)
425 assert(wand != (MagickWand *) NULL);
426 depth=MAGICKCORE_QUANTUM_DEPTH;
427 quantum=GetMagickQuantumDepth(&depth);
428 if (depth != MAGICKCORE_QUANTUM_DEPTH)
429 ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum);
430 if ((width == 0) || (width == 0))
431 ThrowWandFatalException(WandError,"ZeroRegionSize",quantum);
432 image=GetImageFromMagickWand(wand);
433 if (image == (Image *) NULL)
434 return((PixelIterator *) NULL);
435 view=AcquireCacheView(image);
436 if (view == (CacheView *) NULL)
437 return((PixelIterator *) NULL);
438 iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator));
439 if (iterator == (PixelIterator *) NULL)
440 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
442 (void) ResetMagickMemory(iterator,0,sizeof(*iterator));
443 iterator->id=AcquireWandId();
444 (void) FormatLocaleString(iterator->name,MaxTextExtent,"%s-%.20g",
445 PixelIteratorId,(double) iterator->id);
446 iterator->exception=AcquireExceptionInfo();
448 SetGeometry(image,&iterator->region);
449 iterator->region.width=width;
450 iterator->region.height=height;
451 iterator->region.x=x;
452 iterator->region.y=y;
453 iterator->pixel_wands=NewPixelWands(iterator->region.width);
455 iterator->debug=IsEventLogging();
456 if (iterator->debug != MagickFalse)
457 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
458 iterator->signature=WandSignature;
463 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
467 % 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 %
471 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
473 % PixelGetCurrentIteratorRow() returns the current row as an array of pixel
474 % wands from the pixel iterator.
476 % The format of the PixelGetCurrentIteratorRow method is:
478 % PixelWand **PixelGetCurrentIteratorRow(PixelIterator *iterator,
479 % size_t *number_wands)
481 % A description of each parameter follows:
483 % o iterator: the pixel iterator.
485 % o number_wands: the number of pixel wands.
488 WandExport PixelWand **PixelGetCurrentIteratorRow(PixelIterator *iterator,
489 size_t *number_wands)
491 register const Quantum
497 assert(iterator != (PixelIterator *) NULL);
498 assert(iterator->signature == WandSignature);
499 if (iterator->debug != MagickFalse)
500 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
502 iterator->active=MagickTrue;
503 pixels=GetCacheViewVirtualPixels(iterator->view,iterator->region.x,
504 iterator->region.y+iterator->y,iterator->region.width,1,
505 iterator->exception);
506 if (pixels == (const Quantum *) NULL)
507 return((PixelWand **) NULL);
508 for (x=0; x < (ssize_t) iterator->region.width; x++)
510 PixelSetQuantumPixel(iterator->image,pixels,iterator->pixel_wands[x]);
511 pixels+=GetPixelChannels(iterator->image);
513 *number_wands=iterator->region.width;
514 return(iterator->pixel_wands);
518 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
522 % 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 %
526 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
528 % PixelGetIteratorException() returns the severity, reason, and description of
529 % any error that occurs when using other methods in this API.
531 % The format of the PixelGetIteratorException method is:
533 % char *PixelGetIteratorException(const Pixeliterator *iterator,
534 % ExceptionType *severity)
536 % A description of each parameter follows:
538 % o iterator: the pixel iterator.
540 % o severity: the severity of the error is returned here.
543 WandExport char *PixelGetIteratorException(const PixelIterator *iterator,
544 ExceptionType *severity)
549 assert(iterator != (const PixelIterator *) NULL);
550 assert(iterator->signature == WandSignature);
551 if (iterator->debug != MagickFalse)
552 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
553 assert(severity != (ExceptionType *) NULL);
554 *severity=iterator->exception->severity;
555 description=(char *) AcquireQuantumMemory(2UL*MaxTextExtent,
556 sizeof(*description));
557 if (description == (char *) NULL)
558 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
561 if (iterator->exception->reason != (char *) NULL)
562 (void) CopyMagickString(description,GetLocaleExceptionMessage(
563 iterator->exception->severity,iterator->exception->reason),MaxTextExtent);
564 if (iterator->exception->description != (char *) NULL)
566 (void) ConcatenateMagickString(description," (",MaxTextExtent);
567 (void) ConcatenateMagickString(description,GetLocaleExceptionMessage(
568 iterator->exception->severity,iterator->exception->description),
570 (void) ConcatenateMagickString(description,")",MaxTextExtent);
576 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
580 % P i x e l G e t E x c e p t i o n T y p e %
584 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
586 % PixelGetIteratorExceptionType() the exception type associated with the wand.
587 % If no exception has occurred, UndefinedExceptionType is returned.
589 % The format of the PixelGetIteratorExceptionType method is:
591 % ExceptionType PixelGetIteratorExceptionType(const PixelWand *wand)
593 % A description of each parameter follows:
595 % o wand: the magick wand.
598 WandExport ExceptionType PixelGetIteratorExceptionType(
599 const PixelIterator *wand)
601 assert(wand != (const PixelIterator *) NULL);
602 assert(wand->signature == WandSignature);
603 if (wand->debug != MagickFalse)
604 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
605 return(wand->exception->severity);
609 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
613 % P i x e l G e t I t e r a t o r R o w %
617 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
619 % PixelGetIteratorRow() returns the current pixel iterator row.
621 % The format of the PixelGetIteratorRow method is:
623 % MagickBooleanType PixelGetIteratorRow(PixelIterator *iterator)
625 % A description of each parameter follows:
627 % o iterator: the pixel iterator.
630 WandExport ssize_t PixelGetIteratorRow(PixelIterator *iterator)
632 assert(iterator != (const PixelIterator *) NULL);
633 assert(iterator->signature == WandSignature);
634 if (iterator->debug != MagickFalse)
635 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
640 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
644 % P i x e l G e t N e x t I t e r a t o r R o w %
648 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
650 % PixelGetNextIteratorRow() returns the next row as an array of pixel wands
651 % from the pixel iterator.
653 % The format of the PixelGetNextIteratorRow method is:
655 % PixelWand **PixelGetNextIteratorRow(PixelIterator *iterator,
656 % size_t *number_wands)
658 % A description of each parameter follows:
660 % o iterator: the pixel iterator.
662 % o number_wands: the number of pixel wands.
665 WandExport PixelWand **PixelGetNextIteratorRow(PixelIterator *iterator,
666 size_t *number_wands)
668 register const Quantum
674 assert(iterator != (PixelIterator *) NULL);
675 assert(iterator->signature == WandSignature);
676 if (iterator->debug != MagickFalse)
677 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
679 if (iterator->active != MagickFalse)
681 if (PixelSetIteratorRow(iterator,iterator->y) == MagickFalse)
682 return((PixelWand **) NULL);
683 pixels=GetCacheViewVirtualPixels(iterator->view,iterator->region.x,
684 iterator->region.y+iterator->y,iterator->region.width,1,
685 iterator->exception);
686 if (pixels == (const Quantum *) NULL)
687 return((PixelWand **) NULL);
688 for (x=0; x < (ssize_t) iterator->region.width; x++)
690 PixelSetQuantumPixel(iterator->image,pixels,iterator->pixel_wands[x]);
691 pixels+=GetPixelChannels(iterator->image);
693 *number_wands=iterator->region.width;
694 return(iterator->pixel_wands);
698 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
702 % 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 %
706 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
708 % PixelGetPreviousIteratorRow() returns the previous row as an array of pixel
709 % wands from the pixel iterator.
711 % The format of the PixelGetPreviousIteratorRow method is:
713 % PixelWand **PixelGetPreviousIteratorRow(PixelIterator *iterator,
714 % size_t *number_wands)
716 % A description of each parameter follows:
718 % o iterator: the pixel iterator.
720 % o number_wands: the number of pixel wands.
723 WandExport PixelWand **PixelGetPreviousIteratorRow(PixelIterator *iterator,
724 size_t *number_wands)
726 register const Quantum
732 assert(iterator != (PixelIterator *) NULL);
733 assert(iterator->signature == WandSignature);
734 if (iterator->debug != MagickFalse)
735 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
737 if (iterator->active != MagickFalse)
739 if (PixelSetIteratorRow(iterator,iterator->y) == MagickFalse)
740 return((PixelWand **) NULL);
741 pixels=GetCacheViewVirtualPixels(iterator->view,iterator->region.x,
742 iterator->region.y+iterator->y,iterator->region.width,1,
743 iterator->exception);
744 if (pixels == (const Quantum *) NULL)
745 return((PixelWand **) NULL);
746 for (x=0; x < (ssize_t) iterator->region.width; x++)
748 PixelSetQuantumPixel(iterator->image,pixels,iterator->pixel_wands[x]);
749 pixels+=GetPixelChannels(iterator->image);
751 *number_wands=iterator->region.width;
752 return(iterator->pixel_wands);
756 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
760 % P i x e l R e s e t I t e r a t o r %
764 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
766 % PixelResetIterator() resets the pixel iterator. Use it in conjunction
767 % with PixelGetNextIteratorRow() to iterate over all the pixels in a pixel
770 % The format of the PixelResetIterator method is:
772 % void PixelResetIterator(PixelIterator *iterator)
774 % A description of each parameter follows:
776 % o iterator: the pixel iterator.
779 WandExport void PixelResetIterator(PixelIterator *iterator)
781 assert(iterator != (PixelIterator *) NULL);
782 assert(iterator->signature == WandSignature);
783 if (iterator->debug != MagickFalse)
784 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
785 iterator->active=MagickFalse;
790 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
794 % P i x e l S e t F i r s t I t e r a t o r R o w %
798 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
800 % PixelSetFirstIteratorRow() sets the pixel iterator to the first pixel row.
802 % The format of the PixelSetFirstIteratorRow method is:
804 % void PixelSetFirstIteratorRow(PixelIterator *iterator)
806 % A description of each parameter follows:
808 % o iterator: the magick iterator.
811 WandExport void PixelSetFirstIteratorRow(PixelIterator *iterator)
813 assert(iterator != (PixelIterator *) NULL);
814 assert(iterator->signature == WandSignature);
815 if (iterator->debug != MagickFalse)
816 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
817 iterator->active=MagickFalse;
818 iterator->y=iterator->region.y;
822 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
826 % P i x e l S e t I t e r a t o r R o w %
830 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
832 % PixelSetIteratorRow() set the pixel iterator row.
834 % The format of the PixelSetIteratorRow method is:
836 % MagickBooleanType PixelSetIteratorRow(PixelIterator *iterator,
839 % A description of each parameter follows:
841 % o iterator: the pixel iterator.
844 WandExport MagickBooleanType PixelSetIteratorRow(PixelIterator *iterator,
847 assert(iterator != (const PixelIterator *) NULL);
848 assert(iterator->signature == WandSignature);
849 if (iterator->debug != MagickFalse)
850 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
851 if ((row < 0) || (row >= (ssize_t) iterator->region.height))
853 iterator->active=MagickTrue;
859 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
863 % P i x e l S e t L a s t I t e r a t o r R o w %
867 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
869 % PixelSetLastIteratorRow() sets the pixel iterator to the last pixel row.
871 % The format of the PixelSetLastIteratorRow method is:
873 % void PixelSetLastIteratorRow(PixelIterator *iterator)
875 % A description of each parameter follows:
877 % o iterator: the magick iterator.
880 WandExport void PixelSetLastIteratorRow(PixelIterator *iterator)
882 assert(iterator != (PixelIterator *) NULL);
883 assert(iterator->signature == WandSignature);
884 if (iterator->debug != MagickFalse)
885 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
886 iterator->active=MagickFalse;
887 iterator->y=(ssize_t) iterator->region.height-1;
891 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
895 % P i x e l S y n c I t e r a t o r %
899 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
901 % PixelSyncIterator() syncs the pixel iterator.
903 % The format of the PixelSyncIterator method is:
905 % MagickBooleanType PixelSyncIterator(PixelIterator *iterator)
907 % A description of each parameter follows:
909 % o iterator: the pixel iterator.
912 WandExport MagickBooleanType PixelSyncIterator(PixelIterator *iterator)
920 assert(iterator != (const PixelIterator *) NULL);
921 assert(iterator->signature == WandSignature);
922 if (iterator->debug != MagickFalse)
923 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
924 if (SetCacheViewStorageClass(iterator->view,DirectClass) == MagickFalse)
926 pixels=GetCacheViewAuthenticPixels(iterator->view,iterator->region.x,
927 iterator->region.y+iterator->y,iterator->region.width,1,
928 iterator->exception);
929 if (pixels == (Quantum *) NULL)
931 for (x=0; x < (ssize_t) iterator->region.width; x++)
933 PixelGetQuantumPixel(iterator->image,iterator->pixel_wands[x],pixels);
934 pixels+=GetPixelChannels(iterator->image);
936 if (SyncCacheViewAuthenticPixels(iterator->view,iterator->exception) == MagickFalse)