Aller au contenu
View in the app

A better way to browse. Learn more.

Next

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[C++] Conversion d'un JPG en un BMP

Featured Replies

Posté(e)

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 !

Posté(e)
  • Auteur

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) ....

Posté(e)

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];
}
}

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.