Click to See Complete Forum and Search --> : compiling applicaion using libgd.dll


Anon
09-25-2001, 04:27 AM
Hi all,
Has anyone tried compiling application using libgd.dll on windows. I got it compiled. But the application crashes when it tries to execute
gdImageJpeg(im,out, -1);

The source code is given below

#include <gd.h>

/* Bring in standard I/O so we can output the GIF to a file */
#include <stdio.h>

int main() {
/* Declare the image */
gdImagePtr im;
/* Declare an output file */
int black, white;
FILE *out;
/* Create the image */
im = gdImageCreate(100, 100);
/* Allocate background */
white = gdImageColorAllocate(im, 255, 255, 255);
/* Allocate drawing color */
black = gdImageColorAllocate(im, 0, 0, 0);
/* Draw rectangle */
gdImageRectangle(im, 0, 0, 99, 99, black);
/* Open output file in binary mode */
//gdImageRectangle(im, 0, 0, 99, 99, black);

out = fopen("rect.jpg", "wb");
if (out==NULL){
printf("error in writing file\n");
return 0;
}else
printf("%p",out);
/* Write JPEG using default quality */

gdImageJpeg(im,out, -1);
/* Close file */
fclose(out);
/* Destroy image */
gdImageDestroy(im);
return 0;
}