怎么将2个stdpicture合并成一个stdpicture?
有2个图片 tmp.bmp 和 mask.bmp 用paintpicture等可以将他们装进一个picturebox中,并且呈现出透明效果。见下面的代码。
Sub test()
Dim sPic As StdPicture, sMask As StdPicture
''加载2个图片,可以从文件或从ClipBoard获取。这2个图片“互补”组合在一起可以达到“透明”效果
Set sPic = LoadPicture("c:\tmp.bmp")
Set sMask = LoadPicture("c:\mask.bmp")
''Pic1为一个picturebox控件。用下面的方法可以显示透明效果
pic1.PaintPicture sMask, 0, 0, pic1.Width, pic1.Height, 0, 0, pic1.Width, pic1.Height, vbSrcAnd ' &H8800C6
pic1.PaintPicture sPic, 0, 0, pic1.Width, pic1.Height, 0, 0, pic1.Width, pic1.Height, vbSrcPaint ' &HEE0086
''sPic.Render hdc, 0, 0, 0, 0, 0, 0, 0, 0, 0&'''怎么得到StdPicture的hdc?
Dim oPic As StdPicture
Set oPic = pic1.Image ''这里得到的oPic是不透明的!!!
End Sub
Private Declare Function AlphaBlend Lib "msimg32.dll" (ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal BLENDFUNCT As Long) As Long
Private Sub Form_Load()
Picture1.AutoSize = True
Picture1.AutoRedraw = True
Picture2.AutoSize = True
Picture2.AutoRedraw = True
End Sub
Private Sub Command1_Click()
Picture1.Picture = LoadPicture("C:\1.bmp")
Picture2.Picture = LoadPicture("C:\2.bmp")
AlphaBlend Picture1.hdc, 10, 10, 100, 100, Picture2.hdc, 20, 20, 100, 100, &H10000 * 128
Picture1.Refresh
End Sub