private void ColorPickerForm_FormClosed(object sender, FormClosedEventArgs e) { isAlreadyMadeFlag = false; instance = null; binaryForm = null; }
private void ProcessBinary() { Bitmap screenBitmap = (Bitmap)originalScreen.Image; Bitmap binaryBitmap = (Bitmap)binaryScreen.Image; if (modeComboBox.SelectedIndex == 0) { int r = Convert.ToInt32(rTextBox.Text); int g = Convert.ToInt32(gTextBox.Text); int b = Convert.ToInt32(bTextBox.Text); for (int x = 0; x < screenBitmap.Width; x++) { for (int y = 0; y < screenBitmap.Height; y++) { Color rgbValue = screenBitmap.GetPixel(x, y); if (rgbValue.R == r && rgbValue.G == g && rgbValue.B == b) { binaryBitmap.SetPixel(x, y, Color.Black); } else { binaryBitmap.SetPixel(x, y, Color.White); } } } binaryScreen.Refresh(); } else { int s1 = Convert.ToInt32(s1TextBox.Text); int s2 = Convert.ToInt32(s2TextBox.Text); int v1 = Convert.ToInt32(v1TextBox.Text); int v2 = Convert.ToInt32(v2TextBox.Text); for (int x = 0; x < screenBitmap.Width; x++) { for (int y = 0; y < screenBitmap.Height; y++) { Color rgbValue = screenBitmap.GetPixel(x, y); double hue; double saturation; double value; ColorPickerForm.RGB2HSV(rgbValue.R, rgbValue.G, rgbValue.B, out hue, out saturation, out value); saturation = saturation * 100 / 255; value = value * 100 / 255; if ((s1 <= (int)saturation && (int)saturation <= s2) && (v1 <= (int)value && (int)value <= v2)) { binaryBitmap.SetPixel(x, y, Color.Black); } else { binaryBitmap.SetPixel(x, y, Color.White); } } } binaryScreen.Refresh(); } }