Package: libgd2-xpm
Version: 2.0.36~rc1~dfsg-3.2
Severity: normal

A gdImageRectangle drawn with y1==y2 ends up with end pieces drawn at
the sides.  The program foo.c shows

    .         .
    ...........
    .         .

where I expected just a horizontal line.  Output to /tmp/x.png, look at
it directly or trust the imagemagick convert to /tmp/x.xpm.

I think the sides should not be drawn when y1==y2, per diff below.

#include <stdio.h>
#include <stdlib.h>
#include <gd.h>

int
main (void)
{
  gdImagePtr im;
  int black, white;
  FILE *fp;

  im = gdImageCreate (20, 10);

  black = gdImageColorAllocate(im, 0, 0, 0);
  white = gdImageColorAllocate(im, 255, 255, 255);

  gdImageFilledRectangle(im, 0,0, 19,9, black);
  gdImageRectangle(im, 5,5, 15,5, white);

  fp = fopen("/tmp/x.png", "wb");
  gdImagePng(im, fp);
  if (fclose(fp) != 0) abort();

  system ("convert  -monochrome /tmp/x.png /tmp/x.xpm && cat /tmp/x.xpm");
  exit(0);
}

--- gd.c.orig	2010-07-08 07:19:58.000000000 +1000
+++ gd.c	2010-07-08 07:21:18.000000000 +1000
@@ -2200,8 +2200,11 @@
 		y2v = y2h - 1;
 		gdImageLine(im, x1h, y1h, x2h, y1h, color);
 		gdImageLine(im, x1h, y2h, x2h, y2h, color);
-		gdImageLine(im, x1v, y1v, x1v, y2v, color);
-		gdImageLine(im, x2v, y1v, x2v, y2v, color);
+                if (y1v <= y2v) {
+                	/* sides, if y1h - y1l > 2 */
+			gdImageLine(im, x1v, y1v, x1v, y2v, color);
+			gdImageLine(im, x2v, y1v, x2v, y2v, color);
+                }
 	}
 }
 



-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.30-1-486
Locale: LANG=en_AU, LC_CTYPE=en_AU (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash

Versions of packages libgd2-xpm depends on:
ii  libc6                   2.11.1-3         Embedded GNU C Library: Shared lib
ii  libfontconfig1          2.8.0-2.1        generic font configuration library
ii  libfreetype6            2.3.11-1         FreeType 2 font engine, shared lib
ii  libjpeg62               6b1-1            The Independent JPEG Group's JPEG 
ii  libpng12-0              1.2.44-1         PNG library - runtime
ii  libx11-6                2:1.3.3-3        X11 client-side library
ii  libxpm4                 1:3.5.8-1        X11 pixmap library
ii  zlib1g                  1:1.2.3.4.dfsg-3 compression library - runtime

libgd2-xpm recommends no packages.

Versions of packages libgd2-xpm suggests:
ii  libgd-tools          2.0.36~rc1~dfsg-3.2 GD command line tools and example 

-- no debconf information

Reply via email to