forked from alxhill/gif-decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgif_frame.hpp
61 lines (49 loc) · 1.04 KB
/
gif_frame.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef __gif_h__
#define __gif_h__
#include "debug.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
using namespace std;
struct rgb {
uint8_t r,g,b;
};
struct gif_gce
{
uint8_t block_size;
uint16_t disposal_method;
bool user_input_flag;
bool transparent_colour_flag;
uint16_t delay_time;
uint8_t transparent_colour_index;
};
struct gif_descriptor
{
uint16_t left;
uint16_t top;
uint16_t width;
uint16_t height;
bool lct_flag;
bool interlace_flag;
bool sort_flag;
unsigned int lct_size;
};
class GIFFrame
{
struct gif_gce gce;
uint8_t *lct;
vector<uint8_t> index_stream;
ifstream &gif_file;
public:
struct gif_descriptor dsc;
struct rgb** pixels;
GIFFrame(ifstream &gfile) : gif_file(gfile) {};
void decode(uint8_t *gct = nullptr, uint8_t gct_size = 0);
void decode_gce();
void decode_descriptor();
void decode_lct();
void decode_data(uint8_t gct_size);
void build_frame(uint8_t *gct, uint8_t gct_size);
};
#endif