Esempio n. 1
0
File: Program.cs Progetto: PJayB/PIC
            static SignedColor CalculateError(SignedColor delta, int x, int y, DitherPattern pattern)
            {
                if (y == 0)
                {
                    x--;
                }
                else
                {
                    x -= pattern.KernelMinX;
                }

                int mul = pattern.Kernel[y][x];

                if (mul == 0)
                {
                    return(new SignedColor());
                }
                else
                {
                    int         div = pattern.Divisor;
                    SignedColor c   = new SignedColor();
                    c.R = (delta.R * mul) / div;
                    c.G = (delta.G * mul) / div;
                    c.B = (delta.B * mul) / div;
                    c.A = (delta.A * mul) / div;
                    return(c);
                }
            }
Esempio n. 2
0
File: Program.cs Progetto: PJayB/PIC
            public Color Dither(int x, int y, Color c, DitherPattern pattern)
            {
                // Get the existing error at this pixel
                SignedColor e = GetError(x, y);

                // Get the quantized color
                Color q = QuantizeColor(c, e);

                // Calculate the difference
                SignedColor delta = Diff(c, q);

                // Kernel may be zero size (so we should ignore it)
                if (pattern.KernelHeight > 0)
                {
                    // First row handled differently
                    for (int i = 1; i <= pattern.KernelMaxX; ++i)
                    {
                        AddError(x + i, y, CalculateError(delta, i, 0, pattern));
                    }

                    // Process subsequent rows
                    for (int j = 1; j < pattern.KernelHeight; ++j)
                    {
                        for (int i = pattern.KernelMinX; i <= pattern.KernelMaxX; ++i)
                        {
                            AddError(x + i, y + j, CalculateError(delta, i, j, pattern));
                        }
                    }
                }

                _totalError += delta.RGBError;

                return(q);
            }
Esempio n. 3
0
File: Program.cs Progetto: PJayB/PIC
 private void AddError(int x, int y, SignedColor c)
 {
     if (x >= 0 && x < _width && y >= 0 && y < _height)
     {
         _errorMatrix[y * _width + x].Add(c);
     }
 }
Esempio n. 4
0
File: Program.cs Progetto: PJayB/PIC
 private void SetError(int x, int y, SignedColor c)
 {
     if (x >= 0 && x < _width && y >= 0 && y < _height)
     {
         _errorMatrix[y * _width + x] = c;
     }
 }
Esempio n. 5
0
File: Program.cs Progetto: PJayB/PIC
 public void Add(SignedColor c)
 {
     A += c.A;
     R += c.R;
     G += c.G;
     B += c.B;
 }
        public bool Equals(ContractSettings other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (!(PublicForeColor.Equals(other.PublicForeColor) && SelectionColor.Equals(other.SelectionColor) &&
                  SignedColor.Equals(other.SignedColor) && TextVisibility == other.TextVisibility &&
                  AcceptedCountVisibility == other.AcceptedCountVisibility &&
                  AccessCountVisibility == other.AccessCountVisibility))
            {
                return(false);
            }

            if (!ColumnOrders.SequenceEqual(other.ColumnOrders))
            {
                return(false);
            }

            if (!ColumnWidths.SequenceEqual(other.ColumnWidths))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 7
0
File: Program.cs Progetto: PJayB/PIC
            static Color QuantizeColor(Color c, SignedColor e)
            {
                int r = QuantizeChannel(c.R + e.R);
                int g = QuantizeChannel(c.G + e.G);
                int b = QuantizeChannel(c.B + e.B);
                int a = QuantizeChannel(c.A + e.A);

                return(Color.FromArgb(a, r, g, b));
            }