Bab00n Posted April 5, 2006 Share Posted April 5, 2006 Salut @ tous !! j'ai besoin de convertir une image jpg en bmp dans un programme en C++. je devellope avec Builder 6. j'ai trouver sa : Graphics::TBitmap *bmp = new Graphics::TBItmap(); TJPEGImage *jpg = new TJPEGImage(); jpg->LoadFromFile("Image1.jpg"); bmp->Assign(jpg); bmp->SaveToFile(éImage1.bmpé); delete bmp; delete jpg; mais lors de la compil j'ai une erreur [C++ Error] Unit1.cpp(43): E2316 'TBItmap' is not a member of 'Graphics' J'ai peut etre pas tout les include necessaire ? je suis un debutant en C++ ! dsl !! merci d'avance ! Link to comment Share on other sites More sharing options...
LePhasme Posted April 5, 2006 Share Posted April 5, 2006 Essaie en mettant un i minuscule à TBItmap à la première ligne. Link to comment Share on other sites More sharing options...
Bab00n Posted April 5, 2006 Author Share Posted April 5, 2006 ahhhhhhhh c'est pas vrai ...... c'était sa .... c'est pas possible d'etre aussi con !! j'était habituer a Visual Basic 6 qui transforme les maj en min et les min en maj tout seul ... par sontre maintenent le code ne fonctionne toujour pas j'ai un autre erreur : [C++ Error] Unit1.cpp(54): E2451 Undefined symbol 'TJPEGImage' et pourtant la TJPEGImage est correctement écrit (enfin normalement) .... Link to comment Share on other sites More sharing options...
LePhasme Posted April 6, 2006 Share Posted April 6, 2006 Tu as inclu les bons fichier .h ? Tu link bien avec les bonnes librairies ? Link to comment Share on other sites More sharing options...
tsubasaleguedin Posted April 6, 2006 Share Posted April 6, 2006 utilise libjpeg Pour le linkage sur linux et windows avec gcc tu ajoute -ljpeg Dans l'exemple ci dessous c'est ma fonction qui me sert a lire un Jpeg vers un bitmap RGB que j'exploite comme texture OpenGL (en C). Il y un test qui sera surement inutile pour toi je verifie que la hauteur et largeur font 256. #include <jpeglib.h> #include <jerror.h> unsigned char image[256*256*3]; unsigned char texture[256][256][3]; //Jpeg Loading function void loadJpegImage(char *fichier) { 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(fichier,"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); if ((cinfo.image_width!=256)||(cinfo.image_height!=256)) { fprintf(stdout,"Erreur : l'image doit etre de taille 256x256\n"); exit(1); } if (cinfo.jpeg_color_space==JCS_GRAYSCALE) { fprintf(stdout,"Erreur : l'image doit etre de type RGB\n"); exit(1); } 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); for (i=0;i<256;i++) for (j=0;j<256;j++) { texture[i][j][0]=image[i*256*3+j*3]; texture[i][j][1]=image[i*256*3+j*3+1]; texture[i][j][2]=image[i*256*3+j*3+2]; } } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.