gvsu/cs677/pa3/BMP.h
josh 5cd2b95b00 BMP copying working
git-svn-id: svn://anubis/gvsu@203 45c1a28c-8058-47b2-ae61-ca45b979098e
2008-10-20 02:40:19 +00:00

50 lines
1.2 KiB
C++

// BMP.h
// extracts/inserts data from/into .bmp file
// Adapted by Josh Holtrop from the original access_bmp.c by gw
// Supports reading and creating 24-bit color BMP images
#include <stdio.h>
class BMP
{
public:
typedef struct
{
char id[2];
int file_size;
int reserved;
int offset;
} __attribute__ ((packed)) header_t;
typedef struct
{
int header_size;
int width;
int height;
unsigned short int color_planes;
unsigned short int color_depth;
unsigned int compression;
int image_size;
int xresolution;
int yresolution;
int num_colors;
int num_important_colors;
} __attribute__ ((packed)) info_t;
BMP(const char * fileName);
BMP(const char * fileName, int width, int height, unsigned char * data);
~BMP();
void read(unsigned char * buf);
int getWidth() { return m_info.width; }
int getHeight() { return m_info.height; }
private:
FILE * m_fp;
header_t m_header;
info_t m_info;
bool open(const char * fileName);
bool create(const char * fileName, int width, int height, unsigned char * data);
void close();
};