Salut !
Quelqu'un a déjà utilisé la lib GD avec VC++ 6.0 ?
J'ai tenté le code fourni en exemple dans la doc de GD :
/* Bring in gd library functions */
#include "gd.h"
/* Bring in standard I/O so we can output the PNG to a file */
#include <stdio.h>
int main() {
/* Declare the image */
gdImagePtr im;
/* Declare output files */
FILE *pngout, *jpegout;
/* Declare color indexes */
int black;
int white;
/* Allocate the image: 64 pixels across by 64 pixels tall */
im = gdImageCreate(64, 64);
/* Allocate the color black (red, green and blue all minimum).
Since this is the first color in a new image, it will
be the background color. */
black = gdImageColorAllocate(im, 0, 0, 0);
/* Allocate the color white (red, green and blue all maximum). */
white = gdImageColorAllocate(im, 255, 255, 255);
/* Draw a line from the upper left to the lower right,
using white color index. */
gdImageLine(im, 0, 0, 63, 63, white);
/* Open a file for writing. "wb" means "write binary", important
under MSDOS, harmless under Unix. */
pngout = fopen("test.png", "wb");
/* Do the same for a JPEG-format file. */
jpegout = fopen("test.jpg", "wb");
/* Output the image to the disk file in PNG format. */
gdImagePng(im, pngout);
/* Output the same image in JPEG format, using the default
JPEG quality setting. */
gdImageJpeg(im, jpegout, -1);
/* Close the files. */
fclose(pngout);
fclose(jpegout);
/* Destroy the image in memory. */
gdImageDestroy(im);
}
J'ai donc bien ajouté le link vers gd.lib et le chemin pour trouver gd.h, et ça compile.
L'accès à la DLL bgd.dll semble fonctionner mais au moment de l'appel à la fonction gdImagePng ou gdImageJpeg j'ai un plantage "testgd.exe a provoqué une erreur et sera fermé etc..."
Je suis sûr que le problème est situé à ces fonctions puisque j'ai ajouté des fprintf (stdout, "msg") entre chaque appel pour m'en rendre compte. De plus, les deux fichiers sont bien créés sur le disque mais évidemment leur contenu reste vide.
Pourquoi ce problème ? Ai-je oublié des links ou autres choses à ajouter ?
Merci de me répondre !
A+
Stéphane
P.S. : Mon but est d'avoir une image jpeg en entrée, la redimensionner, et enregistrer le thumbnail sur le disque. Si vous connaissez une bonne lib graphique standard qui me permette de faire ça je suis preneur également ! Merci !