Bitmap imagestream = GrayScale(Img);
public Image GrayScale(Image Img) { Stream imageStream = new MemoryStream(); using (Bitmap bmp = new Bitmap(Img)) { int rgb; Color c; for (int y = 0; y < bmp.Height; y++) for (int x = 0; x < bmp.Width; x++) { c = bmp.GetPixel(x, y); rgb = (int)((c.R + c.G + c.B) / 3); bmp.SetPixel(x, y, Color.FromArgb(rgb, rgb, rgb)); } bmp.Save(imageStream, ImageFormat.Jpeg); } return Image.FromStream(imageStream); } private void button2_Click(object sender, EventArgs e) { Image Img = Image.FromFile("C:\\Users\\L31101\\Desktop\\19.male.happy.normalized.jpg"); Bitmap imagestream = GrayScale(Img); }
Bitmap imagestream = new Bitmap(GrayScale(Img));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)