Lines 61-70
write_bmp(const char *filename, int width, int height, char *rgb)
Link Here
|
61 |
struct BMPHeader bmph; |
61 |
struct BMPHeader bmph; |
62 |
|
62 |
|
63 |
/* The length of each line must be a multiple of 4 bytes */ |
63 |
/* The length of each line must be a multiple of 4 bytes */ |
64 |
|
|
|
65 |
bytesPerLine = (3 * (width + 1) / 4) * 4; |
64 |
bytesPerLine = (3 * (width + 1) / 4) * 4; |
66 |
|
65 |
|
67 |
strcpy(bmph.bfType, "BM"); |
66 |
/* copy only "BM" without a terminating null byte */ |
|
|
67 |
strncpy(bmph.bfType, "BM", 2); |
68 |
bmph.bfOffBits = 54; |
68 |
bmph.bfOffBits = 54; |
69 |
bmph.bfSize = bmph.bfOffBits + bytesPerLine * height; |
69 |
bmph.bfSize = bmph.bfOffBits + bytesPerLine * height; |
70 |
bmph.bfReserved = 0; |
70 |
bmph.bfReserved = 0; |