imulong.h

来自「《3D游戏引擎设计》的源码」· C头文件 代码 · 共 80 行

H
80
字号
#ifndef IMULONG_H
#define IMULONG_H

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

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

	// image file access
	mgcImageUlong (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
	unsigned long* operator() () { return (unsigned long*)data; }
	unsigned long& operator[] (int i) const
		{ return *(unsigned long*)(data+size*i); }
	unsigned long& operator() (int x) const
		{ return *(unsigned long*)(data+size*x); }
	unsigned long& operator() (int x, int y) const
		{ return *(unsigned long*)(data+size*Index(x,y)); }
	unsigned long& operator() (int x, int y, int z) const
		{ return *(unsigned long*)(data+size*Index(x,y,z)); }
	unsigned long& operator() (int x, int y, int z, int w) const
		{ return *(unsigned long*)(data+size*Index(x,y,z,w)); }
	unsigned long& operator() (const mgcCoordinate& coordinate) const
		{ return *(unsigned long*)(data+size*Index(coordinate)); }

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

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

protected:
	unsigned long 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 get_data_failed;
	static const unsigned put_data_failed;
	static const unsigned load_failed;
	static const unsigned save_failed;
	static const char* message[7];
	static int Number (unsigned single_error);
	static void Report (unsigned single_error);
};

#endif


⌨️ 快捷键说明

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