Encode a single mipmap level's pixel data in the target format
| 68 | |
| 69 | // Encode a single mipmap level's pixel data in the target format |
| 70 | static std::vector<uint8_t> encodeLevel(const Image& rgbaLevel, PixelFormat fmt) |
| 71 | { |
| 72 | int w = rgbaLevel.width(); |
| 73 | int h = rgbaLevel.height(); |
| 74 | |
| 75 | if (fmt == PixelFormat::DXT1) |
| 76 | return DXTCompressor::CompressDXT1(rgbaLevel.data().data(), w, h); |
| 77 | if (fmt == PixelFormat::DXT3) |
| 78 | return DXTCompressor::CompressDXT3(rgbaLevel.data().data(), w, h); |
| 79 | if (fmt == PixelFormat::DXT5) |
| 80 | return DXTCompressor::CompressDXT5(rgbaLevel.data().data(), w, h); |
| 81 | |
| 82 | // Uncompressed: convert pixels |
| 83 | size_t dstSize = ComputeDataSize(w, h, fmt); |
| 84 | std::vector<uint8_t> encoded(dstSize); |
| 85 | ConvertPixels(rgbaLevel.data().data(), encoded.data(), w, h, PixelFormat::RGBA8888, fmt); |
| 86 | return encoded; |
| 87 | } |
| 88 | |
| 89 | bool WritePAA(const std::string& path, const Image& img, PixelFormat format) |
| 90 | { |
no test coverage detected