any can explain the function of stride in bitmapdata?

Stride is there due to hardware requirements that have unfortunately leaked through to the API layer.

It is important because Windows drivers sometimes require that scanlines (rows in the image) be memory aligned. That is why they are sometimes larger than they would strictly need to be.

See for example this MSDN article DIBs and Their Use.

Every scanline is DWORD-aligned. The scanline is buffered to alignment; the buffering is not necessarily 0.

Your handling seems to be sufficient.

Leave a Comment