]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/xwindow.c
(no commit message)
[imagemagick] / MagickCore / xwindow.c
index 4649415735d1e6630c9d051806991062db05b1d9..fb55ead3f407240d997c6781f3c6fa1bee70d8d5 100644 (file)
@@ -17,7 +17,7 @@
 %                                  July 1992                                  %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -49,7 +49,9 @@
 #include "MagickCore/color-private.h"
 #include "MagickCore/colormap.h"
 #include "MagickCore/composite.h"
+#include "MagickCore/constitute.h"
 #include "MagickCore/display.h"
+#include "MagickCore/distort.h"
 #include "MagickCore/exception.h"
 #include "MagickCore/exception-private.h"
 #include "MagickCore/geometry.h"
 #include "MagickCore/quantum-private.h"
 #include "MagickCore/resource_.h"
 #include "MagickCore/resize.h"
-#include "MagickCore/shear.h"
 #include "MagickCore/statistic.h"
 #include "MagickCore/string_.h"
 #include "MagickCore/string-private.h"
 #include "MagickCore/transform.h"
+#include "MagickCore/token.h"
 #include "MagickCore/utility.h"
 #include "MagickCore/utility-private.h"
 #include "MagickCore/widget.h"
@@ -443,7 +445,8 @@ MagickExport void DestroyXResources(void)
 %  The format of the XAnnotateImage method is:
 %
 %      MagickBooleanType XAnnotateImage(Display *display,
-%        const XPixelInfo *pixel,XAnnotateInfo *annotate_info,Image *image)
+%        const XPixelInfo *pixel,XAnnotateInfo *annotate_info,Image *image,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -456,9 +459,12 @@ MagickExport void DestroyXResources(void)
 %
 %    o image: the image.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 MagickPrivate MagickBooleanType XAnnotateImage(Display *display,
-  const XPixelInfo *pixel,XAnnotateInfo *annotate_info,Image *image)
+  const XPixelInfo *pixel,XAnnotateInfo *annotate_info,Image *image,
+  ExceptionInfo *exception)
 {
   CacheView
     *annotate_view;
@@ -466,9 +472,6 @@ MagickPrivate MagickBooleanType XAnnotateImage(Display *display,
   GC
     annotate_context;
 
-  ExceptionInfo
-    *exception;
-
   Image
     *annotate_image;
 
@@ -482,9 +485,6 @@ MagickPrivate MagickBooleanType XAnnotateImage(Display *display,
   Pixmap
     annotate_pixmap;
 
-  Quantum
-    virtual_pixel[MaxPixelChannels];
-
   unsigned int
     depth,
     height,
@@ -544,7 +544,7 @@ MagickPrivate MagickBooleanType XAnnotateImage(Display *display,
   /*
     Initialize annotated image.
   */
-  annotate_image=AcquireImage((ImageInfo *) NULL,&image->exception);
+  annotate_image=AcquireImage((ImageInfo *) NULL,exception);
   if (annotate_image == (Image *) NULL)
     return(MagickFalse);
   annotate_image->columns=annotate_info->width;
@@ -557,15 +557,10 @@ MagickPrivate MagickBooleanType XAnnotateImage(Display *display,
   x=0;
   y=0;
   (void) XParseGeometry(annotate_info->geometry,&x,&y,&width,&height);
-  (void) GetOneVirtualPixel(image,(ssize_t) x,(ssize_t) y,virtual_pixel,
-    &image->exception);
-  annotate_image->background_color.red=virtual_pixel[RedPixelChannel];
-  annotate_image->background_color.green=virtual_pixel[GreenPixelChannel];
-  annotate_image->background_color.blue=virtual_pixel[BluePixelChannel];
-  annotate_image->background_color.alpha=virtual_pixel[AlphaPixelChannel];
+  (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,(ssize_t) x,
+    (ssize_t) y,&annotate_image->background_color,exception);
   if (annotate_info->stencil == ForegroundStencil)
     annotate_image->matte=MagickTrue;
-  exception=(&image->exception);
   annotate_view=AcquireCacheView(annotate_image);
   for (y=0; y < (int) annotate_image->rows; y++)
   {
@@ -650,8 +645,7 @@ MagickPrivate MagickBooleanType XAnnotateImage(Display *display,
       /*
         Rotate image.
       */
-      rotate_image=
-        RotateImage(annotate_image,annotate_info->degrees,&image->exception);
+      rotate_image=RotateImage(annotate_image,annotate_info->degrees,exception);
       if (rotate_image == (Image *) NULL)
         return(MagickFalse);
       annotate_image=DestroyImage(annotate_image);
@@ -702,9 +696,9 @@ MagickPrivate MagickBooleanType XAnnotateImage(Display *display,
   */
   (void) XParseGeometry(annotate_info->geometry,&x,&y,&width,&height);
   matte=image->matte;
-  (void) CompositeImage(image,annotate_image->matte != MagickFalse ?
-    OverCompositeOp : CopyCompositeOp,annotate_image,(ssize_t) x,(ssize_t) y,
-    exception);
+  (void) CompositeImage(image,annotate_image,
+    annotate_image->matte != MagickFalse ? OverCompositeOp : CopyCompositeOp,
+    MagickTrue,(ssize_t) x,(ssize_t) y,exception);
   image->matte=matte;
   annotate_image=DestroyImage(annotate_image);
   return(MagickTrue);
@@ -1693,7 +1687,8 @@ MagickPrivate void XComponentTerminus(void)
 %  The format of the XConfigureImageColormap method is:
 %
 %      void XConfigureImageColormap(Display *display,
-%        XResourceInfo *resource_info,XWindows *windows,Image *image)
+%        XResourceInfo *resource_info,XWindows *windows,Image *image,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -1706,9 +1701,12 @@ MagickPrivate void XComponentTerminus(void)
 %
 %    o image: the image.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 MagickPrivate void XConfigureImageColormap(Display *display,
-  XResourceInfo *resource_info,XWindows *windows,Image *image)
+  XResourceInfo *resource_info,XWindows *windows,Image *image,
+  ExceptionInfo *exception)
 {
   Colormap
     colormap;
@@ -1719,7 +1717,7 @@ MagickPrivate void XConfigureImageColormap(Display *display,
   XSetCursorState(display,windows,MagickTrue);
   XCheckRefreshWindows(display,windows);
   XMakeStandardColormap(display,windows->visual_info,resource_info,image,
-    windows->map_info,windows->pixel_info);
+    windows->map_info,windows->pixel_info,exception);
   colormap=windows->map_info->colormap;
   (void) XSetWindowColormap(display,windows->image.id,colormap);
   (void) XSetWindowColormap(display,windows->command.id,colormap);
@@ -1942,7 +1940,7 @@ MagickPrivate void XDestroyWindowColors(Display *display,Window window)
 %
 %      void XDisplayImageInfo(Display *display,
 %        const XResourceInfo *resource_info,XWindows *windows,Image *undo_image,
-%        Image *image)
+%        Image *image,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -1957,10 +1955,12 @@ MagickPrivate void XDestroyWindowColors(Display *display,Window window)
 %
 %    o image: the image.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 MagickPrivate void XDisplayImageInfo(Display *display,
   const XResourceInfo *resource_info,XWindows *windows,Image *undo_image,
-  Image *image)
+  Image *image,ExceptionInfo *exception)
 {
   char
     filename[MaxTextExtent],
@@ -2060,9 +2060,9 @@ MagickPrivate void XDisplayImageInfo(Display *display,
   /*
     Write info about the image to a file.
   */
-  (void) IdentifyImage(image,file,MagickTrue,&image->exception);
+  (void) IdentifyImage(image,file,MagickTrue,exception);
   (void) fclose(file);
-  text=FileToString(filename,~0,&image->exception);
+  text=FileToString(filename,~0,exception);
   (void) RelinquishUniqueFileResource(filename);
   if (text == (char *) NULL)
     {
@@ -2109,7 +2109,7 @@ MagickPrivate void XDisplayImageInfo(Display *display,
 %
 %  The format of the XDitherImage method is:
 %
-%      void XDitherImage(Image *image,XImage *ximage)
+%      void XDitherImage(Image *image,XImage *ximage,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -2118,8 +2118,10 @@ MagickPrivate void XDisplayImageInfo(Display *display,
 %    o ximage: Specifies a pointer to a XImage structure;  returned from
 %      XCreateImage.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
-static void XDitherImage(Image *image,XImage *ximage)
+static void XDitherImage(Image *image,XImage *ximage,ExceptionInfo *exception)
 {
   static const short int
     dither_red[2][16]=
@@ -2229,17 +2231,17 @@ static void XDitherImage(Image *image,XImage *ximage)
   for (y=0; y < (int) image->rows; y++)
   {
     p=GetCacheViewVirtualPixels(image_view,0,(ssize_t) y,image->columns,1,
-      &image->exception);
+      exception);
     if (p == (const Quantum *) NULL)
       break;
     for (x=0; x < (int) image->columns; x++)
     {
-      color.red=ClampToQuantum((MagickRealType) (red_map[i][j][(int)
-        ScaleQuantumToChar(GetPixelRed(image,p))] << 8));
-      color.green=ClampToQuantum((MagickRealType) (green_map[i][j][(int)
-        ScaleQuantumToChar(GetPixelGreen(image,p))] << 8));
-      color.blue=ClampToQuantum((MagickRealType) (blue_map[i][j][(int)
-        ScaleQuantumToChar(GetPixelBlue(image,p))] << 8));
+      color.red=(double) ClampToQuantum((MagickRealType) (red_map[i][j][
+        (int) ScaleQuantumToChar(GetPixelRed(image,p))] << 8));
+      color.green=(double) ClampToQuantum((MagickRealType) (green_map[i][j][
+        (int) ScaleQuantumToChar(GetPixelGreen(image,p))] << 8));
+      color.blue=(double) ClampToQuantum((MagickRealType) (blue_map[i][j][
+        (int) ScaleQuantumToChar(GetPixelBlue(image,p))] << 8));
       pixel=(size_t) (((size_t) color.red & 0xe0) |
         (((size_t) color.green & 0xe0) >> 3) |
         (((size_t) color.blue & 0xc0) >> 6));
@@ -2282,7 +2284,8 @@ static void XDitherImage(Image *image,XImage *ximage)
 %
 %  The format of the XDrawImage method is:
 %
-%    MagickBooleanType XDrawImage(display,pixel,draw_info,image)
+%    MagickBooleanType XDrawImage(Display *display,const XPixelInfo *pixel,
+%      XDrawInfo *draw_info,Image *image,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -2295,16 +2298,16 @@ static void XDitherImage(Image *image,XImage *ximage)
 %
 %    o image: the image.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 MagickPrivate MagickBooleanType XDrawImage(Display *display,
-  const XPixelInfo *pixel,XDrawInfo *draw_info,Image *image)
+  const XPixelInfo *pixel,XDrawInfo *draw_info,Image *image,
+  ExceptionInfo *exception)
 {
   CacheView
     *draw_view;
 
-  ExceptionInfo
-    *exception;
-
   GC
     draw_context;
 
@@ -2318,9 +2321,6 @@ MagickPrivate MagickBooleanType XDrawImage(Display *display,
   MagickBooleanType
     matte;
 
-  Quantum
-    virtual_pixel[MaxPixelChannels];
-
   Pixmap
     draw_pixmap;
 
@@ -2466,7 +2466,7 @@ MagickPrivate MagickBooleanType XDrawImage(Display *display,
   /*
     Initialize draw image.
   */
-  draw_image=AcquireImage((ImageInfo *) NULL,&image->exception);
+  draw_image=AcquireImage((ImageInfo *) NULL,exception);
   if (draw_image == (Image *) NULL)
     return(MagickFalse);
   draw_image->columns=draw_info->width;
@@ -2479,16 +2479,11 @@ MagickPrivate MagickBooleanType XDrawImage(Display *display,
   x=0;
   y=0;
   (void) XParseGeometry(draw_info->geometry,&x,&y,&width,&height);
-  (void) GetOneVirtualPixel(image,(ssize_t) x,(ssize_t) y,virtual_pixel,
-    &image->exception);
-  draw_image->background_color.red=virtual_pixel[RedPixelChannel];
-  draw_image->background_color.green=virtual_pixel[GreenPixelChannel];
-  draw_image->background_color.blue=virtual_pixel[BluePixelChannel];
-  draw_image->background_color.alpha=virtual_pixel[AlphaPixelChannel];
-  if (SetImageStorageClass(draw_image,DirectClass,&image->exception) == MagickFalse)
+  (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,(ssize_t) x,
+    (ssize_t) y,&draw_image->background_color,exception);
+  if (SetImageStorageClass(draw_image,DirectClass,exception) == MagickFalse)
     return(MagickFalse);
   draw_image->matte=MagickTrue;
-  exception=(&image->exception);
   draw_view=AcquireCacheView(draw_image);
   for (y=0; y < (int) draw_image->rows; y++)
   {
@@ -2509,7 +2504,7 @@ MagickPrivate MagickBooleanType XDrawImage(Display *display,
           /*
             Set this pixel to the background color.
           */
-          SetPixelPixelInfo(draw_image,&draw_image->background_color,q);
+          SetPixelInfoPixel(draw_image,&draw_image->background_color,q);
           SetPixelAlpha(draw_image,(Quantum) (draw_info->stencil ==
             OpaqueStencil ? TransparentAlpha : OpaqueAlpha),q);
         }
@@ -2566,7 +2561,7 @@ MagickPrivate MagickBooleanType XDrawImage(Display *display,
       /*
         Rotate image.
       */
-      rotate_image=RotateImage(draw_image,draw_info->degrees,&image->exception);
+      rotate_image=RotateImage(draw_image,draw_info->degrees,exception);
       if (rotate_image == (Image *) NULL)
         return(MagickFalse);
       draw_image=DestroyImage(draw_image);
@@ -2640,13 +2635,13 @@ MagickPrivate MagickBooleanType XDrawImage(Display *display,
   draw_view=DestroyCacheView(draw_view);
   (void) XParseGeometry(draw_info->geometry,&x,&y,&width,&height);
   if (draw_info->stencil == TransparentStencil)
-    (void) CompositeImage(image,CopyOpacityCompositeOp,draw_image,(ssize_t) x,
-      (ssize_t) y,exception);
+    (void) CompositeImage(image,draw_image,CopyAlphaCompositeOp,MagickTrue,
+      (ssize_t) x,(ssize_t) y,exception);
   else
     {
       matte=image->matte;
-      (void) CompositeImage(image,OverCompositeOp,draw_image,(ssize_t) x,
-        (ssize_t) y,exception);
+      (void) CompositeImage(image,draw_image,OverCompositeOp,MagickTrue,
+        (ssize_t) x,(ssize_t) y,exception);
       image->matte=matte;
     }
   draw_image=DestroyImage(draw_image);
@@ -3498,7 +3493,7 @@ MagickExport void XGetResourceInfo(const ImageInfo *image_info,
   resource_info->client_name=AcquireString(client_name);
   resource_value=XGetResourceClass(database,client_name,"backdrop",
     (char *) "False");
-  resource_info->backdrop=IsMagickTrue(resource_value);
+  resource_info->backdrop=IsStringTrue(resource_value);
   resource_info->background_color=XGetResourceInstance(database,client_name,
     "background",(char *) "#d6d6d6d6d6d6");
   resource_info->border_color=XGetResourceInstance(database,client_name,
@@ -3519,20 +3514,20 @@ MagickExport void XGetResourceInfo(const ImageInfo *image_info,
       resource_value);
   resource_value=XGetResourceClass(database,client_name,
     "colorRecovery",(char *) "False");
-  resource_info->color_recovery=IsMagickTrue(resource_value);
+  resource_info->color_recovery=IsStringTrue(resource_value);
   resource_value=XGetResourceClass(database,client_name,"confirmExit",
     (char *) "False");
-  resource_info->confirm_exit=IsMagickTrue(resource_value);
+  resource_info->confirm_exit=IsStringTrue(resource_value);
   resource_value=XGetResourceClass(database,client_name,"confirmEdit",
     (char *) "False");
-  resource_info->confirm_edit=IsMagickTrue(resource_value);
+  resource_info->confirm_edit=IsStringTrue(resource_value);
   resource_value=XGetResourceClass(database,client_name,"delay",(char *) "1");
   resource_info->delay=(unsigned int) StringToUnsignedLong(resource_value);
   resource_info->display_gamma=XGetResourceClass(database,client_name,
     "displayGamma",(char *) "2.2");
   resource_value=XGetResourceClass(database,client_name,"displayWarnings",
     (char *) "True");
-  resource_info->display_warnings=IsMagickTrue(resource_value);
+  resource_info->display_warnings=IsStringTrue(resource_value);
   resource_info->font=XGetResourceClass(database,client_name,"font",
     (char *) NULL);
   resource_info->font=XGetResourceClass(database,client_name,"fontList",
@@ -3563,7 +3558,7 @@ MagickExport void XGetResourceInfo(const ImageInfo *image_info,
     "foreground",ForegroundColor);
   resource_value=XGetResourceClass(database,client_name,"gammaCorrect",
     (char *) "True");
-  resource_info->gamma_correct=IsMagickTrue(resource_value);
+  resource_info->gamma_correct=IsStringTrue(resource_value);
   resource_info->image_geometry=ConstantString(XGetResourceClass(database,
     client_name,"geometry",(char *) NULL));
   resource_value=XGetResourceClass(database,client_name,"gravity",
@@ -3576,11 +3571,11 @@ MagickExport void XGetResourceInfo(const ImageInfo *image_info,
     "iconGeometry",(char *) NULL);
   resource_value=XGetResourceClass(database,client_name,"iconic",
     (char *) "False");
-  resource_info->iconic=IsMagickTrue(resource_value);
+  resource_info->iconic=IsStringTrue(resource_value);
   resource_value=XGetResourceClass(database,client_name,"immutable",
     LocaleCompare(client_name,"PerlMagick") == 0 ? (char *) "True" :
     (char *) "False");
-  resource_info->immutable=IsMagickTrue(resource_value);
+  resource_info->immutable=IsStringTrue(resource_value);
   resource_value=XGetResourceClass(database,client_name,"magnify",
     (char *) "3");
   resource_info->magnify=(unsigned int) StringToUnsignedLong(resource_value);
@@ -3627,13 +3622,13 @@ MagickExport void XGetResourceInfo(const ImageInfo *image_info,
   resource_info->undo_cache=(unsigned int) StringToUnsignedLong(resource_value);
   resource_value=XGetResourceClass(database,client_name,"update",
     (char *) "False");
-  resource_info->update=IsMagickTrue(resource_value);
+  resource_info->update=IsStringTrue(resource_value);
   resource_value=XGetResourceClass(database,client_name,"usePixmap",
     (char *) "True");
-  resource_info->use_pixmap=IsMagickTrue(resource_value);
+  resource_info->use_pixmap=IsStringTrue(resource_value);
   resource_value=XGetResourceClass(database,client_name,"sharedMemory",
     (char *) "True");
-  resource_info->use_shared_memory=IsMagickTrue(resource_value);
+  resource_info->use_shared_memory=IsStringTrue(resource_value);
   resource_info->visual_type=XGetResourceClass(database,client_name,"visual",
     (char *) NULL);
   resource_info->window_group=XGetResourceClass(database,client_name,
@@ -3840,7 +3835,7 @@ static Window XGetSubwindow(Display *display,Window window,int x,int y)
 %  The format of the XGetWindowColor method is:
 %
 %      MagickBooleanType XGetWindowColor(Display *display,XWindows *windows,
-%        char *name)
+%        char *name,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -3852,9 +3847,11 @@ static Window XGetSubwindow(Display *display,Window window,int x,int y)
 %    o name: the name of the color if found in the X Color Database is
 %      returned in this character string.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 MagickPrivate MagickBooleanType XGetWindowColor(Display *display,
-  XWindows *windows,char *name)
+  XWindows *windows,char *name,ExceptionInfo *exception)
 {
   int
     x,
@@ -3931,12 +3928,12 @@ MagickPrivate MagickBooleanType XGetWindowColor(Display *display,
     Match color against the color database.
   */
   (void) XQueryColor(display,window_attributes.colormap,&color);
-  pixel.red=ScaleShortToQuantum(color.red);
-  pixel.green=ScaleShortToQuantum(color.green);
-  pixel.blue=ScaleShortToQuantum(color.blue);
+  pixel.red=(double) ScaleShortToQuantum(color.red);
+  pixel.green=(double) ScaleShortToQuantum(color.green);
+  pixel.blue=(double) ScaleShortToQuantum(color.blue);
   pixel.alpha=OpaqueAlpha;
   (void) QueryColorname(windows->image.image,&pixel,X11Compliance,name,
-    &windows->image.image->exception);
+    exception);
   return(MagickTrue);
 }
 \f
@@ -3960,7 +3957,8 @@ MagickPrivate MagickBooleanType XGetWindowColor(Display *display,
 %  The format of the XGetWindowImage method is:
 %
 %      Image *XGetWindowImage(Display *display,const Window window,
-%        const unsigned int borders,const unsigned int level)
+%        const unsigned int borders,const unsigned int level,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -3978,9 +3976,11 @@ MagickPrivate MagickBooleanType XGetWindowColor(Display *display,
 %      one call.  A value of one causes the function to descend the window
 %      hierarchy and overlay the target image with each subwindow image.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 static Image *XGetWindowImage(Display *display,const Window window,
-  const unsigned int borders,const unsigned int level)
+  const unsigned int borders,const unsigned int level,ExceptionInfo *exception)
 {
   typedef struct _ColormapInfo
   {
@@ -4162,7 +4162,8 @@ static Image *XGetWindowImage(Display *display,const Window window,
       if ((status == True) && (number_children != 0))
         {
           for (i=0; i < (int) number_children; i++)
-            (void) XGetWindowImage(display,children[i],MagickFalse,level+1);
+            (void) XGetWindowImage(display,children[i],MagickFalse,level+1,
+              exception);
           (void) XFree((void *) children);
         }
     }
@@ -4174,9 +4175,6 @@ static Image *XGetWindowImage(Display *display,const Window window,
       ColormapInfo
         *next;
 
-      ExceptionInfo
-        *exception;
-
       Image
         *composite_image,
         *image;
@@ -4346,7 +4344,7 @@ static Image *XGetWindowImage(Display *display,const Window window,
         /*
           Allocate image structure.
         */
-        composite_image=AcquireImage((ImageInfo *) NULL,&image->exception);
+        composite_image=AcquireImage((ImageInfo *) NULL,exception);
         if (composite_image == (Image *) NULL)
           {
             XDestroyImage(ximage);
@@ -4360,7 +4358,6 @@ static Image *XGetWindowImage(Display *display,const Window window,
           composite_image->storage_class=PseudoClass;
         composite_image->columns=(size_t) ximage->width;
         composite_image->rows=(size_t) ximage->height;
-        exception=(&composite_image->exception);
         composite_view=AcquireCacheView(composite_image);
         switch (composite_image->storage_class)
         {
@@ -4428,7 +4425,8 @@ static Image *XGetWindowImage(Display *display,const Window window,
                     ScaleShortToQuantum(colors[index].blue),q);
                   q+=GetPixelChannels(composite_image);
                 }
-                if (SyncCacheViewAuthenticPixels(composite_view,exception) == MagickFalse)
+                status=SyncCacheViewAuthenticPixels(composite_view,exception);
+                if (status == MagickFalse)
                   break;
               }
             else
@@ -4455,7 +4453,8 @@ static Image *XGetWindowImage(Display *display,const Window window,
                     ScaleShortToQuantum((unsigned short) color),q);
                   q+=GetPixelChannels(composite_image);
                 }
-                if (SyncCacheViewAuthenticPixels(composite_view,exception) == MagickFalse)
+                status=SyncCacheViewAuthenticPixels(composite_view,exception);
+                if (status == MagickFalse)
                   break;
               }
             break;
@@ -4465,7 +4464,9 @@ static Image *XGetWindowImage(Display *display,const Window window,
             /*
               Create colormap.
             */
-            if (AcquireImageColormap(composite_image,number_colors,exception) == MagickFalse)
+            status=AcquireImageColormap(composite_image,number_colors,
+              exception);
+            if (status == MagickFalse)
               {
                 XDestroyImage(ximage);
                 composite_image=DestroyImage(composite_image);
@@ -4473,11 +4474,11 @@ static Image *XGetWindowImage(Display *display,const Window window,
               }
             for (i=0; i < (int) composite_image->colors; i++)
             {
-              composite_image->colormap[colors[i].pixel].red=
+              composite_image->colormap[colors[i].pixel].red=(double)
                 ScaleShortToQuantum(colors[i].red);
-              composite_image->colormap[colors[i].pixel].green=
+              composite_image->colormap[colors[i].pixel].green=(double)
                 ScaleShortToQuantum(colors[i].green);
-              composite_image->colormap[colors[i].pixel].blue=
+              composite_image->colormap[colors[i].pixel].blue=(double)
                 ScaleShortToQuantum(colors[i].blue);
             }
             /*
@@ -4493,11 +4494,12 @@ static Image *XGetWindowImage(Display *display,const Window window,
               {
                 index=(Quantum) XGetPixel(ximage,x,y);
                 SetPixelIndex(composite_image,index,q);
-                SetPixelPixelInfo(composite_image,
+                SetPixelInfoPixel(composite_image,
                   composite_image->colormap+(ssize_t) index,q);
                 q+=GetPixelChannels(composite_image);
               }
-              if (SyncCacheViewAuthenticPixels(composite_view,exception) == MagickFalse)
+              status=SyncCacheViewAuthenticPixels(composite_view,exception);
+              if (status == MagickFalse)
                 break;
             }
             break;
@@ -4521,8 +4523,9 @@ static Image *XGetWindowImage(Display *display,const Window window,
         y_offset-=(int) crop_info.y;
         if (y_offset < 0)
           y_offset=0;
-        (void) CompositeImage(image,CopyCompositeOp,composite_image,(ssize_t)
-          x_offset,(ssize_t) y_offset,exception);
+        (void) CompositeImage(image,composite_image,CopyCompositeOp,MagickTrue,
+          (ssize_t) x_offset,(ssize_t) y_offset,exception);
+        composite_image=DestroyImage(composite_image);
       }
       /*
         Relinquish resources.
@@ -4862,7 +4865,8 @@ MagickPrivate void XHighlightRectangle(Display *display,Window window,
 %
 %  The format of the XImportImage method is:
 %
-%      Image *XImportImage(const ImageInfo *image_info,XImportInfo *ximage_info)
+%      Image *XImportImage(const ImageInfo *image_info,XImportInfo *ximage_info,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -4870,9 +4874,11 @@ MagickPrivate void XHighlightRectangle(Display *display,Window window,
 %
 %    o ximage_info: Specifies a pointer to an XImportInfo structure.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 MagickExport Image *XImportImage(const ImageInfo *image_info,
-  XImportInfo *ximage_info)
+  XImportInfo *ximage_info,ExceptionInfo *exception)
 {
   Colormap
     *colormaps;
@@ -4996,7 +5002,6 @@ MagickExport Image *XImportImage(const ImageInfo *image_info,
           if ((ximage_info->frame == MagickFalse) &&
               (prior_target != MagickFalse))
             target=prior_target;
-          XDelay(display,SuspendTime << 4);
         }
     }
   if (ximage_info->screen)
@@ -5065,7 +5070,7 @@ MagickExport Image *XImportImage(const ImageInfo *image_info,
   */
   (void) XGrabServer(display);
   image=XGetWindowImage(display,target,ximage_info->borders,
-    ximage_info->descend ? 1U : 0U);
+    ximage_info->descend ? 1U : 0U,exception);
   (void) XUngrabServer(display);
   if (image == (Image *) NULL)
     ThrowXWindowFatalException(XServerError,"UnableToReadXWindowImage",
@@ -5083,10 +5088,10 @@ MagickExport Image *XImportImage(const ImageInfo *image_info,
           /*
             Crop image as defined by the cropping rectangle.
           */
-          clone_image=CloneImage(image,0,0,MagickTrue,&image->exception);
+          clone_image=CloneImage(image,0,0,MagickTrue,exception);
           if (clone_image != (Image *) NULL)
             {
-              crop_image=CropImage(clone_image,&crop_info,&image->exception);
+              crop_image=CropImage(clone_image,&crop_info,exception);
               if (crop_image != (Image *) NULL)
                 {
                   image=DestroyImage(image);
@@ -5494,8 +5499,8 @@ MagickPrivate MagickBooleanType XMakeImage(Display *display,
           window->image->page.x=0;
           window->image->page.y=0;
           (void) ParsePageGeometry(window->image,window->crop_geometry,
-            &crop_info,&image->exception);
-          crop_image=CropImage(window->image,&crop_info,&image->exception);
+            &crop_info,exception);
+          crop_image=CropImage(window->image,&crop_info,exception);
           if (crop_image != (Image *) NULL)
             {
               if (window->image != image)
@@ -5515,11 +5520,9 @@ MagickPrivate MagickBooleanType XMakeImage(Display *display,
           */
           resize_image=NewImageList();
           if (window->pixel_info->colors != 0)
-            resize_image=SampleImage(window->image,width,height,
-              &image->exception);
+            resize_image=SampleImage(window->image,width,height,exception);
           else
-            resize_image=ThumbnailImage(window->image,width,height,
-              &image->exception);
+            resize_image=ThumbnailImage(window->image,width,height,exception);
           if (resize_image != (Image *) NULL)
             {
               if (window->image != image)
@@ -5926,14 +5929,14 @@ static void XMakeImageLSBFirst(const XResourceInfo *resource_info,
       (void) FormatLocaleString(size,MaxTextExtent,"%.20gx%.20g",(double)
         image->columns,(double) image->rows);
       image_info->size=ConstantString(size);
-      pattern=ReadImage(image_info,&image->exception);
+      pattern=ReadImage(image_info,exception);
       image_info=DestroyImageInfo(image_info);
       if (pattern != (Image *) NULL)
         {
-          canvas=CloneImage(image,0,0,MagickTrue,&image->exception);
+          canvas=CloneImage(image,0,0,MagickTrue,exception);
           if (canvas != (Image *) NULL)
-            (void) CompositeImage(canvas,DstOverCompositeOp,pattern,0,0,
-              exception);
+            (void) CompositeImage(canvas,pattern,DstOverCompositeOp,MagickTrue,
+              0,0,exception);
           pattern=DestroyImage(pattern);
         }
     }
@@ -5970,7 +5973,7 @@ static void XMakeImageLSBFirst(const XResourceInfo *resource_info,
       for (y=0; y < (int) canvas->rows; y++)
       {
         p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,canvas->columns,1,
-          &canvas->exception);
+          exception);
         if (p == (const Quantum *) NULL)
           break;
         bit=0;
@@ -6011,7 +6014,7 @@ static void XMakeImageLSBFirst(const XResourceInfo *resource_info,
           for (y=0; y < (int) canvas->rows; y++)
           {
             p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-              canvas->columns,1,&canvas->exception);
+              canvas->columns,1,exception);
             if (p == (const Quantum *) NULL)
               break;
             nibble=0;
@@ -6063,7 +6066,7 @@ static void XMakeImageLSBFirst(const XResourceInfo *resource_info,
           for (y=0; y < (int) canvas->rows; y++)
           {
             p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-              canvas->columns,1,&canvas->exception);
+              canvas->columns,1,exception);
             if (p == (const Quantum *) NULL)
               break;
             nibble=0;
@@ -6101,13 +6104,13 @@ static void XMakeImageLSBFirst(const XResourceInfo *resource_info,
           if (resource_info->color_recovery &&
               resource_info->quantize_info->dither)
             {
-              XDitherImage(canvas,ximage);
+              XDitherImage(canvas,ximage,exception);
               break;
             }
           for (y=0; y < (int) canvas->rows; y++)
           {
             p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-              canvas->columns,1,&canvas->exception);
+              canvas->columns,1,exception);
             if (p == (const Quantum *) NULL)
               break;
             for (x=0; x < (int) canvas->columns; x++)
@@ -6138,7 +6141,7 @@ static void XMakeImageLSBFirst(const XResourceInfo *resource_info,
           for (y=0; y < (int) canvas->rows; y++)
           {
             p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-              canvas->columns,1,&canvas->exception);
+              canvas->columns,1,exception);
             if (p == (const Quantum *) NULL)
               break;
             for (x=0; x < (int) canvas->columns; x++)
@@ -6173,7 +6176,7 @@ static void XMakeImageLSBFirst(const XResourceInfo *resource_info,
           {
             nibble=0;
             p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-              canvas->columns,1,&canvas->exception);
+              canvas->columns,1,exception);
             if (p == (const Quantum *) NULL)
               break;
             for (x=0; x < (int) canvas->columns; x++)
@@ -6225,7 +6228,7 @@ static void XMakeImageLSBFirst(const XResourceInfo *resource_info,
           for (y=0; y < (int) canvas->rows; y++)
           {
             p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-              canvas->columns,1,&canvas->exception);
+              canvas->columns,1,exception);
             if (p == (const Quantum *) NULL)
               break;
             nibble=0;
@@ -6264,13 +6267,13 @@ static void XMakeImageLSBFirst(const XResourceInfo *resource_info,
           if (resource_info->color_recovery &&
               resource_info->quantize_info->dither)
             {
-              XDitherImage(canvas,ximage);
+              XDitherImage(canvas,ximage,exception);
               break;
             }
           for (y=0; y < (int) canvas->rows; y++)
           {
             p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-              canvas->columns,1,&canvas->exception);
+              canvas->columns,1,exception);
             if (p == (const Quantum *) NULL)
               break;
             for (x=0; x < (int) canvas->columns; x++)
@@ -6296,7 +6299,7 @@ static void XMakeImageLSBFirst(const XResourceInfo *resource_info,
               for (y=0; y < (int) canvas->rows; y++)
               {
                 p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-                  canvas->columns,1,&canvas->exception);
+                  canvas->columns,1,exception);
                 if (p == (const Quantum *) NULL)
                   break;
                 if ((red_gamma != 1.0) || (green_gamma != 1.0) ||
@@ -6343,7 +6346,7 @@ static void XMakeImageLSBFirst(const XResourceInfo *resource_info,
                 for (y=0; y < (int) canvas->rows; y++)
                 {
                   p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-                    canvas->columns,1,&canvas->exception);
+                    canvas->columns,1,exception);
                   if (p == (const Quantum *) NULL)
                     break;
                   if ((red_gamma != 1.0) || (green_gamma != 1.0) ||
@@ -6396,7 +6399,7 @@ static void XMakeImageLSBFirst(const XResourceInfo *resource_info,
                 for (y=0; y < (int) canvas->rows; y++)
                 {
                   p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-                    canvas->columns,1,&canvas->exception);
+                    canvas->columns,1,exception);
                   if (p == (const Quantum *) NULL)
                     break;
                   for (x=0; x < (int) canvas->columns; x++)
@@ -6428,7 +6431,7 @@ static void XMakeImageLSBFirst(const XResourceInfo *resource_info,
       for (y=0; y < (int) canvas->rows; y++)
       {
         p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,canvas->columns,1,
-          &canvas->exception);
+          exception);
         if (p == (const Quantum *) NULL)
           break;
         bit=0;
@@ -6558,14 +6561,14 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
       (void) FormatLocaleString(size,MaxTextExtent,"%.20gx%.20g",(double)
         image->columns,(double) image->rows);
       image_info->size=ConstantString(size);
-      pattern=ReadImage(image_info,&image->exception);
+      pattern=ReadImage(image_info,exception);
       image_info=DestroyImageInfo(image_info);
       if (pattern != (Image *) NULL)
         {
-          canvas=CloneImage(image,0,0,MagickTrue,&image->exception);
+          canvas=CloneImage(image,0,0,MagickTrue,exception);
           if (canvas != (Image *) NULL)
-            (void) CompositeImage(canvas,DstOverCompositeOp,pattern,0,0,
-              exception);
+            (void) CompositeImage(canvas,pattern,DstOverCompositeOp,MagickFalse,
+              0,0,exception);
           pattern=DestroyImage(pattern);
         }
     }
@@ -6602,7 +6605,7 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
       for (y=0; y < (int) canvas->rows; y++)
       {
         p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,canvas->columns,1,
-          &canvas->exception);
+          exception);
         if (p == (const Quantum *) NULL)
           break;
         bit=0;
@@ -6643,7 +6646,7 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
           for (y=0; y < (int) canvas->rows; y++)
           {
             p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-              canvas->columns,1,&canvas->exception);
+              canvas->columns,1,exception);
             if (p == (const Quantum *) NULL)
               break;
             nibble=0;
@@ -6696,7 +6699,7 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
           for (y=0; y < (int) canvas->rows; y++)
           {
             p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-              canvas->columns,1,&canvas->exception);
+              canvas->columns,1,exception);
             if (p == (const Quantum *) NULL)
               break;
             nibble=0;
@@ -6735,19 +6738,18 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
           if (resource_info->color_recovery &&
               resource_info->quantize_info->dither)
             {
-              XDitherImage(canvas,ximage);
+              XDitherImage(canvas,ximage,exception);
               break;
             }
           for (y=0; y < (int) canvas->rows; y++)
           {
             p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-              canvas->columns,1,&canvas->exception);
+              canvas->columns,1,exception);
             if (p == (const Quantum *) NULL)
               break;
             for (x=0; x < (int) canvas->columns; x++)
             {
-              pixel=pixels[(ssize_t)
-                GetPixelIndex(canvas,p)];
+              pixel=pixels[(ssize_t) GetPixelIndex(canvas,p)];
               *q++=(unsigned char) pixel;
               p+=GetPixelChannels(canvas);
             }
@@ -6773,7 +6775,7 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
           for (y=0; y < (int) canvas->rows; y++)
           {
             p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-              canvas->columns,1,&canvas->exception);
+              canvas->columns,1,exception);
             if (p == (const Quantum *) NULL)
               break;
             for (x=0; x < (int) canvas->columns; x++)
@@ -6808,7 +6810,7 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
           for (y=0; y < (int) canvas->rows; y++)
           {
             p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-              canvas->columns,1,&canvas->exception);
+              canvas->columns,1,exception);
             if (p == (const Quantum *) NULL)
               break;
             nibble=0;
@@ -6861,7 +6863,7 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
           for (y=0; y < (int) canvas->rows; y++)
           {
             p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-              canvas->columns,1,&canvas->exception);
+              canvas->columns,1,exception);
             if (p == (const Quantum *) NULL)
               break;
             nibble=0;
@@ -6900,13 +6902,13 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
           if (resource_info->color_recovery &&
               resource_info->quantize_info->dither)
             {
-              XDitherImage(canvas,ximage);
+              XDitherImage(canvas,ximage,exception);
               break;
             }
           for (y=0; y < (int) canvas->rows; y++)
           {
             p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-              canvas->columns,1,&canvas->exception);
+              canvas->columns,1,exception);
             if (p == (const Quantum *) NULL)
               break;
             for (x=(int) canvas->columns-1; x >= 0; x--)
@@ -6932,7 +6934,7 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
               for (y=0; y < (int) canvas->rows; y++)
               {
                 p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-                  canvas->columns,1,&canvas->exception);
+                  canvas->columns,1,exception);
                 if (p == (const Quantum *) NULL)
                   break;
                 if ((red_gamma != 1.0) || (green_gamma != 1.0) ||
@@ -6979,7 +6981,7 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
                 for (y=0; y < (int) canvas->rows; y++)
                 {
                   p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-                    canvas->columns,1,&canvas->exception);
+                    canvas->columns,1,exception);
                   if (p == (const Quantum *) NULL)
                     break;
                   if ((red_gamma != 1.0) || (green_gamma != 1.0) ||
@@ -7032,7 +7034,7 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
                 for (y=0; y < (int) canvas->rows; y++)
                 {
                   p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,
-                    canvas->columns,1,&canvas->exception);
+                    canvas->columns,1,exception);
                   if (p == (const Quantum *) NULL)
                     break;
                   for (x=(int) canvas->columns-1; x >= 0; x--)
@@ -7064,7 +7066,7 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
       for (y=0; y < (int) canvas->rows; y++)
       {
         p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,canvas->columns,1,
-          &canvas->exception);
+          exception);
         if (p == (const Quantum *) NULL)
           break;
         bit=0;
@@ -7108,7 +7110,8 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
 %
 %  The format of the XMakeMagnifyImage method is:
 %
-%      void XMakeMagnifyImage(display,windows)
+%      void XMakeMagnifyImage(Display *display,XWindows *windows,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -7117,8 +7120,11 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
 %
 %    o windows: Specifies a pointer to a XWindows structure.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
-MagickPrivate void XMakeMagnifyImage(Display *display,XWindows *windows)
+MagickPrivate void XMakeMagnifyImage(Display *display,XWindows *windows,
+  ExceptionInfo *exception)
 {
   char
     tuple[MaxTextExtent];
@@ -7509,9 +7515,8 @@ MagickPrivate void XMakeMagnifyImage(Display *display,XWindows *windows)
   /*
     Show center pixel color.
   */
-  (void) GetOneVirtualMagickPixel(windows->image.image,(ssize_t)
-    windows->magnify.x,(ssize_t) windows->magnify.y,&pixel,
-    &windows->image.image->exception);
+  (void) GetOneVirtualPixelInfo(windows->image.image,TileVirtualPixelMethod,
+    (ssize_t) windows->magnify.x,(ssize_t) windows->magnify.y,&pixel,exception);
   (void) FormatLocaleString(tuple,MaxTextExtent,"%d,%d: ",
     windows->magnify.x,windows->magnify.y);
   (void) ConcatenateMagickString(tuple,"(",MaxTextExtent);
@@ -7542,7 +7547,7 @@ MagickPrivate void XMakeMagnifyImage(Display *display,XWindows *windows)
   (void) XDrawImageString(display,windows->magnify.pixmap,
     windows->magnify.annotate_context,x,y,tuple,(int) strlen(tuple));
   (void) QueryColorname(windows->image.image,&pixel,SVGCompliance,tuple,
-     &windows->image.image->exception);
+    exception);
   y+=height;
   (void) XDrawImageString(display,windows->magnify.pixmap,
     windows->magnify.annotate_context,x,y,tuple,(int) strlen(tuple));
@@ -7665,8 +7670,9 @@ static MagickBooleanType XMakePixmap(Display *display,
 %
 %  The format of the XMakeStandardColormap method is:
 %
-%      XMakeStandardColormap(display,visual_info,resource_info,image,
-%        map_info,pixel)
+%      void XMakeStandardColormap(Display *display,XVisualInfo *visual_info,
+%        XResourceInfo *resource_info,Image *image,XStandardColormap *map_info,
+%        XPixelInfo *pixel,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -7685,6 +7691,8 @@ static MagickBooleanType XMakePixmap(Display *display,
 %
 %    o pixel: Specifies a pointer to a XPixelInfo structure.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 
 #if defined(__cplusplus) || defined(c_plusplus)
@@ -7740,14 +7748,11 @@ static inline Quantum ScaleXToQuantum(const size_t x,
 
 MagickPrivate void XMakeStandardColormap(Display *display,
   XVisualInfo *visual_info,XResourceInfo *resource_info,Image *image,
-  XStandardColormap *map_info,XPixelInfo *pixel)
+  XStandardColormap *map_info,XPixelInfo *pixel,ExceptionInfo *exception)
 {
   Colormap
     colormap;
 
-  ExceptionInfo
-    *exception;
-
   register ssize_t
     i;
 
@@ -7772,7 +7777,6 @@ MagickPrivate void XMakeStandardColormap(Display *display,
   assert(map_info != (XStandardColormap *) NULL);
   assert(resource_info != (XResourceInfo *) NULL);
   assert(pixel != (XPixelInfo *) NULL);
-  exception=(&image->exception);
   if (resource_info->map_type != (char *) NULL)
     {
       /*
@@ -7797,7 +7801,7 @@ MagickPrivate void XMakeStandardColormap(Display *display,
             /*
               Improve image appearance with error diffusion.
             */
-            affinity_image=AcquireImage((ImageInfo *) NULL,&image->exception);
+            affinity_image=AcquireImage((ImageInfo *) NULL,exception);
             if (affinity_image == (Image *) NULL)
               ThrowXWindowFatalException(ResourceLimitFatalError,
                 "UnableToDitherImage",image->filename);
@@ -7995,9 +7999,9 @@ MagickPrivate void XMakeStandardColormap(Display *display,
               "UnableToCreateColormap",image->filename);
           for (i=0; i < (ssize_t) image->colors; i++)
           {
-            diversity[i].red=image->colormap[i].red;
-            diversity[i].green=image->colormap[i].green;
-            diversity[i].blue=image->colormap[i].blue;
+            diversity[i].red=ClampToQuantum(image->colormap[i].red);
+            diversity[i].green=ClampToQuantum(image->colormap[i].green);
+            diversity[i].blue=ClampToQuantum(image->colormap[i].blue);
             diversity[i].index=(unsigned short) i;
             diversity[i].count=0;
           }
@@ -9724,7 +9728,8 @@ MagickPrivate Window XWindowByProperty(Display *display,const Window window,
 %
 %  The format of the XImportImage method is:
 %
-%      Image *XImportImage(const ImageInfo *image_info,XImportInfo *ximage_info)
+%      Image *XImportImage(const ImageInfo *image_info,XImportInfo *ximage_info,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -9732,9 +9737,11 @@ MagickPrivate Window XWindowByProperty(Display *display,const Window window,
 %
 %    o ximage_info: Specifies a pointer to an XImportInfo structure.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 MagickPrivate Image *XImportImage(const ImageInfo *image_info,
-  XImportInfo *ximage_info)
+  XImportInfo *ximage_info,ExceptionInfo *exception)
 {
   assert(image_info != (const ImageInfo *) NULL);
   assert(image_info->signature == MagickSignature);
@@ -9742,6 +9749,8 @@ MagickPrivate Image *XImportImage(const ImageInfo *image_info,
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
       image_info->filename);
   assert(ximage_info != (XImportInfo *) NULL);
+  assert(exception != (ExceptionInfo *) NULL);
+  assert(exception->signature == MagickSignature);
   return((Image *) NULL);
 }
 #endif