fixed rgb values of pixmap struct
[my-code/api.git] / bmp / bmp.h
index 58bee0a..0741cd6 100644 (file)
--- a/bmp/bmp.h
+++ b/bmp/bmp.h
@@ -8,20 +8,27 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
 
 /* defines */
 #define B_SUCCESS 1
 #define B_ERROR -1
-#define B_NO_READ_MODE -2
+#define B_WRONG_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 B_E_READ_DATA -8
+#define B_E_WRITE_DATA -9
+#define B_E_GEOMETRY -10
+#define MAX_CHARS_FILE 128
 #define BMP_H_SIZE 14
 #define BMP_I_SIZE 40
+#define GRAB 'g'
 
 /* bmp specific variables */
 typedef struct s_bmp_hdr {
@@ -30,7 +37,7 @@ typedef struct s_bmp_hdr {
   unsigned short int reserved1;
   unsigned short int reserved2;
   unsigned int offset; /* <- 14 + 40 bytes = 0x36 */
-} t_bmp_hdr; /* 14 bytes */
+} __attribute__ ((packed)) t_bmp_hdr; /* 14 bytes */
 
 typedef struct s_bmp_info {
   unsigned int size; /* 40 bytes = 0x28 */
@@ -44,13 +51,13 @@ typedef struct s_bmp_info {
   unsigned int yres;
   unsigned int noc;
   unsigned int ic;
-} t_bmp_info; /* 40 bytes */
+} __attribute__ ((packed)) t_bmp_info; /* 40 bytes */
 
 typedef struct s_pixel {
-  unsigned char r;
-  unsigned char g;
   unsigned char b;
-} t_pixel;
+  unsigned char g;
+  unsigned char r;
+} __attribute__ ((packed)) t_pixel;
 
 typedef struct s_bmp {
   int outfd;
@@ -67,7 +74,12 @@ typedef struct s_bmp {
 } t_bmp;
 
 /* function prototypes */
-int bmp_init(t_bmp *bmp);
+int bmp_init(t_bmp *bmp,int outfd);
 int bmp_shutdown(t_bmp *bmp);
+int bmp_check_header_and_info(t_bmp *bmp);
+int bmp_alloc_map(t_bmp *bmp);
+int bmp_write_file(t_bmp *bmp);
+int bmp_cut_grab_bottom(t_bmp *dst,t_bmp *src,int dz,unsigned char m);
+int bmp_read_file(t_bmp *bmp);
 
 #endif