48#include "MagickCore/studio.h"
49#include "MagickCore/MagickCore.h"
50#include "MagickCore/exception-private.h"
51#include "MagickCore/memory-private.h"
52#include "MagickCore/monitor-private.h"
53#include "MagickCore/thread-private.h"
109 assert(image_view != (
ImageView *) NULL);
110 assert(image_view->signature == MagickCoreSignature);
111 clone_view=(
ImageView *) AcquireCriticalMemory(
sizeof(*clone_view));
112 (void) memset(clone_view,0,
sizeof(*clone_view));
113 clone_view->description=ConstantString(image_view->description);
114 clone_view->extent=image_view->extent;
115 clone_view->view=CloneCacheView(image_view->view);
116 clone_view->exception=AcquireExceptionInfo();
117 InheritException(clone_view->exception,image_view->exception);
118 clone_view->debug=image_view->debug;
119 clone_view->signature=MagickCoreSignature;
147 assert(image_view != (
ImageView *) NULL);
148 assert(image_view->signature == MagickCoreSignature);
149 if (image_view->description != (
char *) NULL)
150 image_view->description=DestroyString(image_view->description);
151 image_view->view=DestroyCacheView(image_view->view);
152 image_view->exception=DestroyExceptionInfo(image_view->exception);
153 image_view->signature=(~MagickCoreSignature);
154 image_view=(
ImageView *) RelinquishMagickMemory(image_view);
209MagickExport MagickBooleanType DuplexTransferImageViewIterator(
211 DuplexTransferImageViewMethod transfer,
void *context)
223#if defined(MAGICKCORE_OPENMP_SUPPORT)
232 assert(source->signature == MagickCoreSignature);
233 if (transfer == (DuplexTransferImageViewMethod) NULL)
235 source_image=source->image;
236 destination_image=destination->image;
237 status=SetImageStorageClass(destination_image,DirectClass,
238 destination->exception);
239 if (status == MagickFalse)
243#if defined(MAGICKCORE_OPENMP_SUPPORT)
244 height=source->extent.height-(size_t) source->extent.y;
245 #pragma omp parallel for schedule(static) shared(progress,status) \
246 magick_number_threads(source_image,destination_image,height,1)
248 for (y=source->extent.y; y < (ssize_t) source->extent.height; y++)
251 id = GetOpenMPThreadId();
257 *magick_restrict duplex_pixels,
258 *magick_restrict pixels;
261 *magick_restrict destination_pixels;
263 if (status == MagickFalse)
265 pixels=GetCacheViewVirtualPixels(source->view,source->extent.x,y,
266 source->extent.width,1,source->exception);
267 if (pixels == (
const Quantum *) NULL)
272 duplex_pixels=GetCacheViewVirtualPixels(duplex->view,duplex->extent.x,y,
273 duplex->extent.width,1,duplex->exception);
274 if (duplex_pixels == (
const Quantum *) NULL)
279 destination_pixels=GetCacheViewAuthenticPixels(destination->view,
280 destination->extent.x,y,destination->extent.width,1,
281 destination->exception);
282 if (destination_pixels == (Quantum *) NULL)
287 if (transfer(source,duplex,destination,y,
id,context) == MagickFalse)
289 sync=SyncCacheViewAuthenticPixels(destination->view,destination->exception);
290 if (sync == MagickFalse)
292 if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
297#if defined(MAGICKCORE_OPENMP_SUPPORT)
301 proceed=SetImageProgress(source_image,source->description,progress,
302 source->extent.height);
303 if (proceed == MagickFalse)
334MagickExport
void *GetImageViewAuthenticMetacontent(
337 assert(image_view != (
ImageView *) NULL);
338 assert(image_view->signature == MagickCoreSignature);
339 return(GetCacheViewAuthenticMetacontent(image_view->view));
364MagickExport Quantum *GetImageViewAuthenticPixels(
367 assert(image_view != (
ImageView *) NULL);
368 assert(image_view->signature == MagickCoreSignature);
369 return(GetCacheViewAuthenticPixelQueue(image_view->view));
398MagickExport
char *GetImageViewException(
const ImageView *image_view,
399 ExceptionType *severity)
404 assert(image_view != (
const ImageView *) NULL);
405 assert(image_view->signature == MagickCoreSignature);
406 assert(severity != (ExceptionType *) NULL);
407 *severity=image_view->exception->severity;
408 description=(
char *) AcquireQuantumMemory(MagickPathExtent,
409 2*
sizeof(*description));
410 if (description == (
char *) NULL)
411 ThrowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed");
413 if (image_view->exception->reason != (
char *) NULL)
414 (void) CopyMagickString(description,GetLocaleExceptionMessage(
415 image_view->exception->severity,image_view->exception->reason),
417 if (image_view->exception->description != (
char *) NULL)
419 (void) ConcatenateMagickString(description,
" (",MagickPathExtent);
420 (void) ConcatenateMagickString(description,GetLocaleExceptionMessage(
421 image_view->exception->severity,image_view->exception->description),
423 (void) ConcatenateMagickString(description,
")",MagickPathExtent);
452 assert(image_view != (
ImageView *) NULL);
453 assert(image_view->signature == MagickCoreSignature);
454 return(image_view->extent);
481 assert(image_view != (
ImageView *) NULL);
482 assert(image_view->signature == MagickCoreSignature);
483 return(image_view->image);
529MagickExport MagickBooleanType GetImageViewIterator(
ImageView *source,
530 GetImageViewMethod get,
void *context)
541#if defined(MAGICKCORE_OPENMP_SUPPORT)
550 assert(source->signature == MagickCoreSignature);
551 if (get == (GetImageViewMethod) NULL)
553 source_image=source->image;
556#if defined(MAGICKCORE_OPENMP_SUPPORT)
557 height=source->extent.height-(size_t) source->extent.y;
558 #pragma omp parallel for schedule(static) shared(progress,status) \
559 magick_number_threads(source_image,source_image,height,1)
561 for (y=source->extent.y; y < (ssize_t) source->extent.height; y++)
564 id = GetOpenMPThreadId();
569 if (status == MagickFalse)
571 pixels=GetCacheViewVirtualPixels(source->view,source->extent.x,y,
572 source->extent.width,1,source->exception);
573 if (pixels == (
const Quantum *) NULL)
578 if (get(source,y,
id,context) == MagickFalse)
580 if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
585#if defined(MAGICKCORE_OPENMP_SUPPORT)
589 proceed=SetImageProgress(source_image,source->description,progress,
590 source->extent.height);
591 if (proceed == MagickFalse)
622MagickExport
const void *GetImageViewVirtualMetacontent(
625 assert(image_view != (
ImageView *) NULL);
626 assert(image_view->signature == MagickCoreSignature);
627 return(GetCacheViewVirtualMetacontent(image_view->view));
652MagickExport
const Quantum *GetImageViewVirtualPixels(
655 assert(image_view != (
ImageView *) NULL);
656 assert(image_view->signature == MagickCoreSignature);
657 return(GetCacheViewVirtualPixelQueue(image_view->view));
683MagickExport MagickBooleanType IsImageView(
const ImageView *image_view)
685 if (image_view == (
const ImageView *) NULL)
687 if (image_view->signature != MagickCoreSignature)
722 assert(image != (
Image *) NULL);
723 assert(image->signature == MagickCoreSignature);
724 image_view=(
ImageView *) AcquireCriticalMemory(
sizeof(*image_view));
725 (void) memset(image_view,0,
sizeof(*image_view));
726 image_view->description=ConstantString(
"ImageView");
727 image_view->image=image;
728 image_view->view=AcquireVirtualCacheView(image_view->image,exception);
729 image_view->extent.width=image->columns;
730 image_view->extent.height=image->rows;
731 image_view->extent.x=0;
732 image_view->extent.y=0;
733 image_view->exception=AcquireExceptionInfo();
734 image_view->debug=(GetLogEventMask() & ImageEvent) != 0 ? MagickTrue :
736 image_view->signature=MagickCoreSignature;
770MagickExport
ImageView *NewImageViewRegion(
Image *image,
const ssize_t x,
771 const ssize_t y,
const size_t width,
const size_t height,
777 assert(image != (
Image *) NULL);
778 assert(image->signature == MagickCoreSignature);
779 image_view=(
ImageView *) AcquireCriticalMemory(
sizeof(*image_view));
780 (void) memset(image_view,0,
sizeof(*image_view));
781 image_view->description=ConstantString(
"ImageView");
782 image_view->view=AcquireVirtualCacheView(image_view->image,exception);
783 image_view->image=image;
784 image_view->extent.width=width;
785 image_view->extent.height=height;
786 image_view->extent.x=x;
787 image_view->extent.y=y;
788 image_view->exception=AcquireExceptionInfo();
789 image_view->debug=(GetLogEventMask() & ImageEvent) != 0 ? MagickTrue :
791 image_view->signature=MagickCoreSignature;
820MagickExport
void SetImageViewDescription(
ImageView *image_view,
821 const char *description)
823 assert(image_view != (
ImageView *) NULL);
824 assert(image_view->signature == MagickCoreSignature);
825 image_view->description=ConstantString(description);
872MagickExport MagickBooleanType SetImageViewIterator(
ImageView *destination,
873 SetImageViewMethod set,
void *context)
884#if defined(MAGICKCORE_OPENMP_SUPPORT)
892 assert(destination != (
ImageView *) NULL);
893 assert(destination->signature == MagickCoreSignature);
894 if (set == (SetImageViewMethod) NULL)
896 destination_image=destination->image;
897 status=SetImageStorageClass(destination_image,DirectClass,
898 destination->exception);
899 if (status == MagickFalse)
903#if defined(MAGICKCORE_OPENMP_SUPPORT)
904 height=destination->extent.height-(size_t) destination->extent.y;
905 #pragma omp parallel for schedule(static) shared(progress,status) \
906 magick_number_threads(destination_image,destination_image,height,1)
908 for (y=destination->extent.y; y < (ssize_t) destination->extent.height; y++)
911 id = GetOpenMPThreadId();
917 *magick_restrict pixels;
919 if (status == MagickFalse)
921 pixels=GetCacheViewAuthenticPixels(destination->view,destination->extent.x,
922 y,destination->extent.width,1,destination->exception);
923 if (pixels == (Quantum *) NULL)
928 if (set(destination,y,
id,context) == MagickFalse)
930 sync=SyncCacheViewAuthenticPixels(destination->view,destination->exception);
931 if (sync == MagickFalse)
933 if (destination_image->progress_monitor != (MagickProgressMonitor) NULL)
938#if defined(MAGICKCORE_OPENMP_SUPPORT)
942 proceed=SetImageProgress(destination_image,destination->description,
943 progress,destination->extent.height);
944 if (proceed == MagickFalse)
999MagickExport MagickBooleanType TransferImageViewIterator(
ImageView *source,
1000 ImageView *destination,TransferImageViewMethod transfer,
void *context)
1012#if defined(MAGICKCORE_OPENMP_SUPPORT)
1021 assert(source->signature == MagickCoreSignature);
1022 if (transfer == (TransferImageViewMethod) NULL)
1023 return(MagickFalse);
1024 source_image=source->image;
1025 destination_image=destination->image;
1026 status=SetImageStorageClass(destination_image,DirectClass,
1027 destination->exception);
1028 if (status == MagickFalse)
1029 return(MagickFalse);
1032#if defined(MAGICKCORE_OPENMP_SUPPORT)
1033 height=source->extent.height-(size_t) source->extent.y;
1034 #pragma omp parallel for schedule(static) shared(progress,status) \
1035 magick_number_threads(source_image,destination_image,height,1)
1037 for (y=source->extent.y; y < (ssize_t) source->extent.height; y++)
1040 id = GetOpenMPThreadId();
1046 *magick_restrict pixels;
1049 *magick_restrict destination_pixels;
1051 if (status == MagickFalse)
1053 pixels=GetCacheViewVirtualPixels(source->view,source->extent.x,y,
1054 source->extent.width,1,source->exception);
1055 if (pixels == (
const Quantum *) NULL)
1060 destination_pixels=GetCacheViewAuthenticPixels(destination->view,
1061 destination->extent.x,y,destination->extent.width,1,
1062 destination->exception);
1063 if (destination_pixels == (Quantum *) NULL)
1068 if (transfer(source,destination,y,
id,context) == MagickFalse)
1070 sync=SyncCacheViewAuthenticPixels(destination->view,destination->exception);
1071 if (sync == MagickFalse)
1073 if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
1078#if defined(MAGICKCORE_OPENMP_SUPPORT)
1082 proceed=SetImageProgress(source_image,source->description,progress,
1083 source->extent.height);
1084 if (proceed == MagickFalse)
1134MagickExport MagickBooleanType UpdateImageViewIterator(
ImageView *source,
1135 UpdateImageViewMethod update,
void *context)
1146#if defined(MAGICKCORE_OPENMP_SUPPORT)
1155 assert(source->signature == MagickCoreSignature);
1156 if (update == (UpdateImageViewMethod) NULL)
1157 return(MagickFalse);
1158 source_image=source->image;
1159 status=SetImageStorageClass(source_image,DirectClass,source->exception);
1160 if (status == MagickFalse)
1161 return(MagickFalse);
1164#if defined(MAGICKCORE_OPENMP_SUPPORT)
1165 height=source->extent.height-(size_t) source->extent.y;
1166 #pragma omp parallel for schedule(static) shared(progress,status) \
1167 magick_number_threads(source_image,source_image,height,1)
1169 for (y=source->extent.y; y < (ssize_t) source->extent.height; y++)
1172 id = GetOpenMPThreadId();
1175 *magick_restrict pixels;
1177 if (status == MagickFalse)
1179 pixels=GetCacheViewAuthenticPixels(source->view,source->extent.x,y,
1180 source->extent.width,1,source->exception);
1181 if (pixels == (Quantum *) NULL)
1186 if (update(source,y,
id,context) == MagickFalse)
1188 status=SyncCacheViewAuthenticPixels(source->view,source->exception);
1189 if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
1194#if defined(MAGICKCORE_OPENMP_SUPPORT)
1198 proceed=SetImageProgress(source_image,source->description,progress,
1199 source->extent.height);
1200 if (proceed == MagickFalse)