예제 #1
0
        public void Paiting()
        {
            var    wheel = new ColorPicker(400);
            var    img   = wheel.DrawImage(hue, sat, val);
            Color  col;
            Bitmap bitmap = new Bitmap(pictureBox2.Width, pictureBox2.Height);


            using (var g = Graphics.FromImage(img))
            {
                var pen = val < 0.5 ? Pens.White : Pens.Black;

                var wheelPosition = wheel.GetWheelPosition(hue);
                g.DrawEllipse(pen, (float)wheelPosition.X - 5, (float)wheelPosition.Y - 5, 10, 10);

                var trianglePosition = wheel.GetTrianglePosition(sat, val);
                g.DrawEllipse(pen, (float)trianglePosition.X - 5, (float)trianglePosition.Y - 5, 10, 10);

                col = GetPixel((Bitmap)img, (int)trianglePosition.X, (int)trianglePosition.Y);
                Graphics grf = Graphics.FromImage(bitmap);

                for (int y = 0; y < pictureBox2.Width; y++)
                {
                    for (int x = 0; x < pictureBox2.Height; x++)
                    {
                        bitmap.SetPixel(y, x, col);
                    }
                }
            }
            pictureBox2.Image = bitmap;
            pictureBox2.Refresh();

            pictureBox1.Image = img;
        }