public void writeBlock(byte[][,] raster, byte[,] data,
int compIndex, int x, int y)
{
int w = raster[0].GetLength(0),
h = raster[0].GetLength(1);
byte[,] comp = raster[compIndex];
// Blocks may spill over the frame so we bound by the frame size
int yMax = data.GetLength(0); if ((y + yMax) > h) yMax = h - y;
int xMax = data.GetLength(1); if ((x + xMax) > w) xMax = w - x;
for (int yIndex = 0; yIndex < yMax; yIndex++)
{
for (int xIndex = 0; xIndex < xMax; xIndex++)
{
comp[x + xIndex, y + yIndex] = data[yIndex, xIndex];
}
}
}