How to change an image to grayscale using Visual baisc
SaswatPadhi
7May2009 20:00
Re: grayscale
This should work in vb.net :smile::
Code: vb
PrivateSub btnGo_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnGo.Click Dim bm AsNew Bitmap(picCanvas.Image) Dim X AsInteger Dim Y AsInteger Dim clr AsInteger
For X = 0To bm.Width - 1 For Y = 0To bm.Height - 1 clr = (CInt(bm.GetPixel(X, Y).R) + _ bm.GetPixel(X, Y).G + _ bm.GetPixel(X, Y).B) \ 3 bm.SetPixel(X, Y, Color.FromArgb(clr, clr, clr)) Next Y Next X