Можно ли при использовании StretchBlt вырезать рисунок не из PictureBox'a, а напрямую из *.bmp и сделать при этом прозрачный фон?
З.Ы.Самое главное прозрачный фон никак не могу выбрать чё использовать
'
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc 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 Declare Function StretchBlt Lib "gdi32" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Declare Function TransparentBlt Lib "msimg32.dll" _
(ByVal hdc 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 nSrcWidth As Long, _
ByVal nSrcHeight As Long, _
ByVal crTransparent As Long) As Boolean
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Private Const SRCAND = &H8800C6 ' (DWORD) dest = source AND dest
Private Const SRCINVERT = &H660046 ' (DWORD) dest = source XOR dest
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 PatBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal dwRop As Long) As Long
Dim CDC As Long
Dim Ipicture As IPictureDisp
Dim IpictureWidth As Long
Dim IpictureHeight As Long
Private Sub Form_Load()
Me.Width = 7000
Me.Height = 4000
Picture = LoadPicture("C:\windows\Ïóçûðè.bmp")
End Sub
Private Sub Form_Paint()
Form_resize
End Sub
Private Sub Form_resize()
Me.ScaleMode = vbPixels
CDC = CreateCompatibleDC(Me.hdc)
Set Ipicture = LoadPicture("C:\windows\winnt.bmp")
IpictureWidth = CInt(ScaleY(Ipicture.Width, vbHimetric, vbPixels))
IpictureHeight = CInt(ScaleY(Ipicture.Height, vbHimetric, vbPixels))
DeleteObject SelectObject(CDC, Ipicture)
Call TransparentBlt(Me.hdc, 0, 0, ScaleWidth, ScaleHeight, CDC, 0, 0, IpictureWidth, IpictureHeight, vbBlack)
End Sub
Private Sub Form_Unload(Cancel As Integer)
DeleteDC CDC
End Sub
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Dim CDC As Long
Dim Ipicture As IPictureDisp
Dim IpictureWidth As Long
Dim IpictureHeight As Long
Private Sub Form_Load()
Me.ScaleMode = vbPixels
Me.Width = 3900
Me.Height = 4000
Picture = LoadPicture("C:\windows\Пузыри.bmp")
CDC = CreateCompatibleDC(Me.hdc)
Set Ipicture = LoadPicture("C:\windows\winnt.bmp")
DeleteObject SelectObject(CDC, Ipicture)
IpictureWidth = CInt(ScaleY(Ipicture.Width, vbHimetric, vbPixels))
IpictureHeight = CInt(ScaleY(Ipicture.Height, vbHimetric, vbPixels))
Call TransparentBlt(Me.hdc, 0, 0, ScaleWidth, ScaleHeight, CDC, 0, 0, IpictureWidth, IpictureHeight, vbBlack)
End Sub
Private Sub Form_Unload(Cancel As Integer)
DeleteDC CDC
End Sub
Сейчас этот форум просматривают: Yandex-бот и гости: 201