From: Cristy Date: Tue, 22 Mar 2016 17:02:52 +0000 (-0400) Subject: Respect gravity when rendering text (e.g. convert -gravity center my.txt ...) X-Git-Tag: 7.0.1-0~147 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=665f18d11465890bf631aaca2533b629efe75d48;p=imagemagick Respect gravity when rendering text (e.g. convert -gravity center my.txt ...) --- diff --git a/coders/txt.c b/coders/txt.c index 85e6c1a57..3740e9fc7 100644 --- a/coders/txt.c +++ b/coders/txt.c @@ -251,15 +251,15 @@ static Image *ReadTEXTImage(const ImageInfo *image_info,Image *image, (void) SetImageBackgroundColor(image,exception); draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL); (void) CloneString(&draw_info->text,image_info->filename); - (void) FormatLocaleString(geometry,MagickPathExtent,"0x0%+ld%+ld",(long) page.x, - (long) page.y); + (void) FormatLocaleString(geometry,MagickPathExtent,"%lux%lu%+ld%+ld", + image->columns,image->rows,(long) page.x,(long) page.y); (void) CloneString(&draw_info->geometry,geometry); status=GetTypeMetrics(image,draw_info,&metrics,exception); if (status == MagickFalse) ThrowReaderException(TypeError,"UnableToGetTypeMetrics"); page.y=(ssize_t) ceil((double) page.y+metrics.ascent-0.5); - (void) FormatLocaleString(geometry,MagickPathExtent,"0x0%+ld%+ld",(long) page.x, - (long) page.y); + (void) FormatLocaleString(geometry,MagickPathExtent,"%lux%lu%+ld%+ld", + image->columns,image->rows,(long) page.x,(long) page.y); (void) CloneString(&draw_info->geometry,geometry); (void) CopyMagickString(filename,image_info->filename,MagickPathExtent); if (*draw_info->text != '\0') @@ -275,7 +275,8 @@ static Image *ReadTEXTImage(const ImageInfo *image_info,Image *image, offset+=(ssize_t) (metrics.ascent-metrics.descent); if (image->previous == (Image *) NULL) { - status=SetImageProgress(image,LoadImageTag,offset,image->rows); + status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) offset, + image->rows); if (status == MagickFalse) break; } @@ -371,9 +372,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception) *image; long - type, x_offset, - y, y_offset; PixelInfo @@ -393,7 +392,9 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception) *q; ssize_t - count; + count, + type, + y; unsigned long depth, @@ -532,12 +533,18 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception) green+=(range+1)/2.0; blue+=(range+1)/2.0; } - pixel.red=ScaleAnyToQuantum((QuantumAny) (red+0.5),range); - pixel.green=ScaleAnyToQuantum((QuantumAny) (green+0.5),range); - pixel.blue=ScaleAnyToQuantum((QuantumAny) (blue+0.5),range); - pixel.black=ScaleAnyToQuantum((QuantumAny) (black+0.5),range); - pixel.alpha=ScaleAnyToQuantum((QuantumAny) (alpha+0.5),range); - q=GetAuthenticPixels(image,x_offset,y_offset,1,1,exception); + pixel.red=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (red+0.5), + range); + pixel.green=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (green+0.5), + range); + pixel.blue=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (blue+0.5), + range); + pixel.black=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (black+0.5), + range); + pixel.alpha=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (alpha+0.5), + range); + q=GetAuthenticPixels(image,(ssize_t) x_offset,(ssize_t) y_offset,1,1, + exception); if (q == (Quantum *) NULL) continue; SetPixelViaPixelInfo(image,&pixel,q); @@ -728,7 +735,7 @@ static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image, MagickFalse,value); if (LocaleCompare(image_info->magick,"SPARSE-COLOR") != 0) { - ssize_t + size_t depth; depth=compliance == SVGCompliance ? image->depth :