bitmap.h

来自「这是整套横扫千军3D版游戏的源码」· C头文件 代码 · 共 77 行

H
77
字号
// Bitmap.h: interface for the CBitmap class.
//
//////////////////////////////////////////////////////////////////////

#ifndef __BITMAP_H__
#define __BITMAP_H__

#include <string>

#include "Platform/Win/win32.h"
#include "Rendering/Textures/nv_dds.h"

using std::string;

class CBitmap  
{
public:
	CBitmap(unsigned char* data,int xsize,int ysize);
	CBitmap();
	CBitmap(const CBitmap& old);
	CBitmap& operator=(const CBitmap& bm);

	virtual ~CBitmap();

	void Alloc(int w,int h);
	bool Load(string const& filename, unsigned char defaultAlpha=255);
	bool LoadGrayscale(string const& filename);
	void Save(string const& filename);

	unsigned int CreateTexture(bool mipmaps=false);
	unsigned int CreateDDSTexture();

	void CreateAlpha(unsigned char red,unsigned char green,unsigned char blue);
	void SetTransparent(unsigned char red, unsigned char green, unsigned char blue);

	void Renormalize(float3 newCol);

	CBitmap GetRegion(int startx, int starty, int width, int height);
	CBitmap CreateMipmapLevel(void);

	unsigned char* mem;
	int xsize;
	int ysize;

	enum BitmapType
	{
		BitmapTypeStandardRGBA,
		BitmapTypeStandardAlpha,
		BitmapTypeDDS
	};

	int type;
	nv_dds::CDDSImage *ddsimage;

public:
	CBitmap CreateRescaled(int newx, int newy);
	void ReverseYAxis();
	void InvertColors();
	void GrayScale();
	void Tint(const float tint[3]);
	
	// Mac Specific (QuickTime Graphics Importer)
#if defined(__APPLE__)
	// Gets data reference including filename that we wan't quicktime to load
	// from (allows us to use the VFS as well as files)
	// NOTE: actually return Handle (defined as char **)
	char **GetPtrDataRef(unsigned char *data, unsigned int size, 
		const std::string &filename);
	// Loads OpenGL Compatable Texture Data From Src Compressed File (not dds)
	unsigned char *LoadTextureData(const std::string &filename, 
		unsigned char *data, unsigned int sizeData, int &xsize, 
		int &ysize, bool &hasAlpha);
#endif /* __APPLE__ */
};

#endif // __BITMAP_H__

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?