43#include "wand/studio.h"
44#include "wand/MagickWand.h"
45#include "wand/magick-wand-private.h"
47#include "magick/monitor-private.h"
48#include "magick/thread-private.h"
53#define PixelViewId "PixelView"
91#if !defined(MAGICKCORE_EXCLUDE_DEPRECATED)
117WandExport
DrawingWand *DrawAllocateWand(
const DrawInfo *draw_info,Image *image)
119 return(AcquireDrawingWand(draw_info,image));
152 assert(wand->signature == WandSignature);
153 if (wand->debug != MagickFalse)
154 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
155 clone_wand=(
MagickWand *) AcquireMagickMemory(
sizeof(*clone_wand));
157 ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
159 (void) memset(clone_wand,0,
sizeof(*clone_wand));
160 clone_wand->id=AcquireWandId();
161 (void) FormatLocaleString(clone_wand->name,MaxTextExtent,
"%s-%.20g",
162 MagickWandId,(
double) clone_wand->id);
163 clone_wand->exception=AcquireExceptionInfo();
164 InheritException(clone_wand->exception,wand->exception);
165 clone_wand->image_info=CloneImageInfo(wand->image_info);
166 clone_wand->quantize_info=CloneQuantizeInfo(wand->quantize_info);
167 clone_wand->images=images;
168 clone_wand->debug=IsEventLogging();
169 if (clone_wand->debug != MagickFalse)
170 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",clone_wand->name);
171 clone_wand->signature=WandSignature;
181 assert(wand->signature == WandSignature);
182 if (wand->debug != MagickFalse)
183 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
184 if (wand->images == (Image *) NULL)
186 average_image=EvaluateImages(wand->images,MeanEvaluateOperator,
188 if (average_image == (Image *) NULL)
190 return(CloneMagickWandFromImages(wand,average_image));
223 assert(pixel_view != (
PixelView *) NULL);
224 assert(pixel_view->signature == WandSignature);
225 if (pixel_view->debug != MagickFalse)
226 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",pixel_view->name);
227 clone_view=(
PixelView *) AcquireMagickMemory(
sizeof(*clone_view));
229 ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
231 (void) memset(clone_view,0,
sizeof(*clone_view));
232 clone_view->id=AcquireWandId();
233 (void) FormatLocaleString(clone_view->name,MaxTextExtent,
"%s-%.20g",
234 PixelViewId,(
double) clone_view->id);
235 clone_view->exception=AcquireExceptionInfo();
236 InheritException(clone_view->exception,pixel_view->exception);
237 clone_view->view=CloneCacheView(pixel_view->view);
238 clone_view->region=pixel_view->region;
239 clone_view->number_threads=pixel_view->number_threads;
240 for (i=0; i < (ssize_t) pixel_view->number_threads; i++)
241 clone_view->pixel_wands[i]=ClonePixelWands((
const PixelWand **)
242 pixel_view->pixel_wands[i],pixel_view->region.width);
243 clone_view->debug=pixel_view->debug;
244 if (clone_view->debug != MagickFalse)
245 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",clone_view->name);
246 clone_view->signature=WandSignature;
279 const size_t number_wands,
const size_t number_threads)
284 assert(pixel_wands != (
PixelWand ***) NULL);
285 for (i=0; i < (ssize_t) number_threads; i++)
286 if (pixel_wands[i] != (
PixelWand **) NULL)
287 pixel_wands[i]=DestroyPixelWands(pixel_wands[i],number_wands);
288 pixel_wands=(
PixelWand ***) RelinquishMagickMemory(pixel_wands);
294 assert(pixel_view != (
PixelView *) NULL);
295 assert(pixel_view->signature == WandSignature);
296 pixel_view->pixel_wands=DestroyPixelsTLS(pixel_view->pixel_wands,
297 pixel_view->region.width,pixel_view->number_threads);
298 pixel_view->view=DestroyCacheView(pixel_view->view);
299 pixel_view->exception=DestroyExceptionInfo(pixel_view->exception);
300 pixel_view->signature=(~WandSignature);
301 RelinquishWandId(pixel_view->id);
302 pixel_view=(
PixelView *) RelinquishMagickMemory(pixel_view);
351WandExport MagickBooleanType DuplexTransferPixelViewIterator(
353 DuplexTransferPixelViewMethod transfer,
void *context)
355#define DuplexTransferPixelViewTag "PixelView/DuplexTransfer"
375 assert(source->signature == WandSignature);
376 if (transfer == (DuplexTransferPixelViewMethod) NULL)
378 source_image=source->wand->images;
379 duplex_image=duplex->wand->images;
380 destination_image=destination->wand->images;
381 if (SetImageStorageClass(destination_image,DirectClass) == MagickFalse)
385 exception=destination->exception;
386#if defined(MAGICKCORE_OPENMP_SUPPORT)
387 #pragma omp parallel for schedule(static) shared(progress,status)
389 for (y=source->region.y; y < (ssize_t) source->region.height; y++)
392 id = GetOpenMPThreadId();
398 *magick_restrict duplex_indexes,
399 *magick_restrict indexes;
402 *magick_restrict duplex_pixels,
403 *magick_restrict pixels;
406 *magick_restrict destination_indexes;
412 *magick_restrict destination_pixels;
414 if (status == MagickFalse)
416 pixels=GetCacheViewVirtualPixels(source->view,source->region.x,y,
417 source->region.width,1,source->exception);
418 if (pixels == (
const PixelPacket *) NULL)
423 indexes=GetCacheViewVirtualIndexQueue(source->view);
424 for (x=0; x < (ssize_t) source->region.width; x++)
425 PixelSetQuantumColor(source->pixel_wands[
id][x],pixels+x);
426 if (source_image->colorspace == CMYKColorspace)
427 for (x=0; x < (ssize_t) source->region.width; x++)
428 PixelSetBlackQuantum(source->pixel_wands[
id][x],
429 GetPixelIndex(indexes+x));
430 if (source_image->storage_class == PseudoClass)
431 for (x=0; x < (ssize_t) source->region.width; x++)
432 PixelSetIndex(source->pixel_wands[
id][x],
433 GetPixelIndex(indexes+x));
434 duplex_pixels=GetCacheViewVirtualPixels(duplex->view,duplex->region.x,y,
435 duplex->region.width,1,duplex->exception);
436 if (duplex_pixels == (
const PixelPacket *) NULL)
441 duplex_indexes=GetCacheViewVirtualIndexQueue(duplex->view);
442 for (x=0; x < (ssize_t) duplex->region.width; x++)
443 PixelSetQuantumColor(duplex->pixel_wands[
id][x],duplex_pixels+x);
444 if (duplex_image->colorspace == CMYKColorspace)
445 for (x=0; x < (ssize_t) duplex->region.width; x++)
446 PixelSetBlackQuantum(duplex->pixel_wands[
id][x],
447 GetPixelIndex(duplex_indexes+x));
448 if (duplex_image->storage_class == PseudoClass)
449 for (x=0; x < (ssize_t) duplex->region.width; x++)
450 PixelSetIndex(duplex->pixel_wands[
id][x],
451 GetPixelIndex(duplex_indexes+x));
452 destination_pixels=GetCacheViewAuthenticPixels(destination->view,
453 destination->region.x,y,destination->region.width,1,exception);
454 if (destination_pixels == (PixelPacket *) NULL)
459 destination_indexes=GetCacheViewAuthenticIndexQueue(destination->view);
460 for (x=0; x < (ssize_t) destination->region.width; x++)
461 PixelSetQuantumColor(destination->pixel_wands[
id][x],
462 destination_pixels+x);
463 if (destination_image->colorspace == CMYKColorspace)
464 for (x=0; x < (ssize_t) destination->region.width; x++)
465 PixelSetBlackQuantum(destination->pixel_wands[
id][x],
466 GetPixelIndex(destination_indexes+x));
467 if (destination_image->storage_class == PseudoClass)
468 for (x=0; x < (ssize_t) destination->region.width; x++)
469 PixelSetIndex(destination->pixel_wands[
id][x],
470 GetPixelIndex(destination_indexes+x));
471 if (transfer(source,duplex,destination,context) == MagickFalse)
473 for (x=0; x < (ssize_t) destination->region.width; x++)
474 PixelGetQuantumColor(destination->pixel_wands[
id][x],
475 destination_pixels+x);
476 if (destination_image->colorspace == CMYKColorspace)
477 for (x=0; x < (ssize_t) destination->region.width; x++)
478 SetPixelIndex(destination_indexes+x,PixelGetBlackQuantum(
479 destination->pixel_wands[
id][x]));
480 sync=SyncCacheViewAuthenticPixels(destination->view,exception);
481 if (sync == MagickFalse)
483 InheritException(destination->exception,GetCacheViewException(
487 if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
493#if defined(MAGICKCORE_OPENMP_SUPPORT)
497 proceed=SetImageProgress(source_image,DuplexTransferPixelViewTag,
498 progress,source->region.height);
499 if (proceed == MagickFalse)
532WandExport
char *GetPixelViewException(
const PixelView *pixel_view,
533 ExceptionType *severity)
538 assert(pixel_view != (
const PixelView *) NULL);
539 assert(pixel_view->signature == WandSignature);
540 if (pixel_view->debug != MagickFalse)
541 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",pixel_view->name);
542 assert(severity != (ExceptionType *) NULL);
543 *severity=pixel_view->exception->severity;
544 description=(
char *) AcquireQuantumMemory(2UL*MaxTextExtent,
545 sizeof(*description));
546 if (description == (
char *) NULL)
547 ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
550 if (pixel_view->exception->reason != (
char *) NULL)
551 (void) CopyMagickString(description,GetLocaleExceptionMessage(
552 pixel_view->exception->severity,pixel_view->exception->reason),
554 if (pixel_view->exception->description != (
char *) NULL)
556 (void) ConcatenateMagickString(description,
" (",MaxTextExtent);
557 (void) ConcatenateMagickString(description,GetLocaleExceptionMessage(
558 pixel_view->exception->severity,pixel_view->exception->description),
560 (void) ConcatenateMagickString(description,
")",MaxTextExtent);
587WandExport
size_t GetPixelViewHeight(
const PixelView *pixel_view)
589 assert(pixel_view != (
PixelView *) NULL);
590 assert(pixel_view->signature == WandSignature);
591 return(pixel_view->region.height);
632WandExport MagickBooleanType GetPixelViewIterator(
PixelView *source,
633 GetPixelViewMethod get,
void *context)
635#define GetPixelViewTag "PixelView/Get"
650 assert(source->signature == WandSignature);
651 if (get == (GetPixelViewMethod) NULL)
653 source_image=source->wand->images;
656#if defined(MAGICKCORE_OPENMP_SUPPORT)
657 #pragma omp parallel for schedule(static) shared(progress,status)
659 for (y=source->region.y; y < (ssize_t) source->region.height; y++)
662 id = GetOpenMPThreadId();
673 if (status == MagickFalse)
675 pixels=GetCacheViewVirtualPixels(source->view,source->region.x,y,
676 source->region.width,1,source->exception);
677 if (pixels == (
const PixelPacket *) NULL)
682 indexes=GetCacheViewVirtualIndexQueue(source->view);
683 for (x=0; x < (ssize_t) source->region.width; x++)
684 PixelSetQuantumColor(source->pixel_wands[
id][x],pixels+x);
685 if (source_image->colorspace == CMYKColorspace)
686 for (x=0; x < (ssize_t) source->region.width; x++)
687 PixelSetBlackQuantum(source->pixel_wands[
id][x],
688 GetPixelIndex(indexes+x));
689 if (source_image->storage_class == PseudoClass)
690 for (x=0; x < (ssize_t) source->region.width; x++)
691 PixelSetIndex(source->pixel_wands[
id][x],
692 GetPixelIndex(indexes+x));
693 if (get(source,context) == MagickFalse)
695 if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
700#if defined(MAGICKCORE_OPENMP_SUPPORT)
704 proceed=SetImageProgress(source_image,GetPixelViewTag,progress,
705 source->region.height);
706 if (proceed == MagickFalse)
738 id = GetOpenMPThreadId();
740 assert(pixel_view != (
PixelView *) NULL);
741 assert(pixel_view->signature == WandSignature);
742 return(pixel_view->pixel_wands[
id]);
769 assert(pixel_view != (
PixelView *) NULL);
770 assert(pixel_view->signature == WandSignature);
771 return(pixel_view->wand);
796WandExport
size_t GetPixelViewWidth(
const PixelView *pixel_view)
798 assert(pixel_view != (
PixelView *) NULL);
799 assert(pixel_view->signature == WandSignature);
800 return(pixel_view->region.width);
825WandExport ssize_t GetPixelViewX(
const PixelView *pixel_view)
827 assert(pixel_view != (
PixelView *) NULL);
828 assert(pixel_view->signature == WandSignature);
829 return(pixel_view->region.x);
854WandExport ssize_t GetPixelViewY(
const PixelView *pixel_view)
856 assert(pixel_view != (
PixelView *) NULL);
857 assert(pixel_view->signature == WandSignature);
858 return(pixel_view->region.y);
884WandExport MagickBooleanType IsPixelView(
const PixelView *pixel_view)
889 if (pixel_view == (
const PixelView *) NULL)
891 if (pixel_view->signature != WandSignature)
893 length=strlen(PixelViewId);
894 if (LocaleNCompare(pixel_view->name,PixelViewId,length) != 0)
931WandExport MagickBooleanType MagickClipPathImage(
MagickWand *wand,
932 const char *pathname,
const MagickBooleanType inside)
934 return(MagickClipImagePath(wand,pathname,inside));
959WandExport
double DrawGetFillAlpha(
const DrawingWand *wand)
961 return(DrawGetFillOpacity(wand));
985WandExport
double DrawGetStrokeAlpha(
const DrawingWand *wand)
987 return(DrawGetStrokeOpacity(wand));
1012WandExport DrawInfo *DrawPeekGraphicWand(
const DrawingWand *wand)
1014 return(PeekDrawingWand(wand));
1042WandExport
void DrawPopGraphicContext(
DrawingWand *wand)
1044 (void) PopDrawingWand(wand);
1072WandExport
void DrawPushGraphicContext(
DrawingWand *wand)
1074 (void) PushDrawingWand(wand);
1102WandExport
void DrawSetFillAlpha(
DrawingWand *wand,
const double fill_alpha)
1104 DrawSetFillOpacity(wand,fill_alpha);
1131WandExport
void DrawSetStrokeAlpha(
DrawingWand *wand,
const double stroke_alpha)
1133 DrawSetStrokeOpacity(wand,stroke_alpha);
1176WandExport MagickBooleanType MagickColorFloodfillImage(
MagickWand *wand,
1178 const ssize_t x,
const ssize_t y)
1190 assert(wand->signature == WandSignature);
1191 if (wand->debug != MagickFalse)
1192 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1193 if (wand->images == (Image *) NULL)
1194 ThrowWandException(WandError,
"ContainsNoImages",wand->name);
1195 draw_info=CloneDrawInfo(wand->image_info,(DrawInfo *) NULL);
1196 PixelGetQuantumColor(fill,&draw_info->fill);
1197 (void) GetOneVirtualPixel(wand->images,x % wand->images->columns,
1198 y % wand->images->rows,&target,wand->exception);
1200 PixelGetQuantumColor(bordercolor,&target);
1201 wand->images->fuzz=fuzz;
1202 status=ColorFloodfillImage(wand->images,draw_info,target,x,y,
1203 bordercolor != (
PixelWand *) NULL ? FillToBorderMethod : FloodfillMethod);
1204 if (status == MagickFalse)
1205 InheritException(wand->exception,&wand->images->exception);
1206 draw_info=DestroyDrawInfo(draw_info);
1233WandExport
char *MagickDescribeImage(
MagickWand *wand)
1235 return(MagickIdentifyImage(wand));
1267 assert(wand->signature == WandSignature);
1268 if (wand->debug != MagickFalse)
1269 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1270 if (wand->images == (Image *) NULL)
1272 flatten_image=FlattenImages(wand->images,wand->exception);
1273 if (flatten_image == (Image *) NULL)
1275 return(CloneMagickWandFromImages(wand,flatten_image));
1304WandExport
char *MagickGetImageAttribute(
MagickWand *wand,
const char *property)
1306 return(MagickGetImageProperty(wand,property));
1331WandExport ssize_t MagickGetImageIndex(
MagickWand *wand)
1333 return(MagickGetIteratorIndex(wand));
1366WandExport MagickBooleanType MagickGetImageChannelExtrema(
MagickWand *wand,
1367 const ChannelType channel,
size_t *minima,
size_t *maxima)
1373 assert(wand->signature == WandSignature);
1374 if (wand->debug != MagickFalse)
1375 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1376 if (wand->images == (Image *) NULL)
1377 ThrowWandException(WandError,
"ContainsNoImages",wand->name);
1378 status=GetImageChannelExtrema(wand->images,channel,minima,maxima,
1410WandExport MagickBooleanType MagickGetImageExtrema(
MagickWand *wand,
1411 size_t *minima,
size_t *maxima)
1417 assert(wand->signature == WandSignature);
1418 if (wand->debug != MagickFalse)
1419 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1420 if (wand->images == (Image *) NULL)
1421 ThrowWandException(WandError,
"ContainsNoImages",wand->name);
1422 status=GetImageExtrema(wand->images,minima,maxima,wand->exception);
1449WandExport MagickBooleanType MagickGetImageMatte(
MagickWand *wand)
1452 assert(wand->signature == WandSignature);
1453 if (wand->debug != MagickFalse)
1454 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1455 if (wand->images == (Image *) NULL)
1456 ThrowWandException(WandError,
"ContainsNoImages",wand->name);
1457 return(wand->images->matte);
1511WandExport MagickBooleanType MagickGetImagePixels(
MagickWand *wand,
1512 const ssize_t x,
const ssize_t y,
const size_t columns,
1513 const size_t rows,
const char *map,
const StorageType storage,
1516 return(MagickExportImagePixels(wand,x,y,columns,rows,map,storage,pixels));
1544WandExport MagickSizeType MagickGetImageSize(
MagickWand *wand)
1547 assert(wand->signature == WandSignature);
1548 if (wand->debug != MagickFalse)
1549 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1550 if (wand->images == (Image *) NULL)
1551 ThrowWandException(WandError,
"ContainsNoImages",wand->name);
1552 return(GetBlobSize(wand->images));
1584WandExport MagickBooleanType MagickMapImage(
MagickWand *wand,
1585 const MagickWand *map_wand,
const MagickBooleanType dither)
1591 assert(wand->signature == WandSignature);
1592 if (wand->debug != MagickFalse)
1593 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1594 if ((wand->images == (Image *) NULL) || (map_wand->images == (Image *) NULL))
1595 ThrowWandException(WandError,
"ContainsNoImages",wand->name);
1596 status=MapImage(wand->images,map_wand->images,dither);
1597 if (status == MagickFalse)
1598 InheritException(wand->exception,&wand->images->exception);
1643WandExport MagickBooleanType MagickMatteFloodfillImage(
MagickWand *wand,
1644 const double alpha,
const double fuzz,
const PixelWand *bordercolor,
1645 const ssize_t x,
const ssize_t y)
1657 assert(wand->signature == WandSignature);
1658 if (wand->debug != MagickFalse)
1659 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1660 if (wand->images == (Image *) NULL)
1661 ThrowWandException(WandError,
"ContainsNoImages",wand->name);
1662 draw_info=CloneDrawInfo(wand->image_info,(DrawInfo *) NULL);
1663 (void) GetOneVirtualPixel(wand->images,x % wand->images->columns,
1664 y % wand->images->rows,&target,wand->exception);
1666 PixelGetQuantumColor(bordercolor,&target);
1667 wand->images->fuzz=fuzz;
1668 status=MatteFloodfillImage(wand->images,target,ClampToQuantum(
1669 (
double) QuantumRange-(
double) QuantumRange*alpha),x,y,bordercolor !=
1670 (
PixelWand *) NULL ? FillToBorderMethod : FloodfillMethod);
1671 if (status == MagickFalse)
1672 InheritException(wand->exception,&wand->images->exception);
1673 draw_info=DestroyDrawInfo(draw_info);
1704WandExport MagickBooleanType MagickMedianFilterImage(
MagickWand *wand,
1705 const double radius)
1711 assert(wand->signature == WandSignature);
1712 if (wand->debug != MagickFalse)
1713 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1714 if (wand->images == (Image *) NULL)
1715 ThrowWandException(WandError,
"ContainsNoImages",wand->name);
1716 median_image=MedianFilterImage(wand->images,radius,wand->exception);
1717 if (median_image == (Image *) NULL)
1718 return(MagickFalse);
1719 ReplaceImageInList(&wand->images,median_image);
1751 assert(wand->signature == WandSignature);
1752 if (wand->debug != MagickFalse)
1753 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1754 if (wand->images == (Image *) NULL)
1756 minimum_image=EvaluateImages(wand->images,MinEvaluateOperator,
1758 if (minimum_image == (Image *) NULL)
1760 return(CloneMagickWandFromImages(wand,minimum_image));
1789WandExport MagickBooleanType MagickModeImage(
MagickWand *wand,
1790 const double radius)
1796 assert(wand->signature == WandSignature);
1797 if (wand->debug != MagickFalse)
1798 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1799 if (wand->images == (Image *) NULL)
1800 ThrowWandException(WandError,
"ContainsNoImages",wand->name);
1801 mode_image=ModeImage(wand->images,radius,wand->exception);
1802 if (mode_image == (Image *) NULL)
1803 return(MagickFalse);
1804 ReplaceImageInList(&wand->images,mode_image);
1838 assert(wand->signature == WandSignature);
1839 if (wand->debug != MagickFalse)
1840 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
1841 if (wand->images == (Image *) NULL)
1843 mosaic_image=MosaicImages(wand->images,wand->exception);
1844 if (mosaic_image == (Image *) NULL)
1846 return(CloneMagickWandFromImages(wand,mosaic_image));
1886WandExport MagickBooleanType MagickOpaqueImage(
MagickWand *wand,
1889 return(MagickPaintOpaqueImage(wand,target,fill,fuzz));
1934WandExport MagickBooleanType MagickPaintFloodfillImage(
MagickWand *wand,
1935 const ChannelType channel,
const PixelWand *fill,
const double fuzz,
1936 const PixelWand *bordercolor,
const ssize_t x,
const ssize_t y)
1941 status=MagickFloodfillPaintImage(wand,channel,fill,fuzz,bordercolor,x,y,
1987WandExport MagickBooleanType MagickPaintOpaqueImage(
MagickWand *wand,
1990 return(MagickPaintOpaqueImageChannel(wand,DefaultChannels,target,fill,fuzz));
1993WandExport MagickBooleanType MagickPaintOpaqueImageChannel(
MagickWand *wand,
2000 status=MagickOpaquePaintImageChannel(wand,channel,target,fill,fuzz,
2042WandExport MagickBooleanType MagickPaintTransparentImage(
MagickWand *wand,
2043 const PixelWand *target,
const double alpha,
const double fuzz)
2045 return(MagickTransparentPaintImage(wand,target,alpha,fuzz,MagickFalse));
2077WandExport MagickBooleanType MagickRadialBlurImage(
MagickWand *wand,
2080 return(MagickRotationalBlurImage(wand,angle));
2083WandExport MagickBooleanType MagickRadialBlurImageChannel(
MagickWand *wand,
2084 const ChannelType channel,
const double angle)
2086 return(MagickRotationalBlurImageChannel(wand,channel,angle));
2122WandExport MagickBooleanType MagickRecolorImage(
MagickWand *wand,
2123 const size_t order,
const double *color_matrix)
2129 assert(wand->signature == WandSignature);
2130 if (wand->debug != MagickFalse)
2131 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2132 if (color_matrix == (
const double *) NULL)
2133 return(MagickFalse);
2134 if (wand->images == (Image *) NULL)
2135 ThrowWandException(WandError,
"ContainsNoImages",wand->name);
2136 transform_image=RecolorImage(wand->images,order,color_matrix,
2138 if (transform_image == (Image *) NULL)
2139 return(MagickFalse);
2140 ReplaceImageInList(&wand->images,transform_image);
2172WandExport MagickBooleanType MagickReduceNoiseImage(
MagickWand *wand,
2173 const double radius)
2179 assert(wand->signature == WandSignature);
2180 if (wand->debug != MagickFalse)
2181 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2182 if (wand->images == (Image *) NULL)
2183 ThrowWandException(WandError,
"ContainsNoImages",wand->name);
2184 noise_image=ReduceNoiseImage(wand->images,radius,wand->exception);
2185 if (noise_image == (Image *) NULL)
2186 return(MagickFalse);
2187 ReplaceImageInList(&wand->images,noise_image);
2219 assert(wand->signature == WandSignature);
2220 if (wand->debug != MagickFalse)
2221 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2222 if (wand->images == (Image *) NULL)
2224 maximum_image=EvaluateImages(wand->images,MaxEvaluateOperator,
2226 if (maximum_image == (Image *) NULL)
2228 return(CloneMagickWandFromImages(wand,maximum_image));
2258WandExport MagickBooleanType MagickSetImageAttribute(
MagickWand *wand,
2259 const char *property,
const char *value)
2261 return(SetImageProperty(wand->images,property,value));
2290WandExport MagickBooleanType MagickSetImageIndex(
MagickWand *wand,
2291 const ssize_t index)
2293 return(MagickSetIteratorIndex(wand,index));
2326WandExport MagickBooleanType MagickSetImageOption(
MagickWand *wand,
2327 const char *format,
const char *key,
const char *value)
2330 option[MaxTextExtent];
2333 assert(wand->signature == WandSignature);
2334 if (wand->debug != MagickFalse)
2335 (void) LogMagickEvent(WandEvent,GetMagickModule(),
"%s",wand->name);
2336 (void) FormatLocaleString(option,MaxTextExtent,
"%s:%s=%s",format,key,value);
2337 return(DefineImageOption(wand->image_info,option));
2377WandExport MagickBooleanType MagickTransparentImage(
MagickWand *wand,
2378 const PixelWand *target,
const double alpha,
const double fuzz)
2380 return(MagickPaintTransparentImage(wand,target,alpha,fuzz));
2417 const size_t width,
const size_t height,
const ssize_t x,
2420 return(MagickGetImageRegion(wand,width,height,x,y));
2474WandExport MagickBooleanType MagickSetImagePixels(
MagickWand *wand,
2475 const ssize_t x,
const ssize_t y,
const size_t columns,
2476 const size_t rows,
const char *map,
const StorageType storage,
2479 return(MagickImportImagePixels(wand,x,y,columns,rows,map,storage,pixels));
2510WandExport
unsigned char *MagickWriteImageBlob(
MagickWand *wand,
size_t *length)
2512 return(MagickGetImageBlob(wand,length));
2539static PixelWand ***AcquirePixelsTLS(
const size_t number_wands,
2540 const size_t number_threads)
2548 pixel_wands=(
PixelWand ***) AcquireQuantumMemory(number_threads,
2549 sizeof(*pixel_wands));
2550 if (pixel_wands == (
PixelWand ***) NULL)
2552 (void) memset(pixel_wands,0,number_threads*
sizeof(*pixel_wands));
2553 for (i=0; i < (ssize_t) number_threads; i++)
2555 pixel_wands[i]=NewPixelWands(number_wands);
2556 if (pixel_wands[i] == (
PixelWand **) NULL)
2557 return(DestroyPixelsTLS(pixel_wands,number_wands,number_threads));
2559 return(pixel_wands);
2568 assert(wand->signature == MagickCoreSignature);
2569 pixel_view=(
PixelView *) AcquireMagickMemory(
sizeof(*pixel_view));
2571 ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
2572 GetExceptionMessage(errno));
2573 (void) memset(pixel_view,0,
sizeof(*pixel_view));
2574 pixel_view->id=AcquireWandId();
2575 (void) FormatLocaleString(pixel_view->name,MaxTextExtent,
"%s-%.20g",
2576 PixelViewId,(
double) pixel_view->id);
2577 pixel_view->exception=AcquireExceptionInfo();
2578 pixel_view->wand=wand;
2579 pixel_view->view=AcquireVirtualCacheView(pixel_view->wand->images,
2580 pixel_view->exception);
2581 pixel_view->region.width=wand->images->columns;
2582 pixel_view->region.height=wand->images->rows;
2583 pixel_view->number_threads=GetOpenMPMaximumThreads();
2584 pixel_view->pixel_wands=AcquirePixelsTLS(pixel_view->region.width,
2585 pixel_view->number_threads);
2586 if (pixel_view->pixel_wands == (
PixelWand ***) NULL)
2587 ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
2588 GetExceptionMessage(errno));
2589 pixel_view->debug=IsEventLogging();
2590 pixel_view->signature=WandSignature;
2622 const ssize_t y,
const size_t width,
const size_t height)
2628 assert(wand->signature == MagickCoreSignature);
2629 pixel_view=(
PixelView *) AcquireMagickMemory(
sizeof(*pixel_view));
2631 ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
2632 GetExceptionMessage(errno));
2633 (void) memset(pixel_view,0,
sizeof(*pixel_view));
2634 pixel_view->id=AcquireWandId();
2635 (void) FormatLocaleString(pixel_view->name,MaxTextExtent,
"%s-%.20g",
2636 PixelViewId,(
double) pixel_view->id);
2637 pixel_view->exception=AcquireExceptionInfo();
2638 pixel_view->view=AcquireVirtualCacheView(pixel_view->wand->images,
2639 pixel_view->exception);
2640 pixel_view->wand=wand;
2641 pixel_view->region.width=width;
2642 pixel_view->region.height=height;
2643 pixel_view->region.x=x;
2644 pixel_view->region.y=y;
2645 pixel_view->number_threads=GetOpenMPMaximumThreads();
2646 pixel_view->pixel_wands=AcquirePixelsTLS(pixel_view->region.width,
2647 pixel_view->number_threads);
2648 if (pixel_view->pixel_wands == (
PixelWand ***) NULL)
2649 ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
2650 GetExceptionMessage(errno));
2651 pixel_view->debug=IsEventLogging();
2652 pixel_view->signature=WandSignature;
2687 return(PixelGetNextIteratorRow(iterator,&number_wands));
2716WandExport
char *PixelIteratorGetException(
const PixelIterator *iterator,
2717 ExceptionType *severity)
2719 return(PixelGetIteratorException(iterator,severity));
2761WandExport MagickBooleanType SetPixelViewIterator(
PixelView *destination,
2762 SetPixelViewMethod set,
void *context)
2764#define SetPixelViewTag "PixelView/Set"
2781 assert(destination != (
PixelView *) NULL);
2782 assert(destination->signature == WandSignature);
2783 if (set == (SetPixelViewMethod) NULL)
2784 return(MagickFalse);
2785 destination_image=destination->wand->images;
2786 if (SetImageStorageClass(destination_image,DirectClass) == MagickFalse)
2787 return(MagickFalse);
2790 exception=destination->exception;
2791#if defined(MAGICKCORE_OPENMP_SUPPORT)
2792 #pragma omp parallel for schedule(static) shared(progress,status)
2794 for (y=destination->region.y; y < (ssize_t) destination->region.height; y++)
2797 id = GetOpenMPThreadId();
2803 *magick_restrict indexes;
2809 *magick_restrict pixels;
2811 if (status == MagickFalse)
2813 pixels=GetCacheViewAuthenticPixels(destination->view,destination->region.x,
2814 y,destination->region.width,1,exception);
2815 if (pixels == (PixelPacket *) NULL)
2817 InheritException(destination->exception,GetCacheViewException(
2818 destination->view));
2822 indexes=GetCacheViewAuthenticIndexQueue(destination->view);
2823 if (set(destination,context) == MagickFalse)
2825 for (x=0; x < (ssize_t) destination->region.width; x++)
2826 PixelGetQuantumColor(destination->pixel_wands[
id][x],pixels+x);
2827 if (destination_image->colorspace == CMYKColorspace)
2828 for (x=0; x < (ssize_t) destination->region.width; x++)
2829 SetPixelIndex(indexes+x,PixelGetBlackQuantum(
2830 destination->pixel_wands[
id][x]));
2831 sync=SyncCacheViewAuthenticPixels(destination->view,exception);
2832 if (sync == MagickFalse)
2834 InheritException(destination->exception,GetCacheViewException(
2835 destination->view));
2838 if (destination_image->progress_monitor != (MagickProgressMonitor) NULL)
2843#if defined(MAGICKCORE_OPENMP_SUPPORT)
2847 proceed=SetImageProgress(destination_image,SetPixelViewTag,progress,
2848 destination->region.height);
2849 if (proceed == MagickFalse)
2898WandExport MagickBooleanType TransferPixelViewIterator(
PixelView *source,
2899 PixelView *destination,TransferPixelViewMethod transfer,
void *context)
2901#define TransferPixelViewTag "PixelView/Transfer"
2920 assert(source->signature == WandSignature);
2921 if (transfer == (TransferPixelViewMethod) NULL)
2922 return(MagickFalse);
2923 source_image=source->wand->images;
2924 destination_image=destination->wand->images;
2925 if (SetImageStorageClass(destination_image,DirectClass) == MagickFalse)
2926 return(MagickFalse);
2929 exception=destination->exception;
2930#if defined(MAGICKCORE_OPENMP_SUPPORT)
2931 #pragma omp parallel for schedule(static) shared(progress,status)
2933 for (y=source->region.y; y < (ssize_t) source->region.height; y++)
2936 id = GetOpenMPThreadId();
2942 *magick_restrict indexes;
2945 *magick_restrict pixels;
2948 *magick_restrict destination_indexes;
2954 *magick_restrict destination_pixels;
2956 if (status == MagickFalse)
2958 pixels=GetCacheViewVirtualPixels(source->view,source->region.x,y,
2959 source->region.width,1,source->exception);
2960 if (pixels == (
const PixelPacket *) NULL)
2965 indexes=GetCacheViewVirtualIndexQueue(source->view);
2966 for (x=0; x < (ssize_t) source->region.width; x++)
2967 PixelSetQuantumColor(source->pixel_wands[
id][x],pixels+x);
2968 if (source_image->colorspace == CMYKColorspace)
2969 for (x=0; x < (ssize_t) source->region.width; x++)
2970 PixelSetBlackQuantum(source->pixel_wands[
id][x],
2971 GetPixelIndex(indexes+x));
2972 if (source_image->storage_class == PseudoClass)
2973 for (x=0; x < (ssize_t) source->region.width; x++)
2974 PixelSetIndex(source->pixel_wands[
id][x],
2975 GetPixelIndex(indexes+x));
2976 destination_pixels=GetCacheViewAuthenticPixels(destination->view,
2977 destination->region.x,y,destination->region.width,1,exception);
2978 if (destination_pixels == (PixelPacket *) NULL)
2983 destination_indexes=GetCacheViewAuthenticIndexQueue(destination->view);
2984 for (x=0; x < (ssize_t) destination->region.width; x++)
2985 PixelSetQuantumColor(destination->pixel_wands[
id][x],pixels+x);
2986 if (destination_image->colorspace == CMYKColorspace)
2987 for (x=0; x < (ssize_t) destination->region.width; x++)
2988 PixelSetBlackQuantum(destination->pixel_wands[
id][x],
2989 GetPixelIndex(indexes+x));
2990 if (destination_image->storage_class == PseudoClass)
2991 for (x=0; x < (ssize_t) destination->region.width; x++)
2992 PixelSetIndex(destination->pixel_wands[
id][x],
2993 GetPixelIndex(indexes+x));
2994 if (transfer(source,destination,context) == MagickFalse)
2996 for (x=0; x < (ssize_t) destination->region.width; x++)
2997 PixelGetQuantumColor(destination->pixel_wands[
id][x],
2998 destination_pixels+x);
2999 if (destination_image->colorspace == CMYKColorspace)
3000 for (x=0; x < (ssize_t) destination->region.width; x++)
3001 SetPixelIndex(destination_indexes+x,PixelGetBlackQuantum(
3002 destination->pixel_wands[
id][x]));
3003 sync=SyncCacheViewAuthenticPixels(destination->view,exception);
3004 if (sync == MagickFalse)
3006 InheritException(destination->exception,GetCacheViewException(
3010 if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
3015#if defined(MAGICKCORE_OPENMP_SUPPORT)
3019 proceed=SetImageProgress(source_image,TransferPixelViewTag,progress,
3020 source->region.height);
3021 if (proceed == MagickFalse)
3066WandExport MagickBooleanType UpdatePixelViewIterator(
PixelView *source,
3067 UpdatePixelViewMethod update,
void *context)
3069#define UpdatePixelViewTag "PixelView/Update"
3087 assert(source->signature == WandSignature);
3088 if (update == (UpdatePixelViewMethod) NULL)
3089 return(MagickFalse);
3090 source_image=source->wand->images;
3091 if (SetImageStorageClass(source_image,DirectClass) == MagickFalse)
3092 return(MagickFalse);
3095 exception=source->exception;
3096#if defined(MAGICKCORE_OPENMP_SUPPORT)
3097 #pragma omp parallel for schedule(static) shared(progress,status)
3099 for (y=source->region.y; y < (ssize_t) source->region.height; y++)
3102 id = GetOpenMPThreadId();
3105 *magick_restrict indexes;
3111 *magick_restrict pixels;
3113 if (status == MagickFalse)
3115 pixels=GetCacheViewAuthenticPixels(source->view,source->region.x,y,
3116 source->region.width,1,exception);
3117 if (pixels == (PixelPacket *) NULL)
3119 InheritException(source->exception,GetCacheViewException(
3124 indexes=GetCacheViewAuthenticIndexQueue(source->view);
3125 for (x=0; x < (ssize_t) source->region.width; x++)
3126 PixelSetQuantumColor(source->pixel_wands[
id][x],pixels+x);
3127 if (source_image->colorspace == CMYKColorspace)
3128 for (x=0; x < (ssize_t) source->region.width; x++)
3129 PixelSetBlackQuantum(source->pixel_wands[
id][x],
3130 GetPixelIndex(indexes+x));
3131 if (update(source,context) == MagickFalse)
3133 for (x=0; x < (ssize_t) source->region.width; x++)
3134 PixelGetQuantumColor(source->pixel_wands[
id][x],pixels+x);
3135 if (source_image->colorspace == CMYKColorspace)
3136 for (x=0; x < (ssize_t) source->region.width; x++)
3137 SetPixelIndex(indexes+x,PixelGetBlackQuantum(
3138 source->pixel_wands[
id][x]));
3139 if (SyncCacheViewAuthenticPixels(source->view,exception) == MagickFalse)
3141 InheritException(source->exception,GetCacheViewException(source->view));
3144 if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
3149#if defined(MAGICKCORE_OPENMP_SUPPORT)
3153 proceed=SetImageProgress(source_image,UpdatePixelViewTag,progress,
3154 source->region.height);
3155 if (proceed == MagickFalse)