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-2013 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(
166 sizeof(*clone_iterator));
167 if (clone_iterator == (PixelIterator *) NULL)
168 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
170 (void) ResetMagickMemory(clone_iterator,0,sizeof(*clone_iterator));
171 clone_iterator->id=AcquireWandId();
172 (void) FormatLocaleString(clone_iterator->name,MaxTextExtent,"%s-%.20g",
173 PixelIteratorId,(double) clone_iterator->id);
174 clone_iterator->exception=AcquireExceptionInfo();
175 InheritException(clone_iterator->exception,iterator->exception);
176 clone_iterator->view=CloneCacheView(iterator->view);
177 clone_iterator->region=iterator->region;
178 clone_iterator->active=iterator->active;
179 clone_iterator->y=iterator->y;
180 clone_iterator->pixel_wands=ClonePixelWands((const PixelWand **)
181 iterator->pixel_wands,iterator->region.width);
182 clone_iterator->debug=iterator->debug;
183 if (clone_iterator->debug != MagickFalse)
184 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",
185 clone_iterator->name);
186 clone_iterator->signature=WandSignature;
187 return(clone_iterator);
191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
195 % D e s t r o y P i x e l I t e r a t o r %
199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
201 % DestroyPixelIterator() deallocates resources associated with a PixelIterator.
203 % The format of the DestroyPixelIterator method is:
205 % PixelIterator *DestroyPixelIterator(PixelIterator *iterator)
207 % A description of each parameter follows:
209 % o iterator: the pixel iterator.
212 WandExport PixelIterator *DestroyPixelIterator(PixelIterator *iterator)
214 assert(iterator != (const PixelIterator *) NULL);
215 assert(iterator->signature == WandSignature);
216 if (iterator->debug != MagickFalse)
217 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
218 iterator->view=DestroyCacheView(iterator->view);
219 iterator->pixel_wands=DestroyPixelWands(iterator->pixel_wands,
220 iterator->region.width);
221 iterator->exception=DestroyExceptionInfo(iterator->exception);
222 iterator->signature=(~WandSignature);
223 RelinquishWandId(iterator->id);
224 iterator=(PixelIterator *) RelinquishMagickMemory(iterator);
229 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
233 % I s P i x e l I t e r a t o r %
237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
239 % IsPixelIterator() returns MagickTrue if the iterator is verified as a pixel
242 % The format of the IsPixelIterator method is:
244 % MagickBooleanType IsPixelIterator(const PixelIterator *iterator)
246 % A description of each parameter follows:
248 % o iterator: the magick iterator.
251 WandExport MagickBooleanType IsPixelIterator(const PixelIterator *iterator)
256 if (iterator == (const PixelIterator *) NULL)
258 if (iterator->signature != WandSignature)
260 length=strlen(PixelIteratorId);
261 if (LocaleNCompare(iterator->name,PixelIteratorId,length) != 0)
267 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
271 % N e w P i x e l I t e r a t o r %
275 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
277 % NewPixelIterator() returns a new pixel iterator.
279 % The format of the NewPixelIterator method is:
281 % PixelIterator *NewPixelIterator(MagickWand *wand)
283 % A description of each parameter follows:
285 % o wand: the magick wand.
288 WandExport PixelIterator *NewPixelIterator(MagickWand *wand)
308 depth=MAGICKCORE_QUANTUM_DEPTH;
309 quantum=GetMagickQuantumDepth(&depth);
310 if (depth != MAGICKCORE_QUANTUM_DEPTH)
311 ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum);
312 assert(wand != (MagickWand *) NULL);
313 image=GetImageFromMagickWand(wand);
314 if (image == (Image *) NULL)
315 return((PixelIterator *) NULL);
316 exception=AcquireExceptionInfo();
317 view=AcquireVirtualCacheView(image);
318 if (view == (CacheView *) NULL)
319 return((PixelIterator *) NULL);
320 iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator));
321 if (iterator == (PixelIterator *) NULL)
322 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
323 GetExceptionMessage(errno));
324 (void) ResetMagickMemory(iterator,0,sizeof(*iterator));
325 iterator->id=AcquireWandId();
326 (void) FormatLocaleString(iterator->name,MaxTextExtent,"%s-%.20g",
327 PixelIteratorId,(double) iterator->id);
328 iterator->exception=exception;
330 SetGeometry(image,&iterator->region);
331 iterator->region.width=image->columns;
332 iterator->region.height=image->rows;
333 iterator->region.x=0;
334 iterator->region.y=0;
335 iterator->pixel_wands=NewPixelWands(iterator->region.width);
337 iterator->debug=IsEventLogging();
338 if (iterator->debug != MagickFalse)
339 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
340 iterator->signature=WandSignature;
345 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
349 % 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 %
353 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
355 % PixelClearIteratorException() clear any exceptions associated with the
358 % The format of the PixelClearIteratorException method is:
360 % MagickBooleanType PixelClearIteratorException(PixelIterator *iterator)
362 % A description of each parameter follows:
364 % o iterator: the pixel iterator.
367 WandExport MagickBooleanType PixelClearIteratorException(
368 PixelIterator *iterator)
370 assert(iterator != (PixelIterator *) NULL);
371 assert(iterator->signature == WandSignature);
372 if (iterator->debug != MagickFalse)
373 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
374 ClearMagickException(iterator->exception);
379 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383 % N e w P i x e l R e g i o n I t e r a t o r %
387 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
389 % NewPixelRegionIterator() returns a new pixel iterator.
391 % The format of the NewPixelRegionIterator method is:
393 % PixelIterator *NewPixelRegionIterator(MagickWand *wand,const ssize_t x,
394 % const ssize_t y,const size_t width,const size_t height)
396 % A description of each parameter follows:
398 % o wand: the magick wand.
400 % o x,y,columns,rows: These values define the perimeter of a region of
404 WandExport PixelIterator *NewPixelRegionIterator(MagickWand *wand,
405 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 exception=AcquireExceptionInfo();
436 view=AcquireVirtualCacheView(image);
437 if (view == (CacheView *) NULL)
438 return((PixelIterator *) NULL);
439 iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator));
440 if (iterator == (PixelIterator *) NULL)
441 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
443 (void) ResetMagickMemory(iterator,0,sizeof(*iterator));
444 iterator->id=AcquireWandId();
445 (void) FormatLocaleString(iterator->name,MaxTextExtent,"%s-%.20g",
446 PixelIteratorId,(double) iterator->id);
447 iterator->exception=exception;
449 SetGeometry(image,&iterator->region);
450 iterator->region.width=width;
451 iterator->region.height=height;
452 iterator->region.x=x;
453 iterator->region.y=y;
454 iterator->pixel_wands=NewPixelWands(iterator->region.width);
456 iterator->debug=IsEventLogging();
457 if (iterator->debug != MagickFalse)
458 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
459 iterator->signature=WandSignature;
464 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
468 % 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 %
472 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
474 % PixelGetCurrentIteratorRow() returns the current row as an array of pixel
475 % wands from the pixel iterator.
477 % The format of the PixelGetCurrentIteratorRow method is:
479 % PixelWand **PixelGetCurrentIteratorRow(PixelIterator *iterator,
480 % size_t *number_wands)
482 % A description of each parameter follows:
484 % o iterator: the pixel iterator.
486 % o number_wands: the number of pixel wands.
489 WandExport PixelWand **PixelGetCurrentIteratorRow(PixelIterator *iterator,
490 size_t *number_wands)
492 register const Quantum
498 assert(iterator != (PixelIterator *) NULL);
499 assert(iterator->signature == WandSignature);
500 if (iterator->debug != MagickFalse)
501 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
503 iterator->active=MagickTrue;
504 pixels=GetCacheViewVirtualPixels(iterator->view,iterator->region.x,
505 iterator->region.y+iterator->y,iterator->region.width,1,
506 iterator->exception);
507 if (pixels == (const Quantum *) NULL)
508 return((PixelWand **) NULL);
509 for (x=0; x < (ssize_t) iterator->region.width; x++)
511 PixelSetQuantumPixel(GetCacheViewImage(iterator->view),pixels,
512 iterator->pixel_wands[x]);
513 pixels+=GetPixelChannels(GetCacheViewImage(iterator->view));
515 *number_wands=iterator->region.width;
516 return(iterator->pixel_wands);
520 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
524 % 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 %
528 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
530 % PixelGetIteratorException() returns the severity, reason, and description of
531 % any error that occurs when using other methods in this API.
533 % The format of the PixelGetIteratorException method is:
535 % char *PixelGetIteratorException(const PixelIterator *iterator,
536 % ExceptionType *severity)
538 % A description of each parameter follows:
540 % o iterator: the pixel iterator.
542 % o severity: the severity of the error is returned here.
545 WandExport char *PixelGetIteratorException(const PixelIterator *iterator,
546 ExceptionType *severity)
551 assert(iterator != (const PixelIterator *) NULL);
552 assert(iterator->signature == WandSignature);
553 if (iterator->debug != MagickFalse)
554 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
555 assert(severity != (ExceptionType *) NULL);
556 *severity=iterator->exception->severity;
557 description=(char *) AcquireQuantumMemory(2UL*MaxTextExtent,
558 sizeof(*description));
559 if (description == (char *) NULL)
560 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
563 if (iterator->exception->reason != (char *) NULL)
564 (void) CopyMagickString(description,GetLocaleExceptionMessage(
565 iterator->exception->severity,iterator->exception->reason),MaxTextExtent);
566 if (iterator->exception->description != (char *) NULL)
568 (void) ConcatenateMagickString(description," (",MaxTextExtent);
569 (void) ConcatenateMagickString(description,GetLocaleExceptionMessage(
570 iterator->exception->severity,iterator->exception->description),
572 (void) ConcatenateMagickString(description,")",MaxTextExtent);
578 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
582 % P i x e l G e t E x c e p t i o n T y p e %
586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
588 % PixelGetIteratorExceptionType() the exception type associated with the
589 % iterator. If no exception has occurred, UndefinedExceptionType is returned.
591 % The format of the PixelGetIteratorExceptionType method is:
593 % ExceptionType PixelGetIteratorExceptionType(
594 % const PixelIterator *iterator)
596 % A description of each parameter follows:
598 % o iterator: the pixel iterator.
601 WandExport ExceptionType PixelGetIteratorExceptionType(
602 const PixelIterator *iterator)
604 assert(iterator != (const PixelIterator *) NULL);
605 assert(iterator->signature == WandSignature);
606 if (iterator->debug != MagickFalse)
607 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
608 return(iterator->exception->severity);
612 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
616 % P i x e l G e t I t e r a t o r R o w %
620 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
622 % PixelGetIteratorRow() returns the current pixel iterator row.
624 % The format of the PixelGetIteratorRow method is:
626 % MagickBooleanType PixelGetIteratorRow(PixelIterator *iterator)
628 % A description of each parameter follows:
630 % o iterator: the pixel iterator.
633 WandExport ssize_t PixelGetIteratorRow(PixelIterator *iterator)
635 assert(iterator != (const PixelIterator *) NULL);
636 assert(iterator->signature == WandSignature);
637 if (iterator->debug != MagickFalse)
638 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
643 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
647 % P i x e l G e t N e x t I t e r a t o r R o w %
651 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
653 % PixelGetNextIteratorRow() returns the next row as an array of pixel wands
654 % from the pixel iterator.
656 % The format of the PixelGetNextIteratorRow method is:
658 % PixelWand **PixelGetNextIteratorRow(PixelIterator *iterator,
659 % size_t *number_wands)
661 % A description of each parameter follows:
663 % o iterator: the pixel iterator.
665 % o number_wands: the number of pixel wands.
668 WandExport PixelWand **PixelGetNextIteratorRow(PixelIterator *iterator,
669 size_t *number_wands)
671 register const Quantum
677 assert(iterator != (PixelIterator *) NULL);
678 assert(iterator->signature == WandSignature);
679 if (iterator->debug != MagickFalse)
680 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
682 if (iterator->active != MagickFalse)
684 if (PixelSetIteratorRow(iterator,iterator->y) == MagickFalse)
685 return((PixelWand **) NULL);
686 pixels=GetCacheViewVirtualPixels(iterator->view,iterator->region.x,
687 iterator->region.y+iterator->y,iterator->region.width,1,
688 iterator->exception);
689 if (pixels == (const Quantum *) NULL)
690 return((PixelWand **) NULL);
691 for (x=0; x < (ssize_t) iterator->region.width; x++)
693 PixelSetQuantumPixel(GetCacheViewImage(iterator->view),pixels,
694 iterator->pixel_wands[x]);
695 pixels+=GetPixelChannels(GetCacheViewImage(iterator->view));
697 *number_wands=iterator->region.width;
698 return(iterator->pixel_wands);
702 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
706 % 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 %
710 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
712 % PixelGetPreviousIteratorRow() returns the previous row as an array of pixel
713 % wands from the pixel iterator.
715 % The format of the PixelGetPreviousIteratorRow method is:
717 % PixelWand **PixelGetPreviousIteratorRow(PixelIterator *iterator,
718 % size_t *number_wands)
720 % A description of each parameter follows:
722 % o iterator: the pixel iterator.
724 % o number_wands: the number of pixel wands.
727 WandExport PixelWand **PixelGetPreviousIteratorRow(PixelIterator *iterator,
728 size_t *number_wands)
730 register const Quantum
736 assert(iterator != (PixelIterator *) NULL);
737 assert(iterator->signature == WandSignature);
738 if (iterator->debug != MagickFalse)
739 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
741 if (iterator->active != MagickFalse)
743 if (PixelSetIteratorRow(iterator,iterator->y) == MagickFalse)
744 return((PixelWand **) NULL);
745 pixels=GetCacheViewVirtualPixels(iterator->view,iterator->region.x,
746 iterator->region.y+iterator->y,iterator->region.width,1,
747 iterator->exception);
748 if (pixels == (const Quantum *) NULL)
749 return((PixelWand **) NULL);
750 for (x=0; x < (ssize_t) iterator->region.width; x++)
752 PixelSetQuantumPixel(GetCacheViewImage(iterator->view),pixels,
753 iterator->pixel_wands[x]);
754 pixels+=GetPixelChannels(GetCacheViewImage(iterator->view));
756 *number_wands=iterator->region.width;
757 return(iterator->pixel_wands);
761 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
765 % P i x e l R e s e t I t e r a t o r %
769 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771 % PixelResetIterator() resets the pixel iterator. Use it in conjunction
772 % with PixelGetNextIteratorRow() to iterate over all the pixels in a pixel
775 % The format of the PixelResetIterator method is:
777 % void PixelResetIterator(PixelIterator *iterator)
779 % A description of each parameter follows:
781 % o iterator: the pixel iterator.
784 WandExport void PixelResetIterator(PixelIterator *iterator)
786 assert(iterator != (PixelIterator *) NULL);
787 assert(iterator->signature == WandSignature);
788 if (iterator->debug != MagickFalse)
789 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
790 iterator->active=MagickFalse;
795 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
799 % P i x e l S e t F i r s t I t e r a t o r R o w %
803 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
805 % PixelSetFirstIteratorRow() sets the pixel iterator to the first pixel row.
807 % The format of the PixelSetFirstIteratorRow method is:
809 % void PixelSetFirstIteratorRow(PixelIterator *iterator)
811 % A description of each parameter follows:
813 % o iterator: the magick iterator.
816 WandExport void PixelSetFirstIteratorRow(PixelIterator *iterator)
818 assert(iterator != (PixelIterator *) NULL);
819 assert(iterator->signature == WandSignature);
820 if (iterator->debug != MagickFalse)
821 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
822 iterator->active=MagickFalse;
823 iterator->y=iterator->region.y;
827 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
831 % P i x e l S e t I t e r a t o r R o w %
835 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
837 % PixelSetIteratorRow() set the pixel iterator row.
839 % The format of the PixelSetIteratorRow method is:
841 % MagickBooleanType PixelSetIteratorRow(PixelIterator *iterator,
844 % A description of each parameter follows:
846 % o iterator: the pixel iterator.
849 WandExport MagickBooleanType PixelSetIteratorRow(PixelIterator *iterator,
852 assert(iterator != (const PixelIterator *) NULL);
853 assert(iterator->signature == WandSignature);
854 if (iterator->debug != MagickFalse)
855 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
856 if ((row < 0) || (row >= (ssize_t) iterator->region.height))
858 iterator->active=MagickTrue;
864 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
868 % P i x e l S e t L a s t I t e r a t o r R o w %
872 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
874 % PixelSetLastIteratorRow() sets the pixel iterator to the last pixel row.
876 % The format of the PixelSetLastIteratorRow method is:
878 % void PixelSetLastIteratorRow(PixelIterator *iterator)
880 % A description of each parameter follows:
882 % o iterator: the magick iterator.
885 WandExport void PixelSetLastIteratorRow(PixelIterator *iterator)
887 assert(iterator != (PixelIterator *) NULL);
888 assert(iterator->signature == WandSignature);
889 if (iterator->debug != MagickFalse)
890 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
891 iterator->active=MagickFalse;
892 iterator->y=(ssize_t) iterator->region.height-1;
896 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
900 % P i x e l S y n c I t e r a t o r %
904 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
906 % PixelSyncIterator() syncs the pixel iterator.
908 % The format of the PixelSyncIterator method is:
910 % MagickBooleanType PixelSyncIterator(PixelIterator *iterator)
912 % A description of each parameter follows:
914 % o iterator: the pixel iterator.
917 WandExport MagickBooleanType PixelSyncIterator(PixelIterator *iterator)
928 assert(iterator != (const PixelIterator *) NULL);
929 assert(iterator->signature == WandSignature);
930 if (iterator->debug != MagickFalse)
931 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
932 status=SetCacheViewStorageClass(iterator->view,DirectClass,
933 iterator->exception);
934 if (status == MagickFalse)
936 pixels=GetCacheViewAuthenticPixels(iterator->view,iterator->region.x,
937 iterator->region.y+iterator->y,iterator->region.width,1,
938 iterator->exception);
939 if (pixels == (Quantum *) NULL)
941 for (x=0; x < (ssize_t) iterator->region.width; x++)
943 PixelGetQuantumPixel(GetCacheViewImage(iterator->view),
944 iterator->pixel_wands[x],pixels);
945 pixels+=GetPixelChannels(GetCacheViewImage(iterator->view));
947 if (SyncCacheViewAuthenticPixels(iterator->view,iterator->exception) == MagickFalse)