Beispiel #1
0
        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            if (pictureBox1.Image != null)
            {
                double kX      = (double)pictureBox1.Image.Width / pictureBox1.Width;
                double kY      = (double)pictureBox1.Image.Height / pictureBox1.Height;
                double k       = Math.Max(kX, kY);
                double nobideX = (pictureBox1.Width * k - pictureBox1.Image.Width) / 2;
                double nobideY = (pictureBox1.Height * k - pictureBox1.Image.Height) / 2;
                double kx      = Math.Round(e.X * k - nobideX);
                double ky      = Math.Round(e.Y * k - nobideY);

                label7.Text = "X: " + kx.ToString() + ", Y: " + ky.ToString();

                imgData imgDateObj = new imgData();
                Color[] pixels     = getPixel((int)kx, (int)ky, new Bitmap(pictureBox1.Image), new Bitmap(pictureBox2.Image));
                label2.Text = "R: " + pixels[0].R.ToString();
                label3.Text = "G: " + pixels[0].G.ToString();
                label4.Text = "B: " + pixels[0].B.ToString();

                if (radioButton1.Checked)
                {
                    PixelClassRGB rgbi = new PixelClassRGB(pixels[1].R, pixels[1].G, pixels[1].B);
                    label12.Text = "R: " + rgbi.R.ToString();
                    label11.Text = "G: " + rgbi.G.ToString();
                    label10.Text = "B: " + rgbi.B.ToString();
                    label9.Text  = "I: " + rgbi.I.ToString();
                }
                else if (radioButton2.Checked)
                {
                    if (inverted)
                    {
                        PixelClassHSV hsv = new PixelClassHSV(pixels[1].R, pixels[1].G, pixels[1].B);
                        label12.Text = "H: " + hsv.H.ToString();
                        label11.Text = "S: " + hsv.S.ToString();
                        label10.Text = "V: " + hsv.V.ToString();
                    }
                    else
                    {
                        PixelClassHSV hsv = new PixelClassHSV(pixels[0].R, pixels[0].G, pixels[0].B);
                        label12.Text = "H: " + hsv.H.ToString();
                        label11.Text = "S: " + hsv.S.ToString();
                        label10.Text = "V: " + hsv.V.ToString();
                    }
                }
                else if (radioButton8.Checked)
                {
                    if (inverted)
                    {
                        PixelClassCMYK cmyk = new PixelClassCMYK(pixels[1].R, pixels[1].G, pixels[1].B);
                        label12.Text = "C: " + cmyk.C.ToString();
                        label11.Text = "M: " + cmyk.M.ToString();
                        label10.Text = "Y: " + cmyk.Y.ToString();
                        label9.Text  = "K: " + cmyk.K.ToString();
                    }
                    else
                    {
                        PixelClassCMYK cmyk = new PixelClassCMYK(pixels[0].R, pixels[0].G, pixels[0].B);
                        label12.Text = "C: " + cmyk.C.ToString();
                        label11.Text = "M: " + cmyk.M.ToString();
                        label10.Text = "Y: " + cmyk.Y.ToString();
                        label9.Text  = "K: " + cmyk.K.ToString();
                    }
                }
                else if (radioButton9.Checked)
                {
                    if (inverted)
                    {
                        PixelClassYUV yuv = new PixelClassYUV(pixels[1].R, pixels[1].G, pixels[1].B);
                        label12.Text = "Y: " + yuv.Y.ToString();
                        label11.Text = "U: " + yuv.U.ToString();
                        label10.Text = "V: " + yuv.V.ToString();
                    }
                    else
                    {
                        PixelClassYUV yuv = new PixelClassYUV(pixels[0].R, pixels[0].G, pixels[0].B);
                        label12.Text = "Y: " + yuv.Y.ToString();
                        label11.Text = "U: " + yuv.U.ToString();
                        label10.Text = "V: " + yuv.V.ToString();
                    }
                }
            }
        }