X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=bmp%2Fbmp.h;fp=bmp%2Fbmp.h;h=58bee0abebe28cf74ade206a9e091aeddebe021a;hb=f8382861ee7bff6d129bd149579d26bf9b81ada0;hp=0000000000000000000000000000000000000000;hpb=7d9d106b404d26e7ad22e0a61dedaf6f6a34c6a4;p=my-code%2Fapi.git diff --git a/bmp/bmp.h b/bmp/bmp.h new file mode 100644 index 0000000..58bee0a --- /dev/null +++ b/bmp/bmp.h @@ -0,0 +1,73 @@ +/* bmp.h -- bmp headers */ + +#ifndef BMP_H +#define BMP_H + +/* includes */ +#define _GNU_SOURCE +#include +#include +#include + +/* defines */ +#define B_SUCCESS 1 +#define B_ERROR -1 +#define B_NO_READ_MODE -2 +#define B_NO_FILE -3 +#define B_NO_HI -4 +#define B_NO_SUPPORT -5 +#define B_HI_FAIL -6 +#define B_E_MEM -7 +#define B_E_READ_DATA -8; +#define MAX_CHARS_FILE 32 +#define BMP_H_SIZE 14 +#define BMP_I_SIZE 40 + +/* bmp specific variables */ +typedef struct s_bmp_hdr { + unsigned short int identifier; + unsigned int size; + unsigned short int reserved1; + unsigned short int reserved2; + unsigned int offset; /* <- 14 + 40 bytes = 0x36 */ +} t_bmp_hdr; /* 14 bytes */ + +typedef struct s_bmp_info { + unsigned int size; /* 40 bytes = 0x28 */ + int width; + int height; + unsigned short int planes; + unsigned short int bpp; + unsigned int compression; + unsigned int imagesize; + unsigned int xres; + unsigned int yres; + unsigned int noc; + unsigned int ic; +} t_bmp_info; /* 40 bytes */ + +typedef struct s_pixel { + unsigned char r; + unsigned char g; + unsigned char b; +} t_pixel; + +typedef struct s_bmp { + int outfd; + int width; + int height; + unsigned char mode; +#define READ (1<<0) +#define WRITE (1<<1) + char file[MAX_CHARS_FILE]; + int fd; + t_bmp_hdr hdr; + t_bmp_info info; + t_pixel *map; +} t_bmp; + +/* function prototypes */ +int bmp_init(t_bmp *bmp); +int bmp_shutdown(t_bmp *bmp); + +#endif