MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / encodeLevel

Function encodeLevel

engine/Poseidon/Graphics/Textures/PAAEncoder.cpp:70–87  ·  view source on GitHub ↗

Encode a single mipmap level's pixel data in the target format

Source from the content-addressed store, hash-verified

68
69// Encode a single mipmap level's pixel data in the target format
70static 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
89bool WritePAA(const std::string& path, const Image& img, PixelFormat format)
90{

Callers 1

WritePAAFunction · 0.85

Calls 7

CompressDXT1Function · 0.85
CompressDXT3Function · 0.85
CompressDXT5Function · 0.85
ComputeDataSizeFunction · 0.85
ConvertPixelsFunction · 0.85
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected