1

Can someone explain me how it's calculated row and column?

byte[] pixel = new byte[img.Stride * img.Height];
for (l=0; l< pixel.Length -4;l+=4 )
{
    row= l/img.Stride;
    column=(l% img.Stride)/4;
....
}
Bob
  • 49
  • 11
  • it is unclear to me what you are asking, but maybe this page on Image Stride will help you out: https://msdn.microsoft.com/en-us/library/windows/desktop/aa473780(v=vs.85).aspx – Peter B Jun 22 '17 at 11:23

1 Answers1

0

You can refer the link, c# scan0 and stride

Stride:

The stride is the width of a single row of pixels (a scan line), rounded up to a four-byte boundary. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up.

If you want to move from one row to the next, you need to add the stride to the address of the row you're currently looking at. Rows are aligned to 4 byte boundaries so that all kinds of code can access it more efficiently. (Various operations in CPUs are optimized to work on 4 byte or 8 byte boundaries.)

Thanks, Christo

christo issac
  • 440
  • 3
  • 12