initial commit, 4.5 stable
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
This commit is contained in:
39
thirdparty/msdfgen/core/save-fl32.cpp
vendored
Normal file
39
thirdparty/msdfgen/core/save-fl32.cpp
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
#include "save-fl32.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
namespace msdfgen {
|
||||
|
||||
// Requires byte reversal for floats on big-endian platform
|
||||
#ifndef __BIG_ENDIAN__
|
||||
|
||||
template <int N>
|
||||
bool saveFl32(const BitmapConstRef<float, N> &bitmap, const char *filename) {
|
||||
if (FILE *f = fopen(filename, "wb")) {
|
||||
byte header[16] = { byte('F'), byte('L'), byte('3'), byte('2') };
|
||||
header[4] = byte(bitmap.height);
|
||||
header[5] = byte(bitmap.height>>8);
|
||||
header[6] = byte(bitmap.height>>16);
|
||||
header[7] = byte(bitmap.height>>24);
|
||||
header[8] = byte(bitmap.width);
|
||||
header[9] = byte(bitmap.width>>8);
|
||||
header[10] = byte(bitmap.width>>16);
|
||||
header[11] = byte(bitmap.width>>24);
|
||||
header[12] = byte(N);
|
||||
fwrite(header, 1, 16, f);
|
||||
fwrite(bitmap.pixels, sizeof(float), N*bitmap.width*bitmap.height, f);
|
||||
fclose(f);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template bool saveFl32(const BitmapConstRef<float, 1> &bitmap, const char *filename);
|
||||
template bool saveFl32(const BitmapConstRef<float, 2> &bitmap, const char *filename);
|
||||
template bool saveFl32(const BitmapConstRef<float, 3> &bitmap, const char *filename);
|
||||
template bool saveFl32(const BitmapConstRef<float, 4> &bitmap, const char *filename);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
Reference in New Issue
Block a user