Haio 0.2.X
Homebrew Asset IO/CDN
Loading...
Searching...
No Matches
detect.cpp
Go to the documentation of this file.
1#include <haio_codec.hpp>
2#include <haio_util.hpp>
3
4namespace {
5
6constexpr std::array<uint8_t, 6> signature87a = {
7 'G', 'I', 'F', '8', '7', 'a'
8};
9
10constexpr std::array<uint8_t, 6> signature89a = {
11 'G', 'I', 'F', '8', '9', 'a'
12};
13
14bool headerSays(Haio::Bytes data) {
15 return Haio::Util::matches(data, signature87a)
16 || Haio::Util::matches(data, signature89a);
17}
18
19}
20
21namespace Haio::Codecs {
22
23/** what a gif holds when nobody asks for something else */
24template <> struct DefaultColor<Format::GIF> { static constexpr Color value = Color::RGBA8888; };
25
26/**
27 * @addtogroup detect
28 * @{
29 */
30template <>
32 return headerSays(data);
33}
34/** @} */
35
36/**
37 * @addtogroup detect
38 * @{
39 */
40/**
41 * GIF has a palette rather than an RGB colour type, but the decoder expands
42 * it directly to RGB888.
43 */
44template <>
46 return headerSays(data);
47}
48/** @} */
49
50}
bool Detect< Format::GIF, Color::RGB888 >(Bytes data)
Definition detect.cpp:45
bool Detect< Format::GIF, Color::RGBA8888 >(Bytes data)
Definition detect.cpp:31
bool matches(Bytes data, Bytes magic)
Definition matches.cpp:7
std::span< const uint8_t > Bytes