StdPaint.ConsoleBuffer.ResampledCopy C# (CSharp) Method

ResampledCopy() public static method

Creates a resampled copy of a console buffer using the specified dimensions.
public static ResampledCopy ( ConsoleBuffer buffer, int width, int height ) : ConsoleBuffer
buffer ConsoleBuffer The buffer to be resampled.
width int The width of the resampled buffer.
height int The height of the resampled buffer.
return ConsoleBuffer
        public static ConsoleBuffer ResampledCopy(ConsoleBuffer buffer, int width, int height)
        {
            var sb = new ConsoleBuffer(width, height);
            double dw = ((double)buffer.Width / width);
            double dh = ((double)buffer.Height / height);

            for(int i = 0; i < width; i++)
            for(int j = 0; j < height; j++)
            {
                sb._buffer[j, i].BackColor = buffer._buffer[(int)(j * dh), (int)(i * dw)].BackColor;
            }

            return sb;
        }