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-2014 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"
82 active; /* user has been given pixel data */
98 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102 % C l e a r P i x e l I t e r a t o r %
106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108 % ClearPixelIterator() clear resources associated with a PixelIterator.
110 % The format of the ClearPixelIterator method is:
112 % void ClearPixelIterator(PixelIterator *iterator)
114 % A description of each parameter follows:
116 % o iterator: the pixel iterator.
119 WandExport void ClearPixelIterator(PixelIterator *iterator)
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;
131 iterator->debug=IsEventLogging();
135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
139 % C l o n e P i x e l I t e r a t o r %
143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
145 % ClonePixelIterator() makes an exact copy of the specified iterator.
147 % The format of the ClonePixelIterator method is:
149 % PixelIterator *ClonePixelIterator(const PixelIterator *iterator)
151 % A description of each parameter follows:
153 % o iterator: the magick iterator.
156 WandExport PixelIterator *ClonePixelIterator(const PixelIterator *iterator)
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",
169 (void) ResetMagickMemory(clone_iterator,0,sizeof(*clone_iterator));
170 clone_iterator->id=AcquireWandId();
171 (void) FormatLocaleString(clone_iterator->name,MaxTextExtent,"%s-%.20g",
172 PixelIteratorId,(double) 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);
190 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
194 % D e s t r o y P i x e l I t e r a t o r %
198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
200 % DestroyPixelIterator() deallocates resources associated with a PixelIterator.
202 % The format of the DestroyPixelIterator method is:
204 % PixelIterator *DestroyPixelIterator(PixelIterator *iterator)
206 % A description of each parameter follows:
208 % o iterator: the pixel iterator.
211 WandExport PixelIterator *DestroyPixelIterator(PixelIterator *iterator)
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);
228 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
232 % I s P i x e l I t e r a t o r %
236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
238 % IsPixelIterator() returns MagickTrue if the iterator is verified as a pixel
241 % The format of the IsPixelIterator method is:
243 % MagickBooleanType IsPixelIterator(const PixelIterator *iterator)
245 % A description of each parameter follows:
247 % o iterator: the magick iterator.
250 WandExport MagickBooleanType IsPixelIterator(const PixelIterator *iterator)
255 if (iterator == (const PixelIterator *) NULL)
257 if (iterator->signature != WandSignature)
259 length=strlen(PixelIteratorId);
260 if (LocaleNCompare(iterator->name,PixelIteratorId,length) != 0)
266 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
270 % N e w P i x e l I t e r a t o r %
274 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
276 % NewPixelIterator() returns a new pixel iterator.
278 % The format of the NewPixelIterator method is:
280 % PixelIterator *NewPixelIterator(MagickWand *wand)
282 % A description of each parameter follows:
284 % o wand: the magick wand.
287 WandExport PixelIterator *NewPixelIterator(MagickWand *wand)
307 depth=MAGICKCORE_QUANTUM_DEPTH;
308 quantum=GetMagickQuantumDepth(&depth);
309 if (depth != MAGICKCORE_QUANTUM_DEPTH)
310 ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum);
311 assert(wand != (MagickWand *) NULL);
312 image=GetImageFromMagickWand(wand);
313 if (image == (Image *) NULL)
314 return((PixelIterator *) NULL);
315 exception=AcquireExceptionInfo();
316 view=AcquireVirtualCacheView(image,exception);
317 if (view == (CacheView *) NULL)
318 return((PixelIterator *) NULL);
319 iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator));
320 if (iterator == (PixelIterator *) NULL)
321 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
322 GetExceptionMessage(errno));
323 (void) ResetMagickMemory(iterator,0,sizeof(*iterator));
324 iterator->id=AcquireWandId();
325 (void) FormatLocaleString(iterator->name,MaxTextExtent,"%s-%.20g",
326 PixelIteratorId,(double) iterator->id);
327 iterator->exception=exception;
329 SetGeometry(image,&iterator->region);
330 iterator->region.width=image->columns;
331 iterator->region.height=image->rows;
332 iterator->region.x=0;
333 iterator->region.y=0;
334 iterator->pixel_wands=NewPixelWands(iterator->region.width);
336 iterator->debug=IsEventLogging();
337 if (iterator->debug != MagickFalse)
338 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
339 iterator->signature=WandSignature;
344 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
348 % 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 %
352 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
354 % PixelClearIteratorException() clear any exceptions associated with the
357 % The format of the PixelClearIteratorException method is:
359 % MagickBooleanType PixelClearIteratorException(PixelIterator *iterator)
361 % A description of each parameter follows:
363 % o iterator: the pixel iterator.
366 WandExport MagickBooleanType PixelClearIteratorException(
367 PixelIterator *iterator)
369 assert(iterator != (PixelIterator *) NULL);
370 assert(iterator->signature == WandSignature);
371 if (iterator->debug != MagickFalse)
372 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
373 ClearMagickException(iterator->exception);
378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
382 % N e w P i x e l R e g i o n I t e r a t o r %
386 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
388 % NewPixelRegionIterator() returns a new pixel iterator.
390 % The format of the NewPixelRegionIterator method is:
392 % PixelIterator *NewPixelRegionIterator(MagickWand *wand,const ssize_t x,
393 % const ssize_t y,const size_t width,const size_t height)
395 % A description of each parameter follows:
397 % o wand: the magick wand.
399 % o x,y,columns,rows: These values define the perimeter of a region of
403 WandExport PixelIterator *NewPixelRegionIterator(MagickWand *wand,
404 const ssize_t x,const ssize_t y,const size_t width,const size_t height)
424 assert(wand != (MagickWand *) NULL);
425 depth=MAGICKCORE_QUANTUM_DEPTH;
426 quantum=GetMagickQuantumDepth(&depth);
427 if (depth != MAGICKCORE_QUANTUM_DEPTH)
428 ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum);
429 if ((width == 0) || (height == 0))
430 ThrowWandFatalException(WandError,"ZeroRegionSize",quantum);
431 image=GetImageFromMagickWand(wand);
432 if (image == (Image *) NULL)
433 return((PixelIterator *) NULL);
434 exception=AcquireExceptionInfo();
435 view=AcquireVirtualCacheView(image,exception);
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=exception;
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(GetCacheViewImage(iterator->view),pixels,
511 iterator->pixel_wands[x]);
512 pixels+=GetPixelChannels(GetCacheViewImage(iterator->view));
514 *number_wands=iterator->region.width;
515 return(iterator->pixel_wands);
519 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 %
527 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
529 % PixelGetIteratorException() returns the severity, reason, and description of
530 % any error that occurs when using other methods in this API.
532 % The format of the PixelGetIteratorException method is:
534 % char *PixelGetIteratorException(const PixelIterator *iterator,
535 % ExceptionType *severity)
537 % A description of each parameter follows:
539 % o iterator: the pixel iterator.
541 % o severity: the severity of the error is returned here.
544 WandExport char *PixelGetIteratorException(const PixelIterator *iterator,
545 ExceptionType *severity)
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",
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)
567 (void) ConcatenateMagickString(description," (",MaxTextExtent);
568 (void) ConcatenateMagickString(description,GetLocaleExceptionMessage(
569 iterator->exception->severity,iterator->exception->description),
571 (void) ConcatenateMagickString(description,")",MaxTextExtent);
577 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
581 % P i x e l G e t E x c e p t i o n T y p e %
585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
587 % PixelGetIteratorExceptionType() the exception type associated with the
588 % iterator. If no exception has occurred, UndefinedExceptionType is returned.
590 % The format of the PixelGetIteratorExceptionType method is:
592 % ExceptionType PixelGetIteratorExceptionType(
593 % const PixelIterator *iterator)
595 % A description of each parameter follows:
597 % o iterator: the pixel iterator.
600 WandExport ExceptionType PixelGetIteratorExceptionType(
601 const PixelIterator *iterator)
603 assert(iterator != (const PixelIterator *) NULL);
604 assert(iterator->signature == WandSignature);
605 if (iterator->debug != MagickFalse)
606 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
607 return(iterator->exception->severity);
611 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
615 % P i x e l G e t I t e r a t o r R o w %
619 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
621 % PixelGetIteratorRow() returns the current pixel iterator row.
623 % The format of the PixelGetIteratorRow method is:
625 % MagickBooleanType PixelGetIteratorRow(PixelIterator *iterator)
627 % A description of each parameter follows:
629 % o iterator: the pixel iterator.
632 WandExport ssize_t PixelGetIteratorRow(PixelIterator *iterator)
634 assert(iterator != (const PixelIterator *) NULL);
635 assert(iterator->signature == WandSignature);
636 if (iterator->debug != MagickFalse)
637 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
642 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
646 % P i x e l G e t N e x t I t e r a t o r R o w %
650 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
652 % PixelGetNextIteratorRow() returns the next row as an array of pixel wands
653 % from the pixel iterator.
655 % The format of the PixelGetNextIteratorRow method is:
657 % PixelWand **PixelGetNextIteratorRow(PixelIterator *iterator,
658 % size_t *number_wands)
660 % A description of each parameter follows:
662 % o iterator: the pixel iterator.
664 % o number_wands: the number of pixel wands.
667 WandExport PixelWand **PixelGetNextIteratorRow(PixelIterator *iterator,
668 size_t *number_wands)
670 register const Quantum
676 assert(iterator != (PixelIterator *) NULL);
677 assert(iterator->signature == WandSignature);
678 if (iterator->debug != MagickFalse)
679 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
681 if (iterator->active != MagickFalse)
683 if (PixelSetIteratorRow(iterator,iterator->y) == MagickFalse)
684 return((PixelWand **) NULL);
685 pixels=GetCacheViewVirtualPixels(iterator->view,iterator->region.x,
686 iterator->region.y+iterator->y,iterator->region.width,1,
687 iterator->exception);
688 if (pixels == (const Quantum *) NULL)
689 return((PixelWand **) NULL);
690 for (x=0; x < (ssize_t) iterator->region.width; x++)
692 PixelSetQuantumPixel(GetCacheViewImage(iterator->view),pixels,
693 iterator->pixel_wands[x]);
694 pixels+=GetPixelChannels(GetCacheViewImage(iterator->view));
696 *number_wands=iterator->region.width;
697 return(iterator->pixel_wands);
701 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
705 % 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 %
709 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
711 % PixelGetPreviousIteratorRow() returns the previous row as an array of pixel
712 % wands from the pixel iterator.
714 % The format of the PixelGetPreviousIteratorRow method is:
716 % PixelWand **PixelGetPreviousIteratorRow(PixelIterator *iterator,
717 % size_t *number_wands)
719 % A description of each parameter follows:
721 % o iterator: the pixel iterator.
723 % o number_wands: the number of pixel wands.
726 WandExport PixelWand **PixelGetPreviousIteratorRow(PixelIterator *iterator,
727 size_t *number_wands)
729 register const Quantum
735 assert(iterator != (PixelIterator *) NULL);
736 assert(iterator->signature == WandSignature);
737 if (iterator->debug != MagickFalse)
738 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
740 if (iterator->active != MagickFalse)
742 if (PixelSetIteratorRow(iterator,iterator->y) == MagickFalse)
743 return((PixelWand **) NULL);
744 pixels=GetCacheViewVirtualPixels(iterator->view,iterator->region.x,
745 iterator->region.y+iterator->y,iterator->region.width,1,
746 iterator->exception);
747 if (pixels == (const Quantum *) NULL)
748 return((PixelWand **) NULL);
749 for (x=0; x < (ssize_t) iterator->region.width; x++)
751 PixelSetQuantumPixel(GetCacheViewImage(iterator->view),pixels,
752 iterator->pixel_wands[x]);
753 pixels+=GetPixelChannels(GetCacheViewImage(iterator->view));
755 *number_wands=iterator->region.width;
756 return(iterator->pixel_wands);
760 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
764 % P i x e l R e s e t I t e r a t o r %
768 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
770 % PixelResetIterator() resets the pixel iterator. Use it in conjunction
771 % with PixelGetNextIteratorRow() to iterate over all the pixels in a pixel
774 % The format of the PixelResetIterator method is:
776 % void PixelResetIterator(PixelIterator *iterator)
778 % A description of each parameter follows:
780 % o iterator: the pixel iterator.
783 WandExport void PixelResetIterator(PixelIterator *iterator)
785 assert(iterator != (PixelIterator *) NULL);
786 assert(iterator->signature == WandSignature);
787 if (iterator->debug != MagickFalse)
788 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
789 iterator->active=MagickFalse;
794 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
798 % P i x e l S e t F i r s t I t e r a t o r R o w %
802 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
804 % PixelSetFirstIteratorRow() sets the pixel iterator to the first pixel row.
806 % The format of the PixelSetFirstIteratorRow method is:
808 % void PixelSetFirstIteratorRow(PixelIterator *iterator)
810 % A description of each parameter follows:
812 % o iterator: the magick iterator.
815 WandExport void PixelSetFirstIteratorRow(PixelIterator *iterator)
817 assert(iterator != (PixelIterator *) NULL);
818 assert(iterator->signature == WandSignature);
819 if (iterator->debug != MagickFalse)
820 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
821 iterator->active=MagickFalse;
822 iterator->y=iterator->region.y;
826 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
830 % P i x e l S e t I t e r a t o r R o w %
834 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
836 % PixelSetIteratorRow() set the pixel iterator row.
838 % The format of the PixelSetIteratorRow method is:
840 % MagickBooleanType PixelSetIteratorRow(PixelIterator *iterator,
843 % A description of each parameter follows:
845 % o iterator: the pixel iterator.
848 WandExport MagickBooleanType PixelSetIteratorRow(PixelIterator *iterator,
851 assert(iterator != (const PixelIterator *) NULL);
852 assert(iterator->signature == WandSignature);
853 if (iterator->debug != MagickFalse)
854 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
855 if ((row < 0) || (row >= (ssize_t) iterator->region.height))
857 iterator->active=MagickTrue;
863 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
867 % P i x e l S e t L a s t I t e r a t o r R o w %
871 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
873 % PixelSetLastIteratorRow() sets the pixel iterator to the last pixel row.
875 % The format of the PixelSetLastIteratorRow method is:
877 % void PixelSetLastIteratorRow(PixelIterator *iterator)
879 % A description of each parameter follows:
881 % o iterator: the magick iterator.
884 WandExport void PixelSetLastIteratorRow(PixelIterator *iterator)
886 assert(iterator != (PixelIterator *) NULL);
887 assert(iterator->signature == WandSignature);
888 if (iterator->debug != MagickFalse)
889 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
890 iterator->active=MagickFalse;
891 iterator->y=(ssize_t) iterator->region.height-1;
895 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
899 % P i x e l S y n c I t e r a t o r %
903 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
905 % PixelSyncIterator() syncs the pixel iterator.
907 % The format of the PixelSyncIterator method is:
909 % MagickBooleanType PixelSyncIterator(PixelIterator *iterator)
911 % A description of each parameter follows:
913 % o iterator: the pixel iterator.
916 WandExport MagickBooleanType PixelSyncIterator(PixelIterator *iterator)
927 assert(iterator != (const PixelIterator *) NULL);
928 assert(iterator->signature == WandSignature);
929 if (iterator->debug != MagickFalse)
930 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
931 status=SetCacheViewStorageClass(iterator->view,DirectClass,
932 iterator->exception);
933 if (status == MagickFalse)
935 pixels=GetCacheViewAuthenticPixels(iterator->view,iterator->region.x,
936 iterator->region.y+iterator->y,iterator->region.width,1,
937 iterator->exception);
938 if (pixels == (Quantum *) NULL)
940 for (x=0; x < (ssize_t) iterator->region.width; x++)
942 PixelGetQuantumPixel(GetCacheViewImage(iterator->view),
943 iterator->pixel_wands[x],pixels);
944 pixels+=GetPixelChannels(GetCacheViewImage(iterator->view));
946 if (SyncCacheViewAuthenticPixels(iterator->view,iterator->exception) == MagickFalse)