bitmap.h
来自「3D数学基础:图形与游戏开发书籍源码,里面有很多实用的代码,对做3D的同志很有意」· C头文件 代码 · 共 78 行
H
78 行
/////////////////////////////////////////////////////////////////////////////
//
// 3D Math Primer for Games and Graphics Development
//
// Bitmap.h - Simple bitmap loader
//
// Visit gamemath.com for the latest version of this file.
//
/////////////////////////////////////////////////////////////////////////////
#ifndef __BITMAP_H_INCLUDED__
#define __BITMAP_H_INCLUDED__
/////////////////////////////////////////////////////////////////////////////
//
// class Bitmap - a simple class to hold a bitmap image
//
/////////////////////////////////////////////////////////////////////////////
class Bitmap {
public:
// An enum to describe the format of the image
enum EFormat {
eFormat_None, // dummy placeholder value
eFormat_8888, // 32-bit ARGB
// !KLUDGE! FOr now, this is all we'll support.
};
// Constructor/destructor
Bitmap();
~Bitmap();
// Memory management
void allocateMemory(int xs, int ys, EFormat format);
void freeMemory();
// Accessors
int xSize() const { return sizeX; }
int ySize() const { return sizeY; }
EFormat format() const { return fmt; }
void *rawData() const { return data; }
// Access to the pixel data. Colors are specified using
// the standard 0xAARRGGBB format used by class Renderer
unsigned getPix(int x, int y) const;
void setPix(int x, int y, unsigned argb);
// Load a bitmap from an image file. Uses the extension to
// figure out how to load.
bool load(const char *filename, char *returnErrMsg);
// Load a specific file format.
bool loadTGA(const char *filename, char *returnErrMsg);
bool loadBMP(const char *filename, char *returnErrMsg);
private:
int sizeX;
int sizeY;
EFormat fmt;
void *data;
};
/////////////////////////////////////////////////////////////////////////////
#endif // #ifndef __BITMAP_H_INCLUDED__
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?