A c++14 header only TGA file parsing and conversion library.
A minimal, but fully TGA 2.0 standard compliant parser.
#include <bktga/tga.hpp>
#include <vector>
#include <iostream>
int main() {
namespace tga = ::bktga;
std::vector<std::string> const files {
"./test/tc-rgb16a1-128x128-rle.tga"
, "./tga.hpp"
, "./non-existant-file.none"
};
for (auto const& file : files) {
auto result = tga::detect(tga::read_from_file, file);
if (!result) {
std::cerr << "Cannot open \"" << file << "\" as TGA: " << result.error() << '\n';
continue;
}
auto const data = tga::decode(result);
std::cout << "Okay" << std::endl;
// use data...
}
return 0;
}Okay
Cannot open "./tga.hpp" as TGA: unknown reserved image type
Cannot open "./non-existant-file.none" as TGA: The system cannot find the file specified.
Other compiler + standard library version combinations might work, but the following have been tested.
- ⭕ MSVC 2015 Update 1 (_MSC_FULLVER 190023506)
- ⭕ GCC 4.9
- ❌ GCC 4.8 (no digit separators; lack of standard library features in libstdc++)
- ⭕ Clang 3.6
- ❗ Clang 3.5 (with GCC 4.9, or with libc++)
- ⭕ Xcode 6.4