请问关于 StretchBlt 函数
dell9 2003-08-19 02:16:33 当我用StretchBlt 把一个bmp中的内容拉伸到另一个bmp里时, 目标图片c.bmp成了全黑色,请问这是怎么回事?
我的源代码是 (VB)
Dim PIC1 As New StdPicture
Dim PIC2 As New StdPicture
Dim HoldBmp1&
Dim HoldBmp2&
Dim hdc1&, hdcRef1&
Dim hdc2&, hdcRef2&
Private hDesk1&
Private hDesk2&
Dim FName As String
Private Sub Command1_Click()
Dim i As Integer
Set PIC1 = LoadPicture(App.Path & "\B0D51.bmp")
Set PIC2 = LoadPicture(App.Path & "\B0D52.bmp")
HoldBmp1 = SelectObject(hdc1, PIC1.Handle)
HoldBmp2 = SelectObject(hdc2, PIC2.Handle)
'SetBkColor hdc2, RGB(0, 0, 0)
'SetBkMode hdc1, TRANSPARENT
'SetBkMode hdc2, TRANSPARENT
i = StretchBlt(hdc2, 0, 0, 11, 12, hdc1, 0, 0, 16, 16, SRCCOPY)
Debug.Print i
SavePicture PIC2, App.Path & "\c.bmp"
SelectObject hdc1, HoldBmp1
DeleteObject PIC1.Handle
SelectObject hdc2, HoldBmp2
DeleteObject PIC2.Handle
End Sub
Private Sub Form_Load()
hDesk1 = GetDesktopWindow()
hdcRef1 = GetDC(hDesk1)
hdc1 = CreateCompatibleDC(hdcRef1)
ReleaseDC hDesk1, hdcRef1
hDesk2 = GetDesktopWindow()
hdcRef2 = GetDC(hDesk2)
hdc2 = CreateCompatibleDC(hdcRef2)
ReleaseDC hDesk2, hdcRef2
End Sub