28 {
29 GifInfo info;
30
31
33 if (error_message) {
34 *error_message = "Empty GIF data";
35 }
36 return info;
37 }
38
39
40 if (data.
size() < 13) {
41 if (error_message) {
42 *error_message = "GIF data too small";
43 }
44 return info;
45 }
46
47
48 if (data[0] != 'G' || data[1] != 'I' || data[2] != 'F') {
49 if (error_message) {
50 *error_message = "Invalid GIF signature";
51 }
52 return info;
53 }
54
55
56 if (!((data[3] == '8' && data[4] == '7' && data[5] == 'a') ||
57 (data[3] == '8' && data[4] == '9' && data[5] == 'a'))) {
58 if (error_message) {
59 *error_message = "Unsupported GIF version";
60 }
61 return info;
62 }
63
64
65
66
67 fl::u16
width = data[6] | (data[7] << 8);
68 fl::u16
height = data[8] | (data[9] << 8);
69
71 if (error_message) {
72 *error_message = "Invalid GIF dimensions";
73 }
74 return info;
75 }
76
77
78
81 stream->write(data);
82
83 if (decoder->begin(stream)) {
84
85 info.width = decoder->getWidth();
86 info.height = decoder->getHeight();
87 info.frameCount = decoder->getFrameCount();
88 info.loopCount = decoder->getLoopCount();
89 info.isAnimated = decoder->isAnimated();
90 info.bitsPerPixel = 8;
91 info.isValid = true;
92
93 decoder->end();
94 } else {
95
98 info.frameCount = 1;
99 info.loopCount = 0;
100 info.isAnimated = false;
101 info.bitsPerPixel = 8;
102 info.isValid = true;
103
104 if (error_message) {
105 *error_message = "";
106 }
107 }
108
109 return info;
110}
constexpr bool empty() const FL_NOEXCEPT
constexpr fl::size size() const FL_NOEXCEPT
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT