⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imagbase.h

📁 3D Game Engine Design Source Code非常棒
💻 H
字号:
#ifndef IMAGBASE_H
#define IMAGBASE_H

#include "lattice.h"
#include "elements.h"
#include "imagfile.h"

class mgcImage : public mgcLattice
{
public:
	// image construction and destruction
	mgcImage (int _type);
	mgcImage (int _type, int _dimensions, const int* initial);
	mgcImage (int _type, int _dimensions, int initial_all);
	mgcImage (int _type, int _dimensions, int initial0, int initial1, ...);
	mgcImage (int _type, const mgcLattice& lattice);
	mgcImage (const mgcImage& image);
	virtual ~mgcImage ();

	// image file access
	mgcImage (char* fname, int trgtype = -1);
	virtual mgcImage& Load (char* fname, int trgtype = -1);
	virtual mgcImage& Save (char* fname, int trgtype = -1);
	virtual mgcImage& SaveAs (char* fname, int ff, int trgtype = -1);

	// image information
	int type, size;
	mgcLattice Lattice () { return *(mgcLattice*)this; }

	// element access
	void* operator() () { return data; }
	mgcElement operator[] (int i);
	mgcElement operator() (int x);
	mgcElement operator() (int x, int y);
	mgcElement operator() (int x, int y, int z);
	mgcElement operator() (int x, int y, int z, int w);
	mgcElement operator() (const mgcCoordinate& coordinate);

	// assignments and comparisons
	int Become (int trgtype);
	mgcImage& operator= (const mgcImage& image);
    mgcImage& operator= (const mgcElement& element);
	int operator== (const mgcImage& image);
	int operator== (const mgcElement& element);
	int operator!= (const mgcImage& image)    { return !( *this == image ); }
	int operator!= (const mgcElement& element) { return !(*this == element); }

	// output of image information
	friend ostream& operator<< (ostream& ostr, const mgcImage& image);

	static int initialize_elements;

private:
	void Create (int _type);
protected:
	char* data;
	mgcElement element;

// error handling
public:
	static int verbose;
	static unsigned error;
	static void Report (ostream& ostr);
private:
	static const unsigned allocation_failed;
	static const unsigned zero_dimension;
    static const unsigned invalid_dimension;
	static const unsigned invalid_type;
	static const unsigned incompatible_types;
	static const unsigned load_failed;
	static const unsigned get_data_failed;
	static const unsigned save_failed;
    static const unsigned put_data_failed;
	static const char* message[9];
	static int Number (unsigned single_error);
	static void Report (unsigned single_error);
};

#endif

⌨️ 快捷键说明

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