Ejemplo n.º 1
0
        public void PickColor(int x, int y)
        {
            float scalefactor = getScalingFactor();

            bitbltwidth  = (int)(this.Width * scalefactor);
            bitbltheight = (int)(this.Height * scalefactor);

            IntPtr screenDc = GetDC(IntPtr.Zero);

            StretchBlt(memscreenDc, 0, 0, Width, Height, screenDc, 0, 0, bitbltwidth, bitbltheight, 0x00CC0020);
            GetBitmapBits(hScreenBitmap, Width * Height * 4, screenbits);

            intcolor targetc = GC(x, y);

            MatchPixelList.Clear();
            for (int i = 0; i < Width; i++)
            {
                for (int j = 0; j < Height; j++)
                {
                    intcolor c = GC(i, j);
                    if (Math.Abs(c.b - targetc.b) + Math.Abs(c.g - targetc.g) + Math.Abs(c.r - targetc.r) < Root.CDThreshold)
                    {
                        MatchPixelList.Add(new Point(i, j));
                    }
                    else
                    {
                        SC(i, j, 0, 0);
                    }
                }
            }

            ReleaseDC(IntPtr.Zero, screenDc);
        }
Ejemplo n.º 2
0
        public void SC(int i, int j, intcolor c)
        {
            int pbase = (Width * j + i) * 4;

            screenbits[pbase]     = (byte)c.b;
            screenbits[pbase + 1] = (byte)c.g;
            screenbits[pbase + 2] = (byte)c.r;
        }
Ejemplo n.º 3
0
        public intcolor GC(int i, int j)
        {
            intcolor c     = new intcolor();
            int      pbase = (Width * j + i) * 4;

            c.b = screenbits[pbase];
            c.g = screenbits[pbase + 1];
            c.r = screenbits[pbase + 2];
            return(c);
        }
Ejemplo n.º 4
0
        public void ShiftHue_Start()
        {
            float scalefactor = getScalingFactor();

            bitbltwidth  = (int)(this.Width * scalefactor);
            bitbltheight = (int)(this.Height * scalefactor);

            IntPtr screenDc = GetDC(IntPtr.Zero);

            StretchBlt(memscreenDc, 0, 0, Width, Height, screenDc, 0, 0, bitbltwidth, bitbltheight, 0x00CC0020);
            GetBitmapBits(hScreenBitmap, Width * Height * 4, screenbits);

            for (int i = 0; i < Width; i++)
            {
                for (int j = 0; j < Height; j++)
                {
                    intcolor c = GC(i, j);
                    intcolor r;

                    if (Math.Abs(c.g - c.r) >= 60)
                    {
                        r.b = (c.g - c.r + 255) / 2;
                        r.g = Math.Min(Math.Min(c.g, c.r) * 2 + c.b, 255);
                        r.r = Math.Min(Math.Min(c.g, c.r) * 2, 255);
                        SC(i, j, r);
                    }
                    else if (Math.Abs(c.g - c.r) >= 5)
                    {
                        r.b = (c.g - c.r + 255) / 2;
                        r.g = Math.Min(Math.Min(c.g, c.r) * 2 + c.b, 255);
                        r.r = Math.Min(Math.Min(c.g, c.r) * 2, 255);

                        double drg  = Math.Abs(c.g - c.r) / 60.0;
                        double drg_ = 1 - drg;
                        r.b = (int)(drg * r.b + drg_ * c.b);
                        r.g = (int)(drg * r.g + drg_ * c.g);
                        r.r = (int)(drg * r.r + drg_ * c.r);

                        SC(i, j, r);
                    }
                    else
                    {
                    }
                }
            }

            ReleaseDC(IntPtr.Zero, screenDc);

            SetBitmapBits(hScreenBitmap, Width * Height * 4, screenbits);
            BitBlt(canvusDc, 0, 0, this.Width, this.Height, memscreenDc, 0, 0, 0x00CC0020);

            DrawButtons(false);
            UpdateFormDisplay(true);
        }