Using netcoreapp3.1 and EmguCV 3.4.1 I create on the one hand a WriteableBitmap and on the other an EmguCV Mat. Both have same size of 2793 x 2585
var wb = new WriteableBitmap(2793, 2585, 96, 96, PixelFormats.Bgr24, null);
int wbStride = wb.BackBufferStride; //8380
var m = new Mat(2585, 2793, DepthType.Cv8U, 3);
int matStride = m.Step; //8379
For the WriteableBitmap BackBufferStride = 8380 but for the Mat I get Step = 8379. I found out that there exist two different formulas often used to calculate the stride:
a) Stride = ((width * bitsPerPixel + 31) & ~31) >> 3;
b) Stride = (width * bitsPerPixel + 7) / 8
Formula a) results in the value that I get for WriteableBitmap BackBufferStride and Formula b) in the value of EmguCV Mat.
Why are Strides different for same width and height? Which formula is the right one?