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

📄 imint.h

📁 《3D游戏引擎设计》的源码
💻 H
字号:
#ifndef IMINT_H
#define IMINT_H

#include "imagbase.h"
#include "imagfile.h"

class mgcImageInt : public mgcImage
{
// object information
public:
	// image creation
	mgcImageInt ();
	mgcImageInt (int _dimensions, const int* initial);
	mgcImageInt (int _dimensions, int initial_all);
	mgcImageInt (int _dimensions, int initial0, int initial1, ...);
	mgcImageInt (const mgcImage& image);
	mgcImageInt (const mgcLattice& lattice);

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

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

	// assignments and comparisons
    mgcImageInt& operator= (const mgcImageInt& image);
	mgcImageInt& operator= (const mgcImage& image);
	mgcImageInt& operator= (int value);
	int operator== (const mgcImage& image);
	int operator== (int value);
	int operator!= (const mgcImage& image)  { return !( *this == image ); }
	int operator!= (int value)  { return !( *this == value ); }

	// arithmetic updates
	static int zero_divide_result;
	mgcImageInt& operator+= (const mgcImageInt &image);
	mgcImageInt& operator-= (const mgcImageInt &image);
	mgcImageInt& operator*= (const mgcImageInt &image);
	mgcImageInt& operator/= (const mgcImageInt &image);
	mgcImageInt& operator+= (int value);
	mgcImageInt& operator-= (int value);
	mgcImageInt& operator*= (int value);
	mgcImageInt& operator/= (int value);

	// arithmetic operations
	mgcImageInt operator- ();
	mgcImageInt operator+ (const mgcImageInt &image);
	mgcImageInt operator- (const mgcImageInt &image);
	mgcImageInt operator* (const mgcImageInt &image);
	mgcImageInt operator/ (const mgcImageInt &image);
	mgcImageInt operator+ (int value);
	mgcImageInt operator- (int value);
	mgcImageInt operator* (int value);
	mgcImageInt operator/ (int value);
	friend mgcImageInt operator+ (int value, mgcImageInt &image);
	friend mgcImageInt operator- (int value, mgcImageInt &image);
	friend mgcImageInt operator* (int value, mgcImageInt &image);
	friend mgcImageInt operator/ (int value, mgcImageInt &image);

	// pixel statistics
	int Min () const { return minimum; }
	int Max () const { return maximum; }
	void Min (int value)  { minimum = value; }
	void Max (int value)  { maximum = value; }
	void ComputeMaxMin ();

protected:
	int minimum, maximum;

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

#endif


⌨️ 快捷键说明

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