SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
ImageQuantize.cpp
Go to the documentation of this file.
2
3using namespace vtfpp;
4
5std::vector<std::byte> ImageQuantize::convertP8ImageDataToBGRA8888(std::span<const std::byte> paletteData, std::span<const std::byte> imageData) {
6 if (paletteData.size() != 256 * sizeof(ImagePixel::BGRA8888)) {
7 return {};
8 }
9
10 std::span palettePixelData{reinterpret_cast<const ImagePixel::BGRA8888*>(paletteData.data()), 256};
11
12 std::vector<std::byte> out;
13 out.resize(imageData.size() * sizeof(ImagePixel::BGRA8888));
14 BufferStream stream{out};
15 for (const auto index : imageData) {
16 stream << palettePixelData[static_cast<uint8_t>(index)];
17 }
18 return out;
19}
std::vector< std::byte > convertP8ImageDataToBGRA8888(std::span< const std::byte > paletteData, std::span< const std::byte > imageData)
Converts a paletted image to something usable.
Definition: HOT.h:11