求vb程序代码:把彩色位图转换成黑白位图,不用模块

来源:百度知道 编辑:UC知道 时间:2024/05/07 06:45:15
不用modify把加载的图片从彩色的变成黑白的图片···

速度很慢。。。

Dim color, newcolor As Long
Dim red, green, blue As Integer
Dim x, y As Integer
For x = 1 To Picture1.Width
For y = 1 To Picture1.Height
color = Picture1.Point(x, y)
red = color Mod 256
green = color / 256 Mod 256
blue = color / 256 / 256
newcolor = CLng(0.299 * CDbl(red) + 0.585 * CDbl(green) + 0.114 * CDbl(blue))
newcolor = newcolor * 65793
Picture1.PSet (x, y), newcolor
Next
Next