-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfio.h
More file actions
67 lines (57 loc) · 1.57 KB
/
fio.h
File metadata and controls
67 lines (57 loc) · 1.57 KB
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
62
63
64
65
66
67
// This is free and unencumbered software released into the public domain.
// For more information, see LICENSE.
#ifndef FIO_H
#define FIO_H
#include <stddef.h>
#include <stdint.h>
#include "util.h"
struct mmap_file {
size_t size;
void *data;
};
struct bmp_header {
uint16_t signature;
uint32_t size;
uint32_t reserved;
uint32_t offset;
} __pack;
_Static_assert(sizeof(struct bmp_header) == 14, "unsupported architecture");
struct dib_header {
uint32_t size;
uint32_t width;
uint32_t height;
struct {
uint16_t planes;
uint16_t bits_per_px;
} __pack;
uint32_t compression;
uint32_t image_size;
uint32_t x_px_per_m;
uint32_t y_px_per_m;
uint32_t colors_in_colortable;
char incomplete[];
} __pack;
struct bitmap_data {
uint32_t width;
uint32_t padded_bytes_per_row;
uint32_t height;
void *data;
struct mmap_file handle;
};
struct rfp_file {
uint32_t header;
uint32_t size;
uint8_t data[];
} __pack;
_Static_assert(sizeof(struct rfp_file) == 8, "unsupported architecture");
typedef uint8_t v8[8] __align(8);
typedef uint8_t v4[4] __align(4);
int load_file(const char *, struct mmap_file *);
void unload_file(struct mmap_file *);
int load_bitmap(const char *, struct bitmap_data *);
int convert_bmp_window_to_rfp(struct bitmap_data *, unsigned, unsigned, const char *);
struct rfp_file *load_rfp_file(struct mmap_file *);
struct rfp_file *load_cfp_file(struct mmap_file *);
void rfp_compress(const char *, const char *);
void rfp_decompress(void *restrict, v4 *restrict);
#endif // FIO_H