HDIB et compagnie

eikonos Messages postés 13 Date d'inscription vendredi 25 avril 2003 Statut Membre Dernière intervention 16 mai 2003 - 29 avril 2003 à 09:22
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 - 29 avril 2003 à 10:58
Comment fonctionne un HDIB
Comment le Créer sous vb6 pour une DLL qui et la suivante

HDIB etReadJpeg (HWND hWnd, const char *fname) ;

Description
Read a DIB from a given lossy Jpeg file.

Parameters
hWnd : a window handle, used as mother window for error
message boxes.

fname : the file to be read.

Returns
A Handle on the DIB if successful, NULL otherwise.

Merci d'avance

1 réponse

Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
29 avril 2003 à 10:58
ok , rien de trop complexe , ca devrai aller.
En fait , ta fonction prend en parametre le handle de la fenetre parent , mais bon , rien de grave, et le nom du fichier a charger.

en retour , tu obtient un hDib , soit un Handle vers un Device Independant Bitmap.
en clair , un pointeur vers une bitmap , independant du materiel ( ecran , OS , imprimante.....)

vu que j'ai pas d'info sur ta fonction , je vais forcer la creation d'un hDib , mais toi , tu le recuperers directement......

pour info , le hDib , est la propriete Handle , recupere des objets image, je me sert de ca, pour faire des blits , a partir ces composants...

Option Explicit

Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDc As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hDc As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hDc As Long, ByVal hObject As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

Private Sub Form_Load()
    Me.show:        DoEvents
    Call ChargerJPEG(Form1.hWnd, Picture1.hDc, "c;\monjpeg.jpg")
End Sub

Public Sub ChargerJPEG(ParentHwnd As Long, DC As Long, File As String)
    Dim hBmp As Long, tmpDC As Long
    tmpDC = CreateCompatibleDC(DC)      ' cree un device compatible avec celui vers lequel on souhaite transferer l'image
    
'    hBmp = ReadJpeg(ParentHwnd, File)              'charger jpeg

'    hBmp = CreateCompatibleBitmap(DC, 255, 255)  ' pour creer un bitmap
    hBmp = Image1.Picture.Handle                           ' utiliser le hdib de image1

    Call SelectObject(tmpDC, hBmp)      ' associe le bitmap au DC
    
    Call BitBlt(DC, 0, 0, 255, 255, tmpDC, 0, 0, vbSrcCopy)     ' effectue un blit (copie) , il faudrait utiliser la  taille , recuperee grace a un getobject......
    
    Call DeleteDC(tmpDC)            ' efface le dc tampon
    Call DeleteObject(hBmp)        ' et le bitmap
End Sub



-----------------------------------------------------------------------
By Renfield

thomas_reynald@msn.com

Aucune touche n'a été bléssée lors de la saisie de ce texte..........
0
Rejoignez-nous