MCPcopy Create free account
hub / github.com/MyGUI/mygui / saveBmp

Function saveBmp

MyGUIEngine/src/msdfgen/core/save-bmp.cpp:92–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92bool 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
111bool saveBmp(BitmapConstSection<byte, 3> bitmap, const char *filename) {
112 FILE *file = fopen(filename, "wb");

Callers 1

writeOutputFunction · 0.85

Calls 3

writeBmpHeaderFunction · 0.85
pixelFloatToByteFunction · 0.85
reorientMethod · 0.45

Tested by

no test coverage detected