1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#pragma once
#include "common.h"
class Bitmap {
public:
Bitmap();
~Bitmap();
void Free();
BOOL AllocateHeader();
void SetErrorCode(int code);
BOOL SetHeader(const Bitmap *other);
BOOL LoadFile(const char *path);
BOOL InitHeader(int width, int height);
BOOL InitGreyscalePalette();
BOOL Allocate(int width, int height);
void Draw(HDC dc, int x, int y);
void Draw(HDC dc, const RECT &rect);
HPALETTE CreatePalette();
BOOL DrawBitmap(const Bitmap *bmp, RECT srcRect, RECT destRect);
BOOL DrawBitmap(const Bitmap *bmp, RECT srcRect, RECT destRect, BYTE transparentCol);
BOOL SetPalette(const Bitmap *other);
BYTE GetPixel(int x, int y) const;
int GetPixel(POINT pt) const;
void SetRect(int left, int top, int right, int bottom);
void SetDefaultRect();
int GetHeight() const;
int GetWidth() const;
int GetBitmapHeaderSize() const { return sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256; }
RGBQUAD *GetColors() { return mBitmap->bmiColors; }
protected:
BITMAPINFO *mBitmap;
BYTE *mPixels;
RGBQUAD *mColors;
int mErrorCode;
RECT mRect;
};
|