예제 #1
0
        public Domino(byte First, byte Second)
        {
            if (First > Second)
            {
                SwapClass.Swap(ref First, ref Second);
            }

            if (First > 6)
            {
                this.First = 6;
            }
            else if (First < 0)
            {
                this.First = 0;
            }
            else
            {
                this.First = First;
            }

            if (Second > 6)
            {
                this.Second = 6;
            }
            else if (Second < 0)
            {
                this.Second = 0;
            }
            else
            {
                this.Second = Second;
            }
        }
예제 #2
0
        public Domino(Image image)
        {
            byte First, Second;
            int  whiteCount = 0;

            for (int i = 0; i < image.Size.Height / 2; i++)
            {
                for (int j = 0; j < image.Size.Width / 2; j++)
                {
                    if ((image as Bitmap).GetPixel(i, j).R + (image as Bitmap).GetPixel(i, j).G + (image as Bitmap).GetPixel(i, j).B > 382.5)
                    {
                        whiteCount++;
                    }
                }
            }
            First      = (byte)(whiteCount / 6);
            whiteCount = 0;
            if (image.Height > image.Width)
            {
                for (int i = image.Size.Height / 2 + 1; i < image.Size.Height; i++)
                {
                    for (int j = 0; j < image.Size.Width / 2; j++)
                    {
                        if ((image as Bitmap).GetPixel(j, i).R + (image as Bitmap).GetPixel(j, i).G + (image as Bitmap).GetPixel(j, i).B > 384)
                        {
                            whiteCount++;
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < image.Size.Height / 2; i++)
                {
                    for (int j = image.Size.Width / 2 + 1; j < image.Size.Width; j++)
                    {
                        if ((image as Bitmap).GetPixel(j, i).R + (image as Bitmap).GetPixel(j, i).G + (image as Bitmap).GetPixel(j, i).B > 384)
                        {
                            whiteCount++;
                        }
                    }
                }
            }
            Second     = (byte)(whiteCount / 6);
            whiteCount = 0;
            if (First > Second)
            {
                SwapClass.Swap(ref First, ref Second);
            }
            this.First  = First;
            this.Second = Second;
        }