1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
//Création du handle sur le bitmap
HBITMAP hBitmap = (HBITMAP)LoadImage(AfxGetInstanceHandle(), "Z:\\image.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
// Création d'un DC par rapport au contexte courant
HDC hDCBmp = CreateCompatibleDC(NULL);
// Selection du Bitmap dans le contexte crée
HBITMAP hOldBmp = (HBITMAP)SelectObject(hDCBmp, hBitmap);
// récupération des Infos bitmap
BITMAP bmpInfo;
GetObject(hOldBmp, sizeof(bmpInfo), &bmpInfo);
// Structure pour le redimensionnement
CSize Size(bmpInfo.bmWidth /2 , bmpInfo.bmHeight /2);
// Redimensionnement de l'image dans le contexte
StretchBlt(hDCBmp,0, 0, Size.cx,Size.cy, hDCBmp, 0, 0,bmpInfo.bmWidth, bmpInfo.bmHeight,SRCCOPY);
// Séléction de l'image redimensionnée dans le contexte
SelectObject(hDCBmp, hOldBmp);
//Affichage
m_imgz.SetBitmap(hOldBmp);
m_imgz.Invalidate();
//Déstruction du contexte
DeleteDC(hDCBmp); |
Partager