[C++]Chargement d'une image avec GD[résolu]

Bonjour,

J’ai pris un exemple de création d’une image à l’aide de GD.
J’aimerai avoir une aide concernant le chargement d’une image (on lui donne le nom d’une image) pour récupérer les données (les couleurs de chaque pixel) de celles-ci pour les mettre dans un tableau mais je ne sais pas comment m’y prendre.

Merci

[code]/* 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);

}[/code]

[code]
/* Je n'ai pas testé ce code, je l 'ai écrit d irect dans le forum */

int main(int argc, char **argv) 
{
  FILE *f;
  struct pixel_s {
    int red;
    int green;
    int blue;
  } pixel;

  /* Check argc */

  if ( (f = fopen(argv[1], "rb")) == NULL) {
     /* erreur */
  }

  data = malloc(1024*1024*sizeof(struct pixel_s)); /* Image 1024x1024 pixels en RGB */

  /* Avant, il faut virer les entetes PNM, c'est bien documenté. */

  /* Ici faites une boucle jusqu'a feof :) */
  fread(&pixel, sizeof(struct pixel_s), 1, f);
  return 0;
}
[/code]

Bon c'est du C, c'est de la stub, mais en PNM; ya rien de plus simple...

A+
/* Je n'ai pas testé ce code, je l 'ai écrit d irect dans le forum */

int main(int argc, char **argv) 
{
  FILE *f;
  struct pixel_s {
    int red;
    int green;
    int blue;
  } pixel;

  /* Check argc */

  if ( (f = fopen(argv[1], "rb")) == NULL) {
     /* erreur */
  }

  data = malloc(1024*1024*sizeof(struct pixel_s)); /* Image 1024x1024 pixels en RGB */

  /* Avant, il faut virer les entetes PNM, c'est bien documenté. */

  /* Ici faites une boucle jusqu'a feof :) */
  fread(&pixel, sizeof(struct pixel_s), 1, f);
  return 0;
}

Bon c’est du C, c’est de la stub, mais en PNM; ya rien de plus simple…

A+

Merci.
Le problème a été résolu.