Exemplo n.º 1
0
        public static HouseEffect Load(string path)
        {
            HouseEffect effect = new HouseEffect();

            using (TextReader reader = new StreamReader(path)) {
                int rows    = int.Parse(reader.ReadLine());
                int columns = int.Parse(reader.ReadLine());

                effect.path    = path;
                effect.name    = Path.GetFileNameWithoutExtension(path);
                effect.rows    = rows;
                effect.columns = columns;
                effect.data    = new byte[rows, columns];

                for (int row = 0; row < rows; ++row)
                {
                    for (int col = 0; col < columns; ++col)
                    {
                        byte val = (byte)int.Parse(reader.ReadLine());
                        effect.data[row, col] = val;
                    }
                }
            }

            return(effect);
        }
Exemplo n.º 2
0
        public static HouseEffect FromSelection(byte[,] values, Rectangle selectedRectangle, Func <int, int> rowMap, string path)
        {
            int top    = selectedRectangle.Top;
            int bottom = selectedRectangle.Bottom;
            int right  = selectedRectangle.Right;
            int left   = selectedRectangle.Left;

            int rows    = bottom - top;
            int columns = right - left;

            HouseEffect effect = new HouseEffect();

            effect.path    = path;
            effect.name    = Path.GetFileNameWithoutExtension(path);
            effect.rows    = rows;
            effect.columns = columns;
            effect.data    = new byte[rows, columns];


            for (int row = top; row < bottom; ++row)
            {
                int mappedRow = rowMap(row);

                for (int col = left; col < right; ++col)
                {
                    byte val = values[mappedRow, col];
                    effect.data[row - top, col - left] = val;
                }
            }

            return(effect);
        }