I have a winform desktop C# application.
I have an image of size 720x576.
The image is represented by a 3 dimensional byte array: 720x576x3.
The x3 is representing the 3 colour channels of Red, Green and Blue.
This Image is divided logically (for my purpose) into 4 regions like so:
Say I have a new byte array for Region 4 and I wish to update this 'Base' Array.
I could do it like this:
for (Int16 camIndex = 0; camIndex < 4; camIndex++)
{
if (camsChanged[camIndex])
{
Rectangle roi = Rectangle.Empty;
switch (camIndex)
{
case 0:
roi = new Rectangle(0, 0, 360, 288);
break;
case 1:
roi = new Rectangle(360, 0, 360, 288);
break;
case 2:
roi = new Rectangle(0, 288, 360, 288);
break;
case 3:
roi = new Rectangle(360, 288, 360, 288);
break;
}
for (int x = roi.X; x < roi.X + roi.Width; x++)
{
for (int y = roi.Y; y < roi.Y + roi.Height; y++)
{
BaseImage[x, y, 0] = NewBaseImage[x, y, 0]; //signifies Red Channel
BaseImage[x, y, 1] = NewBaseImage[x, y, 1]; //signifies Green Channel
BaseImage[x, y, 2] = NewBaseImage[x, y, 2]; //signifies Yellow Channel
}
}
}
}
But is there a quicker way? I looked at Buffer.BlockCopy and Array.Copy but I could not see how it could help me in this scenario as it looked to replace the entire 'Base' array?
Thanks