Skip to content

Commit

Permalink
Fix another subtle off-by-one in the BMP encoder.
Browse files Browse the repository at this point in the history
  • Loading branch information
vkoskiv committed Jan 18, 2020
1 parent ab75898 commit d82b83c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/filehandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ void encodeBMPFromArray(const char *filename, unsigned char *imgData, int width,
unsigned char *bgrData = calloc(3 * width * height, sizeof(unsigned char));
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
bgrData[(x + ((height - 1) - y) * width) * 3 + 0] = imgData[(x + (height - y) * width) * 3 + 2];
bgrData[(x + ((height - 1) - y) * width) * 3 + 1] = imgData[(x + (height - y) * width) * 3 + 1];
bgrData[(x + ((height - 1) - y) * width) * 3 + 2] = imgData[(x + (height - y) * width) * 3 + 0];
bgrData[(x + (height - (y + 1)) * width) * 3 + 0] = imgData[(x + (height - (y + 1)) * width) * 3 + 2];
bgrData[(x + (height - (y + 1)) * width) * 3 + 1] = imgData[(x + (height - (y + 1)) * width) * 3 + 1];
bgrData[(x + (height - (y + 1)) * width) * 3 + 2] = imgData[(x + (height - (y + 1)) * width) * 3 + 0];
}
}
int i;
Expand Down

0 comments on commit d82b83c

Please sign in to comment.