]> granicus.if.org Git - imagemagick/blobdiff - magick/display.c
(no commit message)
[imagemagick] / magick / display.c
index c681e6abcd7e3b68fa0c11cc2055f010088c7b3e..87b2283b34a05f560edec0a5d6c1f64a7a361c1d 100644 (file)
@@ -1631,10 +1631,10 @@ MagickExport MagickBooleanType DisplayImages(const ImageInfo *image_info,
   Image
     *image;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     state;
 
   XrmDatabase
@@ -1670,7 +1670,7 @@ MagickExport MagickBooleanType DisplayImages(const ImageInfo *image_info,
   state=DefaultState;
   for (i=0; (state & ExitState) == 0; i++)
   {
-    if ((images->iterations != 0) && (i >= (long) images->iterations))
+    if ((images->iterations != 0) && (i >= (ssize_t) images->iterations))
       break;
     image=GetImageFromList(images,i % GetImageListLength(images));
     (void) XDisplayImage(display,&resource_info,argv,1,&image,&state);
@@ -1770,14 +1770,14 @@ MagickExport MagickBooleanType RemoteDisplayCommand(const ImageInfo *image_info,
 %
 */
 
-static inline long MagickMax(const long x,const long y)
+static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
 {
   if (x > y)
     return(x);
   return(y);
 }
 
-static inline long MagickMin(const long x,const long y)
+static inline ssize_t MagickMin(const ssize_t x,const ssize_t y)
 {
   if (x < y)
     return(x);
@@ -1859,14 +1859,14 @@ static MagickBooleanType XAnnotateEditImage(Display *display,
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   unsigned int
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XAnnotateInfo
@@ -2580,7 +2580,7 @@ static MagickBooleanType XAnnotateEditImage(Display *display,
         /*
           Annotate Image window with primary selection.
         */
-        for (i=0; i < (long) length; i++)
+        for (i=0; i < (ssize_t) length; i++)
         {
           if ((char) data[i] != '\n')
             {
@@ -2673,7 +2673,7 @@ static MagickBooleanType XAnnotateEditImage(Display *display,
     */
     windows->pixel_info->box_color=windows->pixel_info->pen_colors[box_id];
     if (windows->pixel_info->colors != 0)
-      for (i=0; i < (long) windows->pixel_info->colors; i++)
+      for (i=0; i < (ssize_t) windows->pixel_info->colors; i++)
         if (windows->pixel_info->pixels[i] ==
             windows->pixel_info->pen_colors[box_id].pixel)
           {
@@ -2682,7 +2682,7 @@ static MagickBooleanType XAnnotateEditImage(Display *display,
           }
     windows->pixel_info->pen_color=windows->pixel_info->pen_colors[pen_id];
     if (windows->pixel_info->colors != 0)
-      for (i=0; i < (long) windows->pixel_info->colors; i++)
+      for (i=0; i < (ssize_t) windows->pixel_info->colors; i++)
         if (windows->pixel_info->pixels[i] ==
             windows->pixel_info->pen_colors[pen_id].pixel)
           {
@@ -2876,7 +2876,7 @@ static MagickBooleanType XChopImage(Display *display,
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -3080,8 +3080,9 @@ static MagickBooleanType XChopImage(Display *display,
         */
         if (windows->info.mapped == MagickFalse)
           (void) XMapWindow(display,windows->info.id);
-        (void) FormatMagickString(text,MaxTextExtent," %lux%lu%+ld%+ld",
-          chop_info.width,chop_info.height,chop_info.x,chop_info.y);
+        (void) FormatMagickString(text,MaxTextExtent,
+          " %.20gx%.20g%+.20g%+.20g",(double) chop_info.width,(double)
+          chop_info.height,(double) chop_info.x,(double) chop_info.y);
         XInfoWidget(display,windows,text);
         XHighlightLine(display,windows->image.id,
           windows->image.highlight_context,&segment_info);
@@ -3145,25 +3146,25 @@ static MagickBooleanType XChopImage(Display *display,
     */
     if (direction == HorizontalChopCommand)
       {
-        chop_info.width=(unsigned long) (segment_info.x2-segment_info.x1+1);
+        chop_info.width=(size_t) (segment_info.x2-segment_info.x1+1);
         chop_info.x=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=(unsigned long) (segment_info.x1-segment_info.x2+1);
+            chop_info.width=(size_t) (segment_info.x1-segment_info.x2+1);
             chop_info.x=windows->image.x+segment_info.x2;
           }
       }
     else
       {
         chop_info.width=0;
-        chop_info.height=(unsigned long) (segment_info.y2-segment_info.y1+1);
+        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;
         if (segment_info.y1 > segment_info.y2)
           {
-            chop_info.height=(unsigned long)
+            chop_info.height=(size_t)
               (segment_info.y1-segment_info.y2+1);
             chop_info.y=windows->image.y+segment_info.y2;
           }
@@ -3305,14 +3306,14 @@ static MagickBooleanType XColorEditImage(Display *display,
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
   unsigned int
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XColor
@@ -3685,8 +3686,8 @@ 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 >= (long) (*image)->columns) ||
-            (y_offset >= (long) (*image)->rows))
+        if ((x_offset >= (ssize_t) (*image)->columns) ||
+            (y_offset >= (ssize_t) (*image)->rows))
           continue;
         exception=(&(*image)->exception);
         switch (method)
@@ -3720,7 +3721,7 @@ static MagickBooleanType XColorEditImage(Display *display,
               &(*image)->exception);
             if ((*image)->storage_class == DirectClass)
               {
-                for (y=0; y < (long) (*image)->rows; y++)
+                for (y=0; y < (ssize_t) (*image)->rows; y++)
                 {
                   q=GetAuthenticPixels(*image,0,y,(*image)->columns,1,
                     exception);
@@ -3795,7 +3796,7 @@ static MagickBooleanType XColorEditImage(Display *display,
             */
             if (SetImageStorageClass(*image,DirectClass) == MagickFalse)
               return(MagickFalse);
-            for (y=0; y < (long) (*image)->rows; y++)
+            for (y=0; y < (ssize_t) (*image)->rows; y++)
             {
               q=QueueAuthenticPixels(*image,0,y,(*image)->columns,1,exception);
               if (q == (PixelPacket *) NULL)
@@ -3913,7 +3914,7 @@ static MagickBooleanType XCompositeImage(Display *display,
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -3968,7 +3969,7 @@ static MagickBooleanType XCompositeImage(Display *display,
           Display pointer position.
         */
         (void) FormatMagickString(text,MaxTextExtent," %+ld%+ld ",
-          composite_info.x,composite_info.y);
+          (long) composite_info.x,(long) composite_info.y);
         XInfoWidget(display,windows,text);
       }
     highlight_info=composite_info;
@@ -4272,12 +4273,12 @@ static MagickBooleanType XCompositeImage(Display *display,
       */
       (void) SetImageAlphaChannel(composite_image,OpaqueAlphaChannel);
       opacity=(Quantum) (ScaleQuantumToChar((Quantum) QuantumRange)-
-        ((long) ScaleQuantumToChar((Quantum) QuantumRange)*blend)/100);
+        ((ssize_t) ScaleQuantumToChar((Quantum) QuantumRange)*blend)/100);
       if (SetImageStorageClass(image,DirectClass) == MagickFalse)
         return(MagickFalse);
       image->matte=MagickTrue;
       exception=(&image->exception);
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
@@ -4344,14 +4345,14 @@ static MagickBooleanType XConfigureImage(Display *display,
   char
     geometry[MaxTextExtent];
 
-  long
+  ssize_t
     x,
     y;
 
   MagickStatusType
     status;
 
-  unsigned long
+  size_t
     mask,
     height,
     width;
@@ -4369,8 +4370,8 @@ static MagickBooleanType XConfigureImage(Display *display,
   height=(unsigned int) windows->image.window_changes.height;
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(X11Event,GetMagickModule(),
-      "Configure Image: %dx%d=>%lux%lu",windows->image.ximage->width,
-      windows->image.ximage->height,width,height);
+      "Configure Image: %dx%d=>%.20gx%.20g",windows->image.ximage->width,
+      windows->image.ximage->height,(double) width,(double) height);
   if ((width*height) == 0)
     return(MagickTrue);
   x=0;
@@ -4412,7 +4413,7 @@ static MagickBooleanType XConfigureImage(Display *display,
   window_changes.height=(int) height;
   if (window_changes.height > XDisplayHeight(display,windows->image.screen))
     window_changes.height=XDisplayHeight(display,windows->image.screen);
-  mask=(unsigned long) (CWWidth | CWHeight);
+  mask=(size_t) (CWWidth | CWHeight);
   if (resource_info->backdrop)
     {
       mask|=CWX | CWY;
@@ -4577,7 +4578,7 @@ static MagickBooleanType XCropImage(Display *display,
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -4630,7 +4631,7 @@ static MagickBooleanType XCropImage(Display *display,
           Display pointer position.
         */
         (void) FormatMagickString(text,MaxTextExtent," %+ld%+ld ",
-          crop_info.x,crop_info.y);
+          (long) crop_info.x,(long) crop_info.y);
         XInfoWidget(display,windows,text);
       }
     /*
@@ -4824,8 +4825,9 @@ static MagickBooleanType XCropImage(Display *display,
           */
           if (windows->info.mapped == MagickFalse)
             (void) XMapWindow(display,windows->info.id);
-          (void) FormatMagickString(text,MaxTextExtent," %lux%lu%+ld%+ld",
-            crop_info.width,crop_info.height,crop_info.x,crop_info.y);
+          (void) FormatMagickString(text,MaxTextExtent,
+            " %.20gx%.20g%+.20g%+.20g",(double) crop_info.width,(double)
+            crop_info.height,(double) crop_info.x,(double) crop_info.y);
           XInfoWidget(display,windows,text);
           XHighlightRectangle(display,windows->image.id,
             windows->image.highlight_context,&highlight_info);
@@ -4916,8 +4918,9 @@ static MagickBooleanType XCropImage(Display *display,
           /*
             Display pointer position.
           */
-          (void) FormatMagickString(text,MaxTextExtent," %lux%lu%+ld%+ld",
-            crop_info.width,crop_info.height,crop_info.x,crop_info.y);
+          (void) FormatMagickString(text,MaxTextExtent,
+            " %.20gx%.20g%+.20g%+.20g",(double) crop_info.width,(double)
+            crop_info.height,(double) crop_info.x,(double) crop_info.y);
           XInfoWidget(display,windows,text);
         }
       highlight_info=crop_info;
@@ -5011,8 +5014,8 @@ static MagickBooleanType XCropImage(Display *display,
               (y < (int) (crop_info.y+RoiDelta)) &&
               (y > (int) (crop_info.y-RoiDelta)))
             {
-              crop_info.x=(long) (crop_info.x+crop_info.width);
-              crop_info.y=(long) (crop_info.y+crop_info.height);
+              crop_info.x=(ssize_t) (crop_info.x+crop_info.width);
+              crop_info.y=(ssize_t) (crop_info.y+crop_info.height);
               state|=UpdateConfigurationState;
               break;
             }
@@ -5021,7 +5024,7 @@ static MagickBooleanType XCropImage(Display *display,
               (y < (int) (crop_info.y+crop_info.height+RoiDelta)) &&
               (y > (int) (crop_info.y+crop_info.height-RoiDelta)))
             {
-              crop_info.x=(long) (crop_info.x+crop_info.width);
+              crop_info.x=(ssize_t) (crop_info.x+crop_info.width);
               state|=UpdateConfigurationState;
               break;
             }
@@ -5030,7 +5033,7 @@ static MagickBooleanType XCropImage(Display *display,
               (y < (int) (crop_info.y+RoiDelta)) &&
               (y > (int) (crop_info.y-RoiDelta)))
             {
-              crop_info.y=(long) (crop_info.y+crop_info.height);
+              crop_info.y=(ssize_t) (crop_info.y+crop_info.height);
               state|=UpdateConfigurationState;
               break;
             }
@@ -5092,8 +5095,8 @@ static MagickBooleanType XCropImage(Display *display,
             case XK_Home:
             case XK_KP_Home:
             {
-              crop_info.x=(long) (windows->image.width/2L-crop_info.width/2L);
-              crop_info.y=(long) (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:
@@ -5199,8 +5202,9 @@ static MagickBooleanType XCropImage(Display *display,
           /*
             Set primary selection.
           */
-          (void) FormatMagickString(text,MaxTextExtent,"%lux%lu%+ld%+ld",
-            crop_info.width,crop_info.height,crop_info.x,crop_info.y);
+          (void) FormatMagickString(text,MaxTextExtent,
+            "%.20gx%.20g%+.20g%+.20g",(double) crop_info.width,(double)
+            crop_info.height,(double) crop_info.x,(double) crop_info.y);
           request=(&(event.xselectionrequest));
           (void) XChangeProperty(request->display,request->requestor,
             request->property,request->target,8,PropModeReplace,
@@ -5284,7 +5288,7 @@ static MagickBooleanType XCropImage(Display *display,
     return(MagickFalse);
   image->matte=MagickTrue;
   exception=(&image->exception);
-  for (y=0; y < (long) crop_info.height; y++)
+  for (y=0; y < (ssize_t) crop_info.height; y++)
   {
     q=GetAuthenticPixels(image,crop_info.x,y+crop_info.y,crop_info.width,1,
       exception);
@@ -5407,7 +5411,7 @@ static MagickBooleanType XDrawEditImage(Display *display,
     max_coordinates,
     width;
 
-  unsigned long
+  size_t
     state;
 
   Window
@@ -5903,9 +5907,10 @@ static MagickBooleanType XDrawEditImage(Display *display,
               /*
                 Display info and draw drawing rectangle.
               */
-              (void) FormatMagickString(text,MaxTextExtent," %lux%lu%+ld%+ld",
-                rectangle_info.width,rectangle_info.height,rectangle_info.x,
-                rectangle_info.y);
+              (void) FormatMagickString(text,MaxTextExtent,
+                " %.20gx%.20g%+.20g%+.20g",(double) rectangle_info.width,
+                (double) rectangle_info.height,(double) rectangle_info.x,
+                (double) rectangle_info.y);
               XInfoWidget(display,windows,text);
               XHighlightRectangle(display,windows->image.id,
                 windows->image.highlight_context,&rectangle_info);
@@ -5926,9 +5931,10 @@ static MagickBooleanType XDrawEditImage(Display *display,
               /*
                 Display info and draw drawing rectangle.
               */
-              (void) FormatMagickString(text,MaxTextExtent," %lux%lu%+ld%+ld",
-                rectangle_info.width,rectangle_info.height,rectangle_info.x,
-                rectangle_info.y);
+              (void) FormatMagickString(text,MaxTextExtent,
+                " %.20gx%.20g%+.20g%+.20g",(double) rectangle_info.width,
+                (double) rectangle_info.height,(double) rectangle_info.x,
+                (double) rectangle_info.y);
               XInfoWidget(display,windows,text);
               XHighlightEllipse(display,windows->image.id,
                 windows->image.highlight_context,&rectangle_info);
@@ -6108,7 +6114,7 @@ static MagickBooleanType XDrawEditImage(Display *display,
             rectangle_info.x=0;
           else
             if (rectangle_info.x > (int) windows->image.width)
-              rectangle_info.x=(long) 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
@@ -6120,7 +6126,7 @@ static MagickBooleanType XDrawEditImage(Display *display,
             rectangle_info.y=0;
           else
             if (rectangle_info.y > (int) windows->image.height)
-              rectangle_info.y=(long) 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
@@ -6152,8 +6158,8 @@ static MagickBooleanType XDrawEditImage(Display *display,
           if (coordinate_info[i].y < rectangle_info.y)
             rectangle_info.y=MagickMax(coordinate_info[i].y,0);
         }
-        rectangle_info.width=(unsigned long) (x-rectangle_info.x);
-        rectangle_info.height=(unsigned long) (y-rectangle_info.y);
+        rectangle_info.width=(size_t) (x-rectangle_info.x);
+        rectangle_info.height=(size_t) (y-rectangle_info.y);
         for (i=0; i < number_coordinates; i++)
         {
           coordinate_info[i].x-=rectangle_info.x;
@@ -6232,9 +6238,9 @@ static MagickBooleanType XDrawEditImage(Display *display,
       }
     draw_info.rectangle_info=rectangle_info;
     if (draw_info.rectangle_info.x > (int) (line_width/2))
-      draw_info.rectangle_info.x=(long) line_width/2;
+      draw_info.rectangle_info.x=(ssize_t) line_width/2;
     if (draw_info.rectangle_info.y > (int) (line_width/2))
-      draw_info.rectangle_info.y=(long) 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;
     windows->pixel_info->pen_color=windows->pixel_info->pen_colors[pen_id];
@@ -6466,10 +6472,10 @@ static void XImageCache(Display *display,XResourceInfo *resource_info,
       Image
         *previous_image;
 
-      long
+      ssize_t
         bytes;
 
-      bytes=(long) ((*image)->columns*(*image)->rows*sizeof(PixelPacket));
+      bytes=(ssize_t) ((*image)->columns*(*image)->rows*sizeof(PixelPacket));
       if (undo_image != (Image *) NULL)
         {
           /*
@@ -6480,7 +6486,7 @@ static void XImageCache(Display *display,XResourceInfo *resource_info,
           {
             bytes+=previous_image->list->columns*previous_image->list->rows*
               sizeof(PixelPacket);
-            if (bytes <= (long) (resource_info->undo_cache << 20))
+            if (bytes <= (ssize_t) (resource_info->undo_cache << 20))
               {
                 previous_image=GetPreviousImageInList(previous_image);
                 continue;
@@ -6504,7 +6510,7 @@ static void XImageCache(Display *display,XResourceInfo *resource_info,
             cache_image=DestroyImage(cache_image);
           }
         }
-      if (bytes > (long) (resource_info->undo_cache << 20))
+      if (bytes > (ssize_t) (resource_info->undo_cache << 20))
         break;
       /*
         Save image before transformations are applied.
@@ -6521,8 +6527,8 @@ static void XImageCache(Display *display,XResourceInfo *resource_info,
           cache_image=DestroyImage(cache_image);
           break;
         }
-      cache_image->columns=(unsigned long) windows->image.ximage->width;
-      cache_image->rows=(unsigned long) windows->image.ximage->height;
+      cache_image->columns=(size_t) windows->image.ximage->width;
+      cache_image->rows=(size_t) windows->image.ximage->height;
       cache_image->geometry=windows->image.crop_geometry;
       if (windows->image.crop_geometry != (char *) NULL)
         {
@@ -6922,8 +6928,8 @@ static CommandType XImageWindowCommand(Display *display,
           */
           crop_info.x=0;
           crop_info.y=0;
-          crop_info.width=(unsigned long) windows->image.ximage->width;
-          crop_info.height=(unsigned long) windows->image.ximage->height;
+          crop_info.width=(size_t) windows->image.ximage->width;
+          crop_info.height=(size_t) windows->image.ximage->height;
           if ((key_symbol == XK_Up) || (key_symbol == XK_KP_Up))
             {
               if (resource_info->quantum >= (int) crop_info.height)
@@ -7284,23 +7290,23 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info,
       int
         status;
 
-      long
+      ssize_t
         x,
         y;
 
-      unsigned long
+      size_t
         height,
         width;
 
       /*
         Resize image.
       */
-      width=(unsigned long) windows->image.ximage->width;
-      height=(unsigned long) windows->image.ximage->height;
+      width=(size_t) windows->image.ximage->width;
+      height=(size_t) windows->image.ximage->height;
       x=0;
       y=0;
-      (void) FormatMagickString(geometry,MaxTextExtent,"%lux%lu+0+0",
-        width,height);
+      (void) FormatMagickString(geometry,MaxTextExtent,"%.20gx%.20g+0+0",
+        (double) width,(double) height);
       status=XDialogWidget(display,windows,"Resize",
         "Enter resize geometry (e.g. 640x480, 200%):",geometry);
       if (*geometry == '\0')
@@ -8517,8 +8523,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,
-        (long) (geometry_info.xi+0.5),(long) (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);
@@ -8793,8 +8799,8 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info,
       frame_info.height=page_geometry.height;
       frame_info.outer_bevel=page_geometry.x;
       frame_info.inner_bevel=page_geometry.y;
-      frame_info.x=(long) frame_info.width;
-      frame_info.y=(long) frame_info.height;
+      frame_info.x=(ssize_t) frame_info.width;
+      frame_info.y=(ssize_t) frame_info.height;
       frame_info.width=(*image)->columns+2*frame_info.width;
       frame_info.height=(*image)->rows+2*frame_info.height;
       frame_image=FrameImage(*image,&frame_info,&(*image)->exception);
@@ -8957,7 +8963,7 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info,
       XCheckRefreshWindows(display,windows);
       image_info->preview_type=(PreviewType)
         ParseMagickOption(MagickPreviewOptions,MagickFalse,preview_type);
-      image_info->group=(long) windows->image.id;
+      image_info->group=(ssize_t) windows->image.id;
       (void) DeleteImageProperty(*image,"label");
       (void) SetImageProperty(*image,"label","Preview");
       (void) AcquireUniqueFilename(filename);
@@ -8990,7 +8996,7 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info,
       */
       XSetCursorState(display,windows,MagickTrue);
       XCheckRefreshWindows(display,windows);
-      image_info->group=(long) windows->image.id;
+      image_info->group=(ssize_t) windows->image.id;
       (void) DeleteImageProperty(*image,"label");
       (void) SetImageProperty(*image,"label","Histogram");
       (void) AcquireUniqueFilename(filename);
@@ -9029,7 +9035,7 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info,
       */
       XSetCursorState(display,windows,MagickTrue);
       XCheckRefreshWindows(display,windows);
-      image_info->group=(long) windows->image.id;
+      image_info->group=(ssize_t) windows->image.id;
       (void) DeleteImageProperty(*image,"label");
       (void) SetImageProperty(*image,"label","Matte");
       (void) AcquireUniqueFilename(filename);
@@ -9153,7 +9159,7 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info,
     }
     case VersionCommand:
     {
-      XNoticeWidget(display,windows,GetMagickVersion((unsigned long *) NULL),
+      XNoticeWidget(display,windows,GetMagickVersion((size_t *) NULL),
         GetMagickCopyright());
       break;
     }
@@ -9207,7 +9213,7 @@ static void XMagnifyImage(Display *display,XWindows *windows,XEvent *event)
     x,
     y;
 
-  unsigned long
+  size_t
     state;
 
   /*
@@ -9563,7 +9569,7 @@ static MagickBooleanType XMatteEditImage(Display *display,
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -9964,7 +9970,7 @@ static MagickBooleanType XMatteEditImage(Display *display,
             */
             (void) GetOneVirtualPixel(*image,x_offset,y_offset,&target,
               exception);
-            for (y=0; y < (long) (*image)->rows; y++)
+            for (y=0; y < (ssize_t) (*image)->rows; y++)
             {
               q=GetAuthenticPixels(*image,0,y,(*image)->columns,1,
                 &(*image)->exception);
@@ -10020,7 +10026,7 @@ static MagickBooleanType XMatteEditImage(Display *display,
             */
             if (SetImageStorageClass(*image,DirectClass) == MagickFalse)
               return(MagickFalse);
-            for (y=0; y < (long) (*image)->rows; y++)
+            for (y=0; y < (ssize_t) (*image)->rows; y++)
             {
               q=QueueAuthenticPixels(*image,0,y,(*image)->columns,1,exception);
               if (q == (PixelPacket *) NULL)
@@ -10150,7 +10156,7 @@ static Image *XOpenImage(Display *display,XResourceInfo *resource_info,
     (void *) NULL);
   (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
   exception=AcquireExceptionInfo();
-  (void) SetImageInfo(image_info,MagickFalse,exception);
+  (void) SetImageInfo(image_info,0,exception);
   if (LocaleCompare(image_info->magick,"X") == 0)
     {
       char
@@ -10164,7 +10170,7 @@ static Image *XOpenImage(Display *display,XResourceInfo *resource_info,
         seconds);
       if (*seconds == '\0')
         return((Image *) NULL);
-      XDelay(display,(unsigned long) (1000*StringToLong(seconds)));
+      XDelay(display,(size_t) (1000*StringToLong(seconds)));
     }
   magick_info=GetMagickInfo(image_info->magick,exception);
   if ((magick_info != (const MagickInfo *) NULL) &&
@@ -10274,7 +10280,7 @@ static void XPanImage(Display *display,XWindows *windows,XEvent *event)
   RectangleInfo
     pan_info;
 
-  unsigned long
+  size_t
     state;
 
   /*
@@ -10351,18 +10357,18 @@ static void XPanImage(Display *display,XWindows *windows,XEvent *event)
         else
           if ((int) (pan_info.x+windows->image.width) >
               windows->image.ximage->width)
-            pan_info.x=(long)
+            pan_info.x=(ssize_t)
               (windows->image.ximage->width-windows->image.width);
-        if (pan_info.y < (long) (pan_info.height/2))
+        if (pan_info.y < (ssize_t) (pan_info.height/2))
           pan_info.y=0;
         else
-          pan_info.y=(long) (y_factor*(pan_info.y-(pan_info.height/2)));
+          pan_info.y=(ssize_t) (y_factor*(pan_info.y-(pan_info.height/2)));
         if (pan_info.y < 0)
           pan_info.y=0;
         else
           if ((int) (pan_info.y+windows->image.height) >
               windows->image.ximage->height)
-            pan_info.y=(long)
+            pan_info.y=(ssize_t)
               (windows->image.ximage->height-windows->image.height);
         if ((windows->image.x != (int) pan_info.x) ||
             (windows->image.y != (int) pan_info.y))
@@ -10478,7 +10484,7 @@ static MagickBooleanType XPasteImage(Display *display,
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -10522,7 +10528,7 @@ static MagickBooleanType XPasteImage(Display *display,
           Display pointer position.
         */
         (void) FormatMagickString(text,MaxTextExtent," %+ld%+ld ",
-          paste_info.x,paste_info.y);
+          (long) paste_info.x,(long) paste_info.y);
         XInfoWidget(display,windows,text);
       }
     highlight_info=paste_info;
@@ -11123,7 +11129,7 @@ static MagickBooleanType XROIImage(Display *display,
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -11158,7 +11164,7 @@ static MagickBooleanType XROIImage(Display *display,
           Display pointer position.
         */
         (void) FormatMagickString(text,MaxTextExtent," %+ld%+ld ",
-          roi_info.x,roi_info.y);
+          (long) roi_info.x,(long) roi_info.y);
         XInfoWidget(display,windows,text);
       }
     /*
@@ -11315,8 +11321,9 @@ static MagickBooleanType XROIImage(Display *display,
           */
           if (windows->info.mapped == MagickFalse)
             (void) XMapWindow(display,windows->info.id);
-          (void) FormatMagickString(text,MaxTextExtent," %lux%lu%+ld%+ld",
-            roi_info.width,roi_info.height,roi_info.x,roi_info.y);
+          (void) FormatMagickString(text,MaxTextExtent,
+            " %.20gx%.20g%+.20g%+.20g",(double) roi_info.width,(double)
+            roi_info.height,(double) roi_info.x,(double) roi_info.y);
           XInfoWidget(display,windows,text);
           XHighlightRectangle(display,windows->image.id,
             windows->image.highlight_context,&highlight_info);
@@ -11410,8 +11417,9 @@ static MagickBooleanType XROIImage(Display *display,
           /*
             Display pointer position.
           */
-          (void) FormatMagickString(text,MaxTextExtent," %lux%lu%+ld%+ld",
-            roi_info.width,roi_info.height,roi_info.x,roi_info.y);
+          (void) FormatMagickString(text,MaxTextExtent,
+            " %.20gx%.20g%+.20g%+.20g",(double) roi_info.width,(double)
+            roi_info.height,(double) roi_info.x,(double) roi_info.y);
           XInfoWidget(display,windows,text);
         }
       highlight_info=roi_info;
@@ -11571,8 +11579,8 @@ static MagickBooleanType XROIImage(Display *display,
               (y < (int) (roi_info.y+RoiDelta)) &&
               (y > (int) (roi_info.y-RoiDelta)))
             {
-              roi_info.x=(long) (roi_info.x+roi_info.width);
-              roi_info.y=(long) (roi_info.y+roi_info.height);
+              roi_info.x=(ssize_t) (roi_info.x+roi_info.width);
+              roi_info.y=(ssize_t) (roi_info.y+roi_info.height);
               state|=UpdateConfigurationState;
               break;
             }
@@ -11581,7 +11589,7 @@ static MagickBooleanType XROIImage(Display *display,
               (y < (int) (roi_info.y+roi_info.height+RoiDelta)) &&
               (y > (int) (roi_info.y+roi_info.height-RoiDelta)))
             {
-              roi_info.x=(long) (roi_info.x+roi_info.width);
+              roi_info.x=(ssize_t) (roi_info.x+roi_info.width);
               state|=UpdateConfigurationState;
               break;
             }
@@ -11590,7 +11598,7 @@ static MagickBooleanType XROIImage(Display *display,
               (y < (int) (roi_info.y+RoiDelta)) &&
               (y > (int) (roi_info.y-RoiDelta)))
             {
-              roi_info.y=(long) (roi_info.y+roi_info.height);
+              roi_info.y=(ssize_t) (roi_info.y+roi_info.height);
               state|=UpdateConfigurationState;
               break;
             }
@@ -11658,8 +11666,8 @@ static MagickBooleanType XROIImage(Display *display,
             case XK_Home:
             case XK_KP_Home:
             {
-              roi_info.x=(long) (windows->image.width/2L-roi_info.width/2L);
-              roi_info.y=(long) (windows->image.height/2L-roi_info.height/2L);
+              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);
               break;
             }
             case XK_Left:
@@ -11749,8 +11757,9 @@ static MagickBooleanType XROIImage(Display *display,
           /*
             Set primary selection.
           */
-          (void) FormatMagickString(text,MaxTextExtent,"%lux%lu%+ld%+ld",
-            roi_info.width,roi_info.height,roi_info.x,roi_info.y);
+          (void) FormatMagickString(text,MaxTextExtent,
+            "%.20gx%.20g%+.20g%+.20g",(double) roi_info.width,(double)
+            roi_info.height,(double) roi_info.x,(double) roi_info.y);
           request=(&(event.xselectionrequest));
           (void) XChangeProperty(request->display,request->requestor,
             request->property,request->target,8,PropModeReplace,
@@ -11881,7 +11890,7 @@ static MagickBooleanType XRotateImage(Display *display,
       unsigned int
         distance;
 
-      unsigned long
+      size_t
         state;
 
       XEvent
@@ -12380,7 +12389,7 @@ static MagickBooleanType XSaveImage(Display *display,
     }
   image_info=CloneImageInfo(resource_info->image_info);
   (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
-  (void) SetImageInfo(image_info,MagickFalse,&image->exception);
+  (void) SetImageInfo(image_info,1,&image->exception);
   if ((LocaleCompare(image_info->magick,"JPEG") == 0) ||
       (LocaleCompare(image_info->magick,"JPG") == 0))
     {
@@ -12393,7 +12402,8 @@ static MagickBooleanType XSaveImage(Display *display,
       /*
         Request JPEG quality from user.
       */
-      (void) FormatMagickString(quality,MaxTextExtent,"%lu",image->quality);
+      (void) FormatMagickString(quality,MaxTextExtent,"%.20g",(double)
+        image->quality);
       status=XDialogWidget(display,windows,"Save","Enter JPEG quality:",
         quality);
       if (*quality == '\0')
@@ -12769,8 +12779,9 @@ static void XSetCropGeometry(Display *display,XWindows *windows,
       /*
         Display info on cropping rectangle.
       */
-      (void) FormatMagickString(text,MaxTextExtent," %lux%lu%+ld%+ld",
-        crop_info->width,crop_info->height,crop_info->x,crop_info->y);
+      (void) FormatMagickString(text,MaxTextExtent," %.20gx%.20g%+.20g%+.20g",
+        (double) crop_info->width,(double) crop_info->height,(double)
+        crop_info->x,(double) crop_info->y);
       XInfoWidget(display,windows,text);
     }
   /*
@@ -13241,7 +13252,7 @@ static MagickBooleanType XTrimImage(Display *display,
     x,
     y;
 
-  unsigned long
+  size_t
     background,
     pixel;
 
@@ -13254,7 +13265,7 @@ static MagickBooleanType XTrimImage(Display *display,
     Crop the left edge.
   */
   background=XGetPixel(windows->image.ximage,0,0);
-  trim_info.width=(unsigned long) windows->image.ximage->width;
+  trim_info.width=(size_t) windows->image.ximage->width;
   for (x=0; x < windows->image.ximage->width; x++)
   {
     for (y=0; y < windows->image.ximage->height; y++)
@@ -13287,12 +13298,12 @@ static MagickBooleanType XTrimImage(Display *display,
     if (y < windows->image.ximage->height)
       break;
   }
-  trim_info.width=(unsigned long) (x-trim_info.x+1);
+  trim_info.width=(size_t) (x-trim_info.x+1);
   /*
     Crop the top edge.
   */
   background=XGetPixel(windows->image.ximage,0,0);
-  trim_info.height=(unsigned long) windows->image.ximage->height;
+  trim_info.height=(size_t) windows->image.ximage->height;
   for (y=0; y < windows->image.ximage->height; y++)
   {
     for (x=0; x < windows->image.ximage->width; x++)
@@ -13320,7 +13331,7 @@ static MagickBooleanType XTrimImage(Display *display,
     if (x < windows->image.ximage->width)
       break;
   }
-  trim_info.height=(unsigned long) y-trim_info.y+1;
+  trim_info.height=(size_t) y-trim_info.y+1;
   if (((unsigned int) trim_info.width != windows->image.width) ||
       ((unsigned int) trim_info.height != windows->image.height))
     {
@@ -13462,7 +13473,7 @@ static Image *XVisualDirectoryImage(Display *display,
   exception=AcquireExceptionInfo();
   XSetCursorState(display,windows,MagickTrue);
   XCheckRefreshWindows(display,windows);
-  for (i=0; i < (long) number_files; i++)
+  for (i=0; i < (ssize_t) number_files; i++)
   {
     (void) CopyMagickString(read_info->filename,filelist[i],MaxTextExtent);
     filelist[i]=DestroyString(filelist[i]);
@@ -13585,7 +13596,7 @@ MagickExport MagickBooleanType XDisplayBackgroundImage(Display *display,
   static XWindowInfo
     window_info;
 
-  unsigned long
+  size_t
     delay;
 
   Window
@@ -13680,7 +13691,7 @@ MagickExport MagickBooleanType XDisplayBackgroundImage(Display *display,
   context_values.background=pixel.background_color.pixel;
   context_values.foreground=pixel.foreground_color.pixel;
   pixel.annotate_context=XCreateGC(display,window_info.id,
-    (unsigned long) (GCBackground | GCForeground),&context_values);
+    (size_t) (GCBackground | GCForeground),&context_values);
   if (pixel.annotate_context == (GC) NULL)
     ThrowXWindowFatalException(XServerFatalError,"UnableToCreateGraphicContext",
       image->filename);
@@ -13704,8 +13715,8 @@ MagickExport MagickBooleanType XDisplayBackgroundImage(Display *display,
     window_attributes.width,window_attributes.height);
   geometry_info.width=window_info.width;
   geometry_info.height=window_info.height;
-  geometry_info.x=window_info.x;
-  geometry_info.y=window_info.y;
+  geometry_info.x=(ssize_t) window_info.x;
+  geometry_info.y=(ssize_t) window_info.y;
   (void) ParseMetaGeometry(geometry,&geometry_info.x,&geometry_info.y,
     &geometry_info.width,&geometry_info.height);
   window_info.width=(unsigned int) geometry_info.width;
@@ -13722,10 +13733,11 @@ MagickExport MagickBooleanType XDisplayBackgroundImage(Display *display,
   if (image->debug != MagickFalse)
     {
       (void) LogMagickEvent(X11Event,GetMagickModule(),
-        "Image: %s[%lu] %lux%lu ",image->filename,image->scene,
-        image->columns,image->rows);
+        "Image: %s[%.20g] %.20gx%.20g ",image->filename,(double) image->scene,
+        (double) image->columns,(double) image->rows);
       if (image->colors != 0)
-        (void) LogMagickEvent(X11Event,GetMagickModule(),"%luc ",image->colors);
+        (void) LogMagickEvent(X11Event,GetMagickModule(),"%.20gc ",(double)
+          image->colors);
       (void) LogMagickEvent(X11Event,GetMagickModule(),"%s",image->magick);
     }
   /*
@@ -13822,7 +13834,7 @@ MagickExport MagickBooleanType XDisplayBackgroundImage(Display *display,
 %  The format of the XDisplayImage method is:
 %
 %      Image *XDisplayImage(Display *display,XResourceInfo *resource_info,
-%        char **argv,int argc,Image **image,unsigned long *state)
+%        char **argv,int argc,Image **image,size_t *state)
 %
 %  A description of each parameter follows:
 %
@@ -13843,7 +13855,7 @@ MagickExport MagickBooleanType XDisplayBackgroundImage(Display *display,
 %
 */
 MagickExport Image *XDisplayImage(Display *display,XResourceInfo *resource_info,
-  char **argv,int argc,Image **image,unsigned long *state)
+  char **argv,int argc,Image **image,size_t *state)
 {
 #define MagnifySize  256  /* must be a power of 2 */
 #define MagickMenus  10
@@ -14248,7 +14260,7 @@ MagickExport Image *XDisplayImage(Display *display,XResourceInfo *resource_info,
     height,
     width;
 
-  unsigned long
+  size_t
     delay;
 
   WarningHandler
@@ -14369,10 +14381,11 @@ MagickExport Image *XDisplayImage(Display *display,XResourceInfo *resource_info,
   if (display_image->debug != MagickFalse)
     {
       (void) LogMagickEvent(X11Event,GetMagickModule(),
-        "Image: %s[%lu] %lux%lu ",display_image->filename,
-        display_image->scene,display_image->columns,display_image->rows);
+        "Image: %s[%.20g] %.20gx%.20g ",display_image->filename,
+        (double) display_image->scene,(double) display_image->columns,
+        (double) display_image->rows);
       if (display_image->colors != 0)
-        (void) LogMagickEvent(X11Event,GetMagickModule(),"%luc ",
+        (void) LogMagickEvent(X11Event,GetMagickModule(),"%.20gc ",(double)
           display_image->colors);
       (void) LogMagickEvent(X11Event,GetMagickModule(),"%s",
         display_image->magick);
@@ -14425,7 +14438,7 @@ MagickExport Image *XDisplayImage(Display *display,XResourceInfo *resource_info,
   if (pixel->highlight_context != (GC) NULL)
     (void) XFreeGC(display,pixel->highlight_context);
   pixel->highlight_context=XCreateGC(display,windows->context.id,
-    (unsigned long) (context_mask | GCPlaneMask),&context_values);
+    (size_t) (context_mask | GCPlaneMask),&context_values);
   if (pixel->highlight_context == (GC) NULL)
     ThrowXWindowFatalException(XServerFatalError,"UnableToCreateGraphicContext",
       display_image->filename);
@@ -14456,7 +14469,7 @@ MagickExport Image *XDisplayImage(Display *display,XResourceInfo *resource_info,
   context_values.background=icon_pixel->background_color.pixel;
   context_values.foreground=icon_pixel->foreground_color.pixel;
   icon_pixel->annotate_context=XCreateGC(display,windows->icon.id,
-    (unsigned long) (GCBackground | GCForeground),&context_values);
+    (size_t) (GCBackground | GCForeground),&context_values);
   if (icon_pixel->annotate_context == (GC) NULL)
     ThrowXWindowFatalException(XServerFatalError,"UnableToCreateGraphicContext",
       display_image->filename);
@@ -14494,8 +14507,8 @@ MagickExport Image *XDisplayImage(Display *display,XResourceInfo *resource_info,
           "%s: %s",MagickPackageName,filename);
       else
         (void) FormatMagickString(windows->image.name,MaxTextExtent,
-          "%s: %s[%lu of %lu]",MagickPackageName,filename,display_image->scene,
-          GetImageListLength(display_image));
+          "%s: %s[%.20g of %.20g]",MagickPackageName,filename,(double)
+          display_image->scene,(double) GetImageListLength(display_image));
       (void) CopyMagickString(windows->image.icon_name,filename,MaxTextExtent);
     }
   if (resource_info->immutable)
@@ -14527,7 +14540,7 @@ MagickExport Image *XDisplayImage(Display *display,XResourceInfo *resource_info,
       windows->backdrop.x=0;
       windows->backdrop.y=0;
       (void) CloneString(&windows->backdrop.name,"Backdrop");
-      windows->backdrop.flags=(unsigned long) (USSize | USPosition);
+      windows->backdrop.flags=(size_t) (USSize | USPosition);
       windows->backdrop.width=(unsigned int)
         XDisplayWidth(display,visual_info->screen);
       windows->backdrop.height=(unsigned int)
@@ -15176,7 +15189,7 @@ MagickExport Image *XDisplayImage(Display *display,XResourceInfo *resource_info,
                   context_values.plane_mask=context_values.background ^
                     context_values.foreground;
                   (void) XChangeGC(display,magick_windows[i]->highlight_context,
-                    (unsigned long) (context_mask | GCPlaneMask),
+                    (size_t) (context_mask | GCPlaneMask),
                     &context_values);
                   magick_windows[i]->attributes.background_pixel=
                     pixel->background_color.pixel;
@@ -15377,8 +15390,8 @@ MagickExport Image *XDisplayImage(Display *display,XResourceInfo *resource_info,
                         &window_changes);
                     }
               }
-            if ((event.xconfigure.width == (long) windows->image.width) &&
-                (event.xconfigure.height == (long) windows->image.height))
+            if ((event.xconfigure.width == (int) windows->image.width) &&
+                (event.xconfigure.height == (int) windows->image.height))
               break;
             windows->image.width=(unsigned int) event.xconfigure.width;
             windows->image.height=(unsigned int) event.xconfigure.height;