(vb)利用GetBitmapBits,SetBitmapBits加速图像处理
(不知道前面有没有人写过这个,这里主要是最近写程序的一些心得,希望对大家有用.久未写东西,会有一堆的毛病,将就着吧.)
最近发现了两个好东东,SetBitmapBits,GetBitmapBits,能极大的提高某些图像处理的速度.
引用别人的话
"SetBitmapBits:
vb声明: Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
作用: "将来自缓冲区的二进制位复制到一幅位图"
参数: hBitmap Long,位图的句柄
dwCount Long,欲复制的字节数量
lpBits Any,指向一个缓冲区的指针。这个缓冲区包含了为位图正确格式化的位图位
GetBitmapBits:
vb声明: Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
作用: "将来自位图的二进制位复制到一个缓冲区"
参数: hBitmap Long,位图的句柄
dwCount Long,欲复制的字节数。如设为零,表示取得位图中的字节数
lpBits Any,指向容纳位图位的一个缓冲区的指针。注意事先将缓冲区至少初始化成dwCount个字节 "
举一个例子,将图片旋转90度,下面是我写的顺时针旋转90度的函数.
假设目标图像的宽等于源图的长,目标图像的长等于源图的宽,两图颜色值占用的位数相等.
参数: