home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / RAYTRACE / RT / GBM.H < prev    next >
C/C++ Source or Header  |  1994-04-10  |  2KB  |  77 lines

  1. /*
  2.  
  3. GBM.H  General Bitmap Code
  4.  
  5. Data is stored as an array of lines.
  6. Lines are stored with bottom line first, moving upwards.
  7. Each line is an array of pixels, leftmost first.
  8. Lines are padded to be a multiple of a dword long.
  9. Palettised pixels are either a 1 bit, 4 bit, or 8 bit indexes.
  10. Alternately a B, G, R triple in that order is stored.
  11. This format exactly matches the format used by OS/2 and Windows bitmaps.
  12.  
  13. One notable point: a 1 in a 1bpp image denotes colour 1, as found by
  14. looking at palette entry 1. Data is not inverse when passed to and from GBM.
  15.  
  16. */
  17.  
  18. #ifndef GBM_H
  19. #define    GBM_H
  20.  
  21. typedef int GBM_ERR;
  22. #define    GBM_ERR_OK        ((GBM_ERR) 0)
  23. #define    GBM_ERR_MEM        ((GBM_ERR) 1)
  24. #define    GBM_ERR_NOT_SUPP    ((GBM_ERR) 2)
  25. #define    GBM_ERR_BAD_OPTION    ((GBM_ERR) 3)
  26. #define    GBM_ERR_NOT_FOUND    ((GBM_ERR) 4)
  27. #define    GBM_ERR_BAD_MAGIC    ((GBM_ERR) 5)
  28. #define    GBM_ERR_BAD_SIZE    ((GBM_ERR) 6)
  29. #define    GBM_ERR_READ        ((GBM_ERR) 7)
  30. #define    GBM_ERR_WRITE        ((GBM_ERR) 8)
  31.  
  32. #define    GBM_FT_R1        0x0001
  33. #define    GBM_FT_R4        0x0002
  34. #define    GBM_FT_R8        0x0004
  35. #define    GBM_FT_R24        0x0008
  36. #define    GBM_FT_W1        0x0010
  37. #define    GBM_FT_W4        0x0020
  38. #define    GBM_FT_W8        0x0040
  39. #define    GBM_FT_W24        0x0080
  40.  
  41. typedef struct
  42.     {
  43.     char *short_name;        /* Eg: "Targa"                       */
  44.     char *long_name;        /* Eg: "Truevision Targa / Vista"    */
  45.     char *extensions;        /* Eg: "TGA VST"                     */
  46.     int flags;            /* What functionality exists         */
  47.     } GBMFT;
  48.  
  49. typedef struct { byte r, g, b; } GBMRGB;
  50.  
  51. #define    PRIV_SIZE 2000
  52.  
  53. typedef struct
  54.     {
  55.     int w, h, bpp;            /* Bitmap dimensions                 */
  56.     byte priv [PRIV_SIZE];        /* Private internal buffer           */
  57.     } GBM;
  58.  
  59. #ifndef _GBM_
  60.  
  61. GBM_ERR gbm_init(void);
  62. GBM_ERR gbm_deinit(void);
  63.  
  64. GBM_ERR gbm_query_n_filetypes(int *n_ft);
  65. GBM_ERR gbm_query_filetype(int ft, GBMFT *gbmft);
  66. GBM_ERR gbm_guess_filetype(char *fn, int *ft);
  67.  
  68. GBM_ERR gbm_read_header(char *fn, int fd, int ft, GBM *gbm, char *opt);
  69. GBM_ERR gbm_read_palette(int fd, int ft, GBM *gbm, GBMRGB *gbmrgb);
  70. GBM_ERR gbm_read_data(int fd, int ft, GBM *gbm, byte *data);
  71. GBM_ERR gbm_write(char *fn, int fd, int ft, GBM *gbm, GBMRGB *gbmrgb, byte *data, char *opt);
  72. char *gbm_err(GBM_ERR rc);
  73.  
  74. #endif
  75.  
  76. #endif
  77.