コード例 #1
0
        public static RGB8 GetRGBValue(uint color)
        {
            RGB8 rgb = new RGB8();

            byte[] colorBuffer = BitConverter.GetBytes(color);
            rgb.R = colorBuffer[0];
            rgb.G = colorBuffer[1];
            rgb.B = colorBuffer[2];
            return(rgb);
        }
コード例 #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            System.Drawing.Point p = MousePosition;

            //tsslCursorPos.Text = string.Format("X:{0},Y:{1}", p.X, p.Y);

            uint color = Win32Helper.GetPixel(_hdc, p.X, p.Y);

            RGB8 rgb = Win32Helper.GetRGBValue(color);

            byte r = rgb.R;
            byte g = rgb.G;
            byte b = rgb.B;

            numericUpDown_R.Value = rgb.R;
            numericUpDown_G.Value = rgb.G;
            numericUpDown_B.Value = rgb.B;

            pictureBox1.BackColor = Color.FromArgb(rgb.R, rgb.G, rgb.B);
            byte alpha = Convert.ToByte(trackBar1.Value);

            textBox_RGBHex.Text = "0X" + alpha.ToString("X").PadLeft(2, '0') + rgb.R.ToString("X").PadLeft(2, '0') + rgb.G.ToString("X").PadLeft(2, '0') + rgb.B.ToString("X").PadLeft(2, '0');
        }