Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Bitmap img;
- "Imagen.ImageLocation = openFileDialog1.FileName.ToString();"
- img = new Bitmap(openFileDialog1.FileName.ToString()); // Make a copy of the image in the Bitmap variable
- Then go back to the design form and double click on the second button, this will lead you to the event, and then place the next code:
- // First we declare the variable that will make the strig that will be printed in the textbox
- string texto = "";
- //The we make the cicles to read pixel by pixel and we make the comparation with the withe color.
- for (int i = 0; i < img.Width; i++)
- {
- for (int j = 0; j < img.Height; j++)
- {
- //When we add the value to the string we should invert the
- order because the images are reading from top to bottom
- //and the textBox is write from left to right.
- if (img.GetPixel(j, i).A.ToString() == "255" && img.GetPixel(j,
- i).B.ToString() == "255" && img.GetPixel(j, i).G.ToString() ==
- "255" && img.GetPixel(j, i).R.ToString() == "255")
- {
- texto = texto + "0";
- }
- else
- {
- texto = texto + "1";
- }
- }
- texto = texto + "\r\n"; // this is to make the enter between lines
- }
- //And finally we put the string to the textbox
- txtArreglo.Text = texto;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement