]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/transform.c
(no commit message)
[imagemagick] / MagickCore / transform.c
index 745afc44ba6028c5fbb277859d6ed43206d301eb..ceaf4426ebd6f234a12f9456ee29acc832bc3829 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  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  %
@@ -157,10 +157,11 @@ MagickExport Image *ChopImage(const Image *image,const RectangleInfo *chop_info,
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
-  chop_view=AcquireCacheView(chop_image);
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1)
+  image_view=AcquireVirtualCacheView(image,exception);
+  chop_view=AcquireAuthenticCacheView(chop_image,exception);
+#if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(NoBenefitFromParallelism)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) extent.y; y++)
   {
@@ -199,9 +200,9 @@ MagickExport Image *ChopImage(const Image *image,const RectangleInfo *chop_info,
               chop_traits,
               traits;
 
-            traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
-            channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
-            chop_traits=GetPixelChannelMapTraits(chop_image,channel);
+            channel=GetPixelChannelChannel(image,i);
+            traits=GetPixelChannelTraits(image,channel);
+            chop_traits=GetPixelChannelTraits(chop_image,channel);
             if ((traits == UndefinedPixelTrait) ||
                 (chop_traits == UndefinedPixelTrait))
               continue;
@@ -218,8 +219,8 @@ MagickExport Image *ChopImage(const Image *image,const RectangleInfo *chop_info,
         MagickBooleanType
           proceed;
 
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_ChopImage)
+#if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(NoBenefitFromParallelism)
+        #pragma omp critical (MagickCore_ChopImage)
 #endif
         proceed=SetImageProgress(image,ChopImageTag,progress++,image->rows);
         if (proceed == MagickFalse)
@@ -229,8 +230,9 @@ MagickExport Image *ChopImage(const Image *image,const RectangleInfo *chop_info,
   /*
     Extract chop image.
   */
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1)
+#if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(NoBenefitFromParallelism)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) (image->rows-(extent.y+extent.height)); y++)
   {
@@ -270,9 +272,9 @@ MagickExport Image *ChopImage(const Image *image,const RectangleInfo *chop_info,
               chop_traits,
               traits;
 
-            traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
-            channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
-            chop_traits=GetPixelChannelMapTraits(chop_image,channel);
+            channel=GetPixelChannelChannel(image,i);
+            traits=GetPixelChannelTraits(image,channel);
+            chop_traits=GetPixelChannelTraits(chop_image,channel);
             if ((traits == UndefinedPixelTrait) ||
                 (chop_traits == UndefinedPixelTrait))
               continue;
@@ -289,8 +291,8 @@ MagickExport Image *ChopImage(const Image *image,const RectangleInfo *chop_info,
         MagickBooleanType
           proceed;
 
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_ChopImage)
+#if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(NoBenefitFromParallelism)
+        #pragma omp critical (MagickCore_ChopImage)
 #endif
         proceed=SetImageProgress(image,ChopImageTag,progress++,image->rows);
         if (proceed == MagickFalse)
@@ -369,8 +371,8 @@ MagickExport Image *ConsolidateCMYKImages(const Image *images,
     (void) SetImageColorspace(cmyk_image,CMYKColorspace,exception);
     for (i=0; i < 4; i++)
     {
-      image_view=AcquireCacheView(images);
-      cmyk_view=AcquireCacheView(cmyk_image);
+      image_view=AcquireVirtualCacheView(images,exception);
+      cmyk_view=AcquireAuthenticCacheView(cmyk_image,exception);
       for (y=0; y < (ssize_t) images->rows; y++)
       {
         register const Quantum
@@ -506,12 +508,12 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry,
         Crop is not within virtual canvas, return 1 pixel transparent image.
       */
       (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
-        "GeometryDoesNotContainImage","`%s'",image->filename);
+        "GeometryDoesNotContainImage","'%s'",image->filename);
       crop_image=CloneImage(image,1,1,MagickTrue,exception);
       if (crop_image == (Image *) NULL)
         return((Image *) NULL);
       crop_image->background_color.alpha=(Quantum) TransparentAlpha;
-      (void) SetImageBackgroundColor(crop_image);
+      (void) SetImageBackgroundColor(crop_image,exception);
       crop_image->page=bounding_box;
       crop_image->page.x=(-1);
       crop_image->page.y=(-1);
@@ -556,7 +558,7 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry,
   if ((page.width == 0) || (page.height == 0))
     {
       (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
-        "GeometryDoesNotContainImage","`%s'",image->filename);
+        "GeometryDoesNotContainImage","'%s'",image->filename);
       return((Image *) NULL);
     }
   /*
@@ -582,10 +584,11 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry,
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
-  crop_view=AcquireCacheView(crop_image);
+  image_view=AcquireVirtualCacheView(image,exception);
+  crop_view=AcquireAuthenticCacheView(crop_image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) crop_image->rows; y++)
   {
@@ -614,6 +617,12 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry,
       register ssize_t
         i;
 
+      if (GetPixelMask(image,p) != 0)
+        {
+          p+=GetPixelChannels(image);
+          q+=GetPixelChannels(crop_image);
+          continue;
+        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
@@ -623,9 +632,9 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry,
           crop_traits,
           traits;
 
-        traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
-        channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
-        crop_traits=GetPixelChannelMapTraits(crop_image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
+        crop_traits=GetPixelChannelTraits(crop_image,channel);
         if ((traits == UndefinedPixelTrait) ||
             (crop_traits == UndefinedPixelTrait))
           continue;
@@ -642,7 +651,7 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_CropImage)
+        #pragma omp critical (MagickCore_CropImage)
 #endif
         proceed=SetImageProgress(image,CropImageTag,progress++,image->rows);
         if (proceed == MagickFalse)
@@ -685,7 +694,7 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry,
 %
 */
 
-static inline ssize_t MagickRound(MagickRealType x)
+static inline ssize_t MagickRound(double x)
 {
   /*
     Round the fraction to nearest integer.
@@ -696,7 +705,7 @@ static inline ssize_t MagickRound(MagickRealType x)
 }
 
 MagickExport Image *CropImageToTiles(const Image *image,
-  const char *crop_geometry, ExceptionInfo *exception)
+  const char *crop_geometry,ExceptionInfo *exception)
 {
   Image
     *next,
@@ -747,24 +756,28 @@ MagickExport Image *CropImageToTiles(const Image *image,
           width+=(geometry.x < 0 ? -1 : 1)*geometry.x;
           height+=(geometry.y < 0 ? -1 : 1)*geometry.y;
         }
-      delta.x=(double) (width+(geometry.width >> 1))/geometry.width;
-      delta.y=(double) (height+(geometry.height >> 1))/geometry.height;
+      delta.x=(double) width/geometry.width;
+      delta.y=(double) height/geometry.height;
+      if (delta.x < 1.0)
+        delta.x=1.0;
+      if (delta.y < 1.0)
+        delta.y=1.0;
       for (offset.y=0; offset.y < (double) height; )
       {
         if ((flags & AspectValue) == 0)
           {
-            crop.y=(ssize_t) MagickRound((MagickRealType) (offset.y-
+            crop.y=(ssize_t) MagickRound((double) (offset.y-
               (geometry.y > 0 ? 0 : geometry.y)));
             offset.y+=delta.y;   /* increment now to find width */
-            crop.height=(size_t) MagickRound((MagickRealType) (offset.y+
+            crop.height=(size_t) MagickRound((double) (offset.y+
               (geometry.y < 0 ? 0 : geometry.y)));
           }
         else
           {
-            crop.y=(ssize_t) MagickRound((MagickRealType) (offset.y-
+            crop.y=(ssize_t) MagickRound((double) (offset.y-
               (geometry.y > 0 ? geometry.y : 0)));
             offset.y+=delta.y;  /* increment now to find width */
-            crop.height=(size_t) MagickRound((MagickRealType)
+            crop.height=(size_t) MagickRound((double)
               (offset.y+(geometry.y < -1 ? geometry.y : 0)));
           }
         crop.height-=crop.y;
@@ -773,18 +786,18 @@ MagickExport Image *CropImageToTiles(const Image *image,
         {
           if ((flags & AspectValue) == 0)
             {
-              crop.x=(ssize_t) MagickRound((MagickRealType) (offset.x-
+              crop.x=(ssize_t) MagickRound((double) (offset.x-
                 (geometry.x > 0 ? 0 : geometry.x)));
               offset.x+=delta.x;  /* increment now to find height */
-              crop.width=(size_t) MagickRound((MagickRealType) (offset.x+
+              crop.width=(size_t) MagickRound((double) (offset.x+
                 (geometry.x < 0 ? 0 : geometry.x)));
             }
           else
             {
-              crop.x=(ssize_t) MagickRound((MagickRealType) (offset.x-
+              crop.x=(ssize_t) MagickRound((double) (offset.x-
                 (geometry.x > 0 ? geometry.x : 0)));
               offset.x+=delta.x;  /* increment now to find height */
-              crop.width=(size_t) MagickRound((MagickRealType) (offset.x+
+              crop.width=(size_t) MagickRound((double) (offset.x+
                 (geometry.x < 0 ? geometry.x : 0)));
             }
           crop.width-=crop.x;
@@ -800,7 +813,6 @@ MagickExport Image *CropImageToTiles(const Image *image,
       ClearMagickException(exception);
       return(crop_image);
     }
-
   if (((geometry.width == 0) && (geometry.height == 0)) ||
       ((flags & XValue) != 0) || ((flags & YValue) != 0))
     {
@@ -816,7 +828,7 @@ MagickExport Image *CropImageToTiles(const Image *image,
           crop_image->page.y-=geometry.y;
         }
       return(crop_image);
-     }
+    }
   if ((image->columns > geometry.width) || (image->rows > geometry.height))
     {
       RectangleInfo
@@ -934,10 +946,11 @@ MagickExport Image *ExcerptImage(const Image *image,
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
-  excerpt_view=AcquireCacheView(excerpt_image);
+  image_view=AcquireVirtualCacheView(image,exception);
+  excerpt_view=AcquireAuthenticCacheView(excerpt_image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) excerpt_image->rows; y++)
   {
@@ -966,6 +979,12 @@ MagickExport Image *ExcerptImage(const Image *image,
       register ssize_t
         i;
 
+      if (GetPixelMask(image,p) != 0)
+        {
+          p+=GetPixelChannels(image);
+          q+=GetPixelChannels(excerpt_image);
+          continue;
+        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
@@ -975,9 +994,9 @@ MagickExport Image *ExcerptImage(const Image *image,
           excerpt_traits,
           traits;
 
-        traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
-        channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
-        excerpt_traits=GetPixelChannelMapTraits(excerpt_image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
+        excerpt_traits=GetPixelChannelTraits(excerpt_image,channel);
         if ((traits == UndefinedPixelTrait) ||
             (excerpt_traits == UndefinedPixelTrait))
           continue;
@@ -994,7 +1013,7 @@ MagickExport Image *ExcerptImage(const Image *image,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_ExcerptImage)
+        #pragma omp critical (MagickCore_ExcerptImage)
 #endif
         proceed=SetImageProgress(image,ExcerptImageTag,progress++,image->rows);
         if (proceed == MagickFalse)
@@ -1065,10 +1084,10 @@ MagickExport Image *ExtentImage(const Image *image,
       return((Image *) NULL);
     }
   if (extent_image->background_color.alpha != OpaqueAlpha)
-    extent_image->matte=MagickTrue;
-  (void) SetImageBackgroundColor(extent_image);
-  (void) CompositeImage(extent_image,image->compose,image,-geometry->x,
-    -geometry->y);
+    extent_image->alpha_trait=BlendPixelTrait;
+  (void) SetImageBackgroundColor(extent_image,exception);
+  (void) CompositeImage(extent_image,image,image->compose,MagickTrue,
+    -geometry->x,-geometry->y,exception);
   return(extent_image);
 }
 \f
@@ -1135,10 +1154,11 @@ MagickExport Image *FlipImage(const Image *image,ExceptionInfo *exception)
   status=MagickTrue;
   progress=0;
   page=image->page;
-  image_view=AcquireCacheView(image);
-  flip_view=AcquireCacheView(flip_image);
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1)
+  image_view=AcquireVirtualCacheView(image,exception);
+  flip_view=AcquireAuthenticCacheView(flip_image,exception);
+#if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(NoBenefitFromParallelism)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) flip_image->rows; y++)
   {
@@ -1166,6 +1186,12 @@ MagickExport Image *FlipImage(const Image *image,ExceptionInfo *exception)
       register ssize_t
         i;
 
+      if (GetPixelMask(image,p) != 0)
+        {
+          p+=GetPixelChannels(image);
+          q+=GetPixelChannels(flip_image);
+          continue;
+        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
@@ -1175,9 +1201,9 @@ MagickExport Image *FlipImage(const Image *image,ExceptionInfo *exception)
           flip_traits,
           traits;
 
-        traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
-        channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
-        flip_traits=GetPixelChannelMapTraits(flip_image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
+        flip_traits=GetPixelChannelTraits(flip_image,channel);
         if ((traits == UndefinedPixelTrait) ||
             (flip_traits == UndefinedPixelTrait))
           continue;
@@ -1193,8 +1219,8 @@ MagickExport Image *FlipImage(const Image *image,ExceptionInfo *exception)
         MagickBooleanType
           proceed;
 
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_FlipImage)
+#if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(NoBenefitFromParallelism)
+        #pragma omp critical (MagickCore_FlipImage)
 #endif
         proceed=SetImageProgress(image,FlipImageTag,progress++,image->rows);
         if (proceed == MagickFalse)
@@ -1275,10 +1301,11 @@ MagickExport Image *FlopImage(const Image *image,ExceptionInfo *exception)
   status=MagickTrue;
   progress=0;
   page=image->page;
-  image_view=AcquireCacheView(image);
-  flop_view=AcquireCacheView(flop_image);
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1)
+  image_view=AcquireVirtualCacheView(image,exception);
+  flop_view=AcquireAuthenticCacheView(flop_image,exception);
+#if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(NoBenefitFromParallelism)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) flop_image->rows; y++)
   {
@@ -1308,6 +1335,11 @@ MagickExport Image *FlopImage(const Image *image,ExceptionInfo *exception)
         i;
 
       q-=GetPixelChannels(flop_image);
+      if (GetPixelMask(image,p) != 0)
+        {
+          p+=GetPixelChannels(image);
+          continue;
+        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
@@ -1317,9 +1349,9 @@ MagickExport Image *FlopImage(const Image *image,ExceptionInfo *exception)
           flop_traits,
           traits;
 
-        traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
-        channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
-        flop_traits=GetPixelChannelMapTraits(flop_image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
+        flop_traits=GetPixelChannelTraits(flop_image,channel);
         if ((traits == UndefinedPixelTrait) ||
             (flop_traits == UndefinedPixelTrait))
           continue;
@@ -1334,8 +1366,8 @@ MagickExport Image *FlopImage(const Image *image,ExceptionInfo *exception)
         MagickBooleanType
           proceed;
 
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_FlopImage)
+#if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(NoBenefitFromParallelism)
+        #pragma omp critical (MagickCore_FlopImage)
 #endif
         proceed=SetImageProgress(image,FlopImageTag,progress++,image->rows);
         if (proceed == MagickFalse)
@@ -1399,10 +1431,11 @@ static inline MagickBooleanType CopyImageRegion(Image *destination,
     y;
 
   status=MagickTrue;
-  source_view=AcquireCacheView(source);
-  destination_view=AcquireCacheView(destination);
+  source_view=AcquireVirtualCacheView(source,exception);
+  destination_view=AcquireAuthenticCacheView(destination,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(status)
+  #pragma omp parallel for schedule(static,4) shared(status) \
+    dynamic_number_threads(source,columns,rows,1)
 #endif
   for (y=0; y < (ssize_t) rows; y++)
   {
@@ -1435,6 +1468,12 @@ static inline MagickBooleanType CopyImageRegion(Image *destination,
       register ssize_t
         i;
 
+      if (GetPixelMask(source,p) != 0)
+        {
+          p+=GetPixelChannels(source);
+          q+=GetPixelChannels(destination);
+          continue;
+        }
       for (i=0; i < (ssize_t) GetPixelChannels(source); i++)
       {
         PixelChannel
@@ -1444,9 +1483,9 @@ static inline MagickBooleanType CopyImageRegion(Image *destination,
           destination_traits,
           source_traits;
 
-        source_traits=GetPixelChannelMapTraits(source,(PixelChannel) i);
-        channel=GetPixelChannelMapChannel(source,(PixelChannel) i);
-        destination_traits=GetPixelChannelMapTraits(destination,channel);
+        channel=GetPixelChannelChannel(source,i);
+        source_traits=GetPixelChannelTraits(source,channel);
+        destination_traits=GetPixelChannelTraits(destination,channel);
         if ((source_traits == UndefinedPixelTrait) ||
             (destination_traits == UndefinedPixelTrait))
           continue;
@@ -1661,7 +1700,7 @@ MagickExport Image *SpliceImage(const Image *image,
       splice_image=DestroyImage(splice_image);
       return((Image *) NULL);
     }
-  (void) SetImageBackgroundColor(splice_image);
+  (void) SetImageBackgroundColor(splice_image,exception);
   /*
     Respect image geometry.
   */
@@ -1686,7 +1725,6 @@ MagickExport Image *SpliceImage(const Image *image,
       splice_geometry.y+=(ssize_t) splice_geometry.width/2;
       break;
     }
-    case StaticGravity:
     case CenterGravity:
     {
       splice_geometry.x+=(ssize_t) splice_geometry.width/2;
@@ -1722,10 +1760,11 @@ MagickExport Image *SpliceImage(const Image *image,
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
-  splice_view=AcquireCacheView(splice_image);
+  image_view=AcquireVirtualCacheView(image,exception);
+  splice_view=AcquireAuthenticCacheView(splice_image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) splice_geometry.y; y++)
   {
@@ -1753,6 +1792,12 @@ MagickExport Image *SpliceImage(const Image *image,
       register ssize_t
         i;
 
+      if (GetPixelMask(image,p) != 0)
+        {
+          p+=GetPixelChannels(image);
+          q+=GetPixelChannels(splice_image);
+          continue;
+        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
@@ -1762,9 +1807,9 @@ MagickExport Image *SpliceImage(const Image *image,
           splice_traits,
           traits;
 
-        traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
-        channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
-        splice_traits=GetPixelChannelMapTraits(splice_image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
+        splice_traits=GetPixelChannelTraits(splice_image,channel);
         if ((traits == UndefinedPixelTrait) ||
             (splice_traits == UndefinedPixelTrait))
           continue;
@@ -1780,6 +1825,12 @@ MagickExport Image *SpliceImage(const Image *image,
       register ssize_t
         i;
 
+      if (GetPixelMask(image,p) != 0)
+        {
+          p+=GetPixelChannels(image);
+          q+=GetPixelChannels(splice_image);
+          continue;
+        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
@@ -1789,9 +1840,9 @@ MagickExport Image *SpliceImage(const Image *image,
           traits,
           splice_traits;
 
-        traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
-        channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
-        splice_traits=GetPixelChannelMapTraits(splice_image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
+        splice_traits=GetPixelChannelTraits(splice_image,channel);
         if ((traits == UndefinedPixelTrait) ||
             (splice_traits == UndefinedPixelTrait))
           continue;
@@ -1808,7 +1859,7 @@ MagickExport Image *SpliceImage(const Image *image,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_TransposeImage)
+        #pragma omp critical (MagickCore_TransposeImage)
 #endif
         proceed=SetImageProgress(image,SpliceImageTag,progress++,
           splice_image->rows);
@@ -1817,7 +1868,8 @@ MagickExport Image *SpliceImage(const Image *image,
       }
   }
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=(ssize_t) (splice_geometry.y+splice_geometry.height);
        y < (ssize_t) splice_image->rows; y++)
@@ -1849,6 +1901,12 @@ MagickExport Image *SpliceImage(const Image *image,
       register ssize_t
         i;
 
+      if (GetPixelMask(image,q) != 0)
+        {
+          p+=GetPixelChannels(image);
+          q+=GetPixelChannels(splice_image);
+          continue;
+        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
@@ -1858,9 +1916,9 @@ MagickExport Image *SpliceImage(const Image *image,
           traits,
           splice_traits;
 
-        traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
-        channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
-        splice_traits=GetPixelChannelMapTraits(splice_image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
+        splice_traits=GetPixelChannelTraits(splice_image,channel);
         if ((traits == UndefinedPixelTrait) ||
             (splice_traits == UndefinedPixelTrait))
           continue;
@@ -1876,6 +1934,12 @@ MagickExport Image *SpliceImage(const Image *image,
       register ssize_t
         i;
 
+      if (GetPixelMask(image,q) != 0)
+        {
+          p+=GetPixelChannels(image);
+          q+=GetPixelChannels(splice_image);
+          continue;
+        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
@@ -1885,9 +1949,9 @@ MagickExport Image *SpliceImage(const Image *image,
           traits,
           splice_traits;
 
-        traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
-        channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
-        splice_traits=GetPixelChannelMapTraits(splice_image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
+        splice_traits=GetPixelChannelTraits(splice_image,channel);
         if ((traits == UndefinedPixelTrait) ||
             (splice_traits == UndefinedPixelTrait))
           continue;
@@ -1904,7 +1968,7 @@ MagickExport Image *SpliceImage(const Image *image,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_TransposeImage)
+        #pragma omp critical (MagickCore_TransposeImage)
 #endif
         proceed=SetImageProgress(image,SpliceImageTag,progress++,
           splice_image->rows);
@@ -1951,7 +2015,7 @@ MagickExport Image *SpliceImage(const Image *image,
 %  The format of the TransformImage method is:
 %
 %      MagickBooleanType TransformImage(Image **image,const char *crop_geometry,
-%        const char *image_geometry)
+%        const char *image_geometry,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -1963,9 +2027,11 @@ MagickExport Image *SpliceImage(const Image *image,
 %    o image_geometry: An image geometry string.  This geometry defines the
 %      final size of the image.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 MagickExport MagickBooleanType TransformImage(Image **image,
-  const char *crop_geometry,const char *image_geometry)
+  const char *crop_geometry,const char *image_geometry,ExceptionInfo *exception)
 {
   Image
     *resize_image,
@@ -1990,9 +2056,9 @@ MagickExport MagickBooleanType TransformImage(Image **image,
       /*
         Crop image to a user specified size.
       */
-      crop_image=CropImageToTiles(*image,crop_geometry,&(*image)->exception);
+      crop_image=CropImageToTiles(*image,crop_geometry,exception);
       if (crop_image == (Image *) NULL)
-        transform_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception);
+        transform_image=CloneImage(*image,0,0,MagickTrue,exception);
       else
         {
           transform_image=DestroyImage(transform_image);
@@ -2006,14 +2072,13 @@ MagickExport MagickBooleanType TransformImage(Image **image,
   /*
     Scale image to a user specified size.
   */
-  flags=ParseRegionGeometry(transform_image,image_geometry,&geometry,
-    &(*image)->exception);
+  flags=ParseRegionGeometry(transform_image,image_geometry,&geometry,exception);
   (void) flags;
   if ((transform_image->columns == geometry.width) &&
       (transform_image->rows == geometry.height))
     return(MagickTrue);
   resize_image=ResizeImage(transform_image,geometry.width,geometry.height,
-    transform_image->filter,transform_image->blur,&(*image)->exception);
+    transform_image->filter,exception);
   if (resize_image == (Image *) NULL)
     return(MagickFalse);
   transform_image=DestroyImage(transform_image);
@@ -2038,7 +2103,8 @@ MagickExport MagickBooleanType TransformImage(Image **image,
 %  The format of the TransformImage method is:
 %
 %      MagickBooleanType TransformImages(Image **image,
-%        const char *crop_geometry,const char *image_geometry)
+%        const char *crop_geometry,const char *image_geometry,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -2050,9 +2116,11 @@ MagickExport MagickBooleanType TransformImage(Image **image,
 %    o image_geometry: An image geometry string.  This geometry defines the
 %      final size of the image.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 MagickExport MagickBooleanType TransformImages(Image **images,
-  const char *crop_geometry,const char *image_geometry)
+  const char *crop_geometry,const char *image_geometry,ExceptionInfo *exception)
 {
   Image
     *image,
@@ -2070,7 +2138,7 @@ MagickExport MagickBooleanType TransformImages(Image **images,
   if ((*images)->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
       (*images)->filename);
-  image_list=ImageListToArray(*images,&(*images)->exception);
+  image_list=ImageListToArray(*images,exception);
   if (image_list == (Image **) NULL)
     return(MagickFalse);
   status=MagickTrue;
@@ -2078,7 +2146,7 @@ MagickExport MagickBooleanType TransformImages(Image **images,
   for (i=0; image_list[i] != (Image *) NULL; i++)
   {
     image=image_list[i];
-    status|=TransformImage(&image,crop_geometry,image_geometry);
+    status|=TransformImage(&image,crop_geometry,image_geometry,exception);
     AppendImageToList(&transform_images,image);
   }
   *images=transform_images;
@@ -2149,10 +2217,11 @@ MagickExport Image *TransposeImage(const Image *image,ExceptionInfo *exception)
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
-  transpose_view=AcquireCacheView(transpose_image);
+  image_view=AcquireVirtualCacheView(image,exception);
+  transpose_view=AcquireAuthenticCacheView(transpose_image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -2181,6 +2250,12 @@ MagickExport Image *TransposeImage(const Image *image,ExceptionInfo *exception)
       register ssize_t
         i;
 
+      if (GetPixelMask(image,q) != 0)
+        {
+          p+=GetPixelChannels(image);
+          q+=GetPixelChannels(transpose_image);
+          continue;
+        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
@@ -2190,9 +2265,9 @@ MagickExport Image *TransposeImage(const Image *image,ExceptionInfo *exception)
           traits,
           transpose_traits;
 
-        traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
-        channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
-        transpose_traits=GetPixelChannelMapTraits(transpose_image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
+        transpose_traits=GetPixelChannelTraits(transpose_image,channel);
         if ((traits == UndefinedPixelTrait) ||
             (transpose_traits == UndefinedPixelTrait))
           continue;
@@ -2209,7 +2284,7 @@ MagickExport Image *TransposeImage(const Image *image,ExceptionInfo *exception)
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_TransposeImage)
+        #pragma omp critical (MagickCore_TransposeImage)
 #endif
         proceed=SetImageProgress(image,TransposeImageTag,progress++,
           image->rows);
@@ -2292,10 +2367,11 @@ MagickExport Image *TransverseImage(const Image *image,ExceptionInfo *exception)
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
-  transverse_view=AcquireCacheView(transverse_image);
+  image_view=AcquireVirtualCacheView(image,exception);
+  transverse_view=AcquireAuthenticCacheView(transverse_image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -2328,6 +2404,11 @@ MagickExport Image *TransverseImage(const Image *image,ExceptionInfo *exception)
         i;
 
       q-=GetPixelChannels(transverse_image);
+      if (GetPixelMask(image,p) != 0)
+        {
+          p+=GetPixelChannels(image);
+          continue;
+        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
@@ -2337,9 +2418,9 @@ MagickExport Image *TransverseImage(const Image *image,ExceptionInfo *exception)
           traits,
           transverse_traits;
 
-        traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
-        channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
-        transverse_traits=GetPixelChannelMapTraits(transverse_image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
+        transverse_traits=GetPixelChannelTraits(transverse_image,channel);
         if ((traits == UndefinedPixelTrait) ||
             (transverse_traits == UndefinedPixelTrait))
           continue;
@@ -2356,7 +2437,7 @@ MagickExport Image *TransverseImage(const Image *image,ExceptionInfo *exception)
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_TransverseImage)
+        #pragma omp critical (MagickCore_TransverseImage)
 #endif
         proceed=SetImageProgress(image,TransverseImageTag,progress++,
           image->rows);
@@ -2425,7 +2506,7 @@ MagickExport Image *TrimImage(const Image *image,ExceptionInfo *exception)
       if (crop_image == (Image *) NULL)
         return((Image *) NULL);
       crop_image->background_color.alpha=(Quantum) TransparentAlpha;
-      (void) SetImageBackgroundColor(crop_image);
+      (void) SetImageBackgroundColor(crop_image,exception);
       crop_image->page=image->page;
       crop_image->page.x=(-1);
       crop_image->page.y=(-1);