Skip to content

Bug in BMP padding calculation when pixelsPerModule is odd #697

Description

@KrisVandermotten

BitmapByteQRCode.GetGraphic uses the following formula to calculate the number of padding bytes per row:

var paddingLen = sideLength % 4;

That's not correct. It happens to work when sideLength is even, i.e. when pixelsPerModule is even, but it fails when sideLength is odd.

The correct formula would be (4 - (sideLength % 4)) % 4, or the more efficient equivalent -sideLength & 3.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions