Beispiel #1
0
        /// <summary>
        /// 입력받은 Color Array에서 지정된 넓이, 높이, 위치 만큼 가로로 분할하여 비트맵을 반환한다.
        /// </summary>
        public List <Bitmap> GetDivisionBitmap(System.Drawing.Color[,] pixel, int width, int height)
        {
            List <Bitmap> arrBitmap = new List <Bitmap>();

            // 세로 타일 수
            for (int j = 0; j < pixel.GetLength(1) / height; j++)
            {
                // 가로 타일 수
                for (int i = 0; i < pixel.GetLength(0) / width; i++)
                {
                    Bitmap bitmap = new Bitmap(width, height);
                    // 타일 하나 만들기
                    for (int x = 0; x < width; x++)
                    {
                        for (int y = 0; y < height; y++)
                        {
                            int left = x + width * i;
                            int top  = y + height * j;
                            bitmap.SetPixel(x, y, pixel[left, top]);
                        }
                    }
                    // 만든거 담기
                    arrBitmap.Add(bitmap);
                }
            }

            return(arrBitmap);
        }
Beispiel #2
0
        /// <summary>
        /// 타일 리스트 세팅
        /// </summary>
        public void SetTileList(string sResourcePath)
        {
            //  sResourcePath = @"C:\Users\wjkim\Source\Repos\Serenade\Serenade\Resource\Residential.png";
            SplitImage splitImage = new SplitImage();
            Bitmap     resource   = new Bitmap(sResourcePath);

            System.Drawing.Color[,] color = splitImage.GetBitmapPixel(resource);
            List <Bitmap> resourceSplit = splitImage.GetDivisionBitmap(color, 16, 16);

            WrapPanel wpTileGroup = new WrapPanel();

            wpTileGroup.Orientation = Orientation.Horizontal;
            wpTileGroup.Width       = color.GetLength(0);
            wpTileGroup.Height      = color.GetLength(1);

            wpTileGroup.Margin = new Thickness(5);

            for (int i = 0; i < resourceSplit.Count; i++)
            {
                //// 임시 전체 색상 적용
                //Color testColor = Color.FromRgb(0, 100, byte.Parse(20.ToString()));

                //UcTile ucTile = new UcTile();

                //ucTile.LbName = testColor.ToString();
                //ucTile.ColorTileImage = testColor;
                //ucTile.IsTileType = false;
                //wpTileList.Children.Add(ucTile);
                UcTile ucTile = new UcTile();
                ucTile.BitmapTileImage = resourceSplit[i];
                wpTileGroup.Children.Add(ucTile);
            }
            wpTileList.Children.Add(wpTileGroup);
        }
Beispiel #3
0
        private static void WriteImage(DefineBitsLossless2Tag image, string path)
        {
            if (File.Exists(path))
            {
                return;
            }

            System.Drawing.Color[,] table = image.GetARGBMap();

            int width  = table.GetLength(0);
            int height = table.GetLength(1);

            using (var payload = new Image <Rgba32>(width, height))
            {
                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        System.Drawing.Color pixel = table[x, y];
                        payload[x, y] = new Rgba32(pixel.R, pixel.G, pixel.B, pixel.A);
                    }
                }

                using (var output = new StreamWriter(path))
                {
                    payload.SaveAsPng(output.BaseStream);
                }
            }
        }
Beispiel #4
0
        public static Bitmap FromColorsMatrix(System.Drawing.Color[,] colors)
        {
            var bitmap = new Bitmap(colors.GetLength(1), colors.GetLength(0));

            for (int y = 0; y < bitmap.Height; y++)
            {
                for (int x = 0; x < bitmap.Width; x++)
                {
                    bitmap.SetPixel(x, y, colors[y, x]);
                }
            }

            return(bitmap);
        }
Beispiel #5
0
        // The constructor uses SixLabors ImageSharp to read the image file.
        // The Image< Rgba32 > acts like an array of pixels indexed by column and row.
        // Each pixel is stored in an Rgba32 object.
        // Representation is a 2D array of pixels indexed by row and column.
        // Each pixel is stored in a Color object.

        public Retina(string path)
        {
            using Image <Rgba32> img6L = Image.Load <Rgba32>(path);
            Pixels = new SD.Color[img6L.Height, img6L.Width];

            for (int row = 0; row < Pixels.GetLength(0); row++)
            {
                for (int col = 0; col < Pixels.GetLength(1); col++)
                {
                    int x = col;
                    int y = row;

                    Rgba32   p = img6L[x, y];
                    SD.Color c = SD.Color.FromArgb(p.A, p.R, p.G, p.B);

                    Pixels[row, col] = c;
                }
            }
        }