% March 2003 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
CacheView
*view;
- size_t
- number_threads;
-
ExceptionInfo
*exception;
clone_view->description=ConstantString(image_view->description);
clone_view->extent=image_view->extent;
clone_view->view=CloneCacheView(image_view->view);
- clone_view->number_threads=image_view->number_threads;
clone_view->exception=AcquireExceptionInfo();
InheritException(clone_view->exception,image_view->exception);
clone_view->debug=image_view->debug;
ImageView *source,ImageView *duplex,ImageView *destination,
DuplexTransferImageViewMethod transfer,void *context)
{
- ExceptionInfo
- *exception;
-
Image
*destination_image,
*source_image;
MagickOffsetType
progress;
+ size_t
+ height,
+ width;
+
ssize_t
y;
return(MagickFalse);
source_image=source->image;
destination_image=destination->image;
- if (SetImageStorageClass(destination_image,DirectClass) == MagickFalse)
+ status=SetImageStorageClass(destination_image,DirectClass,
+ destination->exception);
+ if (status == MagickFalse)
return(MagickFalse);
status=MagickTrue;
progress=0;
- exception=destination->exception;
+ height=source->extent.height-source->extent.y;
+ width=source->extent.width-source->extent.x;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads)
+ #pragma omp parallel for schedule(static) shared(progress,status) \
+ dynamic_number_threads(width,height,1)
#endif
for (y=source->extent.y; y < (ssize_t) source->extent.height; y++)
{
continue;
}
destination_pixels=GetCacheViewAuthenticPixels(destination->view,
- destination->extent.x,y,destination->extent.width,1,exception);
+ destination->extent.x,y,destination->extent.width,1,
+ destination->exception);
if (destination_pixels == (Quantum *) NULL)
{
status=MagickFalse;
}
if (transfer(source,duplex,destination,y,id,context) == MagickFalse)
status=MagickFalse;
- sync=SyncCacheViewAuthenticPixels(destination->view,exception);
+ sync=SyncCacheViewAuthenticPixels(destination->view,destination->exception);
if (sync == MagickFalse)
- {
- InheritException(destination->exception,GetCacheViewException(
- source->view));
- status=MagickFalse;
- }
+ status=MagickFalse;
if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_DuplexTransferImageViewIterator)
+ #pragma omp critical (MagickCore_DuplexTransferImageViewIterator)
#endif
proceed=SetImageProgress(source_image,source->description,progress++,
source->extent.height);
% %
% %
% %
-% G e t I m a g e V i e w A u t h e n t i c M e t a c o n t e n t %
+% G e t I m a g e V i e w A u t h e n t i c M e t a c o n t e n t %
% %
% %
% %
MagickOffsetType
progress;
+ size_t
+ height,
+ width;
+
ssize_t
y;
source_image=source->image;
status=MagickTrue;
progress=0;
+ height=source->extent.height-source->extent.y;
+ width=source->extent.width-source->extent.x;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads)
+ #pragma omp parallel for schedule(static) shared(progress,status) \
+ dynamic_number_threads(width,height,1)
#endif
for (y=source->extent.y; y < (ssize_t) source->extent.height; y++)
{
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_GetImageViewIterator)
+ #pragma omp critical (MagickCore_GetImageViewIterator)
#endif
proceed=SetImageProgress(source_image,source->description,progress++,
source->extent.height);
%
% The format of the NewImageView method is:
%
-% ImageView *NewImageView(MagickCore *wand)
+% ImageView *NewImageView(MagickCore *wand,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
-% o wand: the wand.
+% o image: the image.
+%
+% o exception: return any errors or warnings in this structure.
%
*/
-MagickExport ImageView *NewImageView(Image *image)
+MagickExport ImageView *NewImageView(Image *image,ExceptionInfo *exception)
{
ImageView
*image_view;
(void) ResetMagickMemory(image_view,0,sizeof(*image_view));
image_view->description=ConstantString("ImageView");
image_view->image=image;
- image_view->view=AcquireCacheView(image_view->image);
+ image_view->view=AcquireVirtualCacheView(image_view->image,exception);
image_view->extent.width=image->columns;
image_view->extent.height=image->rows;
image_view->extent.x=0;
image_view->extent.y=0;
- image_view->number_threads=GetOpenMPMaximumThreads();
image_view->exception=AcquireExceptionInfo();
image_view->debug=IsEventLogging();
image_view->signature=MagickSignature;
% The format of the NewImageViewRegion method is:
%
% ImageView *NewImageViewRegion(MagickCore *wand,const ssize_t x,
-% const ssize_t y,const size_t width,const size_t height)
+% const ssize_t y,const size_t width,const size_t height,
+% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o x,y,columns,rows: These values define the perimeter of a extent of
% pixel_wands view.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport ImageView *NewImageViewRegion(Image *image,const ssize_t x,
- const ssize_t y,const size_t width,const size_t height)
+ const ssize_t y,const size_t width,const size_t height,
+ ExceptionInfo *exception)
{
ImageView
*image_view;
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
(void) ResetMagickMemory(image_view,0,sizeof(*image_view));
image_view->description=ConstantString("ImageView");
- image_view->view=AcquireCacheView(image_view->image);
+ image_view->view=AcquireVirtualCacheView(image_view->image,exception);
image_view->image=image;
image_view->extent.width=width;
image_view->extent.height=height;
image_view->extent.x=x;
image_view->extent.y=y;
- image_view->number_threads=GetOpenMPMaximumThreads();
image_view->exception=AcquireExceptionInfo();
image_view->debug=IsEventLogging();
image_view->signature=MagickSignature;
MagickExport MagickBooleanType SetImageViewIterator(ImageView *destination,
SetImageViewMethod set,void *context)
{
- ExceptionInfo
- *exception;
-
Image
*destination_image;
MagickOffsetType
progress;
+ size_t
+ height,
+ width;
+
ssize_t
y;
if (set == (SetImageViewMethod) NULL)
return(MagickFalse);
destination_image=destination->image;
- if (SetImageStorageClass(destination_image,DirectClass) == MagickFalse)
+ status=SetImageStorageClass(destination_image,DirectClass,
+ destination->exception);
+ if (status == MagickFalse)
return(MagickFalse);
status=MagickTrue;
progress=0;
- exception=destination->exception;
+ height=destination->extent.height-destination->extent.y;
+ width=destination->extent.width-destination->extent.x;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(destination->number_threads)
+ #pragma omp parallel for schedule(static) shared(progress,status) \
+ dynamic_number_threads(width,height,1)
#endif
for (y=destination->extent.y; y < (ssize_t) destination->extent.height; y++)
{
if (status == MagickFalse)
continue;
pixels=GetCacheViewAuthenticPixels(destination->view,destination->extent.x,
- y,destination->extent.width,1,exception);
+ y,destination->extent.width,1,destination->exception);
if (pixels == (Quantum *) NULL)
{
- InheritException(destination->exception,GetCacheViewException(
- destination->view));
status=MagickFalse;
continue;
}
if (set(destination,y,id,context) == MagickFalse)
status=MagickFalse;
- sync=SyncCacheViewAuthenticPixels(destination->view,exception);
+ sync=SyncCacheViewAuthenticPixels(destination->view,destination->exception);
if (sync == MagickFalse)
- {
- InheritException(destination->exception,GetCacheViewException(
- destination->view));
- status=MagickFalse;
- }
+ status=MagickFalse;
if (destination_image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_SetImageViewIterator)
+ #pragma omp critical (MagickCore_SetImageViewIterator)
#endif
proceed=SetImageProgress(destination_image,destination->description,
progress++,destination->extent.height);
% %
% %
% %
-% S e t I m a g e V i e w T h r e a d s %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% SetImageViewThreads() sets the number of threads in a thread team.
-%
-% The format of the SetImageViewDescription method is:
-%
-% void SetImageViewThreads(ImageView *image_view,
-% const size_t number_threads)
-%
-% A description of each parameter follows:
-%
-% o image_view: the image view.
-%
-% o number_threads: the number of threads in a thread team.
-%
-*/
-MagickExport void SetImageViewThreads(ImageView *image_view,
- const size_t number_threads)
-{
- assert(image_view != (ImageView *) NULL);
- assert(image_view->signature == MagickSignature);
- image_view->number_threads=number_threads;
- if (number_threads > GetOpenMPMaximumThreads())
- image_view->number_threads=GetOpenMPMaximumThreads();
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
% T r a n s f e r I m a g e V i e w I t e r a t o r %
% %
% %
MagickExport MagickBooleanType TransferImageViewIterator(ImageView *source,
ImageView *destination,TransferImageViewMethod transfer,void *context)
{
- ExceptionInfo
- *exception;
-
Image
*destination_image,
*source_image;
MagickOffsetType
progress;
+ size_t
+ height,
+ width;
+
ssize_t
y;
return(MagickFalse);
source_image=source->image;
destination_image=destination->image;
- if (SetImageStorageClass(destination_image,DirectClass) == MagickFalse)
+ status=SetImageStorageClass(destination_image,DirectClass,
+ destination->exception);
+ if (status == MagickFalse)
return(MagickFalse);
status=MagickTrue;
progress=0;
- exception=destination->exception;
+ height=source->extent.height-source->extent.y;
+ width=source->extent.width-source->extent.x;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads)
+ #pragma omp parallel for schedule(static) shared(progress,status) \
+ dynamic_number_threads(width,height,1)
#endif
for (y=source->extent.y; y < (ssize_t) source->extent.height; y++)
{
continue;
}
destination_pixels=GetCacheViewAuthenticPixels(destination->view,
- destination->extent.x,y,destination->extent.width,1,exception);
+ destination->extent.x,y,destination->extent.width,1,
+ destination->exception);
if (destination_pixels == (Quantum *) NULL)
{
status=MagickFalse;
}
if (transfer(source,destination,y,id,context) == MagickFalse)
status=MagickFalse;
- sync=SyncCacheViewAuthenticPixels(destination->view,exception);
+ sync=SyncCacheViewAuthenticPixels(destination->view,destination->exception);
if (sync == MagickFalse)
- {
- InheritException(destination->exception,GetCacheViewException(
- source->view));
- status=MagickFalse;
- }
+ status=MagickFalse;
if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_TransferImageViewIterator)
+ #pragma omp critical (MagickCore_TransferImageViewIterator)
#endif
proceed=SetImageProgress(source_image,source->description,progress++,
source->extent.height);
MagickExport MagickBooleanType UpdateImageViewIterator(ImageView *source,
UpdateImageViewMethod update,void *context)
{
- ExceptionInfo
- *exception;
-
Image
*source_image;
MagickOffsetType
progress;
+ size_t
+ height,
+ width;
+
ssize_t
y;
if (update == (UpdateImageViewMethod) NULL)
return(MagickFalse);
source_image=source->image;
- if (SetImageStorageClass(source_image,DirectClass) == MagickFalse)
+ status=SetImageStorageClass(source_image,DirectClass,source->exception);
+ if (status == MagickFalse)
return(MagickFalse);
status=MagickTrue;
progress=0;
- exception=source->exception;
+ height=source->extent.height-source->extent.y;
+ width=source->extent.width-source->extent.x;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads)
+ #pragma omp parallel for schedule(static) shared(progress,status) \
+ dynamic_number_threads(width,height,1)
#endif
for (y=source->extent.y; y < (ssize_t) source->extent.height; y++)
{
if (status == MagickFalse)
continue;
pixels=GetCacheViewAuthenticPixels(source->view,source->extent.x,y,
- source->extent.width,1,exception);
+ source->extent.width,1,source->exception);
if (pixels == (Quantum *) NULL)
{
- InheritException(source->exception,GetCacheViewException(source->view));
status=MagickFalse;
continue;
}
if (update(source,y,id,context) == MagickFalse)
status=MagickFalse;
- if (SyncCacheViewAuthenticPixels(source->view,exception) == MagickFalse)
- {
- InheritException(source->exception,GetCacheViewException(source->view));
- status=MagickFalse;
- }
+ status=SyncCacheViewAuthenticPixels(source->view,source->exception);
+ if (status == MagickFalse)
+ status=MagickFalse;
if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp critical (MagickCore_UpdateImageViewIterator)
+ #pragma omp critical (MagickCore_UpdateImageViewIterator)
#endif
proceed=SetImageProgress(source_image,source->description,progress++,
source->extent.height);