]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/draw.c
(no commit message)
[imagemagick] / MagickCore / draw.c
index ee38ad6894b7082218f9e8a5444fcf0d161ab953..135625a7d8d841a1bf873f011c6daf0640368877 100644 (file)
@@ -215,9 +215,9 @@ MagickExport DrawInfo *AcquireDrawInfo(void)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  CloneDrawInfo() makes a copy of the given draw info structure.  If NULL
-%  is specified, a new image info structure is created initialized to
-%  default values.
+%  CloneDrawInfo() makes a copy of the given draw_info structure.  If NULL
+%  is specified, a new draw_info structure is created initialized to
+%  default values, according to the given image_info.
 %
 %  The format of the CloneDrawInfo method is:
 %
@@ -240,9 +240,11 @@ MagickExport DrawInfo *CloneDrawInfo(const ImageInfo *image_info,
   clone_info=(DrawInfo *) AcquireMagickMemory(sizeof(*clone_info));
   if (clone_info == (DrawInfo *) NULL)
     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+
   GetDrawInfo(image_info,clone_info);
   if (draw_info == (DrawInfo *) NULL)
     return(clone_info);
+
   if (clone_info->primitive != (char *) NULL)
     (void) CloneString(&clone_info->primitive,draw_info->primitive);
   if (draw_info->geometry != (char *) NULL)
@@ -1273,7 +1275,8 @@ static void DrawBoundingRectangles(Image *image,const DrawInfo *draw_info,
     coordinates;
 
   clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
-  (void) QueryColorDatabase("#0000",&clone_info->fill,&image->exception);
+  (void) QueryColorCompliance("#0000",AllCompliance,&clone_info->fill,
+    &image->exception);
   resolution.x=DefaultResolution;
   resolution.y=DefaultResolution;
   if (clone_info->density != (char *) NULL)
@@ -1325,10 +1328,10 @@ static void DrawBoundingRectangles(Image *image,const DrawInfo *draw_info,
       for (i=0; i < (ssize_t) polygon_info->number_edges; i++)
       {
         if (polygon_info->edges[i].direction != 0)
-          (void) QueryColorDatabase("red",&clone_info->stroke,
+          (void) QueryColorCompliance("red",AllCompliance,&clone_info->stroke,
             &image->exception);
         else
-          (void) QueryColorDatabase("green",&clone_info->stroke,
+          (void) QueryColorCompliance("green",AllCompliance,&clone_info->stroke,
             &image->exception);
         start.x=(double) (polygon_info->edges[i].bounds.x1-mid);
         start.y=(double) (polygon_info->edges[i].bounds.y1-mid);
@@ -1342,7 +1345,8 @@ static void DrawBoundingRectangles(Image *image,const DrawInfo *draw_info,
         (void) DrawPrimitive(image,clone_info,primitive_info);
       }
     }
-  (void) QueryColorDatabase("blue",&clone_info->stroke,&image->exception);
+  (void) QueryColorCompliance("blue",AllCompliance,&clone_info->stroke,
+    &image->exception);
   start.x=(double) (bounds.x1-mid);
   start.y=(double) (bounds.y1-mid);
   end.x=(double) (bounds.x2+mid);
@@ -1421,8 +1425,8 @@ MagickExport MagickBooleanType DrawClipPath(Image *image,
       (void) SetImageClipMask(image,clip_mask,exception);
       clip_mask=DestroyImage(clip_mask);
     }
-  (void) QueryColorDatabase("#00000000",&image->clip_mask->background_color,
-    &image->exception);
+  (void) QueryColorCompliance("#00000000",AllCompliance,
+    &image->clip_mask->background_color,&image->exception);
   image->clip_mask->background_color.alpha=(Quantum) TransparentAlpha;
   (void) SetImageBackgroundColor(image->clip_mask);
   if (image->debug != MagickFalse)
@@ -1430,7 +1434,8 @@ MagickExport MagickBooleanType DrawClipPath(Image *image,
       draw_info->clip_mask);
   clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
   (void) CloneString(&clone_info->primitive,value);
-  (void) QueryColorDatabase("#ffffff",&clone_info->fill,&image->exception);
+  (void) QueryColorCompliance("#ffffff",AllCompliance,&clone_info->fill,
+    &image->exception);
   clone_info->clip_mask=(char *) NULL;
   status=DrawImage(image->clip_mask,clone_info,exception);
   status|=NegateImage(image->clip_mask,MagickFalse,&image->exception);
@@ -1782,7 +1787,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
       graphic_context[n]->viewbox.height=image->rows;
     }
   token=AcquireString(primitive);
-  (void) QueryColorDatabase("#000000",&start_color,&image->exception);
+  (void) QueryColorCompliance("#000000",AllCompliance,&start_color,
+    &image->exception);
   if (SetImageStorageClass(image,DirectClass,&image->exception) == MagickFalse)
     return(MagickFalse);
   status=MagickTrue;
@@ -1859,8 +1865,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
         if (LocaleCompare("border-color",keyword) == 0)
           {
             GetMagickToken(q,&q,token);
-            (void) QueryColorDatabase(token,&graphic_context[n]->border_color,
-              &image->exception);
+            (void) QueryColorCompliance(token,AllCompliance,
+              &graphic_context[n]->border_color,&image->exception);
             break;
           }
         status=MagickFalse;
@@ -1889,11 +1895,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
             fill_rule=ParseCommandOption(MagickFillRuleOptions,MagickFalse,
               token);
             if (fill_rule == -1)
-              {
-                status=MagickFalse;
-                break;
-              }
-            graphic_context[n]->fill_rule=(FillRule) fill_rule;
+              status=MagickFalse;
+            else
+              graphic_context[n]->fill_rule=(FillRule) fill_rule;
             break;
           }
         if (LocaleCompare("clip-units",keyword) == 0)
@@ -1946,11 +1950,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
             decorate=ParseCommandOption(MagickDecorateOptions,MagickFalse,
               token);
             if (decorate == -1)
-              {
-                status=MagickFalse;
-                break;
-              }
-            graphic_context[n]->decorate=(DecorationType) decorate;
+              status=MagickFalse;
+            else
+              graphic_context[n]->decorate=(DecorationType) decorate;
             break;
           }
         status=MagickFalse;
@@ -1985,8 +1987,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
                 &graphic_context[n]->fill_pattern,exception);
             else
               {
-                status=QueryColorDatabase(token,&graphic_context[n]->fill,
-                  &image->exception);
+                status=QueryColorCompliance(token,AllCompliance,
+                  &graphic_context[n]->fill,&image->exception);
                 if (status == MagickFalse)
                   {
                     ImageInfo
@@ -2007,9 +2009,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
           {
             GetMagickToken(q,&q,token);
             factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
-            graphic_context[n]->fill.alpha=ClampToQuantum((MagickRealType)
-              QuantumRange*factor*InterpretLocaleValue(token,
-              (char **) NULL));
+            graphic_context[n]->fill.alpha=(MagickRealType) QuantumRange*
+              factor*InterpretLocaleValue(token,(char **) NULL);
             break;
           }
         if (LocaleCompare("fill-rule",keyword) == 0)
@@ -2021,11 +2022,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
             fill_rule=ParseCommandOption(MagickFillRuleOptions,MagickFalse,
               token);
             if (fill_rule == -1)
-              {
-                status=MagickFalse;
-                break;
-              }
-            graphic_context[n]->fill_rule=(FillRule) fill_rule;
+              status=MagickFalse;
+            else
+              graphic_context[n]->fill_rule=(FillRule) fill_rule;
             break;
           }
         if (LocaleCompare("font",keyword) == 0)
@@ -2058,11 +2057,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
             GetMagickToken(q,&q,token);
             stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,token);
             if (stretch == -1)
-              {
-                status=MagickFalse;
-                break;
-              }
-            graphic_context[n]->stretch=(StretchType) stretch;
+              status=MagickFalse;
+            else
+              graphic_context[n]->stretch=(StretchType) stretch;
             break;
           }
         if (LocaleCompare("font-style",keyword) == 0)
@@ -2073,11 +2070,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
             GetMagickToken(q,&q,token);
             style=ParseCommandOption(MagickStyleOptions,MagickFalse,token);
             if (style == -1)
-              {
-                status=MagickFalse;
-                break;
-              }
-            graphic_context[n]->style=(StyleType) style;
+              status=MagickFalse;
+            else
+              graphic_context[n]->style=(StyleType) style;
             break;
           }
         if (LocaleCompare("font-weight",keyword) == 0)
@@ -2117,11 +2112,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
             GetMagickToken(q,&q,token);
             gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,token);
             if (gravity == -1)
-              {
-                status=MagickFalse;
-                break;
-              }
-            graphic_context[n]->gravity=(GravityType) gravity;
+              status=MagickFalse;
+            else
+              graphic_context[n]->gravity=(GravityType) gravity;
             break;
           }
         status=MagickFalse;
@@ -2139,11 +2132,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
             GetMagickToken(q,&q,token);
             compose=ParseCommandOption(MagickComposeOptions,MagickFalse,token);
             if (compose == -1)
-              {
-                status=MagickFalse;
-                break;
-              }
-            graphic_context[n]->compose=(CompositeOperator) compose;
+              status=MagickFalse;
+            else
+              graphic_context[n]->compose=(CompositeOperator) compose;
             break;
           }
         if (LocaleCompare("interline-spacing",keyword) == 0)
@@ -2180,22 +2171,18 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
       case 'L':
       {
         if (LocaleCompare("line",keyword) == 0)
-          {
-            primitive_type=LinePrimitive;
-            break;
-          }
-        status=MagickFalse;
+          primitive_type=LinePrimitive;
+        else
+          status=MagickFalse;
         break;
       }
       case 'm':
       case 'M':
       {
         if (LocaleCompare("matte",keyword) == 0)
-          {
-            primitive_type=MattePrimitive;
-            break;
-          }
-        status=MagickFalse;
+          primitive_type=MattePrimitive;
+        else
+          status=MagickFalse;
         break;
       }
       case 'o':
@@ -2213,8 +2200,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
             graphic_context[n]->alpha=ClampToQuantum((MagickRealType)
               QuantumRange*(1.0-((1.0-QuantumScale*graphic_context[n]->alpha)*
               factor*InterpretLocaleValue(token,(char **) NULL))));
-            graphic_context[n]->fill.alpha=graphic_context[n]->alpha;
-            graphic_context[n]->stroke.alpha=graphic_context[n]->alpha;
+            graphic_context[n]->fill.alpha=(double) graphic_context[n]->alpha;
+            graphic_context[n]->stroke.alpha=(double) graphic_context[n]->alpha;
             break;
           }
         status=MagickFalse;
@@ -2498,7 +2485,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
               stop_color;
 
             GetMagickToken(q,&q,token);
-            (void) QueryColorDatabase(token,&stop_color,&image->exception);
+            (void) QueryColorCompliance(token,AllCompliance,&stop_color,
+              &image->exception);
             (void) GradientImage(image,LinearGradient,ReflectSpread,
               &start_color,&stop_color,&image->exception);
             start_color=stop_color;
@@ -2514,8 +2502,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
                 &graphic_context[n]->stroke_pattern,exception);
             else
               {
-                status=QueryColorDatabase(token,&graphic_context[n]->stroke,
-                  &image->exception);
+                status=QueryColorCompliance(token,AllCompliance,
+                  &graphic_context[n]->stroke,&image->exception);
                 if (status == MagickFalse)
                   {
                     ImageInfo
@@ -2602,11 +2590,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
             GetMagickToken(q,&q,token);
             linecap=ParseCommandOption(MagickLineCapOptions,MagickFalse,token);
             if (linecap == -1)
-              {
-                status=MagickFalse;
-                break;
-              }
-            graphic_context[n]->linecap=(LineCap) linecap;
+              status=MagickFalse;
+            else
+              graphic_context[n]->linecap=(LineCap) linecap;
             break;
           }
         if (LocaleCompare("stroke-linejoin",keyword) == 0)
@@ -2617,11 +2603,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
             GetMagickToken(q,&q,token);
             linejoin=ParseCommandOption(MagickLineJoinOptions,MagickFalse,token);
             if (linejoin == -1)
-              {
-                status=MagickFalse;
-                break;
-              }
-            graphic_context[n]->linejoin=(LineJoin) linejoin;
+              status=MagickFalse;
+            else
+              graphic_context[n]->linejoin=(LineJoin) linejoin;
             break;
           }
         if (LocaleCompare("stroke-miterlimit",keyword) == 0)
@@ -2634,9 +2618,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
           {
             GetMagickToken(q,&q,token);
             factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
-            graphic_context[n]->stroke.alpha=ClampToQuantum((MagickRealType)
-              QuantumRange*factor*InterpretLocaleValue(token,
-              (char **) NULL));
+            graphic_context[n]->stroke.alpha=(MagickRealType) QuantumRange*
+              factor*InterpretLocaleValue(token,(char **) NULL);
             break;
           }
         if (LocaleCompare("stroke-width",keyword) == 0)
@@ -2665,11 +2648,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
             GetMagickToken(q,&q,token);
             align=ParseCommandOption(MagickAlignOptions,MagickFalse,token);
             if (align == -1)
-              {
-                status=MagickFalse;
-                break;
-              }
-            graphic_context[n]->align=(AlignType) align;
+              status=MagickFalse;
+            else
+              graphic_context[n]->align=(AlignType) align;
             break;
           }
         if (LocaleCompare("text-anchor",keyword) == 0)
@@ -2680,11 +2661,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
             GetMagickToken(q,&q,token);
             align=ParseCommandOption(MagickAlignOptions,MagickFalse,token);
             if (align == -1)
-              {
-                status=MagickFalse;
-                break;
-              }
-            graphic_context[n]->align=(AlignType) align;
+              status=MagickFalse;
+            else
+              graphic_context[n]->align=(AlignType) align;
             break;
           }
         if (LocaleCompare("text-antialias",keyword) == 0)
@@ -2697,8 +2676,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
         if (LocaleCompare("text-undercolor",keyword) == 0)
           {
             GetMagickToken(q,&q,token);
-            (void) QueryColorDatabase(token,&graphic_context[n]->undercolor,
-              &image->exception);
+            (void) QueryColorCompliance(token,AllCompliance,
+              &graphic_context[n]->undercolor,&image->exception);
             break;
           }
         if (LocaleCompare("translate",keyword) == 0)
@@ -3042,11 +3021,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
         GetMagickToken(q,&q,token);
         method=ParseCommandOption(MagickMethodOptions,MagickFalse,token);
         if (method == -1)
-          {
-            status=MagickFalse;
-            break;
-          }
-        primitive_info[j].method=(PaintMethod) method;
+          status=MagickFalse;
+        else
+          primitive_info[j].method=(PaintMethod) method;
         break;
       }
       case TextPrimitive:
@@ -3163,7 +3140,7 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
 %
 %    o image: the image.
 %
-%    o _info: the draw info.
+%    o draw_info: the draw info.
 %
 */
 
@@ -3523,10 +3500,10 @@ MagickExport MagickBooleanType DrawPatternPath(Image *image,
     *pattern=DestroyImage(*pattern);
   image_info=AcquireImageInfo();
   image_info->size=AcquireString(geometry);
-  *pattern=AcquireImage(image_info);
+  *pattern=AcquireImage(image_info,&image->exception);
   image_info=DestroyImageInfo(image_info);
-  (void) QueryColorDatabase("#00000000",&(*pattern)->background_color,
-    &image->exception);
+  (void) QueryColorCompliance("#00000000",AllCompliance,
+    &(*pattern)->background_color,&image->exception);
   (void) SetImageBackgroundColor(*pattern);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(DrawEvent,GetMagickModule(),
@@ -3911,7 +3888,7 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
           if ((x == (ssize_t) ceil(primitive_info->point.x-0.5)) &&
               (y == (ssize_t) ceil(primitive_info->point.y-0.5)))
             {
-              (void) GetStrokeColor(draw_info,x,y,&pixel);
+              (void) GetStrokeColor(draw_info,x,y,&pixel,exception);
               SetPixelPacket(image,&pixel,q);
             }
           q+=GetPixelChannels(image);
@@ -3975,11 +3952,11 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
           fill_opacity=fill_opacity > 0.25 ? 1.0 : 0.0;
           stroke_opacity=stroke_opacity > 0.25 ? 1.0 : 0.0;
         }
-      (void) GetFillColor(draw_info,x,y,&fill_color);
+      (void) GetFillColor(draw_info,x,y,&fill_color,exception);
       fill_opacity=fill_opacity*fill_color.alpha;
       CompositePixelOver(image,&fill_color,fill_opacity,q,(MagickRealType)
         GetPixelAlpha(image,q),q);
-      (void) GetStrokeColor(draw_info,x,y,&stroke_color);
+      (void) GetStrokeColor(draw_info,x,y,&stroke_color,exception);
       stroke_opacity=stroke_opacity*stroke_color.alpha;
       CompositePixelOver(image,&stroke_color,stroke_opacity,q,(MagickRealType)
         GetPixelAlpha(image,q),q);
@@ -4175,7 +4152,7 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
       q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
       if (q == (Quantum *) NULL)
         break;
-      (void) GetFillColor(draw_info,x,y,&fill_color);
+      (void) GetFillColor(draw_info,x,y,&fill_color,exception);
       CompositePixelOver(image,&fill_color,(MagickRealType) fill_color.alpha,q,
         (MagickRealType) GetPixelAlpha(image,q),q);
       (void) SyncCacheViewAuthenticPixels(image_view,exception);
@@ -4197,7 +4174,7 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
           q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
           if (q == (Quantum *) NULL)
             break;
-          (void) GetFillColor(draw_info,x,y,&pixel);
+          (void) GetFillColor(draw_info,x,y,&pixel,exception);
           SetPixelPacket(image,&pixel,q);
           (void) SyncCacheViewAuthenticPixels(image_view,exception);
           break;
@@ -4211,7 +4188,15 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
             pixel,
             target;
 
-          (void) GetOneCacheViewVirtualPixel(image_view,x,y,&target,exception);
+          Quantum
+            virtual_pixel[MaxPixelChannels];
+
+          (void) GetOneCacheViewVirtualPixel(image_view,x,y,virtual_pixel,
+            exception);
+          target.red=(double) virtual_pixel[RedPixelChannel];
+          target.green=(double) virtual_pixel[GreenPixelChannel];
+          target.blue=(double) virtual_pixel[BluePixelChannel];
+          target.alpha=(double) virtual_pixel[AlphaPixelChannel];
           for (y=0; y < (ssize_t) image->rows; y++)
           {
             register Quantum
@@ -4223,13 +4208,13 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
               break;
             for (x=0; x < (ssize_t) image->columns; x++)
             {
-              GetPixelPacket(image,q,&pixel);
+              GetPixelPacketPixel(image,q,&pixel);
               if (IsFuzzyEquivalencePixelPacket(image,&pixel,&target) == MagickFalse)
                 {
                   q+=GetPixelChannels(image);
                   continue;
                 }
-              (void) GetFillColor(draw_info,x,y,&pixel);
+              (void) GetFillColor(draw_info,x,y,&pixel,exception);
               SetPixelPacket(image,&pixel,q);
               q+=GetPixelChannels(image);
             }
@@ -4279,7 +4264,7 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
               break;
             for (x=0; x < (ssize_t) image->columns; x++)
             {
-              (void) GetFillColor(draw_info,x,y,&pixel);
+              (void) GetFillColor(draw_info,x,y,&pixel,exception);
               SetPixelPacket(image,&pixel,q);
               q+=GetPixelChannels(image);
             }
@@ -4310,8 +4295,8 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
           q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
           if (q == (Quantum *) NULL)
             break;
-          (void) GetFillColor(draw_info,x,y,&pixel);
-          SetPixelAlpha(image,pixel.alpha,q);
+          (void) GetFillColor(draw_info,x,y,&pixel,exception);
+          SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
           (void) SyncCacheViewAuthenticPixels(image_view,exception);
           break;
         }
@@ -4324,7 +4309,15 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
             pixel,
             target;
 
-          (void) GetOneCacheViewVirtualPixel(image_view,x,y,&target,exception);
+          Quantum
+            virtual_pixel[MaxPixelChannels];
+
+          (void) GetOneCacheViewVirtualPixel(image_view,x,y,virtual_pixel,
+            exception);
+          target.red=(double) virtual_pixel[RedPixelChannel];
+          target.green=(double) virtual_pixel[GreenPixelChannel];
+          target.blue=(double) virtual_pixel[BluePixelChannel];
+          target.alpha=(double) virtual_pixel[AlphaPixelChannel];
           for (y=0; y < (ssize_t) image->rows; y++)
           {
             register Quantum
@@ -4339,14 +4332,14 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
               break;
             for (x=0; x < (ssize_t) image->columns; x++)
             {
-              GetPixelPacket(image,q,&pixel);
+              GetPixelPacketPixel(image,q,&pixel);
               if (IsFuzzyEquivalencePixelPacket(image,&pixel,&target) == MagickFalse)
                 {
                   q+=GetPixelChannels(image);
                   continue;
                 }
-              (void) GetFillColor(draw_info,x,y,&pixel);
-              SetPixelAlpha(image,pixel.alpha,q);
+              (void) GetFillColor(draw_info,x,y,&pixel,exception);
+              SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
               q+=GetPixelChannels(image);
             }
             sync=SyncCacheViewAuthenticPixels(image_view,exception);
@@ -4400,8 +4393,8 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
               break;
             for (x=0; x < (ssize_t) image->columns; x++)
             {
-              (void) GetFillColor(draw_info,x,y,&pixel);
-              SetPixelAlpha(image,pixel.alpha,q);
+              (void) GetFillColor(draw_info,x,y,&pixel,exception);
+              SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
               q+=GetPixelChannels(image);
             }
             sync=SyncCacheViewAuthenticPixels(image_view,exception);
@@ -4490,7 +4483,7 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
         (void) SetImageAlphaChannel(composite_image,OpaqueAlphaChannel,
           exception);
       if (draw_info->alpha != OpaqueAlpha)
-        (void) SetImageOpacity(composite_image,draw_info->alpha);
+        (void) SetImageAlpha(composite_image,draw_info->alpha);
       SetGeometry(image,&geometry);
       image->gravity=draw_info->gravity;
       geometry.x=x;
@@ -4725,7 +4718,7 @@ MagickExport void GetAffineMatrix(AffineMatrix *affine_matrix)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GetDrawInfo() initializes draw_info to default values.
+%  GetDrawInfo() initializes draw_info to default values from image_info.
 %
 %  The format of the GetDrawInfo method is:
 %
@@ -4746,21 +4739,18 @@ MagickExport void GetDrawInfo(const ImageInfo *image_info,DrawInfo *draw_info)
   ExceptionInfo
     *exception;
 
-  ImageInfo
-    *clone_info;
-
   /*
     Initialize draw attributes.
   */
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
   assert(draw_info != (DrawInfo *) NULL);
   (void) ResetMagickMemory(draw_info,0,sizeof(*draw_info));
-  clone_info=CloneImageInfo(image_info);
   GetAffineMatrix(&draw_info->affine);
   exception=AcquireExceptionInfo();
-  (void) QueryColorDatabase("#000F",&draw_info->fill,exception);
-  (void) QueryColorDatabase("#FFF0",&draw_info->stroke,exception);
-  draw_info->stroke_antialias=clone_info->antialias;
+  (void) QueryColorCompliance("#000F",AllCompliance,&draw_info->fill,
+    exception);
+  (void) QueryColorCompliance("#FFF0",AllCompliance,&draw_info->stroke,
+    exception);
   draw_info->stroke_width=1.0;
   draw_info->alpha=OpaqueAlpha;
   draw_info->fill_rule=EvenOddRule;
@@ -4768,57 +4758,65 @@ MagickExport void GetDrawInfo(const ImageInfo *image_info,DrawInfo *draw_info)
   draw_info->linejoin=MiterJoin;
   draw_info->miterlimit=10;
   draw_info->decorate=NoDecoration;
-  if (clone_info->font != (char *) NULL)
-    draw_info->font=AcquireString(clone_info->font);
-  if (clone_info->density != (char *) NULL)
-    draw_info->density=AcquireString(clone_info->density);
-  draw_info->text_antialias=clone_info->antialias;
   draw_info->pointsize=12.0;
-  if (clone_info->pointsize != 0.0)
-    draw_info->pointsize=clone_info->pointsize;
   draw_info->undercolor.alpha=(Quantum) TransparentAlpha;
-  draw_info->border_color=clone_info->border_color;
   draw_info->compose=OverCompositeOp;
-  if (clone_info->server_name != (char *) NULL)
-    draw_info->server_name=AcquireString(clone_info->server_name);
   draw_info->render=MagickTrue;
   draw_info->debug=IsEventLogging();
-  option=GetImageOption(clone_info,"encoding");
-  if (option != (const char *) NULL)
-    (void) CloneString(&draw_info->encoding,option);
-  option=GetImageOption(clone_info,"kerning");
-  if (option != (const char *) NULL)
-    draw_info->kerning=InterpretLocaleValue(option,(char **) NULL);
-  option=GetImageOption(clone_info,"interline-spacing");
-  if (option != (const char *) NULL)
-    draw_info->interline_spacing=InterpretLocaleValue(option,(char **) NULL);
-  draw_info->direction=UndefinedDirection;
-  option=GetImageOption(clone_info,"interword-spacing");
-  if (option != (const char *) NULL)
-    draw_info->interword_spacing=InterpretLocaleValue(option,(char **) NULL);
-  option=GetImageOption(clone_info,"direction");
-  if (option != (const char *) NULL)
-    draw_info->direction=(DirectionType) ParseCommandOption(
-      MagickDirectionOptions,MagickFalse,option);
-  option=GetImageOption(clone_info,"fill");
-  if (option != (const char *) NULL)
-    (void) QueryColorDatabase(option,&draw_info->fill,exception);
-  option=GetImageOption(clone_info,"stroke");
-  if (option != (const char *) NULL)
-    (void) QueryColorDatabase(option,&draw_info->stroke,exception);
-  option=GetImageOption(clone_info,"strokewidth");
-  if (option != (const char *) NULL)
-    draw_info->stroke_width=InterpretLocaleValue(option,(char **) NULL);
-  option=GetImageOption(clone_info,"undercolor");
-  if (option != (const char *) NULL)
-    (void) QueryColorDatabase(option,&draw_info->undercolor,exception);
-  option=GetImageOption(clone_info,"gravity");
-  if (option != (const char *) NULL)
-    draw_info->gravity=(GravityType) ParseCommandOption(MagickGravityOptions,
-      MagickFalse,option);
+  if (image_info != (ImageInfo *) NULL)
+    {
+      draw_info->stroke_antialias=image_info->antialias;
+      if (image_info->font != (char *) NULL)
+        draw_info->font=AcquireString(image_info->font);
+      if (image_info->density != (char *) NULL)
+        draw_info->density=AcquireString(image_info->density);
+      draw_info->text_antialias=image_info->antialias;
+      if (image_info->pointsize != 0.0)
+        draw_info->pointsize=image_info->pointsize;
+      draw_info->border_color=image_info->border_color;
+      if (image_info->server_name != (char *) NULL)
+        draw_info->server_name=AcquireString(image_info->server_name);
+      option=GetImageOption(image_info,"encoding");
+      if (option != (const char *) NULL)
+        (void) CloneString(&draw_info->encoding,option);
+      option=GetImageOption(image_info,"kerning");
+      if (option != (const char *) NULL)
+        draw_info->kerning=InterpretLocaleValue(option,(char **) NULL);
+      option=GetImageOption(image_info,"interline-spacing");
+      if (option != (const char *) NULL)
+        draw_info->interline_spacing=InterpretLocaleValue(option,
+          (char **) NULL);
+      draw_info->direction=UndefinedDirection;
+      option=GetImageOption(image_info,"interword-spacing");
+      if (option != (const char *) NULL)
+        draw_info->interword_spacing=InterpretLocaleValue(option,
+          (char **) NULL);
+      option=GetImageOption(image_info,"direction");
+      if (option != (const char *) NULL)
+        draw_info->direction=(DirectionType) ParseCommandOption(
+          MagickDirectionOptions,MagickFalse,option);
+      option=GetImageOption(image_info,"fill");
+      if (option != (const char *) NULL)
+        (void) QueryColorCompliance(option,AllCompliance,&draw_info->fill,
+          exception);
+      option=GetImageOption(image_info,"stroke");
+      if (option != (const char *) NULL)
+        (void) QueryColorCompliance(option,AllCompliance,&draw_info->stroke,
+          exception);
+      option=GetImageOption(image_info,"strokewidth");
+      if (option != (const char *) NULL)
+        draw_info->stroke_width=InterpretLocaleValue(option,(char **) NULL);
+      option=GetImageOption(image_info,"undercolor");
+      if (option != (const char *) NULL)
+        (void) QueryColorCompliance(option,AllCompliance,&draw_info->undercolor,
+          exception);
+      option=GetImageOption(image_info,"gravity");
+      if (option != (const char *) NULL)
+        draw_info->gravity=(GravityType) ParseCommandOption(
+          MagickGravityOptions,MagickFalse,option);
+    }
   exception=DestroyExceptionInfo(exception);
   draw_info->signature=MagickSignature;
-  clone_info=DestroyImageInfo(clone_info);
 }
 \f
 /*