Download src/gfx/image_decoder.hpp from thevareoz/astra-browser-core: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/thevareoz/astra-browser-core/resolve/main/src/gfx/image_decoder.hpp
- Command line
-
hf download hf://thevareoz/astra-browser-core/src/gfx/image_decoder.hpp
-
curl -L -o image_decoder.hpp https://huggingface.co/thevareoz/astra-browser-core/resolve/main/src/gfx/image_decoder.hpp
1.41 kB
| namespace astra { | |
| struct DecodedImage { | |
| int width = 0; | |
| int height = 0; | |
| std::string format; // "PNG", "BMP", "PPM" | |
| std::vector<uint32_t> argb; | |
| bool valid = false; | |
| std::string error; | |
| }; | |
| // Zero-build-dependency native image decoder (inspired by Firefox image/decoders/). | |
| // Supports: | |
| // - PNG (8-bit RGB, RGBA, Grayscale, Grayscale+Alpha, Indexed PLTE; all 5 PNG filters) | |
| // - JPEG (Pure C++20 Baseline Sequential DCT: Grayscale & YCbCr 4:4:4/4:2:2/4:2:0, DRI) | |
| // - GIF (Pure C++20 GIF87a/GIF89a LZW decoder: GCT/LCT, transparency, interlacing) | |
| // - WebP (RIFF WEBP container + runtime dlopen libwebp.so.7/6 decoder) | |
| // - BMP (24-bit & 32-bit uncompressed DIB) | |
| // - PPM (P6 binary RGB) | |
| class ImageDecoder { | |
| public: | |
| static DecodedImage decode_bytes(const uint8_t* data, size_t len); | |
| static DecodedImage decode_file(const std::string& path); | |
| private: | |
| static DecodedImage decode_png(const uint8_t* data, size_t len); | |
| static DecodedImage decode_jpeg(const uint8_t* data, size_t len); | |
| static DecodedImage decode_gif(const uint8_t* data, size_t len); | |
| static DecodedImage decode_webp(const uint8_t* data, size_t len); | |
| static DecodedImage decode_bmp(const uint8_t* data, size_t len); | |
| static DecodedImage decode_ppm(const uint8_t* data, size_t len); | |
| }; | |
| } // namespace astra | |