typedef struct tagBITMAPFILEHEADER { WORD bfType; DWORD bfSize; WORD bfReserved1; WORD bfReserved2; DWORD bfOffBits; } BITMAPFILEHEADER, *PBITMAPFILEHEADER; |
typedef struct tagBITMAPINFO { BITMAPINFOHEADER bmiHeader; RGBQUAD bmiColors[1]; } |
typedef struct tagBITMAPINFOHEADER{ DWORD biSize; LONG biWidth; LONG biHeight; WORD biPlanes; WORD biBitCount; DWORD biCompression; DWORD biSizeImage; LONG biXPelsPerMeter; LONG biYPelsPerMeter; DWORD biClrUsed; DWORD biClrImportant; } BITMAPINFOHEADER, FAR *LPBITMAPINFOHEADER, *PBITMAPINFOHEADER; |
typedef struct tagRGBQUAD { // rgbq BYTE rgbBlue; BYTE rgbGreen; BYTE rgbRed; BYTE rgbReserved; } RGBQUAD; |
#include<windows.h> #include"Image.h" int Image::loadBitmap() { fp = CreateFile("test.bmp",GENERIC_READ,0,NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL); if (fp == INVALID_HANDLE_VALUE) { return -1; } temp = (LPBYTE)GlobalAlloc(GPTR,GetFileSize(fp,NULL)); ReadFile(fp,temp,GetFileSize(fp,NULL),&dummy,NULL); CloseHandle(fp); bitmap_head=(LPBITMAPFILEHEADER)temp; bitmap_info=(LPBITMAPINFO)(temp+sizeof(BITMAPFILEHEADER)); bitmap_map = temp+bitmap_head->bfOffBits; return 0; } BITMAPINFO Image::getBitmapInfo() { return *bitmap_info; } unsigned char* Image::getBitmapMap() { return (unsigned char*)bitmap_map; }うん、こちらの方が簡単だ!!。上のクラスは適当ですので絶対に参考にはしてはいけません。参考サイトの方に 行ってください。