summaryrefslogtreecommitdiff
path: root/include/tinyff/image/bmp.h
blob: 82edff3df4ee5e56e914590918a16ae902c8ffb4 (plain)
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
#ifndef BMP_H_
#define BMP_H_

#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>

#include "tinyff/result.h"
#include "tinyff/common.h"
#include "tinyff/stream.h"
#include "tinyff/image/generic.h"

static const unsigned char BMP_SIGNATURE[2] = {
    'B', 'M'
};

typedef struct {
    uint32_t file_size; // tbh, i actually have no idea why this is needed
    uint32_t data_offset;
    
    uint32_t width;
    uint32_t height;
    uint16_t bpp;
    uint32_t compression;
    uint32_t image_size;
    uint32_t x_ppm; // X pixels per meter
    uint32_t y_ppm; // Y pixels per meter
    uint32_t colors_used;
    uint32_t important_colors;

    uint8_t* palette; 
    
    uint8_t* pixels;
    
} ff_bmp_ctx;

#endif BMP_H_