- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
mDrawMaskImg.bas
资源名称:IE_VB.rar [点击查看]
上传用户:davilee3
上传日期:2015-04-22
资源大小:986k
文件大小:3k
源码类别:
浏览器
开发平台:
Visual Basic
- Attribute VB_Name = "mDrawMaskImg"
- 'mDrawMaskImg: 画透明图片
- 'by lingll
- 'lingll2001@21cn.com
- '2004-9-20
- Option Explicit
- 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 CreateBitmap Lib "gdi32" (ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount As Long, lpBits As Any) As Long
- Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
- Private Declare Function GetObjectBitmap Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
- Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
- Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
- Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
- Private Declare Function CopyImage Lib "user32" (ByVal handle As Long, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
- Private Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
- Private Type BITMAP
- bmType As Long
- bmWidth As Long
- bmHeight As Long
- bmWidthBytes As Long
- bmPlanes As Integer
- bmBitsPixel As Integer
- bmBits As Long
- End Type
- Private Const IMAGE_BITMAP As Long = 0
- Private Const LR_COPYRETURNORG As Long = &H4
- Private Const SRCCOPY As Long = &HCC0020
- Private Const SRCINVERT As Long = &H660046
- Private Const SRCAND As Long = &H8800C6
- '以maskColor做透明色
- Public Function DrawMaskImage(hSrcBmp&, hDcDest&, maskColor&) As Boolean
- Dim tImgBmp&, tImgDc&
- Dim tMskBmp&, tMskDc&
- Dim tBmp As BITMAP
- If GetObjectBitmap(hSrcBmp, Len(tBmp), tBmp) = 0 Then
- DrawMaskImage = False
- Exit Function
- End If
- tImgBmp = CopyImage(hSrcBmp, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG)
- tImgDc = CreateCompatibleDC(hDcDest)
- SelectObject tImgDc, tImgBmp
- SetBkColor tImgDc, maskColor
- tMskBmp = CreateBitmap(tBmp.bmWidth, tBmp.bmHeight, 1, 1, 0)
- tMskDc = CreateCompatibleDC(hDcDest)
- SelectObject tMskDc, tMskBmp
- BitBlt tMskDc, 0, 0, tBmp.bmWidth, tBmp.bmHeight, tImgDc, 0, 0, SRCCOPY
- BitBlt tImgDc, 0, 0, tBmp.bmWidth, tBmp.bmHeight, tMskDc, 0, 0, SRCINVERT
- BitBlt hDcDest, 0, 0, tBmp.bmWidth, tBmp.bmHeight, tMskDc, 0, 0, SRCAND
- BitBlt hDcDest, 0, 0, tBmp.bmWidth, tBmp.bmHeight, tImgDc, 0, 0, SRCINVERT
- DeleteObject tImgBmp
- DeleteDC tImgDc
- DeleteObject tMskBmp
- DeleteDC tMskDc
- DrawMaskImage = True
- End Function