hvordan gemmes en "Device Context" i en bmp?
Jeg har en form med 2x PictureBox på, jeg vil så gerne have kopieret den ene over på den anden. Dette vil jeg gøre via dette kode.############
Private Declare Function CreateCompatibleDC Lib "GDI32.dll" (ByVal hDC As Long) As Long
Private Declare Function DeleteDC Lib "GDI32.dll" (ByVal hDC As Long) As Long
Private Declare Function SelectObject Lib "GDI32.dll" ( _
ByVal hDC As Long, ByVal hObject As Long) As Long
Private Declare Function BitBlt Lib "GDI32.dll" (ByVal hdcDest As Long, _
ByVal nXDest As Long, ByVal nYDest As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal hdcSrc As Long, ByVal nXSrc As Long, _
ByVal nYSrc As Long, ByVal dwRop As Long) As Long
Private Sub Command1_Click()
'kopier billede
Dim hDC As Long, hOldBmp As Long
hDC = CreateCompatibleDC(0&)
hOldBmp = SelectObject(hDC, Picture1.Picture.Handle)
Call BitBlt(Picture2.hDC, 0, 0, 100, 100, hDC, 0, 0, vbSrcCopy)
Call SelectObject(hDC, hOldBmp)
Call DeleteDC(hDC)
End Sub
Private Sub Command2_Click()
'Test ved at sætte billidet i clipboard
Clipboard.Clear
Clipboard.SetData Picture2.Image
End Sub
###
billidet bliver godt nok kopieret fra picture1 til picture2 på formen, men billedet er ikke tilgængeligt via "Picture2.Image"
dette er kun en test app, i min rigtige app har jeg kun et hDC handle at kopiere fra, derfor bruger jeg "BitBlt()"
dvs. formålet er at kopiere fra hDC til Picture2.Image