Windowsforms namespace bitirmetezi public partial

Info icon This preview shows pages 52–55. Sign up to view the full content.

View Full Document Right Arrow Icon
System.Windows.Forms; namespace Bitirme_Tezi { public partial class Piksel : UserControl { public Piksel() { InitializeComponent(); } public void Btn_Ac_Click( object sender, EventArgs e) { OpenFileDialog ac = new OpenFileDialog (); ac.Filter = "Resim Türü (*.png, *.jpg) | *.png; *.jpg" ; if (ac.ShowDialog() == DialogResult .OK) { Txt_DosyaYolu.Text = ac.FileName.ToString(); pictureBox1.ImageLocation = Txt_DosyaYolu.Text; Bitmap imgsayisi = new Bitmap (Txt_DosyaYolu.Text); int imgsayisii = imgsayisi.Width * imgsayisi.Height; } } private void Btn_Sifrele_Click( object sender, EventArgs e) { Bitmap img = new Bitmap (Txt_DosyaYolu.Text); for ( int i = 0; i < img.Width; i++) { for ( int j = 0; j < img.Height; j++) { Color pixel = img.GetPixel(i, j); if (i < 1 && j < richTextBox1.TextLength) { char letter = Convert .ToChar(richTextBox1.Text.Substring(j, 1)); int value = Convert .ToInt32(letter); Console .WriteLine( "Letter:" + letter + "value: " + value); string secim = comboBox1.SelectedItem.ToString(); switch (secim) { case "R" : img.SetPixel(i, j, Color .FromArgb(value, pixel.G, pixel.B)); break ; case "G" : img.SetPixel(i, j, Color .FromArgb(pixel.R, value, pixel.B)); break ; case "B" : img.SetPixel(i, j, Color .FromArgb(pixel.R, pixel.G, value)); break ; default : Console .Write( "Değer seçin" ); break ; } } if (i == img.Width - 1 && j == img.Height - 1) { string secim = comboBox1.SelectedItem.ToString(); switch (secim) { case "R" : img.SetPixel(i, j, Color .FromArgb(richTextBox1.TextLength, pixel.G, pixel.B)); break ; case "G" : img.SetPixel(i, j, Color .FromArgb(pixel.R, richTextBox1.TextLength, pixel.B)); break ; case "B" : img.SetPixel(i, j, Color .FromArgb(pixel.R, pixel.G,richTextBox1.TextLength)); break ; } } } } 51
Image of page 52

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
SaveFileDialog saveFile = new SaveFileDialog (); saveFile.Filter = "Resim Türü (*.png,*.jpg) | *.png; *.jpg" ; saveFile.InitialDirectory = Environment .GetFolderPath( Environment . SpecialFolder .Desktop); if (saveFile.ShowDialog() == DialogResult .OK) { Txt_DosyaYolu.Text = saveFile.FileName.ToString(); pictureBox1.ImageLocation = Txt_DosyaYolu.Text; img.Save(Txt_DosyaYolu.Text); } } private void Btn_Coz_Click( object sender, EventArgs e) { Bitmap img = new Bitmap (Txt_DosyaYolu.Text); string mesaj = "" ; Color sonpiksel = img.GetPixel(img.Width - 1, img.Height - 1); string secim = comboBox1.SelectedItem.ToString(); switch (secim) { case "R" : int deger = sonpiksel.R; for ( int i = 0; i < img.Width; i++) { for ( int j = 0; j < img.Height; j++) { Color pixel = img.GetPixel(i, j); if (i < 1 && j < deger) { int value = pixel.R; char c = Convert .ToChar(value); string letter = System.Text. Encoding .ASCII.GetString( new byte [] { Convert .ToByte(c) }); mesaj = mesaj + letter; } } richTextBox1.Text = mesaj; } break ; case "G" : for ( int i = 0; i < img.Width; i++) { for ( int j = 0; j < img.Height; j++) { Color pixel = img.GetPixel(i, j); if (i < 1 && j < sonpiksel.G) { int value = pixel.G; char c = Convert .ToChar(value); string letter = System.Text. Encoding .ASCII.GetString( new byte [] { Convert .ToByte(c) }); mesaj = mesaj + letter; } } richTextBox1.Text = mesaj; } break ; case "B" : for ( int i = 0; i < img.Width; i++) { for ( int j = 0; j < img.Height; j++) { Color pixel = img.GetPixel(i, j); if (i < 1 && j < sonpiksel.B) { int value = pixel.B; char c = Convert .ToChar(value); string letter = System.Text. Encoding .ASCII.GetString( new byte [] { Convert .ToByte(c) }); mesaj = mesaj + letter; } } richTextBox1.Text = mesaj; } break ; } } 52
Image of page 53
EK-2 private void Btn_Ac_Click( object sender, EventArgs e) { OpenFileDialog ac = new OpenFileDialog (); ac.Filter = "Resim Türü (*.png, *.jpg) | *.png; *.jpg" ; if (ac.ShowDialog() ==
Image of page 54

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 55
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern