| 90 | } |
| 91 | |
| 92 | bool saveBmp(BitmapConstSection<byte, 1> bitmap, const char *filename) { |
| 93 | FILE *file = fopen(filename, "wb"); |
| 94 | if (!file) |
| 95 | return false; |
| 96 | |
| 97 | int paddedWidth; |
| 98 | bitmap.reorient(Y_UPWARD); |
| 99 | writeBmpHeader(file, 1, bitmap.width, bitmap.height, paddedWidth); |
| 100 | |
| 101 | byte padding[4] = { }; |
| 102 | int padLength = paddedWidth-bitmap.width; |
| 103 | for (int y = 0; y < bitmap.height; ++y) { |
| 104 | fwrite(bitmap(0, y), sizeof(byte), bitmap.width, file); |
| 105 | fwrite(padding, 1, padLength, file); |
| 106 | } |
| 107 | |
| 108 | return !fclose(file); |
| 109 | } |
| 110 | |
| 111 | bool saveBmp(BitmapConstSection<byte, 3> bitmap, const char *filename) { |
| 112 | FILE *file = fopen(filename, "wb"); |
no test coverage detected