added 2d dft + bmp api (TESTING - may break!)
[my-code/api.git] / bmp / bmp.h
1 /* bmp.h -- bmp headers */
2
3 #ifndef BMP_H
4 #define BMP_H
5
6 /* includes */
7 #define _GNU_SOURCE
8 #include <stdio.h>
9 #include <string.h>
10 #include <stdlib.h>
11
12 /* defines */
13 #define B_SUCCESS 1
14 #define B_ERROR -1
15 #define B_NO_READ_MODE -2
16 #define B_NO_FILE -3
17 #define B_NO_HI -4
18 #define B_NO_SUPPORT -5
19 #define B_HI_FAIL -6
20 #define B_E_MEM -7
21 #define B_E_READ_DATA -8;
22 #define MAX_CHARS_FILE 32
23 #define BMP_H_SIZE 14
24 #define BMP_I_SIZE 40
25
26 /* bmp specific variables */
27 typedef struct s_bmp_hdr {
28   unsigned short int identifier;
29   unsigned int size;
30   unsigned short int reserved1;
31   unsigned short int reserved2;
32   unsigned int offset; /* <- 14 + 40 bytes = 0x36 */
33 } t_bmp_hdr; /* 14 bytes */
34
35 typedef struct s_bmp_info {
36   unsigned int size; /* 40 bytes = 0x28 */
37   int width;
38   int height;
39   unsigned short int planes;
40   unsigned short int bpp;
41   unsigned int compression;
42   unsigned int imagesize;
43   unsigned int xres;
44   unsigned int yres;
45   unsigned int noc;
46   unsigned int ic;
47 } t_bmp_info; /* 40 bytes */
48
49 typedef struct s_pixel {
50   unsigned char r;
51   unsigned char g;
52   unsigned char b;
53 } t_pixel;
54
55 typedef struct s_bmp {
56   int outfd;
57   int width;
58   int height;
59   unsigned char mode;
60 #define READ (1<<0)
61 #define WRITE (1<<1)
62   char file[MAX_CHARS_FILE];
63   int fd;
64   t_bmp_hdr hdr;
65   t_bmp_info info;
66   t_pixel *map;
67 } t_bmp;
68
69 /* function prototypes */
70 int bmp_init(t_bmp *bmp);
71 int bmp_shutdown(t_bmp *bmp);
72
73 #endif