private void change_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; //setting bmp with thw origional photo bmp = origional; //chosing the filter you want to the photo if (imageFilterBox.SelectedItem != null) { switch (imageFilterBox.SelectedItem.ToString()) { case "Default image": bmp = origional; break; case "No Color": if (checkedListBox1.CheckedItems.Count != 0) { string[] colors = new string[checkedListBox1.CheckedItems.Count]; for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++) { colors[i] = checkedListBox1.CheckedItems[i].ToString(); } bmp = StudentUtilities.NoColor(origional, colors); } else { ErrorsClass.PrintMassage(ErrorCodes.ColorNotChosen); } break; case "No background": bmp = StudentUtilities.RemoveBackground(origional, color, trackBar1.Value); break; case "Grey Scale": bmp = StudentUtilities.ToGreyscale(origional); break; case "Combine": #region combine //filter{first filter, second filter,counter1 ,counter2 ,checker (not for the filter himself),filter num (not for the filter himself)} filter = new int[6] { 0, 0, 0, 0, 0, 0 }; if (filterValus.Text != null && filterValus.Text != "0.X,0.Y") { if (second != null && origional != null) { for (int i = 0; i < filterValus.Text.Length; i++) { if (filterValus.Text[i] == '.') { filter[(int)filters.checker] = 1; } if (filterValus.Text[i] == ',') { filter[(int)filters.checker] = 0; //changing the number of filter that is changing filter[(int)filters.filterNum] = 1; } if (filterValus.Text[i] >= '0' && filterValus.Text[i] <= '9') { if (filter[(int)filters.checker] > 0) { holder = filter[(int)filters.filterNum]; filter[holder] = filter[holder] * 10; filter[holder] = filter[holder] + (int)filterValus.Text[i] - 48; if (filter[(int)filters.filterNum] == 0) { filter[(int)filters.counter1]++; } else { filter[(int)filters.counter2]++; } /*MessageBox.Show(filterValus.Text[i].ToString()); * int a = filterValus.Text[i]; * MessageBox.Show(a.ToString()); * MessageBox.Show((filter[(int)filters.counter]*10).ToString()); * double b = (filter[(int)filters.counter] * 10); * MessageBox.Show(a.ToString()+","+b.ToString()+","+(a/b).ToString()); * filter[(int)filters.filterNum] = ((int)filterValus.Text[i] /(filter[(int)filters.counter]*10)); * filter[(int)filters.counter]++;*/ } } } if (filter[(int)filters.counter1] == 0 || filter[(int)filters.counter2] == 0) { MessageBox.Show("You need to insert two numbers that are smaller then 1 and not 0"); break; } double one = (double)filter[(int)filters.firstFilter] / Math.Pow(10, filter[(int)filters.counter1]); double two = (double)filter[(int)filters.secondFilter] / Math.Pow(10, filter[(int)filters.counter2]); bmp = StudentUtilities.LinearCombinationColored(origional, second, one, two, false); } else { MessageBox.Show("You need to insert 2 pics"); } } else { MessageBox.Show("you need to put/change valuse"); } #endregion break; case "Threshold": #region check if the number is 0<=x<=255 and if integer int j; if (int.TryParse(filterValus.Text, out j)) { if (int.Parse(filterValus.Text) >= 0 && int.Parse(filterValus.Text) <= 255) { bmp = StudentUtilities.MatrixToBitmap(StudentUtilities.Threshold(StudentUtilities.BitmapToMatrix(origional), int.Parse(filterValus.Text))); } else { MessageBox.Show("the int meed to be between 0 and 255"); } } else { MessageBox.Show("you need to put a number"); } #endregion break; case "bluer": bmp = StudentUtilities.bluer(origional); break; case "bluer Exept": if (point1 != null && point2 != null) { bmp = StudentUtilities.bluerExept(origional, GetPointFromText(point1.Text), GetPointFromText(point2.Text)); } break; case "bluer Just": if (point1 != null && point2 != null) { bmp = StudentUtilities.bluerJust(origional, GetPointFromText(point1.Text), GetPointFromText(point2.Text)); } break; case "Color Switch": bmp = StudentUtilities.SwichColors(origional, Rcol.SelectedItem.ToString(), Gcol.SelectedItem.ToString(), Bcol.SelectedItem.ToString()); break; } } else { ErrorsClass.PrintMassage(ErrorCodes.OptionNotChosen); } pictureBox1.Image = bmp; this.Cursor = Cursors.Default; }//changing the image
private void button1_Click(object sender, EventArgs e) { pictureBox1.Image = StudentUtilities.LinearCombinationColored(origional, second, 0.5, 0.5, false); }