Public Function Get2Value (ByVal Colr As Long) As Long ' Takes a long integer color value, ' returns an equivalent grayscale value ' between 0 and 255 Dim R As Long, G As Long, B As Long ' Break up long color into r, g, b R = Colr Mod 256 Colr = Colr \ 256 G = Colr Mod 256 Colr = Colr \ 256 B = Colr Mod 256 ' Find equivalent grayscale value Get2Value = IIf((77 * R + 150 * G + 28 * B) / 255 > 127, 1, 0) End Function
扩展名倒无所谓,是按二进制写的就可以,再帮你顶一下吧
' Takes a long integer color value,
' returns an equivalent grayscale value
' between 0 and 255
Dim R As Long, G As Long, B As Long
' Break up long color into r, g, b
R = Colr Mod 256
Colr = Colr \ 256
G = Colr Mod 256
Colr = Colr \ 256
B = Colr Mod 256
' Find equivalent grayscale value
Get2Value = IIf((77 * R + 150 * G + 28 * B) / 255 > 127, 1, 0)
End Function