VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Convert Picture into Grayscale.

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.

Rate 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

Download this snippet    Add to My Saved Code

Convert Picture into Grayscale. Comments

No comments have been posted about Convert Picture into Grayscale.. Why not be the first to post a comment about Convert Picture into Grayscale..

Post your comment

Subject:
Message:
0/1000 characters