public void FindColor() { Bitmap bitmap = Screenshot(); Bitmap image = new Bitmap(bmp); Bitmap bitmap2 = bitmap; Point position = Cursor.Position; int x = position.X; position = Cursor.Position; Color pixel = bitmap2.GetPixel(x, position.Y); PictureBox.Image = bmp; HSV hSV = default(HSV); using (Graphics graphics = Graphics.FromImage(image)) { hSV = pixel.ToHSV(); graphics.DrawLine(new Pen(Color.Black), new Point((int)hSV.GetHue(), 0), new Point((int)hSV.GetHue(), 180)); graphics.FillRectangle(new SolidBrush(Color.Black), new Rectangle(300, 300, 40, 40)); graphics.FillRectangle(new SolidBrush(hSV.ToRGB()), new Rectangle(302, 302, 36, 36)); } double num = hSV.GetHue(); image = Draw.String("Hue:\t\t" + num.ToString(), 10, 300, Color.Black, 10, image); num = hSV.GetSaturation(); image = Draw.String("Saturation:\t" + num.ToString(), 10, 315, Color.Black, 10, image); num = hSV.GetValue(); image = Draw.String("Value:\t\t" + num.ToString(), 10, 330, Color.Black, 10, image); PictureBox.Image = image; PictureBox.Update(); bitmap.Dispose(); image.Dispose(); }
public int CompareHue(HSV color) { int delta = (int)Math.Abs(H - color.GetHue()); return((delta >= 180) ? 360 - delta : delta); }
public int CompareHue(HSV color) { int num = (int)Math.Abs(H - color.GetHue()); return((num >= 180) ? (360 - num) : num); }