Render() public method

public Render ( Bitmap img, Color colorMap, List imageInfos ) : Mosaic
img System.Drawing.Bitmap
colorMap Color
imageInfos List
return Mosaic
        public static void Generate(string imageToMash, string srcImageDirectory, PictureBox pictureBox1, PictureBox pictureBox2, string shapeName)
        {
            try
            {
                var _imageProcessing = new ImageProcessing();

                //var _mosaic = new Mosaic();

                using (var source = new Bitmap(imageToMash))
                {
                    Dictionary <int, List <int> > xDic = new Dictionary <int, List <int> >();

                    CreateMap(source, xDic);
                    Random rand = new Random();
                    Shuffle(ref xDic);
                    int xLength = (int)source.Width / 12;
                    int yLength = (int)source.Height / 12;

                    //_mosaic = _imageProcessing.Render(source, _colorMap, pictureBox1, pictureBox2, shapeName);
                    _imageProcessing.Render(source, xDic, xLength, yLength, pictureBox1, pictureBox2, shapeName);
                }

                //return _mosaic;
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        public Mosaic Generate(string imageToMash, string srcImageDirectory)
        {
            var _imageProcessing = new ImageProcessing();
            var _imageInfos      = new List <ImageInfo>();
            var _mosaic          = new Mosaic();

            var di    = new DirectoryInfo(srcImageDirectory);
            var files = di.GetFiles("*.jpg", SearchOption.AllDirectories).ToList();

            Parallel.ForEach(files, f =>
            {
                using (var inputBmp = _imageProcessing.Resize(f.FullName))
                {
                    var _info = _imageProcessing.GetAverageColor(inputBmp, f.FullName);

                    if (_info != null)
                    {
                        _imageInfos.Add(_info);
                    }
                }
            });

            using (var source = new Bitmap(imageToMash))
            {
                var _colorMap = _imageProcessing.CreateMap(source);
                _mosaic = _imageProcessing.Render(source, _colorMap, _imageInfos);
            }

            return(_mosaic);
        }