-
Notifications
You must be signed in to change notification settings - Fork 0
/
qoi.h
45 lines (35 loc) · 1002 Bytes
/
qoi.h
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
#ifndef __QOI_H__
#define __QOI_H__
#include <stdint.h>
// "qoif"
#define QOI_MAGIC (('q' << 24) | ('o' << 16) | ('i' << 8) | ('f' << 0))
#define RGB 3
#define RGBA 4
#define QOI_SRGB 0
#define QOI_LINEAR 1
typedef uint8_t qoi_channels_t;
typedef uint8_t qoi_colorspace_t;
typedef struct {
uint32_t width;
uint32_t height;
qoi_channels_t channels;
qoi_colorspace_t colorspace;
} qoi_desc_t;
typedef struct {
uint8_t magic[4];
uint32_t width;
uint32_t height;
qoi_channels_t channels;
qoi_colorspace_t colorspace;
} qoi_header_t;
#define QOI_HEADER_LENGTH 14
#define QOI_OP_RGB 0xfe // 0b1111 1110
#define QOI_OP_RGBA 0xff // 0b1111 1111
#define QOI_OP_INDEX 0x00 // 0b00
#define QOI_OP_DIFF 0x40 // 0b01
#define QOI_OP_LUMA 0x80 // 0b10
#define QOI_OP_RUN 0xc0 // 0b11
#define QOI_END_MARKER \
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }
#define QOI_END_MARKER_LENGTH 8
#endif