-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbitmap.h
61 lines (49 loc) · 1.55 KB
/
bitmap.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* bitmap.h -- bitmap image type */
#ifndef FRAMEBUF_BITMAP_H
#define FRAMEBUF_BITMAP_H
#include "base/result.h"
#include "framebuf/colour.h"
#include "framebuf/pixelfmt.h"
/** Common bitmap members. */
#define bitmap_format_MEMBERS \
int width, height; \
pixelfmt_t format; \
int rowbytes; \
colour_t *palette
/** Common bitmap members. */
#define bitmap_all_MEMBERS \
int width, height; \
pixelfmt_t format; \
int rowbytes; \
colour_t *palette; \
void *base
/** A bitmap. */
typedef struct bitmap bitmap_t;
struct bitmap
{
bitmap_all_MEMBERS;
};
result_t bitmap_init(bitmap_t *bm,
int width,
int height,
pixelfmt_t fmt,
int rowbytes,
const colour_t *palette,
void *base);
void bitmap_clear(bitmap_t *bm, colour_t c);
// it ought to be possible to provide instant flip_y by adjusting the base pointer and negating the rowbytes (which is why rowbytes is signed).
//void bitmap_flip_y(bitmap_t *bm)
//{
// uint8_t *base;
//
// base = bm->base;
// base += bm->height * bm->rowbytes;
//
// bm->rowbytes = -bm->rowbytes;
//
// bm->base = base;
//}
result_t bitmap_load_png(bitmap_t *bm, const char *filename);
result_t bitmap_save_png(const bitmap_t *bm, const char *filename);
result_t bitmap_convert(const bitmap_t *bm, pixelfmt_t newfmt, bitmap_t **newbm);
#endif /* FRAMEBUF_BITMAP_H */