You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
861 B
27 lines
861 B
typedef struct rif {
|
|
// "lifV0001"
|
|
// "rifV0001"
|
|
char magic_num[8]; // Big Endian. UTF-8 Encoded. 6C 69 66 56 30 30 30 31
|
|
uint64_t width; // Big Endian
|
|
uint8_t format;
|
|
uint8_t data[];
|
|
} rif_t;
|
|
|
|
#define RIF_MAGIC_LITTLE {'l', 'i', 'f', 'V', '0', '0', '0', '1'}
|
|
#define RIF_MAGIC_BIG {'r', 'i', 'f', 'V', '0', '0', '0', '1'}
|
|
|
|
#define RIF_FORMAT_R8G8B8 0
|
|
#define RIF_FORMAT_R8G8B8A8 1
|
|
|
|
void write_rif_little(char* path, uint32_t width, uint32_t size, uint8_t format, void* data) {
|
|
#define IMG_SIZE 17 + size // 17 is the size of raw_img excluding the data field
|
|
rif_t* img = malloc(IMG_SIZE);
|
|
char magic[] = RIF_MAGIC_LITTLE;
|
|
memcpy(((char*)img)+0, magic, 8);
|
|
img->width = width;
|
|
img->format = format;
|
|
memcpy(((char*)img)+17, data, size);
|
|
FILE* output_file = fopen(path, "w");
|
|
fwrite(img, 1, IMG_SIZE, output_file);
|
|
}
|