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-2012 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)
314 depth=MAGICKCORE_QUANTUM_DEPTH;
315 quantum=GetMagickQuantumDepth(&depth);
316 if (depth != MAGICKCORE_QUANTUM_DEPTH)
317 ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum);
318 assert(wand != (MagickWand *) NULL);
319 image=GetImageFromMagickWand(wand);
320 if (image == (Image *) NULL)
321 return((PixelIterator *) NULL);
322 exception=AcquireExceptionInfo();
323 view=AcquireVirtualCacheView(image,exception);
324 if (view == (CacheView *) NULL)
325 return((PixelIterator *) NULL);
326 iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator));
327 if (iterator == (PixelIterator *) NULL)
328 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
329 GetExceptionMessage(errno));
330 (void) ResetMagickMemory(iterator,0,sizeof(*iterator));
331 iterator->id=AcquireWandId();
332 (void) FormatLocaleString(iterator->name,MaxTextExtent,"%s-%.20g",
333 PixelIteratorId,(double) iterator->id);
334 iterator->exception=exception;
335 iterator->image=CloneImage(image,0,0,MagickTrue,iterator->exception);
337 SetGeometry(image,&iterator->region);
338 iterator->region.width=image->columns;
339 iterator->region.height=image->rows;
340 iterator->region.x=0;
341 iterator->region.y=0;
342 iterator->pixel_wands=NewPixelWands(iterator->region.width);
344 iterator->debug=IsEventLogging();
345 if (iterator->debug != MagickFalse)
346 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
347 iterator->signature=WandSignature;
352 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
356 % 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 %
360 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
362 % PixelClearIteratorException() clear any exceptions associated with the
365 % The format of the PixelClearIteratorException method is:
367 % MagickBooleanType PixelClearIteratorException(PixelIterator *wand)
369 % A description of each parameter follows:
371 % o wand: the pixel wand.
374 WandExport MagickBooleanType PixelClearIteratorException(
375 PixelIterator *iterator)
377 assert(iterator != (PixelIterator *) NULL);
378 assert(iterator->signature == WandSignature);
379 if (iterator->debug != MagickFalse)
380 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
381 ClearMagickException(iterator->exception);
386 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
390 % N e w P i x e l R e g i o n I t e r a t o r %
394 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
396 % NewPixelRegionIterator() returns a new pixel iterator.
398 % The format of the NewPixelRegionIterator method is:
400 % PixelIterator NewPixelRegionIterator(MagickWand *wand,const ssize_t x,
401 % const ssize_t y,const size_t width,const size_t height)
403 % A description of each parameter follows:
405 % o wand: the magick wand.
407 % o x,y,columns,rows: These values define the perimeter of a region of
411 WandExport PixelIterator *NewPixelRegionIterator(MagickWand *wand,
412 const ssize_t x,const ssize_t y,const size_t width,const size_t height)
432 assert(wand != (MagickWand *) NULL);
433 depth=MAGICKCORE_QUANTUM_DEPTH;
434 quantum=GetMagickQuantumDepth(&depth);
435 if (depth != MAGICKCORE_QUANTUM_DEPTH)
436 ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum);
437 if ((width == 0) || (width == 0))
438 ThrowWandFatalException(WandError,"ZeroRegionSize",quantum);
439 image=GetImageFromMagickWand(wand);
440 if (image == (Image *) NULL)
441 return((PixelIterator *) NULL);
442 exception=AcquireExceptionInfo();
443 view=AcquireVirtualCacheView(image,exception);
444 if (view == (CacheView *) NULL)
445 return((PixelIterator *) NULL);
446 iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator));
447 if (iterator == (PixelIterator *) NULL)
448 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
450 (void) ResetMagickMemory(iterator,0,sizeof(*iterator));
451 iterator->id=AcquireWandId();
452 (void) FormatLocaleString(iterator->name,MaxTextExtent,"%s-%.20g",
453 PixelIteratorId,(double) iterator->id);
454 iterator->exception=exception;
456 SetGeometry(image,&iterator->region);
457 iterator->region.width=width;
458 iterator->region.height=height;
459 iterator->region.x=x;
460 iterator->region.y=y;
461 iterator->pixel_wands=NewPixelWands(iterator->region.width);
463 iterator->debug=IsEventLogging();
464 if (iterator->debug != MagickFalse)
465 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
466 iterator->signature=WandSignature;
471 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
475 % 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 %
479 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
481 % PixelGetCurrentIteratorRow() returns the current row as an array of pixel
482 % wands from the pixel iterator.
484 % The format of the PixelGetCurrentIteratorRow method is:
486 % PixelWand **PixelGetCurrentIteratorRow(PixelIterator *iterator,
487 % size_t *number_wands)
489 % A description of each parameter follows:
491 % o iterator: the pixel iterator.
493 % o number_wands: the number of pixel wands.
496 WandExport PixelWand **PixelGetCurrentIteratorRow(PixelIterator *iterator,
497 size_t *number_wands)
499 register const Quantum
505 assert(iterator != (PixelIterator *) NULL);
506 assert(iterator->signature == WandSignature);
507 if (iterator->debug != MagickFalse)
508 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
510 iterator->active=MagickTrue;
511 pixels=GetCacheViewVirtualPixels(iterator->view,iterator->region.x,
512 iterator->region.y+iterator->y,iterator->region.width,1,
513 iterator->exception);
514 if (pixels == (const Quantum *) NULL)
515 return((PixelWand **) NULL);
516 for (x=0; x < (ssize_t) iterator->region.width; x++)
518 PixelSetQuantumPixel(iterator->image,pixels,iterator->pixel_wands[x]);
519 pixels+=GetPixelChannels(iterator->image);
521 *number_wands=iterator->region.width;
522 return(iterator->pixel_wands);
526 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
530 % 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 %
534 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
536 % PixelGetIteratorException() returns the severity, reason, and description of
537 % any error that occurs when using other methods in this API.
539 % The format of the PixelGetIteratorException method is:
541 % char *PixelGetIteratorException(const Pixeliterator *iterator,
542 % ExceptionType *severity)
544 % A description of each parameter follows:
546 % o iterator: the pixel iterator.
548 % o severity: the severity of the error is returned here.
551 WandExport char *PixelGetIteratorException(const PixelIterator *iterator,
552 ExceptionType *severity)
557 assert(iterator != (const PixelIterator *) NULL);
558 assert(iterator->signature == WandSignature);
559 if (iterator->debug != MagickFalse)
560 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
561 assert(severity != (ExceptionType *) NULL);
562 *severity=iterator->exception->severity;
563 description=(char *) AcquireQuantumMemory(2UL*MaxTextExtent,
564 sizeof(*description));
565 if (description == (char *) NULL)
566 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
569 if (iterator->exception->reason != (char *) NULL)
570 (void) CopyMagickString(description,GetLocaleExceptionMessage(
571 iterator->exception->severity,iterator->exception->reason),MaxTextExtent);
572 if (iterator->exception->description != (char *) NULL)
574 (void) ConcatenateMagickString(description," (",MaxTextExtent);
575 (void) ConcatenateMagickString(description,GetLocaleExceptionMessage(
576 iterator->exception->severity,iterator->exception->description),
578 (void) ConcatenateMagickString(description,")",MaxTextExtent);
584 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
588 % P i x e l G e t E x c e p t i o n T y p e %
592 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
594 % PixelGetIteratorExceptionType() the exception type associated with the wand.
595 % If no exception has occurred, UndefinedExceptionType is returned.
597 % The format of the PixelGetIteratorExceptionType method is:
599 % ExceptionType PixelGetIteratorExceptionType(const PixelWand *wand)
601 % A description of each parameter follows:
603 % o wand: the magick wand.
606 WandExport ExceptionType PixelGetIteratorExceptionType(
607 const PixelIterator *wand)
609 assert(wand != (const PixelIterator *) NULL);
610 assert(wand->signature == WandSignature);
611 if (wand->debug != MagickFalse)
612 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
613 return(wand->exception->severity);
617 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
621 % P i x e l G e t I t e r a t o r R o w %
625 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
627 % PixelGetIteratorRow() returns the current pixel iterator row.
629 % The format of the PixelGetIteratorRow method is:
631 % MagickBooleanType PixelGetIteratorRow(PixelIterator *iterator)
633 % A description of each parameter follows:
635 % o iterator: the pixel iterator.
638 WandExport ssize_t PixelGetIteratorRow(PixelIterator *iterator)
640 assert(iterator != (const PixelIterator *) NULL);
641 assert(iterator->signature == WandSignature);
642 if (iterator->debug != MagickFalse)
643 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
648 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
652 % P i x e l G e t N e x t I t e r a t o r R o w %
656 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
658 % PixelGetNextIteratorRow() returns the next row as an array of pixel wands
659 % from the pixel iterator.
661 % The format of the PixelGetNextIteratorRow method is:
663 % PixelWand **PixelGetNextIteratorRow(PixelIterator *iterator,
664 % size_t *number_wands)
666 % A description of each parameter follows:
668 % o iterator: the pixel iterator.
670 % o number_wands: the number of pixel wands.
673 WandExport PixelWand **PixelGetNextIteratorRow(PixelIterator *iterator,
674 size_t *number_wands)
676 register const Quantum
682 assert(iterator != (PixelIterator *) NULL);
683 assert(iterator->signature == WandSignature);
684 if (iterator->debug != MagickFalse)
685 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
687 if (iterator->active != MagickFalse)
689 if (PixelSetIteratorRow(iterator,iterator->y) == MagickFalse)
690 return((PixelWand **) NULL);
691 pixels=GetCacheViewVirtualPixels(iterator->view,iterator->region.x,
692 iterator->region.y+iterator->y,iterator->region.width,1,
693 iterator->exception);
694 if (pixels == (const Quantum *) NULL)
695 return((PixelWand **) NULL);
696 for (x=0; x < (ssize_t) iterator->region.width; x++)
698 PixelSetQuantumPixel(iterator->image,pixels,iterator->pixel_wands[x]);
699 pixels+=GetPixelChannels(iterator->image);
701 *number_wands=iterator->region.width;
702 return(iterator->pixel_wands);
706 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
710 % 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 %
714 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
716 % PixelGetPreviousIteratorRow() returns the previous row as an array of pixel
717 % wands from the pixel iterator.
719 % The format of the PixelGetPreviousIteratorRow method is:
721 % PixelWand **PixelGetPreviousIteratorRow(PixelIterator *iterator,
722 % size_t *number_wands)
724 % A description of each parameter follows:
726 % o iterator: the pixel iterator.
728 % o number_wands: the number of pixel wands.
731 WandExport PixelWand **PixelGetPreviousIteratorRow(PixelIterator *iterator,
732 size_t *number_wands)
734 register const Quantum
740 assert(iterator != (PixelIterator *) NULL);
741 assert(iterator->signature == WandSignature);
742 if (iterator->debug != MagickFalse)
743 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
745 if (iterator->active != MagickFalse)
747 if (PixelSetIteratorRow(iterator,iterator->y) == MagickFalse)
748 return((PixelWand **) NULL);
749 pixels=GetCacheViewVirtualPixels(iterator->view,iterator->region.x,
750 iterator->region.y+iterator->y,iterator->region.width,1,
751 iterator->exception);
752 if (pixels == (const Quantum *) NULL)
753 return((PixelWand **) NULL);
754 for (x=0; x < (ssize_t) iterator->region.width; x++)
756 PixelSetQuantumPixel(iterator->image,pixels,iterator->pixel_wands[x]);
757 pixels+=GetPixelChannels(iterator->image);
759 *number_wands=iterator->region.width;
760 return(iterator->pixel_wands);
764 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
768 % P i x e l R e s e t I t e r a t o r %
772 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
774 % PixelResetIterator() resets the pixel iterator. Use it in conjunction
775 % with PixelGetNextIteratorRow() to iterate over all the pixels in a pixel
778 % The format of the PixelResetIterator method is:
780 % void PixelResetIterator(PixelIterator *iterator)
782 % A description of each parameter follows:
784 % o iterator: the pixel iterator.
787 WandExport void PixelResetIterator(PixelIterator *iterator)
789 assert(iterator != (PixelIterator *) NULL);
790 assert(iterator->signature == WandSignature);
791 if (iterator->debug != MagickFalse)
792 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
793 iterator->active=MagickFalse;
798 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
802 % P i x e l S e t F i r s t I t e r a t o r R o w %
806 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
808 % PixelSetFirstIteratorRow() sets the pixel iterator to the first pixel row.
810 % The format of the PixelSetFirstIteratorRow method is:
812 % void PixelSetFirstIteratorRow(PixelIterator *iterator)
814 % A description of each parameter follows:
816 % o iterator: the magick iterator.
819 WandExport void PixelSetFirstIteratorRow(PixelIterator *iterator)
821 assert(iterator != (PixelIterator *) NULL);
822 assert(iterator->signature == WandSignature);
823 if (iterator->debug != MagickFalse)
824 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
825 iterator->active=MagickFalse;
826 iterator->y=iterator->region.y;
830 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
834 % P i x e l S e t I t e r a t o r R o w %
838 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
840 % PixelSetIteratorRow() set the pixel iterator row.
842 % The format of the PixelSetIteratorRow method is:
844 % MagickBooleanType PixelSetIteratorRow(PixelIterator *iterator,
847 % A description of each parameter follows:
849 % o iterator: the pixel iterator.
852 WandExport MagickBooleanType PixelSetIteratorRow(PixelIterator *iterator,
855 assert(iterator != (const PixelIterator *) NULL);
856 assert(iterator->signature == WandSignature);
857 if (iterator->debug != MagickFalse)
858 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
859 if ((row < 0) || (row >= (ssize_t) iterator->region.height))
861 iterator->active=MagickTrue;
867 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
871 % P i x e l S e t L a s t I t e r a t o r R o w %
875 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
877 % PixelSetLastIteratorRow() sets the pixel iterator to the last pixel row.
879 % The format of the PixelSetLastIteratorRow method is:
881 % void PixelSetLastIteratorRow(PixelIterator *iterator)
883 % A description of each parameter follows:
885 % o iterator: the magick iterator.
888 WandExport void PixelSetLastIteratorRow(PixelIterator *iterator)
890 assert(iterator != (PixelIterator *) NULL);
891 assert(iterator->signature == WandSignature);
892 if (iterator->debug != MagickFalse)
893 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
894 iterator->active=MagickFalse;
895 iterator->y=(ssize_t) iterator->region.height-1;
899 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
903 % P i x e l S y n c I t e r a t o r %
907 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
909 % PixelSyncIterator() syncs the pixel iterator.
911 % The format of the PixelSyncIterator method is:
913 % MagickBooleanType PixelSyncIterator(PixelIterator *iterator)
915 % A description of each parameter follows:
917 % o iterator: the pixel iterator.
920 WandExport MagickBooleanType PixelSyncIterator(PixelIterator *iterator)
931 assert(iterator != (const PixelIterator *) NULL);
932 assert(iterator->signature == WandSignature);
933 if (iterator->debug != MagickFalse)
934 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
935 status=SetCacheViewStorageClass(iterator->view,DirectClass,
936 iterator->exception);
937 if (status == MagickFalse)
939 pixels=GetCacheViewAuthenticPixels(iterator->view,iterator->region.x,
940 iterator->region.y+iterator->y,iterator->region.width,1,
941 iterator->exception);
942 if (pixels == (Quantum *) NULL)
944 for (x=0; x < (ssize_t) iterator->region.width; x++)
946 PixelGetQuantumPixel(iterator->image,iterator->pixel_wands[x],pixels);
947 pixels+=GetPixelChannels(iterator->image);
949 if (SyncCacheViewAuthenticPixels(iterator->view,iterator->exception) == MagickFalse)