Do you really want to physically move the data, or is 800x600 View enough?
You can use the wrapper as follows:
class MatrixWrapper<T>
{
private T[] _data;
private int _columns;
public MatrixWrapper(T[] data, int rows, int columns)
{
_data = data;
_columns = columns;
}
public T this[int r, int c]
{
get { return _data[Index(r, c)]; }
set { _data[Index(r, c)] = value; }
}
private int Index(int r, int c)
{
return r * _columns + c;
}
}
And you use it like:
double[] data = new double[4800];
var wrapper = new MatrixWrapper<double>(data, 80, 60);
wrapper[2, 2] = 2.0;
source
share