Facebook
From kiran, 3 Years ago, written in C.
Embed
Download Paste or View Raw
Hits: 93
  1. // BMP-related data types based on Microsoft's own
  2.  
  3. #include <stdint.h>
  4.  
  5. // aliases for C/C++ primitive data types
  6. // https://msdn.microsoft.com/en-us/library/cc230309.aspx
  7. typedef uint8_t  BYTE;
  8. typedef uint32_t DWORD;
  9. typedef int32_t  LONG;
  10. typedef uint16_t WORD;
  11.  
  12. // information about the type, size, and layout of a file
  13. // https://msdn.microsoft.com/en-us/library/dd183374(v=vs.85).aspx
  14. typedef struct
  15. {
  16.     WORD bfType;
  17.     DWORD bfSize;
  18.     WORD bfReserved1;
  19.     WORD bfReserved2;
  20.     DWORD bfOffBits;
  21. } __attribute__((__packed__))
  22. BITMAPFILEHEADER;
  23.  
  24. // information about the dimensions and color format
  25. // https://msdn.microsoft.com/en-us/library/dd183376(v=vs.85).aspx
  26. typedef struct
  27. {
  28.     DWORD biSize;
  29.     LONG biWidth;
  30.     LONG biHeight;
  31.     WORD biPlanes;
  32.     WORD biBitCount;
  33.     DWORD biCompression;
  34.     DWORD biSizeImage;
  35.     LONG biXPelsPerMeter;
  36.     LONG biYPelsPerMeter;
  37.     DWORD biClrUsed;
  38.     DWORD biClrImportant;
  39. } __attribute__((__packed__))
  40. BITMAPINFOHEADER;
  41.  
  42. // relative intensities of red, green, and blue
  43. // https://msdn.microsoft.com/en-us/library/dd162939(v=vs.85).aspx
  44. typedef struct
  45. {
  46.     BYTE rgbtBlue;
  47.     BYTE rgbtGreen;
  48.     BYTE rgbtRed;
  49. } __attribute__((__packed__))
  50. RGBTRIPLE;
  51.