trouble with antialiasing

From: Date: Fri, 26 Oct 2007 06:50:09 +0000
Subject: trouble with antialiasing
Groups: php.gd.devel 
Request: Send a blank email to php-gd-devel+get-272@lists.php.net to get a copy of this message
Hi, I am having trouble getting even the most basic antialiasing to work. I copied the example right out of the manual and built it in as much isolation as possible, but am still getting a non-antialiased line. My test source file is included below, and I am building it with: gcc -lgd -o gtest gtest.c This is on Fedora Core 6, with gd-2.0.35-1.fc6 and gd-devel-2.0.35-1.fc6. I was able to get it to antialias by both (a) creating the image instead with gdImageCreateTrueColor(), and (b) changing the second 99 to a 49, thus making the line be at less than a 45-degree angle. But these seem arbitrary to me -- I was just thrashing around randomly -- and I don't see why the original code does not work. Am I missing something obvious here? thanks, Eric ================================================== /* * File: gtest.c */ #include <stdio.h> #include <stdlib.h> #include <gd.h> int main(int argc, char *argv[]) { gdImagePtr im, brush; int black; int blue; FILE *fp = NULL; im = gdImageCreate(100, 100); /* Background color (first allocated) */ black = gdImageColorAllocate(im, 0, 0, 0); blue = gdImageColorAllocate(im, 0, 0, 255); gdImageSetAntiAliased(im, blue); /* Draw a smooth line from the upper left corner to the lower right corner. */ gdImageLine(im, 0, 0, 99, 99, gdAntiAliased); /* ... Do something with the image, such as saving it to a file... */ fp = fopen(argv[1], "wb"); gdImagePng(im, fp); fclose(fp); /* Destroy it */ gdImageDestroy(im); exit(0); }

« previous php.gd.devel (#272) next »