Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/tools/n64graphics.h
7854 views
1
#ifndef N64GRAPHICS_H_
2
#define N64GRAPHICS_H_
3
4
#include <stdint.h>
5
6
// intermediate formats
7
typedef struct _rgba
8
{
9
uint8_t red;
10
uint8_t green;
11
uint8_t blue;
12
uint8_t alpha;
13
} rgba;
14
15
typedef struct _ia
16
{
17
uint8_t intensity;
18
uint8_t alpha;
19
} ia;
20
21
// CI palette
22
typedef struct
23
{
24
uint16_t data[256];
25
int max; // max number of entries
26
int used; // number of entries used
27
} palette_t;
28
29
//---------------------------------------------------------
30
// N64 RGBA/IA/I/CI -> intermediate RGBA/IA
31
//---------------------------------------------------------
32
33
// N64 raw RGBA16/RGBA32 -> intermediate RGBA
34
rgba *raw2rgba(const uint8_t *raw, int width, int height, int depth);
35
36
// N64 raw IA1/IA4/IA8/IA16 -> intermediate IA
37
ia *raw2ia(const uint8_t *raw, int width, int height, int depth);
38
39
// N64 raw I4/I8 -> intermediate IA
40
ia *raw2i(const uint8_t *raw, int width, int height, int depth);
41
42
//---------------------------------------------------------
43
// intermediate RGBA/IA -> N64 RGBA/IA/I/CI
44
// returns length written to 'raw' used or -1 on error
45
//---------------------------------------------------------
46
47
// intermediate RGBA -> N64 raw RGBA16/RGBA32
48
int rgba2raw(uint8_t *raw, const rgba *img, int width, int height, int depth);
49
50
// intermediate IA -> N64 raw IA1/IA4/IA8/IA16
51
int ia2raw(uint8_t *raw, const ia *img, int width, int height, int depth);
52
53
// intermediate IA -> N64 raw I4/I8
54
int i2raw(uint8_t *raw, const ia *img, int width, int height, int depth);
55
56
57
//---------------------------------------------------------
58
// N64 CI <-> N64 RGBA16/IA16
59
//---------------------------------------------------------
60
61
// N64 CI raw data and palette to raw data (either RGBA16 or IA16)
62
uint8_t *ci2raw(const uint8_t *rawci, const uint8_t *palette, int width, int height, int ci_depth);
63
64
// convert from raw (RGBA16 or IA16) format to CI + palette
65
int raw2ci(uint8_t *rawci, palette_t *pal, const uint8_t *raw, int raw_len, int ci_depth);
66
67
68
//---------------------------------------------------------
69
// intermediate RGBA/IA -> PNG
70
//---------------------------------------------------------
71
72
// intermediate RGBA write to PNG file
73
int rgba2png(const char *png_filename, const rgba *img, int width, int height);
74
75
// intermediate IA write to grayscale PNG file
76
int ia2png(const char *png_filename, const ia *img, int width, int height);
77
78
79
//---------------------------------------------------------
80
// PNG -> intermediate RGBA/IA
81
//---------------------------------------------------------
82
83
// PNG file -> intermediate RGBA
84
rgba *png2rgba(const char *png_filename, int *width, int *height);
85
86
// PNG file -> intermediate IA
87
ia *png2ia(const char *png_filename, int *width, int *height);
88
89
90
//---------------------------------------------------------
91
// version
92
//---------------------------------------------------------
93
94
// get version of underlying graphics reading library
95
const char *n64graphics_get_read_version(void);
96
97
// get version of underlying graphics writing library
98
const char *n64graphics_get_write_version(void);
99
100
#endif // N64GRAPHICS_H_
101
102