#ifndef N64GRAPHICS_H_1#define N64GRAPHICS_H_23#include <stdint.h>45// intermediate formats6typedef struct _rgba7{8uint8_t red;9uint8_t green;10uint8_t blue;11uint8_t alpha;12} rgba;1314typedef struct _ia15{16uint8_t intensity;17uint8_t alpha;18} ia;1920// CI palette21typedef struct22{23uint16_t data[256];24int max; // max number of entries25int used; // number of entries used26} palette_t;2728//---------------------------------------------------------29// N64 RGBA/IA/I/CI -> intermediate RGBA/IA30//---------------------------------------------------------3132// N64 raw RGBA16/RGBA32 -> intermediate RGBA33rgba *raw2rgba(const uint8_t *raw, int width, int height, int depth);3435// N64 raw IA1/IA4/IA8/IA16 -> intermediate IA36ia *raw2ia(const uint8_t *raw, int width, int height, int depth);3738// N64 raw I4/I8 -> intermediate IA39ia *raw2i(const uint8_t *raw, int width, int height, int depth);4041//---------------------------------------------------------42// intermediate RGBA/IA -> N64 RGBA/IA/I/CI43// returns length written to 'raw' used or -1 on error44//---------------------------------------------------------4546// intermediate RGBA -> N64 raw RGBA16/RGBA3247int rgba2raw(uint8_t *raw, const rgba *img, int width, int height, int depth);4849// intermediate IA -> N64 raw IA1/IA4/IA8/IA1650int ia2raw(uint8_t *raw, const ia *img, int width, int height, int depth);5152// intermediate IA -> N64 raw I4/I853int i2raw(uint8_t *raw, const ia *img, int width, int height, int depth);545556//---------------------------------------------------------57// N64 CI <-> N64 RGBA16/IA1658//---------------------------------------------------------5960// N64 CI raw data and palette to raw data (either RGBA16 or IA16)61uint8_t *ci2raw(const uint8_t *rawci, const uint8_t *palette, int width, int height, int ci_depth);6263// convert from raw (RGBA16 or IA16) format to CI + palette64int raw2ci(uint8_t *rawci, palette_t *pal, const uint8_t *raw, int raw_len, int ci_depth);656667//---------------------------------------------------------68// intermediate RGBA/IA -> PNG69//---------------------------------------------------------7071// intermediate RGBA write to PNG file72int rgba2png(const char *png_filename, const rgba *img, int width, int height);7374// intermediate IA write to grayscale PNG file75int ia2png(const char *png_filename, const ia *img, int width, int height);767778//---------------------------------------------------------79// PNG -> intermediate RGBA/IA80//---------------------------------------------------------8182// PNG file -> intermediate RGBA83rgba *png2rgba(const char *png_filename, int *width, int *height);8485// PNG file -> intermediate IA86ia *png2ia(const char *png_filename, int *width, int *height);878889//---------------------------------------------------------90// version91//---------------------------------------------------------9293// get version of underlying graphics reading library94const char *n64graphics_get_read_version(void);9596// get version of underlying graphics writing library97const char *n64graphics_get_write_version(void);9899#endif // N64GRAPHICS_H_100101102