using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Imaging; namespace LabMaster { public partial class gray : Form { public gray() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { bitmapmakegrayscale(pictureBox1.Image );
}
private void bitmapmakegrayscale(Image imagei) { Bitmap image = imagei as Bitmap; Bitmap bp = new Bitmap(image.Width,image .Height ); for (int i = 0; i < image.Width; i++) { for (int j = 0; j < image.Height; j++) { Color orgcol = image.GetPixel(i, j); int grayscale = (int)((orgcol.R * .3)+(orgcol.G * .59)+(orgcol.B * .11)); Color newcol = Color.FromArgb(grayscale, grayscale, grayscale); bp.SetPixel(i, j, newcol); } } pictureBox2.Image = bp; }
} }
|
No responses found. Be the first to respond and make money from revenue sharing program.
|