]> granicus.if.org Git - imagemagick/blobdiff - magick/display.c
(no commit message)
[imagemagick] / magick / display.c
index 58b6bb6ee51dcbfb60e113321b938b861b1ba0ef..29b3111f4594963c094501e0d58396672a5938ba 100644 (file)
@@ -17,7 +17,7 @@
 %                                July 1992                                    %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2011 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  %
@@ -92,7 +92,7 @@
 /*
   Define declarations.
 */
-#define MaxColors  MagickMin(windows->visual_info->colormap_size,256L)
+#define MaxColors  MagickMin((ssize_t) windows->visual_info->colormap_size,256L)
 \f
 /*
   Constant declarations.
@@ -102,6 +102,10 @@ static const unsigned char
   {
     0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55
   },
+  OpaqueBitmap[8] =
+  {
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+  },
   ShadowBitmap[8] =
   {
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@@ -1500,6 +1504,8 @@ typedef enum
 #define DiagonalHeight  16
 #define HighlightWidth  8
 #define HighlightHeight  8
+#define OpaqueWidth  8
+#define OpaqueHeight  8
 #define ScalesWidth  16
 #define ScalesHeight  16
 #define ShadowWidth  8
@@ -2234,7 +2240,7 @@ static MagickBooleanType XAnnotateEditImage(Display *display,
   /*
     Initialize annotate structure.
   */
-  annotate_info=(XAnnotateInfo *) AcquireAlignedMemory(1,sizeof(*annotate_info));
+  annotate_info=(XAnnotateInfo *) AcquireMagickMemory(sizeof(*annotate_info));
   if (annotate_info == (XAnnotateInfo *) NULL)
     return(MagickFalse);
   XGetAnnotateInfo(annotate_info);
@@ -2251,7 +2257,7 @@ static MagickBooleanType XAnnotateEditImage(Display *display,
   annotate_info->degrees=degrees;
   annotate_info->font_info=font_info;
   annotate_info->text=(char *) AcquireQuantumMemory((size_t)
-    windows->image.width/MagickMax(font_info->min_bounds.width,1)+2UL,
+    windows->image.width/MagickMax((ssize_t) font_info->min_bounds.width,1)+2UL,
     sizeof(*annotate_info->text));
   if (annotate_info->text == (char *) NULL)
     return(MagickFalse);
@@ -2525,8 +2531,8 @@ static MagickBooleanType XAnnotateEditImage(Display *display,
             annotate_info->next->previous=annotate_info;
             annotate_info=annotate_info->next;
             annotate_info->text=(char *) AcquireQuantumMemory((size_t)
-              windows->image.width/MagickMax(font_info->min_bounds.width,1)+2UL,
-              sizeof(*annotate_info->text));
+              windows->image.width/MagickMax((ssize_t)
+              font_info->min_bounds.width,1)+2UL,sizeof(*annotate_info->text));
             if (annotate_info->text == (char *) NULL)
               return(MagickFalse);
             annotate_info->y+=annotate_info->height;
@@ -2620,8 +2626,8 @@ static MagickBooleanType XAnnotateEditImage(Display *display,
           annotate_info->next->previous=annotate_info;
           annotate_info=annotate_info->next;
           annotate_info->text=(char *) AcquireQuantumMemory((size_t)
-            windows->image.width/MagickMax(font_info->min_bounds.width,1)+2UL,
-            sizeof(*annotate_info->text));
+            windows->image.width/MagickMax((ssize_t)
+            font_info->min_bounds.width,1)+2UL,sizeof(*annotate_info->text));
           if (annotate_info->text == (char *) NULL)
             return(MagickFalse);
           annotate_info->y+=annotate_info->height;
@@ -3147,13 +3153,13 @@ static MagickBooleanType XChopImage(Display *display,
     if (direction == HorizontalChopCommand)
       {
         chop_info.width=(size_t) (segment_info.x2-segment_info.x1+1);
-        chop_info.x=windows->image.x+segment_info.x1;
+        chop_info.x=(ssize_t) windows->image.x+segment_info.x1;
         chop_info.height=0;
         chop_info.y=0;
         if (segment_info.x1 > (int) segment_info.x2)
           {
             chop_info.width=(size_t) (segment_info.x1-segment_info.x2+1);
-            chop_info.x=windows->image.x+segment_info.x2;
+            chop_info.x=(ssize_t) windows->image.x+segment_info.x2;
           }
       }
     else
@@ -3161,12 +3167,11 @@ static MagickBooleanType XChopImage(Display *display,
         chop_info.width=0;
         chop_info.height=(size_t) (segment_info.y2-segment_info.y1+1);
         chop_info.x=0;
-        chop_info.y=windows->image.y+segment_info.y1;
+        chop_info.y=(ssize_t) windows->image.y+segment_info.y1;
         if (segment_info.y1 > segment_info.y2)
           {
-            chop_info.height=(size_t)
-              (segment_info.y1-segment_info.y2+1);
-            chop_info.y=windows->image.y+segment_info.y2;
+            chop_info.height=(size_t) (segment_info.y1-segment_info.y2+1);
+            chop_info.y=(ssize_t) windows->image.y+segment_info.y2;
           }
       }
   } while ((state & ExitState) == 0);
@@ -3192,11 +3197,11 @@ static MagickBooleanType XChopImage(Display *display,
     (void) XParseGeometry(windows->image.crop_geometry,&x,&y,&width,&height);
   scale_factor=(MagickRealType) width/windows->image.ximage->width;
   chop_info.x+=x;
-  chop_info.x=(int) (scale_factor*chop_info.x+0.5);
+  chop_info.x=(ssize_t) (scale_factor*chop_info.x+0.5);
   chop_info.width=(unsigned int) (scale_factor*chop_info.width+0.5);
   scale_factor=(MagickRealType) height/windows->image.ximage->height;
   chop_info.y+=y;
-  chop_info.y=(int) (scale_factor*chop_info.y+0.5);
+  chop_info.y=(ssize_t) (scale_factor*chop_info.y+0.5);
   chop_info.height=(unsigned int) (scale_factor*chop_info.height+0.5);
   /*
     Chop image.
@@ -3662,6 +3667,9 @@ static MagickBooleanType XColorEditImage(Display *display,
     y_offset=y;
     if ((state & UpdateConfigurationState) != 0)
       {
+        CacheView
+          *image_view;
+
         int
           x,
           y;
@@ -3686,10 +3694,11 @@ static MagickBooleanType XColorEditImage(Display *display,
           (height*(windows->image.y+y_offset)/windows->image.ximage->height+y);
         if ((x_offset < 0) || (y_offset < 0))
           continue;
-        if ((x_offset >= (ssize_t) (*image)->columns) ||
-            (y_offset >= (ssize_t) (*image)->rows))
+        if ((x_offset >= (int) (*image)->columns) ||
+            (y_offset >= (int) (*image)->rows))
           continue;
         exception=(&(*image)->exception);
+        image_view=AcquireCacheView(*image);
         switch (method)
         {
           case PointMethod:
@@ -3700,13 +3709,15 @@ static MagickBooleanType XColorEditImage(Display *display,
             */
             if (SetImageStorageClass(*image,DirectClass) == MagickFalse)
               return(MagickFalse);
-            q=GetAuthenticPixels(*image,x_offset,y_offset,1,1,exception);
+            q=GetCacheViewAuthenticPixels(image_view,(ssize_t)x_offset,
+              (ssize_t)y_offset,1,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
             q->red=ScaleShortToQuantum(color.red);
             q->green=ScaleShortToQuantum(color.green);
             q->blue=ScaleShortToQuantum(color.blue);
-            (void) SyncAuthenticPixels(*image,&(*image)->exception);
+            (void) SyncCacheViewAuthenticPixels(image_view,
+              &(*image)->exception);
             break;
           }
           case ReplaceMethod:
@@ -3717,14 +3728,14 @@ static MagickBooleanType XColorEditImage(Display *display,
             /*
               Update color information using replace algorithm.
             */
-            (void) GetOneVirtualPixel(*image,x_offset,y_offset,&target,
-              &(*image)->exception);
+            (void) GetOneCacheViewVirtualPixel(image_view,(ssize_t) x_offset,
+              (ssize_t) y_offset,&target,&(*image)->exception);
             if ((*image)->storage_class == DirectClass)
               {
-                for (y=0; y < (ssize_t) (*image)->rows; y++)
+                for (y=0; y < (int) (*image)->rows; y++)
                 {
-                  q=GetAuthenticPixels(*image,0,y,(*image)->columns,1,
-                    exception);
+                  q=GetCacheViewAuthenticPixels(image_view,0,(ssize_t) y,
+                    (*image)->columns,1,exception);
                   if (q == (PixelPacket *) NULL)
                     break;
                   for (x=0; x < (int) (*image)->columns; x++)
@@ -3737,13 +3748,13 @@ static MagickBooleanType XColorEditImage(Display *display,
                       }
                     q++;
                   }
-                  if (SyncAuthenticPixels(*image,exception) == MagickFalse)
+                  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
                     break;
                 }
               }
             else
               {
-                for (i=0; i < (int) (*image)->colors; i++)
+                for (i=0; i < (ssize_t) (*image)->colors; i++)
                   if (IsColorSimilar(*image,(*image)->colormap+i,&target))
                     {
                       (*image)->colormap[i].red=ScaleShortToQuantum(color.red);
@@ -3768,8 +3779,8 @@ static MagickBooleanType XColorEditImage(Display *display,
             /*
               Update color information using floodfill algorithm.
             */
-            (void) GetOneVirtualMagickPixel(*image,x_offset,y_offset,&target,
-              exception);
+            (void) GetOneVirtualMagickPixel(*image,(ssize_t) x_offset,
+              (ssize_t) y_offset,&target,exception);
             if (method == FillToBorderMethod)
               {
                 target.red=(MagickRealType)
@@ -3784,8 +3795,8 @@ static MagickBooleanType XColorEditImage(Display *display,
             (void) QueryColorDatabase(resource_info->pen_colors[pen_id],
               &draw_info->fill,exception);
             (void) FloodfillPaintImage(*image,DefaultChannels,draw_info,&target,
-              x_offset,y_offset,method == FloodfillMethod ? MagickFalse :
-              MagickTrue);
+              (ssize_t) x_offset,(ssize_t) y_offset,
+              method == FloodfillMethod ? MagickFalse : MagickTrue);
             draw_info=DestroyDrawInfo(draw_info);
             break;
           }
@@ -3796,9 +3807,10 @@ static MagickBooleanType XColorEditImage(Display *display,
             */
             if (SetImageStorageClass(*image,DirectClass) == MagickFalse)
               return(MagickFalse);
-            for (y=0; y < (ssize_t) (*image)->rows; y++)
+            for (y=0; y < (int) (*image)->rows; y++)
             {
-              q=QueueAuthenticPixels(*image,0,y,(*image)->columns,1,exception);
+              q=QueueCacheViewAuthenticPixels(image_view,0,(ssize_t) y,
+                (*image)->columns,1,exception);
               if (q == (PixelPacket *) NULL)
                 break;
               for (x=0; x < (int) (*image)->columns; x++)
@@ -3808,12 +3820,13 @@ static MagickBooleanType XColorEditImage(Display *display,
                 q->blue=ScaleShortToQuantum(color.blue);
                 q++;
               }
-              if (SyncAuthenticPixels(*image,exception) == MagickFalse)
+              if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
                 break;
             }
             break;
           }
         }
+        image_view=DestroyCacheView(image_view);
         state&=(~UpdateConfigurationState);
       }
   } while ((state & ExitState) == 0);
@@ -3953,8 +3966,8 @@ static MagickBooleanType XCompositeImage(Display *display,
   XQueryPosition(display,windows->image.id,&x,&y);
   (void) XSelectInput(display,windows->image.id,
     windows->image.attributes.event_mask | PointerMotionMask);
-  composite_info.x=windows->image.x+x;
-  composite_info.y=windows->image.y+y;
+  composite_info.x=(ssize_t) windows->image.x+x;
+  composite_info.y=(ssize_t) windows->image.y+y;
   composite_info.width=0;
   composite_info.height=0;
   cursor=XCreateFontCursor(display,XC_ul_angle);
@@ -4091,8 +4104,8 @@ static MagickBooleanType XCompositeImage(Display *display,
         composite_info.width=composite_image->columns;
         composite_info.height=composite_image->rows;
         (void) XCheckDefineCursor(display,windows->image.id,cursor);
-        composite_info.x=windows->image.x+event.xbutton.x;
-        composite_info.y=windows->image.y+event.xbutton.y;
+        composite_info.x=(ssize_t) windows->image.x+event.xbutton.x;
+        composite_info.y=(ssize_t) windows->image.y+event.xbutton.y;
         break;
       }
       case ButtonRelease:
@@ -4110,8 +4123,8 @@ static MagickBooleanType XCompositeImage(Display *display,
             /*
               User has selected the location of the composite image.
             */
-            composite_info.x=windows->image.x+event.xbutton.x;
-            composite_info.y=windows->image.y+event.xbutton.y;
+            composite_info.x=(ssize_t) windows->image.x+event.xbutton.x;
+            composite_info.y=(ssize_t) windows->image.y+event.xbutton.y;
             state|=ExitState;
           }
         break;
@@ -4190,8 +4203,8 @@ static MagickBooleanType XCompositeImage(Display *display,
           if ((x > (int) (windows->info.x+windows->info.width)) ||
               (y > (int) (windows->info.y+windows->info.height)))
             (void) XMapWindow(display,windows->info.id);
-        composite_info.x=windows->image.x+x;
-        composite_info.y=windows->image.y+y;
+        composite_info.x=(ssize_t) windows->image.x+x;
+        composite_info.y=(ssize_t) windows->image.y+y;
         break;
       }
       default:
@@ -4223,11 +4236,11 @@ static MagickBooleanType XCompositeImage(Display *display,
     (void) XParseGeometry(windows->image.crop_geometry,&x,&y,&width,&height);
   scale_factor=(MagickRealType) width/windows->image.ximage->width;
   composite_info.x+=x;
-  composite_info.x=(int) (scale_factor*composite_info.x+0.5);
+  composite_info.x=(ssize_t) (scale_factor*composite_info.x+0.5);
   composite_info.width=(unsigned int) (scale_factor*composite_info.width+0.5);
   scale_factor=(MagickRealType) height/windows->image.ximage->height;
   composite_info.y+=y;
-  composite_info.y=(int) (scale_factor*composite_info.y+0.5);
+  composite_info.y=(ssize_t) (scale_factor*composite_info.y+0.5);
   composite_info.height=(unsigned int) (scale_factor*composite_info.height+0.5);
   if ((composite_info.width != composite_image->columns) ||
       (composite_info.height != composite_image->rows))
@@ -4238,8 +4251,9 @@ static MagickBooleanType XCompositeImage(Display *display,
       /*
         Scale composite image.
       */
-      resize_image=ZoomImage(composite_image,composite_info.width,
-        composite_info.height,&image->exception);
+      resize_image=ResizeImage(composite_image,composite_info.width,
+        composite_info.height,composite_image->filter,composite_image->blur,
+        &image->exception);
       composite_image=DestroyImage(composite_image);
       if (resize_image == (Image *) NULL)
         {
@@ -4253,6 +4267,9 @@ static MagickBooleanType XCompositeImage(Display *display,
       displacement_geometry);
   if (blend != 0.0)
     {
+      CacheView
+        *image_view;
+
       ExceptionInfo
         *exception;
 
@@ -4278,9 +4295,11 @@ static MagickBooleanType XCompositeImage(Display *display,
         return(MagickFalse);
       image->matte=MagickTrue;
       exception=(&image->exception);
-      for (y=0; y < (ssize_t) image->rows; y++)
+      image_view=AcquireCacheView(image);
+      for (y=0; y < (int) image->rows; y++)
       {
-        q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
+        q=GetCacheViewAuthenticPixels(image_view,0,(ssize_t) y,image->columns,1,
+          exception);
         if (q == (PixelPacket *) NULL)
           break;
         for (x=0; x < (int) image->columns; x++)
@@ -4288,9 +4307,10 @@ static MagickBooleanType XCompositeImage(Display *display,
           q->opacity=opacity;
           q++;
         }
-        if (SyncAuthenticPixels(image,exception) == MagickFalse)
+        if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
           break;
       }
+      image_view=DestroyCacheView(image_view);
     }
   /*
     Composite image with X Image window.
@@ -4543,6 +4563,9 @@ static MagickBooleanType XCropImage(Display *display,
       RectifyDismissCommand
     };
 
+  CacheView
+    *image_view;
+
   char
     command[MaxTextExtent],
     text[MaxTextExtent];
@@ -4617,8 +4640,8 @@ static MagickBooleanType XCropImage(Display *display,
   XQueryPosition(display,windows->image.id,&x,&y);
   (void) XSelectInput(display,windows->image.id,
     windows->image.attributes.event_mask | PointerMotionMask);
-  crop_info.x=windows->image.x+x;
-  crop_info.y=windows->image.y+y;
+  crop_info.x=(ssize_t) windows->image.x+x;
+  crop_info.y=(ssize_t) windows->image.y+y;
   crop_info.width=0;
   crop_info.height=0;
   cursor=XCreateFontCursor(display,XC_fleur);
@@ -4699,8 +4722,8 @@ static MagickBooleanType XCropImage(Display *display,
           Note first corner of cropping rectangle-- exit loop.
         */
         (void) XCheckDefineCursor(display,windows->image.id,cursor);
-        crop_info.x=windows->image.x+event.xbutton.x;
-        crop_info.y=windows->image.y+event.xbutton.y;
+        crop_info.x=(ssize_t) windows->image.x+event.xbutton.x;
+        crop_info.y=(ssize_t) windows->image.y+event.xbutton.y;
         state|=ExitState;
         break;
       }
@@ -4783,8 +4806,8 @@ static MagickBooleanType XCropImage(Display *display,
           if ((x > (int) (windows->info.x+windows->info.width)) ||
               (y > (int) (windows->info.y+windows->info.height)))
             (void) XMapWindow(display,windows->info.id);
-        crop_info.x=windows->image.x+x;
-        crop_info.y=windows->image.y+y;
+        crop_info.x=(ssize_t) windows->image.x+x;
+        crop_info.y=(ssize_t) windows->image.y+y;
         break;
       }
       default:
@@ -4846,8 +4869,8 @@ static MagickBooleanType XCropImage(Display *display,
       {
         case ButtonPress:
         {
-          crop_info.x=windows->image.x+event.xbutton.x;
-          crop_info.y=windows->image.y+event.xbutton.y;
+          crop_info.x=(ssize_t) windows->image.x+event.xbutton.x;
+          crop_info.y=(ssize_t) windows->image.y+event.xbutton.y;
           break;
         }
         case ButtonRelease:
@@ -4855,8 +4878,8 @@ static MagickBooleanType XCropImage(Display *display,
           /*
             User has committed to cropping rectangle.
           */
-          crop_info.x=windows->image.x+event.xbutton.x;
-          crop_info.y=windows->image.y+event.xbutton.y;
+          crop_info.x=(ssize_t) windows->image.x+event.xbutton.x;
+          crop_info.y=(ssize_t) windows->image.y+event.xbutton.y;
           XSetCursorState(display,windows,MagickFalse);
           state|=ExitState;
           windows->command.data=0;
@@ -4868,8 +4891,8 @@ static MagickBooleanType XCropImage(Display *display,
           break;
         case MotionNotify:
         {
-          crop_info.x=windows->image.x+event.xmotion.x;
-          crop_info.y=windows->image.y+event.xmotion.y;
+          crop_info.x=(ssize_t) windows->image.x+event.xmotion.x;
+          crop_info.y=(ssize_t) windows->image.y+event.xmotion.y;
         }
         default:
           break;
@@ -4883,26 +4906,26 @@ static MagickBooleanType XCropImage(Display *display,
           if (crop_info.x < 0)
             crop_info.x=0;
           else
-            if (crop_info.x > (int) windows->image.ximage->width)
-              crop_info.x=windows->image.ximage->width;
+            if (crop_info.x > (ssize_t) windows->image.ximage->width)
+              crop_info.x=(ssize_t) windows->image.ximage->width;
           if ((int) crop_info.x < x)
             crop_info.width=(unsigned int) (x-crop_info.x);
           else
             {
               crop_info.width=(unsigned int) (crop_info.x-x);
-              crop_info.x=x;
+              crop_info.x=(ssize_t) x;
             }
           if (crop_info.y < 0)
             crop_info.y=0;
           else
-            if (crop_info.y > (int) windows->image.ximage->height)
-              crop_info.y=windows->image.ximage->height;
+            if (crop_info.y > (ssize_t) windows->image.ximage->height)
+              crop_info.y=(ssize_t) windows->image.ximage->height;
           if ((int) crop_info.y < y)
             crop_info.height=(unsigned int) (y-crop_info.y);
           else
             {
               crop_info.height=(unsigned int) (crop_info.y-y);
-              crop_info.y=y;
+              crop_info.y=(ssize_t) y;
             }
         }
     } while ((state & ExitState) == 0);
@@ -5095,8 +5118,10 @@ static MagickBooleanType XCropImage(Display *display,
             case XK_Home:
             case XK_KP_Home:
             {
-              crop_info.x=(ssize_t) (windows->image.width/2L-crop_info.width/2L);
-              crop_info.y=(ssize_t) (windows->image.height/2L-crop_info.height/2L);
+              crop_info.x=(ssize_t) (windows->image.width/2L-
+                crop_info.width/2L);
+              crop_info.y=(ssize_t) (windows->image.height/2L-
+                crop_info.height/2L);
               break;
             }
             case XK_Left:
@@ -5187,8 +5212,8 @@ static MagickBooleanType XCropImage(Display *display,
             if ((x > (int) (windows->info.x+windows->info.width)) ||
                 (y > (int) (windows->info.y+windows->info.height)))
               (void) XMapWindow(display,windows->info.id);
-          crop_info.x=windows->image.x+event.xmotion.x;
-          crop_info.y=windows->image.y+event.xmotion.y;
+          crop_info.x=(ssize_t) windows->image.x+event.xmotion.x;
+          crop_info.y=(ssize_t) windows->image.y+event.xmotion.y;
           break;
         }
         case SelectionRequest:
@@ -5263,11 +5288,11 @@ static MagickBooleanType XCropImage(Display *display,
     (void) XParseGeometry(windows->image.crop_geometry,&x,&y,&width,&height);
   scale_factor=(MagickRealType) width/windows->image.ximage->width;
   crop_info.x+=x;
-  crop_info.x=(int) (scale_factor*crop_info.x+0.5);
+  crop_info.x=(ssize_t) (scale_factor*crop_info.x+0.5);
   crop_info.width=(unsigned int) (scale_factor*crop_info.width+0.5);
   scale_factor=(MagickRealType) height/windows->image.ximage->height;
   crop_info.y+=y;
-  crop_info.y=(int) (scale_factor*crop_info.y+0.5);
+  crop_info.y=(ssize_t) (scale_factor*crop_info.y+0.5);
   crop_info.height=(unsigned int) (scale_factor*crop_info.height+0.5);
   crop_image=CropImage(image,&crop_info,&image->exception);
   XSetCursorState(display,windows,MagickFalse);
@@ -5288,10 +5313,11 @@ static MagickBooleanType XCropImage(Display *display,
     return(MagickFalse);
   image->matte=MagickTrue;
   exception=(&image->exception);
-  for (y=0; y < (ssize_t) crop_info.height; y++)
+  image_view=AcquireCacheView(image);
+  for (y=0; y < (int) crop_info.height; y++)
   {
-    q=GetAuthenticPixels(image,crop_info.x,y+crop_info.y,crop_info.width,1,
-      exception);
+    q=GetCacheViewAuthenticPixels(image_view,crop_info.x,y+crop_info.y,
+      crop_info.width,1,exception);
     if (q == (PixelPacket *) NULL)
       break;
     for (x=0; x < (int) crop_info.width; x++)
@@ -5299,9 +5325,10 @@ static MagickBooleanType XCropImage(Display *display,
       q->opacity=(Quantum) TransparentOpacity;
       q++;
     }
-    if (SyncAuthenticPixels(image,exception) == MagickFalse)
+    if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
       break;
   }
+  image_view=DestroyCacheView(image_view);
   /*
     Update image configuration.
   */
@@ -5614,8 +5641,6 @@ static MagickBooleanType XDrawEditImage(Display *display,
               if (stipple != (Pixmap) NULL)
                 (void) XFreePixmap(display,stipple);
               stipple=(Pixmap) NULL;
-              if (entry == 6)
-                break;
               if (entry != 7)
                 {
                   switch (entry)
@@ -5651,13 +5676,19 @@ static MagickBooleanType XDrawEditImage(Display *display,
                       break;
                     }
                     case 5:
-                    default:
                     {
                       stipple=XCreateBitmapFromData(display,root_window,
                         (char *) HighlightBitmap,HighlightWidth,
                         HighlightHeight);
                       break;
                     }
+                    case 6:
+                    default:
+                    {
+                      stipple=XCreateBitmapFromData(display,root_window,
+                        (char *) OpaqueBitmap,OpaqueWidth,OpaqueHeight);
+                      break;
+                    }
                   }
                   break;
                 }
@@ -5717,7 +5748,8 @@ static MagickBooleanType XDrawEditImage(Display *display,
                 break;
               if (entry != 5)
                 {
-                  line_width=(unsigned int) StringToUnsignedLong(WidthsMenu[entry]);
+                  line_width=(unsigned int) StringToUnsignedLong(
+                    WidthsMenu[entry]);
                   break;
                 }
               (void) XDialogWidget(display,windows,"Ok","Enter line width:",
@@ -5850,8 +5882,8 @@ static MagickBooleanType XDrawEditImage(Display *display,
     line_info.y1=y;
     line_info.x2=x;
     line_info.y2=y;
-    rectangle_info.x=x;
-    rectangle_info.y=y;
+    rectangle_info.x=(ssize_t) x;
+    rectangle_info.y=(ssize_t) y;
     rectangle_info.width=0;
     rectangle_info.height=0;
     number_coordinates=1;
@@ -6036,8 +6068,8 @@ static MagickBooleanType XDrawEditImage(Display *display,
           */
           line_info.x2=event.xbutton.x;
           line_info.y2=event.xbutton.y;
-          rectangle_info.x=event.xbutton.x;
-          rectangle_info.y=event.xbutton.y;
+          rectangle_info.x=(ssize_t) event.xbutton.x;
+          rectangle_info.y=(ssize_t) event.xbutton.y;
           coordinate_info[number_coordinates].x=event.xbutton.x;
           coordinate_info[number_coordinates].y=event.xbutton.y;
           if (((element != PolygonElement) &&
@@ -6071,8 +6103,8 @@ static MagickBooleanType XDrawEditImage(Display *display,
             {
               line_info.x2=event.xmotion.x;
               line_info.y2=event.xmotion.y;
-              rectangle_info.x=event.xmotion.x;
-              rectangle_info.y=event.xmotion.y;
+              rectangle_info.x=(ssize_t) event.xmotion.x;
+              rectangle_info.y=(ssize_t) event.xmotion.y;
               break;
             }
           coordinate_info[number_coordinates].x=event.xbutton.x;
@@ -6113,26 +6145,26 @@ static MagickBooleanType XDrawEditImage(Display *display,
           if (rectangle_info.x < 0)
             rectangle_info.x=0;
           else
-            if (rectangle_info.x > (int) windows->image.width)
+            if (rectangle_info.x > (ssize_t) windows->image.width)
               rectangle_info.x=(ssize_t) windows->image.width;
           if ((int) rectangle_info.x < x)
             rectangle_info.width=(unsigned int) (x-rectangle_info.x);
           else
             {
               rectangle_info.width=(unsigned int) (rectangle_info.x-x);
-              rectangle_info.x=x;
+              rectangle_info.x=(ssize_t) x;
             }
           if (rectangle_info.y < 0)
             rectangle_info.y=0;
           else
-            if (rectangle_info.y > (int) windows->image.height)
+            if (rectangle_info.y > (ssize_t) windows->image.height)
               rectangle_info.y=(ssize_t) windows->image.height;
           if ((int) rectangle_info.y < y)
             rectangle_info.height=(unsigned int) (y-rectangle_info.y);
           else
             {
               rectangle_info.height=(unsigned int) (rectangle_info.y-y);
-              rectangle_info.y=y;
+              rectangle_info.y=(ssize_t) y;
             }
         }
     } while ((state & ExitState) == 0);
@@ -6143,8 +6175,8 @@ static MagickBooleanType XDrawEditImage(Display *display,
         /*
           Determine polygon bounding box.
         */
-        rectangle_info.x=coordinate_info->x;
-        rectangle_info.y=coordinate_info->y;
+        rectangle_info.x=(ssize_t) coordinate_info->x;
+        rectangle_info.y=(ssize_t) coordinate_info->y;
         x=coordinate_info->x;
         y=coordinate_info->y;
         for (i=1; i < number_coordinates; i++)
@@ -6153,10 +6185,10 @@ static MagickBooleanType XDrawEditImage(Display *display,
             x=coordinate_info[i].x;
           if (coordinate_info[i].y > y)
             y=coordinate_info[i].y;
-          if (coordinate_info[i].x < rectangle_info.x)
-            rectangle_info.x=MagickMax(coordinate_info[i].x,0);
-          if (coordinate_info[i].y < rectangle_info.y)
-            rectangle_info.y=MagickMax(coordinate_info[i].y,0);
+          if ((ssize_t) coordinate_info[i].x < rectangle_info.x)
+            rectangle_info.x=MagickMax((ssize_t) coordinate_info[i].x,0);
+          if ((ssize_t) coordinate_info[i].y < rectangle_info.y)
+            rectangle_info.y=MagickMax((ssize_t) coordinate_info[i].y,0);
         }
         rectangle_info.width=(size_t) (x-rectangle_info.x);
         rectangle_info.height=(size_t) (y-rectangle_info.y);
@@ -6237,9 +6269,9 @@ static MagickBooleanType XDrawEditImage(Display *display,
         Swap(draw_info.line_info.y1,draw_info.line_info.y2);
       }
     draw_info.rectangle_info=rectangle_info;
-    if (draw_info.rectangle_info.x > (int) (line_width/2))
+    if (draw_info.rectangle_info.x > (ssize_t) (line_width/2))
       draw_info.rectangle_info.x=(ssize_t) line_width/2;
-    if (draw_info.rectangle_info.y > (int) (line_width/2))
+    if (draw_info.rectangle_info.y > (ssize_t) (line_width/2))
       draw_info.rectangle_info.y=(ssize_t) line_width/2;
     draw_info.number_coordinates=(unsigned int) number_coordinates;
     draw_info.coordinate_info=coordinate_info;
@@ -6301,11 +6333,11 @@ static void XDrawPanRectangle(Display *display,XWindows *windows)
     Determine dimensions of the panning rectangle.
   */
   scale_factor=(MagickRealType) windows->pan.width/windows->image.ximage->width;
-  highlight_info.x=(int) (scale_factor*windows->image.x+0.5);
+  highlight_info.x=(ssize_t) (scale_factor*windows->image.x+0.5);
   highlight_info.width=(unsigned int) (scale_factor*windows->image.width+0.5);
   scale_factor=(MagickRealType)
     windows->pan.height/windows->image.ximage->height;
-  highlight_info.y=(int) (scale_factor*windows->image.y+0.5);
+  highlight_info.y=(ssize_t) (scale_factor*windows->image.y+0.5);
   highlight_info.height=(unsigned int) (scale_factor*windows->image.height+0.5);
   /*
     Display the panning rectangle.
@@ -8523,8 +8555,8 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info,
       if ((flags & PsiValue) == 0)
         geometry_info.psi=0.1*(*image)->rows;
       vignette_image=VignetteImage(*image,geometry_info.rho,geometry_info.sigma,
-        (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5),
-        &(*image)->exception);
+        (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
+        0.5),&(*image)->exception);
       if (vignette_image != (Image *) NULL)
         {
           *image=DestroyImage(*image);
@@ -9223,8 +9255,8 @@ static void XMagnifyImage(Display *display,XWindows *windows,XEvent *event)
   state=DefaultState;
   x=event->xbutton.x;
   y=event->xbutton.y;
-  windows->magnify.x=windows->image.x+x;
-  windows->magnify.y=windows->image.y+y;
+  windows->magnify.x=(int) windows->image.x+x;
+  windows->magnify.y=(int) windows->image.y+y;
   do
   {
     /*
@@ -9461,8 +9493,8 @@ static void XMakePanImage(Display *display,XResourceInfo *resource_info,
   */
   XSetCursorState(display,windows,MagickTrue);
   XCheckRefreshWindows(display,windows);
-  windows->pan.x=windows->image.x;
-  windows->pan.y=windows->image.y;
+  windows->pan.x=(int) windows->image.x;
+  windows->pan.y=(int) windows->image.y;
   status=XMakeImage(display,resource_info,&windows->pan,image,
     windows->pan.width,windows->pan.height);
   if (status == MagickFalse)
@@ -9911,6 +9943,9 @@ static MagickBooleanType XMatteEditImage(Display *display,
     y_offset=y;
     if ((state & UpdateConfigurationState) != 0)
       {
+        CacheView
+          *image_view;
+
         ExceptionInfo
           *exception;
 
@@ -9945,6 +9980,7 @@ static MagickBooleanType XMatteEditImage(Display *display,
           return(MagickFalse);
         (*image)->matte=MagickTrue;
         exception=(&(*image)->exception);
+        image_view=AcquireCacheView(*image);
         switch (method)
         {
           case PointMethod:
@@ -9953,11 +9989,12 @@ static MagickBooleanType XMatteEditImage(Display *display,
             /*
               Update matte information using point algorithm.
             */
-            q=GetAuthenticPixels(*image,x_offset,y_offset,1,1,exception);
+            q=GetCacheViewAuthenticPixels(image_view,(ssize_t) x_offset,
+              (ssize_t) y_offset,1,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
             q->opacity=(Quantum) StringToLong(matte);
-            (void) SyncAuthenticPixels(*image,exception);
+            (void) SyncCacheViewAuthenticPixels(image_view,exception);
             break;
           }
           case ReplaceMethod:
@@ -9968,12 +10005,12 @@ static MagickBooleanType XMatteEditImage(Display *display,
             /*
               Update matte information using replace algorithm.
             */
-            (void) GetOneVirtualPixel(*image,x_offset,y_offset,&target,
-              exception);
-            for (y=0; y < (ssize_t) (*image)->rows; y++)
+            (void) GetOneCacheViewVirtualPixel(image_view,(ssize_t) x_offset,
+              (ssize_t) y_offset,&target,exception);
+            for (y=0; y < (int) (*image)->rows; y++)
             {
-              q=GetAuthenticPixels(*image,0,y,(*image)->columns,1,
-                &(*image)->exception);
+              q=GetCacheViewAuthenticPixels(image_view,0,(ssize_t) y,
+                (*image)->columns,1,&(*image)->exception);
               if (q == (PixelPacket *) NULL)
                 break;
               for (x=0; x < (int) (*image)->columns; x++)
@@ -9982,7 +10019,7 @@ static MagickBooleanType XMatteEditImage(Display *display,
                   q->opacity=(Quantum) StringToLong(matte);
                 q++;
               }
-              if (SyncAuthenticPixels(*image,exception) == MagickFalse)
+              if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
                 break;
             }
             break;
@@ -9999,8 +10036,8 @@ static MagickBooleanType XMatteEditImage(Display *display,
             /*
               Update matte information using floodfill algorithm.
             */
-            (void) GetOneVirtualMagickPixel(*image,x_offset,y_offset,&target,
-              exception);
+            (void) GetOneVirtualMagickPixel(*image,(ssize_t) x_offset,
+              (ssize_t) y_offset,&target,exception);
             if (method == FillToBorderMethod)
               {
                 target.red=(MagickRealType)
@@ -10014,8 +10051,8 @@ static MagickBooleanType XMatteEditImage(Display *display,
               (DrawInfo *) NULL);
             draw_info->fill.opacity=ClampToQuantum(StringToDouble(matte));
             (void) FloodfillPaintImage(*image,OpacityChannel,draw_info,&target,
-              x_offset,y_offset,method == FloodfillMethod ? MagickFalse :
-              MagickTrue);
+              (ssize_t) x_offset,(ssize_t) y_offset,
+              method == FloodfillMethod ? MagickFalse : MagickTrue);
             draw_info=DestroyDrawInfo(draw_info);
             break;
           }
@@ -10026,9 +10063,10 @@ static MagickBooleanType XMatteEditImage(Display *display,
             */
             if (SetImageStorageClass(*image,DirectClass) == MagickFalse)
               return(MagickFalse);
-            for (y=0; y < (ssize_t) (*image)->rows; y++)
+            for (y=0; y < (int) (*image)->rows; y++)
             {
-              q=QueueAuthenticPixels(*image,0,y,(*image)->columns,1,exception);
+              q=QueueCacheViewAuthenticPixels(image_view,0,(ssize_t) y,
+                (*image)->columns,1,exception);
               if (q == (PixelPacket *) NULL)
                 break;
               for (x=0; x < (int) (*image)->columns; x++)
@@ -10036,7 +10074,7 @@ static MagickBooleanType XMatteEditImage(Display *display,
                 q->opacity=(Quantum) StringToLong(matte);
                 q++;
               }
-              if (SyncAuthenticPixels(*image,exception) == MagickFalse)
+              if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
                 break;
             }
             if (StringToLong(matte) == OpaqueOpacity)
@@ -10044,6 +10082,7 @@ static MagickBooleanType XMatteEditImage(Display *display,
             break;
           }
         }
+        image_view=DestroyCacheView(image_view);
         state&=(~UpdateConfigurationState);
       }
   } while ((state & ExitState) == 0);
@@ -10319,8 +10358,8 @@ static void XPanImage(Display *display,XWindows *windows,XEvent *event)
         /*
           User choose an initial pan location.
         */
-        pan_info.x=event->xbutton.x;
-        pan_info.y=event->xbutton.y;
+        pan_info.x=(ssize_t) event->xbutton.x;
+        pan_info.y=(ssize_t) event->xbutton.y;
         state|=UpdateConfigurationState;
         break;
       }
@@ -10329,15 +10368,15 @@ static void XPanImage(Display *display,XWindows *windows,XEvent *event)
         /*
           User has finished panning the image.
         */
-        pan_info.x=event->xbutton.x;
-        pan_info.y=event->xbutton.y;
+        pan_info.x=(ssize_t) event->xbutton.x;
+        pan_info.y=(ssize_t) event->xbutton.y;
         state|=UpdateConfigurationState | ExitState;
         break;
       }
       case MotionNotify:
       {
-        pan_info.x=event->xmotion.x;
-        pan_info.y=event->xmotion.y;
+        pan_info.x=(ssize_t) event->xmotion.x;
+        pan_info.y=(ssize_t) event->xmotion.y;
         state|=UpdateConfigurationState;
       }
       default:
@@ -10348,10 +10387,10 @@ static void XPanImage(Display *display,XWindows *windows,XEvent *event)
         /*
           Check boundary conditions.
         */
-        if (pan_info.x < (int) (pan_info.width/2))
+        if (pan_info.x < (ssize_t) (pan_info.width/2))
           pan_info.x=0;
         else
-          pan_info.x=(int) (x_factor*(pan_info.x-(pan_info.width/2)));
+          pan_info.x=(ssize_t) (x_factor*(pan_info.x-(pan_info.width/2)));
         if (pan_info.x < 0)
           pan_info.x=0;
         else
@@ -10513,8 +10552,8 @@ static MagickBooleanType XPasteImage(Display *display,
   XQueryPosition(display,windows->image.id,&x,&y);
   (void) XSelectInput(display,windows->image.id,
     windows->image.attributes.event_mask | PointerMotionMask);
-  paste_info.x=windows->image.x+x;
-  paste_info.y=windows->image.y+y;
+  paste_info.x=(ssize_t) windows->image.x+x;
+  paste_info.y=(ssize_t) windows->image.y+y;
   paste_info.width=0;
   paste_info.height=0;
   cursor=XCreateFontCursor(display,XC_ul_angle);
@@ -10619,8 +10658,8 @@ static MagickBooleanType XPasteImage(Display *display,
         scale_factor=(MagickRealType) windows->image.ximage->height/height;
         paste_info.height=(unsigned int) (scale_factor*paste_image->rows+0.5);
         (void) XCheckDefineCursor(display,windows->image.id,cursor);
-        paste_info.x=windows->image.x+event.xbutton.x;
-        paste_info.y=windows->image.y+event.xbutton.y;
+        paste_info.x=(ssize_t) windows->image.x+event.xbutton.x;
+        paste_info.y=(ssize_t) windows->image.y+event.xbutton.y;
         break;
       }
       case ButtonRelease:
@@ -10638,8 +10677,8 @@ static MagickBooleanType XPasteImage(Display *display,
             /*
               User has selected the location of the paste image.
             */
-            paste_info.x=windows->image.x+event.xbutton.x;
-            paste_info.y=windows->image.y+event.xbutton.y;
+            paste_info.x=(ssize_t) windows->image.x+event.xbutton.x;
+            paste_info.y=(ssize_t) windows->image.y+event.xbutton.y;
             state|=ExitState;
           }
         break;
@@ -10718,8 +10757,8 @@ static MagickBooleanType XPasteImage(Display *display,
           if ((x > (int) (windows->info.x+windows->info.width)) ||
               (y > (int) (windows->info.y+windows->info.height)))
             (void) XMapWindow(display,windows->info.id);
-        paste_info.x=windows->image.x+x;
-        paste_info.y=windows->image.y+y;
+        paste_info.x=(ssize_t) windows->image.x+x;
+        paste_info.y=(ssize_t) windows->image.y+y;
         break;
       }
       default:
@@ -10751,11 +10790,11 @@ static MagickBooleanType XPasteImage(Display *display,
     (void) XParseGeometry(windows->image.crop_geometry,&x,&y,&width,&height);
   scale_factor=(MagickRealType) width/windows->image.ximage->width;
   paste_info.x+=x;
-  paste_info.x=(int) (scale_factor*paste_info.x+0.5);
+  paste_info.x=(ssize_t) (scale_factor*paste_info.x+0.5);
   paste_info.width=(unsigned int) (scale_factor*paste_info.width+0.5);
   scale_factor=(MagickRealType) height/windows->image.ximage->height;
   paste_info.y+=y;
-  paste_info.y=(int) (scale_factor*paste_info.y*scale_factor+0.5);
+  paste_info.y=(ssize_t) (scale_factor*paste_info.y*scale_factor+0.5);
   paste_info.height=(unsigned int) (scale_factor*paste_info.height+0.5);
   /*
     Paste image with X Image window.
@@ -11150,8 +11189,8 @@ static MagickBooleanType XROIImage(Display *display,
   XQueryPosition(display,windows->image.id,&x,&y);
   (void) XSelectInput(display,windows->image.id,
     windows->image.attributes.event_mask | PointerMotionMask);
-  roi_info.x=windows->image.x+x;
-  roi_info.y=windows->image.y+y;
+  roi_info.x=(ssize_t) windows->image.x+x;
+  roi_info.y=(ssize_t) windows->image.y+y;
   roi_info.width=0;
   roi_info.height=0;
   cursor=XCreateFontCursor(display,XC_fleur);
@@ -11213,8 +11252,8 @@ static MagickBooleanType XROIImage(Display *display,
           Note first corner of region of interest rectangle-- exit loop.
         */
         (void) XCheckDefineCursor(display,windows->image.id,cursor);
-        roi_info.x=windows->image.x+event.xbutton.x;
-        roi_info.y=windows->image.y+event.xbutton.y;
+        roi_info.x=(ssize_t) windows->image.x+event.xbutton.x;
+        roi_info.y=(ssize_t) windows->image.y+event.xbutton.y;
         state|=ExitState;
         break;
       }
@@ -11279,8 +11318,8 @@ static MagickBooleanType XROIImage(Display *display,
           if ((x > (int) (windows->info.x+windows->info.width)) ||
               (y > (int) (windows->info.y+windows->info.height)))
             (void) XMapWindow(display,windows->info.id);
-        roi_info.x=windows->image.x+x;
-        roi_info.y=windows->image.y+y;
+        roi_info.x=(ssize_t) windows->image.x+x;
+        roi_info.y=(ssize_t) windows->image.y+y;
         break;
       }
       default:
@@ -11342,8 +11381,8 @@ static MagickBooleanType XROIImage(Display *display,
       {
         case ButtonPress:
         {
-          roi_info.x=windows->image.x+event.xbutton.x;
-          roi_info.y=windows->image.y+event.xbutton.y;
+          roi_info.x=(ssize_t) windows->image.x+event.xbutton.x;
+          roi_info.y=(ssize_t) windows->image.y+event.xbutton.y;
           break;
         }
         case ButtonRelease:
@@ -11351,8 +11390,8 @@ static MagickBooleanType XROIImage(Display *display,
           /*
             User has committed to region of interest rectangle.
           */
-          roi_info.x=windows->image.x+event.xbutton.x;
-          roi_info.y=windows->image.y+event.xbutton.y;
+          roi_info.x=(ssize_t) windows->image.x+event.xbutton.x;
+          roi_info.y=(ssize_t) windows->image.y+event.xbutton.y;
           XSetCursorState(display,windows,MagickFalse);
           state|=ExitState;
           if (LocaleCompare(windows->command.name,"Apply") == 0)
@@ -11366,8 +11405,8 @@ static MagickBooleanType XROIImage(Display *display,
           break;
         case MotionNotify:
         {
-          roi_info.x=windows->image.x+event.xmotion.x;
-          roi_info.y=windows->image.y+event.xmotion.y;
+          roi_info.x=(ssize_t) windows->image.x+event.xmotion.x;
+          roi_info.y=(ssize_t) windows->image.y+event.xmotion.y;
         }
         default:
           break;
@@ -11381,26 +11420,26 @@ static MagickBooleanType XROIImage(Display *display,
           if (roi_info.x < 0)
             roi_info.x=0;
           else
-            if (roi_info.x > (int) windows->image.ximage->width)
-              roi_info.x=windows->image.ximage->width;
+            if (roi_info.x > (ssize_t) windows->image.ximage->width)
+              roi_info.x=(ssize_t) windows->image.ximage->width;
           if ((int) roi_info.x < x)
             roi_info.width=(unsigned int) (x-roi_info.x);
           else
             {
               roi_info.width=(unsigned int) (roi_info.x-x);
-              roi_info.x=x;
+              roi_info.x=(ssize_t) x;
             }
           if (roi_info.y < 0)
             roi_info.y=0;
           else
-            if (roi_info.y > (int) windows->image.ximage->height)
-              roi_info.y=windows->image.ximage->height;
+            if (roi_info.y > (ssize_t) windows->image.ximage->height)
+              roi_info.y=(ssize_t) windows->image.ximage->height;
           if ((int) roi_info.y < y)
             roi_info.height=(unsigned int) (y-roi_info.y);
           else
             {
               roi_info.height=(unsigned int) (roi_info.y-y);
-              roi_info.y=y;
+              roi_info.y=(ssize_t) y;
             }
         }
     } while ((state & ExitState) == 0);
@@ -11460,12 +11499,12 @@ static MagickBooleanType XROIImage(Display *display,
                   &width,&height);
               scale_factor=(MagickRealType) width/windows->image.ximage->width;
               crop_info.x+=x;
-              crop_info.x=(int) (scale_factor*crop_info.x+0.5);
+              crop_info.x=(ssize_t) (scale_factor*crop_info.x+0.5);
               crop_info.width=(unsigned int) (scale_factor*crop_info.width+0.5);
               scale_factor=(MagickRealType)
                 height/windows->image.ximage->height;
               crop_info.y+=y;
-              crop_info.y=(int) (scale_factor*crop_info.y+0.5);
+              crop_info.y=(ssize_t) (scale_factor*crop_info.y+0.5);
               crop_info.height=(unsigned int)
                 (scale_factor*crop_info.height+0.5);
               roi_image=CropImage(*image,&crop_info,&(*image)->exception);
@@ -11667,7 +11706,8 @@ static MagickBooleanType XROIImage(Display *display,
             case XK_KP_Home:
             {
               roi_info.x=(ssize_t) (windows->image.width/2L-roi_info.width/2L);
-              roi_info.y=(ssize_t) (windows->image.height/2L-roi_info.height/2L);
+              roi_info.y=(ssize_t) (windows->image.height/2L-
+                roi_info.height/2L);
               break;
             }
             case XK_Left:
@@ -11742,8 +11782,8 @@ static MagickBooleanType XROIImage(Display *display,
             if ((x > (int) (windows->info.x+windows->info.width)) ||
                 (y > (int) (windows->info.y+windows->info.height)))
               (void) XMapWindow(display,windows->info.id);
-          roi_info.x=windows->image.x+event.xmotion.x;
-          roi_info.y=windows->image.y+event.xmotion.y;
+          roi_info.x=(ssize_t) windows->image.x+event.xmotion.x;
+          roi_info.y=(ssize_t) windows->image.y+event.xmotion.y;
           break;
         }
         case SelectionRequest:
@@ -12553,7 +12593,7 @@ static void XScreenEvent(Display *display,XWindows *windows,XEvent *event)
             else
               if (x >= (int) windows->image.width)
                 x=(int) (windows->image.width-1);
-            windows->magnify.x=windows->image.x+x;
+            windows->magnify.x=(int) windows->image.x+x;
             if (y < 0)
               y=0;
             else
@@ -12695,7 +12735,7 @@ static void XScreenEvent(Display *display,XWindows *windows,XEvent *event)
             else
               if (x >= (int) windows->image.width)
                 x=(int) (windows->image.width-1);
-            windows->magnify.x=windows->image.x+x;
+            windows->magnify.x=(int) windows->image.x+x;
             if (y < 0)
               y=0;
             else
@@ -13050,6 +13090,9 @@ static Image *XTileImage(Display *display,XResourceInfo *resource_info,
       tile=0;
       for (p=image->directory; *p != '\0'; p++)
       {
+        CacheView
+          *image_view;
+
         q=p;
         while ((*q != '\n') && (*q != '\0'))
           q++;
@@ -13066,17 +13109,20 @@ static Image *XTileImage(Display *display,XResourceInfo *resource_info,
         x_offset=(int) (width*(tile % (((int) image->columns-x)/width))+x);
         y_offset=(int) (height*(tile/(((int) image->columns-x)/width))+y);
         exception=(&image->exception);
-        (void) GetOneVirtualPixel(image,0,0,&pixel,exception);
+        image_view=AcquireCacheView(image);
+        (void) GetOneCacheViewVirtualPixel(image_view,0,0,&pixel,exception);
         for (i=0; i < (int) height; i++)
         {
-          s=GetAuthenticPixels(image,x_offset,y_offset+i,width,1,exception);
+          s=GetCacheViewAuthenticPixels(image_view,(ssize_t) x_offset,(ssize_t)
+            y_offset+i,width,1,exception);
           if (s == (PixelPacket *) NULL)
             break;
           for (j=0; j < (int) width; j++)
             *s++=pixel;
-          if (SyncAuthenticPixels(image,exception) == MagickFalse)
+          if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
             break;
         }
+        image_view=DestroyCacheView(image_view);
         tile++;
       }
       windows->image.window_changes.width=(int) image->columns;
@@ -13192,13 +13238,13 @@ static void XTranslateImage(Display *display,XWindows *windows,
   else
     if ((int) (windows->image.x+windows->image.width) >
         windows->image.ximage->width)
-      windows->image.x=windows->image.ximage->width-windows->image.width;
+      windows->image.x=(int) windows->image.ximage->width-windows->image.width;
   if (windows->image.y < 0)
     windows->image.y=0;
   else
     if ((int) (windows->image.y+windows->image.height) >
         windows->image.ximage->height)
-      windows->image.y=windows->image.ximage->height-windows->image.height;
+      windows->image.y=(int) windows->image.ximage->height-windows->image.height;
   /*
     Refresh Image window.
   */
@@ -13277,8 +13323,8 @@ static MagickBooleanType XTrimImage(Display *display,
     if (y < windows->image.ximage->height)
       break;
   }
-  trim_info.x=x;
-  if (trim_info.x == (int) windows->image.ximage->width)
+  trim_info.x=(ssize_t) x;
+  if (trim_info.x == (ssize_t) windows->image.ximage->width)
     {
       XSetCursorState(display,windows,MagickFalse);
       return(MagickFalse);
@@ -13315,7 +13361,7 @@ static MagickBooleanType XTrimImage(Display *display,
     if (x < windows->image.ximage->width)
       break;
   }
-  trim_info.y=y;
+  trim_info.y=(ssize_t) y;
   /*
     Crop the bottom edge.
   */
@@ -13434,7 +13480,7 @@ static Image *XVisualDirectoryImage(Display *display,
   /*
     Expand the filenames.
   */
-  filelist=(char **) AcquireAlignedMemory(1,sizeof(*filelist));
+  filelist=(char **) AcquireMagickMemory(sizeof(*filelist));
   if (filelist == (char **) NULL)
     {
       ThrowXWindowFatalException(ResourceLimitError,"MemoryAllocationFailed",
@@ -13467,24 +13513,26 @@ static Image *XVisualDirectoryImage(Display *display,
   backdrop=(windows->visual_info->klass == TrueColor) ||
     (windows->visual_info->klass == DirectColor) ? MagickTrue : MagickFalse;
   read_info=CloneImageInfo(resource_info->image_info);
+  (void) SetImageOption(read_info,"jpeg:size","120x120");
+  (void) CloneString(&read_info->size,DefaultTileGeometry);
   (void) SetImageInfoProgressMonitor(read_info,(MagickProgressMonitor) NULL,
     (void *) NULL);
   images=NewImageList();
   exception=AcquireExceptionInfo();
   XSetCursorState(display,windows,MagickTrue);
   XCheckRefreshWindows(display,windows);
-  for (i=0; i < (ssize_t) number_files; i++)
+  for (i=0; i < (int) number_files; i++)
   {
     (void) CopyMagickString(read_info->filename,filelist[i],MaxTextExtent);
     filelist[i]=DestroyString(filelist[i]);
     *read_info->magick='\0';
-    (void) CloneString(&read_info->size,DefaultTileGeometry);
     next_image=ReadImage(read_info,exception);
     CatchException(exception);
     if (next_image != (Image *) NULL)
       {
         (void) DeleteImageProperty(next_image,"label");
-        (void) SetImageProperty(next_image,"label",DefaultTileLabel);
+        (void) SetImageProperty(next_image,"label",InterpretImageProperties(
+          read_info,next_image,DefaultTileLabel));
         (void) ParseRegionGeometry(next_image,read_info->size,&geometry,
           exception);
         thumbnail_image=ThumbnailImage(next_image,geometry.width,
@@ -13515,9 +13563,9 @@ static Image *XVisualDirectoryImage(Display *display,
   }
   exception=DestroyExceptionInfo(exception);
   filelist=(char **) RelinquishMagickMemory(filelist);
-  read_info=DestroyImageInfo(read_info);
   if (images == (Image *) NULL)
     {
+      read_info=DestroyImageInfo(read_info);
       XSetCursorState(display,windows,MagickFalse);
       ThrowXWindowFatalException(ImageError,"NoImagesWereLoaded",filenames);
       return((Image *) NULL);
@@ -13525,14 +13573,16 @@ static Image *XVisualDirectoryImage(Display *display,
   /*
     Create the Visual Image Directory.
   */
-  montage_info=CloneMontageInfo(resource_info->image_info,(MontageInfo *) NULL);
+  montage_info=CloneMontageInfo(read_info,(MontageInfo *) NULL);
+  montage_info->pointsize=10;
   if (resource_info->font != (char *) NULL)
     (void) CloneString(&montage_info->font,resource_info->font);
   (void) CopyMagickString(montage_info->filename,filename,MaxTextExtent);
-  montage_image=MontageImageList(resource_info->image_info,montage_info,
-    GetFirstImageInList(images),&images->exception);
-  montage_info=DestroyMontageInfo(montage_info);
+  montage_image=MontageImageList(read_info,montage_info,GetFirstImageInList(
+    images),&images->exception);
   images=DestroyImageList(images);
+  montage_info=DestroyMontageInfo(montage_info);
+  read_info=DestroyImageInfo(read_info);
   XSetCursorState(display,windows,MagickFalse);
   if (montage_image == (Image *) NULL)
     return(montage_image);
@@ -15036,8 +15086,8 @@ MagickExport Image *XDisplayImage(Display *display,XResourceInfo *resource_info,
                       display_image,&event);
                     if (nexus != (Image *) NULL)
                       *state|=MontageImageState | NextImageState | ExitState;
-                    vid_info.x=windows->image.x;
-                    vid_info.y=windows->image.y;
+                    vid_info.x=(short int) windows->image.x;
+                    vid_info.y=(short int) windows->image.y;
                     break;
                   }
                 /*
@@ -15197,7 +15247,8 @@ MagickExport Image *XDisplayImage(Display *display,XResourceInfo *resource_info,
                     pixel->border_color.pixel;
                   magick_windows[i]->attributes.colormap=map_info->colormap;
                   (void) XChangeWindowAttributes(display,magick_windows[i]->id,
-                    magick_windows[i]->mask,&magick_windows[i]->attributes);
+                    (unsigned long) magick_windows[i]->mask,
+                    &magick_windows[i]->attributes);
                 }
                 if (windows->pan.mapped != MagickFalse)
                   {