/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % P i x e l S y n c I t e r a t o r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % PixelSyncIterator() syncs the pixel iterator. % % The format of the PixelSyncIterator method is: % % MagickBooleanType PixelSyncIterator(PixelIterator *iterator) % % A description of each parameter follows: % % o iterator: the pixel iterator. % */ WandExport MagickBooleanType PixelSyncIterator(PixelIterator *iterator) { MagickBooleanType status; register ssize_t x; register Quantum *_magickcore_restrict pixels; assert(iterator != (const PixelIterator *) NULL); assert(iterator->signature == MagickWandSignature); if (iterator->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); status=SetCacheViewStorageClass(iterator->view,DirectClass, iterator->exception); if (status == MagickFalse) return(MagickFalse); pixels=GetCacheViewAuthenticPixels(iterator->view,iterator->region.x, iterator->region.y+iterator->y,iterator->region.width,1, iterator->exception); if (pixels == (Quantum *) NULL) return(MagickFalse); for (x=0; x < (ssize_t) iterator->region.width; x++) { PixelGetQuantumPixel(GetCacheViewImage(iterator->view), iterator->pixel_wands[x],pixels); pixels+=GetPixelChannels(GetCacheViewImage(iterator->view)); } if (SyncCacheViewAuthenticPixels(iterator->view,iterator->exception) == MagickFalse) return(MagickFalse); return(MagickTrue); }
MAGICK_NET_EXPORT void PixelCollection_SetArea(CacheView *instance, const size_t x, const size_t y, const size_t width, const size_t height, const Quantum *values, const size_t length, ExceptionInfo **exception) { const Quantum *q; const Image *image; size_t len, r, size; Quantum *pixels; MAGICK_NET_GET_EXCEPTION; image = GetCacheViewImage(instance); q = values; size = image->number_channels*width; for (r = 0; r < height; r++) { pixels = QueueCacheViewAuthenticPixels(instance, x, y + r, width, 1, exceptionInfo); if (pixels == (Quantum *)NULL) break; len = length - (size*r); memcpy(pixels, q, (size < len ? size : len)*sizeof(*pixels)); if (SyncCacheViewAuthenticPixels(instance, exceptionInfo) == MagickFalse) break; if (size > len) break; q += size; } MAGICK_NET_SET_EXCEPTION; }
MAGICK_NET_EXPORT unsigned short *PixelCollection_ToShortArray(const CacheView *instance, const size_t x, const size_t y, const size_t width, const size_t height, const char *mapping, ExceptionInfo **exception) { ExportStart(unsigned short); result = AcquireMagickMemory(length); MAGICK_NET_GET_EXCEPTION; ExportImagePixels(GetCacheViewImage(instance), x, y, width, height, mapping, ShortPixel, result, exceptionInfo); MAGICK_NET_SET_EXCEPTION; return result; }