by Muhammad Abdullah (2 Submissions)
Category: Graphics
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 7th May 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Convert Picture into Grayscale.
'behind the button.
Private Sub cmdGray_Click()
Pic.ScaleMode = vbPixels
x = Pic.ScaleWidth
y = Pic.ScaleHeight
For i = 0 To y - 1
For j = 0 To x - 1
pixel = Pic.Point(j, i)
red = pixel& Mod 256
green = ((pixel And &HFF00) / 256&) Mod 256&
blue = (pixel And &HFF0000) / 65536
gs = ((red * 30) + (green * 59) + (blue * 11)) / 100
Pic.PSet (j, i), RGB(gs, gs, gs)
Next
Next
Pic.ScaleMode = vbTwips
End Sub