Example #1
0
        /// <summary>
        /// Rotate ImageChunks stored in ImagePart
        /// </summary>
        public void RotateChunks()
        {
            ImageChunk tmp = _imageChunkTypes[3];

            for (int i = 3; i > 0; i--)
            {
                _imageChunkTypes[i] = _imageChunkTypes[i - 1];
            }
            _imageChunkTypes[0] = tmp;
        }
Example #2
0
        private static ImageChunk[] PixelRecognize(Bitmap bitmap)
        {
            ImageChunk[] chunkType            = new ImageChunk[4];
            Point[]      colorRelativeSamples = { new Point(29, 49), new Point(2, 74), new Point(2, 24) };
            Point[]      eyeRelativeSamples   = { new Point(15, 58), new Point(15, 40) };
            Point[]      smileRelativeSamples = { new Point(10, 69), new Point(7, 29), new Point(24, 49) };

            for (int i = 0; i < chunkType.Length; i++)
            {
                ImageChunk.ImageChunkColor?iColor = null;
                ImageChunk.ImageChunkFace? iFace  = null;

                if (i == 3)
                {
                    Console.Write("");
                }

                iColor = CheckColorFromSamples(colorRelativeSamples, bitmap);
                if (iColor != ImageChunk.ImageChunkColor.Black && iColor != null)
                {
                    if (CheckColorFromSamples(smileRelativeSamples, bitmap) == ImageChunk.ImageChunkColor.Black)
                    {
                        iFace = ImageChunk.ImageChunkFace.Smile;
                    }
                    else if (CheckColorFromSamples(eyeRelativeSamples, bitmap) == ImageChunk.ImageChunkColor.Black)
                    {
                        iFace = ImageChunk.ImageChunkFace.Eyes;
                    }
                }

                if (iColor != null && iFace != null)
                {
                    chunkType[i] = new ImageChunk(iColor.Value, iFace.Value);
                    bitmap.RotateFlip(RotateFlipType.Rotate270FlipNone);
                }
                else
                {
                    throw new Exception("Nelze rozeznat obrazek.");
                }
            }
            return(chunkType);
        }
Example #3
0
        public bool CheckImageCorectness()
        {
            bool result = true;

            foreach (var imagePart in _imageParts)
            {
                for (int i = 0; i < 4; i++)
                {
                    ImageChunk first = imagePart.GetImageChunk((ImagePartSide)i);
                    if (first.Neighbour != null)
                    {
                        ImageChunk second = first.Neighbour.GetImageChunk(ReversedValue((ImagePartSide)i));

                        result = (first.Color == second.Color && first.Face != second.Face);
                        if (!result)
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }