最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
任意指定透明色的绘图方法
时间:2022-07-02 11:29:39 编辑:袖梨 来源:一聚教程网
透明位图绘制方法在网上见得很多,多数是采用事先做好一个Mask图,这方法优点是速度快,但就是太麻烦,灵活性差。
任意指定透明色,当然经常也要用到,为此,API提供了一个函数TransparentBlt,可这个函数,非常让人遗憾,VB的API浏览器中不带它是有道理的,因为,它在Win98下有严重内存漏洞,你若有98系统,可试一下:
for i=1 to 20000
TransparentBlt ....
next
同样的图片,在我的XP下16毫秒可完成,但在98下用了14秒,而且,提示系统资源不足,当机了!
下面我写了一个函数就是可以代替TransparentBlt的一种方法,速度当然会慢些,但在任何系统下都可放心使用。
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 Declare Function GetCurrentObject Lib "gdi32" (ByVal hdc As Long, ByVal uObjectType As Long) As Long
Private Declare Function GetObj Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor 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 GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal y As Long) As Long
任意指定透明色,当然经常也要用到,为此,API提供了一个函数TransparentBlt,可这个函数,非常让人遗憾,VB的API浏览器中不带它是有道理的,因为,它在Win98下有严重内存漏洞,你若有98系统,可试一下:
for i=1 to 20000
TransparentBlt ....
next
同样的图片,在我的XP下16毫秒可完成,但在98下用了14秒,而且,提示系统资源不足,当机了!
下面我写了一个函数就是可以代替TransparentBlt的一种方法,速度当然会慢些,但在任何系统下都可放心使用。
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 Declare Function GetCurrentObject Lib "gdi32" (ByVal hdc As Long, ByVal uObjectType As Long) As Long
Private Declare Function GetObj Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor 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 GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal y As Long) As Long
相关文章
- 《无限暖暖》天星之羽获得位置介绍 12-20
- 《流放之路2》重铸台解锁方法介绍 12-20
- 《无限暖暖》瞄准那个亮亮的成就怎么做 12-20
- 《无限暖暖》魔气怪终结者完成方法 12-20
- 《无限暖暖》曙光毛团获得位置介绍 12-20
- 《无限暖暖》日光果获得位置介绍 12-20