Bitmapinfoheader

Résolu
cs_noel70 Messages postés 40 Date d'inscription samedi 22 mai 2004 Statut Membre Dernière intervention 25 janvier 2007 - 29 janv. 2005 à 15:01
cs_noel70 Messages postés 40 Date d'inscription samedi 22 mai 2004 Statut Membre Dernière intervention 25 janvier 2007 - 29 janv. 2005 à 20:32
Bonjour a tous,
Voila, j'ai fais une petite procedure pour affichier dans un control static une image.

La procedure pour afficher l'image dans un static:


.data


statClass db "STATIC",0




.data?




hInstance HINSTANCE ?


Affiche_Image proc proc hParent:DWORD, X:DWORD,Y:DWORD,ID:DWORD, Chemin:DWORD


LOCAL hStaticBitMap : DWORD


LOCAL hBmp : DWORD


invoke BitmapFromFile, Chemin ; permet de charger une image depuis un chemin de fichier ( image jpg, ;gif et bmp)


mov hBmp, eax ; recuper le handle de l'image


invoke CreateWindowEx,0 ; creer une fenetre static


ADDR statClass,NULL,


WS_CHILD or WS_VISIBLE or SS_LEFT or SS_BITMAP,


X,Y,CW_USEDEFAULT
,CW_USEDEFAULT
,hParent,ID,


hInstance,NULL




mov hStaticBitMap, eax ; recuper le handle de la fenetre static


invoke SendMessage, hStaticBitMap,STM_SETIMAGE,0,hBmp ; affiche l'image charger dans la fenetre static


ret


Affiche_Image endp

Mais maintenant, ce que je voudrais faire, c'est connaitre quelque information sur cette image,
comme sa hauteur et sa largeur.
Je pense que pour faire cela, il faut utiliser BITMAPINFOHEADER, mais je ne sais pas comment on utilise cette structure. si quelqu ' un peut m'aider,
Merci.

4 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
29 janv. 2005 à 18:37
Faut regarder dans MSDN:

typedef struct tagBITMAP {
LONG [ bmType];
LONG [ bmWidth];
LONG [ bmHeight];
LONG [ bmWidthBytes];
WORD [ bmPlanes];
WORD [ bmBitsPixel];
LPVOID [ bmBits];
} BITMAP, *PBITMAP;

dernier param est de GetObject est l'adresse d'une struct BITMAP à remplir, second param est taille de la structure.

ciao...
BruNews, MVP VC++
3
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
29 janv. 2005 à 15:51
en C:
BITMAP bmp;
HBITMAP hbmp;
GetObject(hbmp, sizeof(bmp), &bmp);
cxDib = bmp.bmWidth;
cyDib = bmp.bmHeight;

ciao...
BruNews, MVP VC++
0
cs_noel70 Messages postés 40 Date d'inscription samedi 22 mai 2004 Statut Membre Dernière intervention 25 janvier 2007
29 janv. 2005 à 18:23
Comment fait-on pour traduire ceci en Masm32, j'ai essayer ceci:


invoke GetObject, hBmp, sizeof Nom_Fichier_Ouverture, Nom_Fichier_Ouverture


mov eax, Nom_Fichier_Ouverture.bmWidth

Mais au moment de la compilation, j'ai un message d'erreur, comme quoi bmWidth n est pas defini
Alors peut-etre qu'il faut declarer bmWidth dans une structure, mais je ne sais pas laquelle.
Si on peut m'aider , Merci
0
cs_noel70 Messages postés 40 Date d'inscription samedi 22 mai 2004 Statut Membre Dernière intervention 25 janvier 2007
29 janv. 2005 à 20:32
Ca marche merci, voila ce que j'ai fait :

Dans ma procedure pour creer un controle static et y afficher mon image avec le chemin du fichier, j'ai rajouté a la fin, mov eax, hBmp, ceci pour recuperer apres le handle de l'image

Puis apres mon appel a cette procedure:


mov hBmp, eax ; recupere le handle de l'image


INVOKE GetObject, hBmp, SIZEOF bmih, ADDR bmih ; recupere les information de l'image


mov eax, bmih.bmWidth


invoke dwtoa,eax,ADDR Longueur_WIDTH ; convertit en string


mov eax, bmih.bmHeight


invoke dwtoa, eax, ADDR Largeur_HEIGHT ; convertit en string


invoke SetDlgItemTextA, hWin, IDC_PETIT_COTE, ADDR Largeur_HEIGHT


invoke SetDlgItemTextA, hWin, IDC_GRAND_COTE, ADDR Longueur_WIDTH

et dans la section .data

bmih BITMAP <>
0
Rejoignez-nous