Problème d'affichage image (pictureBox noir)

aujeanfr Messages postés 20 Date d'inscription mardi 6 avril 2004 Statut Membre Dernière intervention 28 juillet 2004 - 2 juin 2004 à 14:29
ShareVB Messages postés 2676 Date d'inscription vendredi 28 juin 2002 Statut Membre Dernière intervention 13 janvier 2016 - 4 juin 2004 à 19:56
Je n'arrive pas à afficher mon image contenue dans mon HDC. En fait je n'ai que du noir dans la PictureBox comme résultat.
Voici mon code, merci d'avance si qq'un peut m'aider :

CStatic* hWndViewer = (CStatic*)GetDlgItem(IDC_PICTURE);

photo = (HBITMAP)LoadImage(NULL,nomImag,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
access = (HBITMAP)accessoire->m_hObject;

SelectObject(hdc_photo,photo);
SelectObject(hdc_access,access;

//je superpose les 2 images(sauf le blanc)
for(i=0;i<largeur;i++)
{
for(j=0;j<hauteur;j++)
{
if(GetPixel(hdc_access,i,j) != RGB(255,255,255))
{
color = GetPixel(hdc_access,i,j);
SetPixel(hdc_photo,i,j,color);
}
}
}

hBmp_FinalDC = CreateCompatibleDC(hdc_photo);
hBmpFinal= CreateCompatibleBitmap(hBmp_FinalDC,largeur,hauteur);

BitBlt(hBmp_FinalDC,0,0,largeur,hauteur,hdc_photo,0,0,SRCCOPY);

//maintenant j'affiche dans le picturebox : (résultat noir)
hWndViewer->SetBitmap(hBmpFinal);

DeleteDC(hBmp_FinalDC);
DeleteObject(access);
DeleteObject(photo);
DeleteDC(hdc_access);

3 réponses

ShareVB Messages postés 2676 Date d'inscription vendredi 28 juin 2002 Statut Membre Dernière intervention 13 janvier 2016 26
3 juin 2004 à 21:38
salut

moi je mettrais seulement :

hwndViewer.SetBitmap( (HBITMAP)LoadImage(NULL,nomImag,IMAGE_BITMAP,0,0,LR_LOADFROMFILE));

voilà

ShareVB
0
aujeanfr Messages postés 20 Date d'inscription mardi 6 avril 2004 Statut Membre Dernière intervention 28 juillet 2004
4 juin 2004 à 17:01
Merci ShareVB pour ta reponse mais ça n'est pas cette image que je veux modifier...
C'est l'image "contenue" dans hdc_photo que je souhaite afficher.

C là que je bloque...
0
ShareVB Messages postés 2676 Date d'inscription vendredi 28 juin 2002 Statut Membre Dernière intervention 13 janvier 2016 26
4 juin 2004 à 19:56
salut

dans ce cas, tu mets :
hwndViewer.SetBitmap((HBITMAP)hdc_photo);

ou bien

HDC hdc = GetDC(hwndViewer.m_hWnd);

BitBlt(hdc,...,hdc_photo,...);

ReleaseDC(hdc);

voilà

ShareVB
0