private void button2_Click(object sender, EventArgs e) { chart1.Height = panel2.Height; dataGridView1.Height = 25 * firstBitmap.Height; chart1.Location = new Point(chart1.Location.X, dataGridView1.Height + 20); for (int i = 0; i < firstBitmap.Width; i++) { DataGridViewRow row2 = dataGridView1.Rows[i]; dataGridView1.Columns[i].Width = 50; } dataGridView1.ScrollBars = ScrollBars.None; var res = BitmapHandler.GetCalculateEwclidDistance(bitmapHandler.GetBinaryArrayFromBitmap(firstBitmap), firstBitmap); int k = 0; for (int i = 0; i < firstBitmap.Width; i++) { for (int j = 0; j < firstBitmap.Height; j++) { dataGridView1[j, i].Value = res[k]; k++; } } chart1.Series[0].Points.Clear(); secondBitMap = CreateGrayscaleBitmap(secondBitMap); pictureBox2.Show(); pictureBox2.Image = secondBitMap; pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox2.Location = new Point(pictureBox1.Location.X, pictureBox1.Height + 15); pictureBox2.Width = secondBitMap.Width + 120; pictureBox2.Height = secondBitMap.Height + 120; }
private void button1_Click(object sender, EventArgs e) { try { openFileDialog1 = new OpenFileDialog { InitialDirectory = @"C:\", Title = "Browse Text Files", CheckFileExists = true, CheckPathExists = true, DefaultExt = "bmp", Filter = "bmp files (*.bmp)|*.bmp", FilterIndex = 2, RestoreDirectory = true, ReadOnlyChecked = true, ShowReadOnly = true }; if (openFileDialog1.ShowDialog() == DialogResult.OK) { bitmapHandler = new BitmapHandler(); dataGridView1.Rows.Clear(); pictureBox2.Hide(); pictureBox1.Show(); dataGridView1.Show(); var file = openFileDialog1.FileName; firstBitmap = new Bitmap(file); pictureBox1.Width = firstBitmap.Width + 120; pictureBox1.Height = firstBitmap.Height + 120; pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; if ((50 * firstBitmap.Width) > 750) { dataGridView1.Width = 750; dataGridView1.Height = 375; dataGridView1.ScrollBars = ScrollBars.Both; } else { dataGridView1.Width = 50 * firstBitmap.Width; dataGridView1.Height = 25 * firstBitmap.Height; } trackBar1.Height = dataGridView1.Height - 30; label1.Location = new Point(pictureBox1.Width + 30, label1.Location.Y); trackBar1.Location = new Point(pictureBox1.Width + 20, label1.Location.Y + 30); panel2.Location = new Point(panel2.Location.X, dataGridView1.Height + 20); this.Width = firstBitmap.Width + 160 + dataGridView1.Width + trackBar1.Width + 3 + 163; this.Height = dataGridView1.Height + panel2.Height + 65; chart1.Width = dataGridView1.Width + trackBar1.Width + 3; chart1.Height = panel2.Height; dataGridView1.Location = new Point(pictureBox1.Width + 20 + trackBar1.Width + 6, dataGridView1.Location.Y); chart1.Location = new Point(dataGridView1.Location.X - trackBar1.Width - 5, dataGridView1.Height + 20); pictureBox1.Image = firstBitmap; var bmpWidth = firstBitmap.Width; var bmpHeight = firstBitmap.Height; int[,] pixels = new int[bmpWidth, bmpHeight]; dataGridView1.Columns.Clear(); for (int i = 0; i < bmpWidth; i++) { dataGridView1.Columns.Add(i + 1 + "", i + 1 + ""); } Mask.Columns.Add(1 + "", 1 + ""); Mask.Columns.Add(2 + "", 2 + ""); Mask.Columns.Add(2 + "", 2 + ""); dataGridView1.Rows.Add(bmpWidth); Mask.Rows.Add(3); for (int i = 0; i < bmpWidth; i++) { DataGridViewRow row2 = dataGridView1.Rows[i]; dataGridView1.Columns[i].Width = 50; if (i < 3) { Mask.Columns[i].Width = 50; Mask[i, 0].Value = 1; Mask[i, 1].Value = 1; Mask[i, 2].Value = 1; } } Mask.Width = 50 * 3; Mask.Height = 25 * 3; if (IsBinaryImage(firstBitmap)) { AddDataToDataGridView(bitmapHandler.GetBinaryArrayFromBitmap(firstBitmap)); DrawGistogrammForColorBitmap(GetColorFromColorBitmap(firstBitmap)); //signsForGreyScaleBitmap = bitmapHandler.SignsForGreyScaleBitmap; } else if (IsGrayScaleImage(firstBitmap)) { AddDataToDataGridView(GetAvgValuesForFourthLab(firstBitmap)); DrawGistogrammForColorBitmap(GetColorFromColorBitmap(firstBitmap)); } else { AddDataToDataGridView(GetAvgValuesFromGreyScaleBitmap(firstBitmap)); DrawGistogrammForColorBitmap(GetColorFromColorBitmap(firstBitmap)); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } button2.Enabled = true; button5.Enabled = true; button8.Enabled = true; button3.Enabled = true; button4.Enabled = true; button6.Enabled = true; }