Chargement d'une image en divers langages.
-
#include <jpeglib.h>
-
#include <jerror.h>
-
using namespace std;
-
bool doLoadImage(int parameter) {
-
unsigned char * image = (unsigned char *)malloc(3840*1024*3
-
*sizeof(unsigned char));
-
struct jpeg_decompress_struct cinfo;
-
struct jpeg_error_mgr jerr;
-
FILE *file;
-
unsigned char *ligne;
-
int i, j;
-
-
cinfo.err = jpeg_std_error(&jerr);
-
jpeg_create_decompress(&cinfo);
-
if ((file=fopen("./test.jpg", "rb"))==NULL) {
-
fprintf(stderr, "Erreur : impossible d'ouvrir le fichier texture.jpg\n");
-
exit(1);
-
}
-
jpeg_stdio_src(&cinfo, file);
-
jpeg_read_header(&cinfo, TRUE);
-
-
bool check=cinfo.image_width==3840 || cinfo.image_height==1024;
-
jpeg_start_decompress(&cinfo);
-
-
ligne=image;
-
while (cinfo.output_scanline<cinfo.output_height) {
-
ligne=image+3*256*cinfo.output_scanline;
-
jpeg_read_scanlines(&cinfo, &ligne, 1);
-
}
-
-
jpeg_finish_decompress(&cinfo);
-
jpeg_destroy_decompress(&cinfo);
-
return check;
-
}
Poster un nouveau commentaire