|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef __FILEBMP_INCLUDED__
|
|
Toshihiro Shimizu |
890ddd |
#define __FILEBMP_INCLUDED__
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef __cplusplus
|
|
Toshihiro Shimizu |
890ddd |
extern "C" {
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
#if defined(WIN32)
|
|
Toshihiro Shimizu |
890ddd |
typedef struct {unsigned char b,g,r,m;} LPIXEL;
|
|
Toshihiro Shimizu |
890ddd |
#elif defined(__sgi)
|
|
Toshihiro Shimizu |
890ddd |
typedef struct { unsigned char m,b,g,r; } LPIXEL;
|
|
Toshihiro Shimizu |
890ddd |
#elif defined (LINUX)
|
|
Toshihiro Shimizu |
890ddd |
typedef struct { unsigned char r,g,b,m; } LPIXEL;
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#error Not yet implemented
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
enum BMP_ERROR_CODE {
|
|
Toshihiro Shimizu |
890ddd |
OK,
|
|
Toshihiro Shimizu |
890ddd |
UNSUPPORTED_BMP_FORMAT = -1,
|
|
Toshihiro Shimizu |
890ddd |
OUT_OF_MEMORY = -2,
|
|
Toshihiro Shimizu |
890ddd |
UNEXPECTED_EOF = -3,
|
|
Toshihiro Shimizu |
890ddd |
CANT_OPEN_FILE = -4,
|
|
Toshihiro Shimizu |
890ddd |
WRITE_ERROR = -5
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
typedef const wchar_t *MYSTRING;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int writebmp(const MYSTRING filename, int xsize, int ysize, void *buffer, int bpp);
|
|
Toshihiro Shimizu |
890ddd |
int readbmp(const MYSTRING filename, int *xsize, int *ysize, void **buffer);
|
|
Toshihiro Shimizu |
890ddd |
int readbmpregion(const MYSTRING fname, void **pimg, int x1, int y1, int x2, int y2, int scale);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int readbmp_size(const MYSTRING fname, int *lx, int *ly);
|
|
Toshihiro Shimizu |
890ddd |
int readbmp_bbox(const MYSTRING fname, int *x0, int *y0, int *x1, int *y1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
typedef enum {
|
|
Toshihiro Shimizu |
890ddd |
BMP_NONE,
|
|
Toshihiro Shimizu |
890ddd |
BMP_BW,
|
|
Toshihiro Shimizu |
890ddd |
BMP_GREY16,
|
|
Toshihiro Shimizu |
890ddd |
BMP_GREY16C,
|
|
Toshihiro Shimizu |
890ddd |
BMP_GREY256,
|
|
Toshihiro Shimizu |
890ddd |
BMP_GREY256C,
|
|
Toshihiro Shimizu |
890ddd |
BMP_CMAPPED16,
|
|
Toshihiro Shimizu |
890ddd |
BMP_CMAPPED16C,
|
|
Toshihiro Shimizu |
890ddd |
BMP_CMAPPED256,
|
|
Toshihiro Shimizu |
890ddd |
BMP_CMAPPED256C,
|
|
Toshihiro Shimizu |
890ddd |
BMP_RGB
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} BMP_SUBTYPE;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
typedef struct
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
UINT bfSize;
|
|
Toshihiro Shimizu |
890ddd |
UINT bfOffBits;
|
|
Toshihiro Shimizu |
890ddd |
UINT biSize;
|
|
Toshihiro Shimizu |
890ddd |
UINT biWidth;
|
|
Toshihiro Shimizu |
890ddd |
UINT biHeight;
|
|
Toshihiro Shimizu |
890ddd |
UINT biPlanes;
|
|
Toshihiro Shimizu |
890ddd |
UINT biBitCount;
|
|
Toshihiro Shimizu |
890ddd |
UINT biCompression;
|
|
Toshihiro Shimizu |
890ddd |
UINT biSizeImage;
|
|
Toshihiro Shimizu |
890ddd |
UINT biXPelsPerMeter;
|
|
Toshihiro Shimizu |
890ddd |
UINT biYPelsPerMeter;
|
|
Toshihiro Shimizu |
890ddd |
UINT biClrUsed;
|
|
Toshihiro Shimizu |
890ddd |
UINT biClrImportant;
|
|
Toshihiro Shimizu |
890ddd |
UINT biFilesize;
|
|
Toshihiro Shimizu |
890ddd |
UINT biPad;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} BMP_HEADER;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int load_bmp_header(FILE *fp, BMP_HEADER **pHd);
|
|
Toshihiro Shimizu |
890ddd |
int write_bmp_header(FILE *fp, BMP_HEADER *hd);
|
|
Toshihiro Shimizu |
890ddd |
void release_bmp_header(BMP_HEADER *hd);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int write_bmp_palette(FILE *fp, int nc, UCHAR *b, UCHAR *g, UCHAR *r);
|
|
Toshihiro Shimizu |
890ddd |
int make_bmp_palette(int colors, int grey, UCHAR *r, UCHAR *g, UCHAR *b);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*BMP_SUBTYPE
|
|
Toshihiro Shimizu |
890ddd |
bmp_get_colorstyle(IMAGE *img);*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int error_checking_bmp(BMP_HEADER *hd);
|
|
Toshihiro Shimizu |
890ddd |
int read_bmp_line(FILE *fp, void *line,
|
|
Toshihiro Shimizu |
890ddd |
UINT w, UINT h, UCHAR **mp, BMP_SUBTYPE type);
|
|
Toshihiro Shimizu |
890ddd |
int write_bmp_line(FILE *fp, void *line_buffer,
|
|
Toshihiro Shimizu |
890ddd |
UINT w, UINT row, UCHAR *mp, BMP_SUBTYPE type);
|
|
Toshihiro Shimizu |
890ddd |
int skip_bmp_lines(FILE *fp, UINT w, UINT rows, int whence, BMP_SUBTYPE type);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define BMP_WIN_OS2_OLD 12
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef __cplusplus
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|