Exemplo n.º 1
0
 public static int CompareC(PixelInfo x, PixelInfo y)
 {
     return(x.C.CompareTo(y.C));
 }
Exemplo n.º 2
0
 public static int CompareA(PixelInfo x, PixelInfo y)
 {
     return(x.A.CompareTo(y.A));
 }
Exemplo n.º 3
0
 public static int CompareB(PixelInfo x, PixelInfo y)
 {
     return(x.B.CompareTo(y.B));
 }
Exemplo n.º 4
0
        public void Split(out ColorCube a, out ColorCube b)
        {
            a = null;
            b = null;

            int minA = 0;
            int minB = 0;
            int minC = 0;
            int maxA = 0;
            int maxB = 0;
            int maxC = 0;

            for (int i = 0; i < this.Pixels.Count; i++)
            {
                PixelInfo p = this.Pixels[i];
                if (i == 0)
                {
                    minA = maxA = p.A;
                    minB = maxB = p.B;
                    minC = maxC = p.C;
                    continue;
                }
                minA = ColorCube.Min(p.A, minA);
                minB = ColorCube.Min(p.B, minB);
                minC = ColorCube.Min(p.C, minC);
                maxA = ColorCube.Max(p.A, maxA);
                maxB = ColorCube.Max(p.B, maxB);
                maxC = ColorCube.Max(p.C, maxC);
            }

            int A = maxA - minA;
            int B = maxB - minB;
            int C = maxC - minC;

            if ((A >= B) && (A >= C))
            {
                this.Pixels.Sort(ColorCube.CompareA);
            }
            else if ((B >= A) && (B >= C))
            {
                this.Pixels.Sort(ColorCube.CompareB);
            }
            else
            {
                this.Pixels.Sort(ColorCube.CompareC);
            }

            {
                int h = (this.Pixels.Count >> 1);
                int p = 0;
                a = new ColorCube(h);
                for (int i = 0; i < h; i++)
                {
                    a.Pixels.Add(this.Pixels[p++]);
                }

                h = this.Pixels.Count - h;
                b = new ColorCube(h);
                for (int i = 0; i < h; i++)
                {
                    b.Pixels.Add(this.Pixels[p++]);
                }
            }
        }