Search code examples
windowsimageimage-processingpaddingstride

What is the purpose of padding on rows of bitmap image data (Stride - Width)?


I could understand if it was being used for some sort of metadata, but I can't find anything confirming this.

Is there a reason for this added padding? If so, what is it?


Solution

  • The padding has to do with something called "data alignment". Many BMP files are aligned so that each row is a multiple of 32-bits. It makes for faster reading, and easier reading of arbitrary rows (depending on CPU).