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

📄 ieimage.h

📁 很珍贵得视频编辑器原码及CODEC。需要安装下列CODEC.可播放多种格式的视频
💻 H
字号:
// IEImage.h: interface for the IEImage class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(_IEIMAGE_H_)
#define _IEIMAGE_H_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define limit(a) ( (a > 255) ? 255 : ( (a < 0) ? 0 : a ) )

class IEDib;

template< class T > class IEImage 
{
protected:
	// Stores the width of the current image.
	int     width;

	// Stores the height of the current image.
	int     height;

	// The image data is stored in a contiguous block of memory row by row. 
	// In order to simplify the access to each row, we built an array that stores pointers 
	// to the beginning of each row. The variable #pixels stores a pointer this array. 
	// In other words, the variable #pixels is a pointer to an array of pointers 
	// to each row in the current image. 
	// In this way, one can access the gray level in row i and column j 
	// using one of the following syntax: pixels[i][j] or pixels[0][i * #width + j].
	T**     pixels;

public:
	// Creates an image without allocating space for the image data.
	IEImage();

	// Creates an image of size w x h
	// and allocates space for storing the image data.
	IEImage(int w, int h);

	// Copy constructor.
	IEImage(const IEImage<T>& img);
	
	// Destructor.
	virtual ~IEImage();

public:
	// Allocates a buffer of size w x h x sizeof(T) for storing the image data 
	// and sets the allocated memory to "0". 
	// Sets #pixels to point out to the allocated buffer
	// and sets #ptr to point out to the 2-D interface.
	// If a buffer for storing image data was already allocated, it is freed.
	void    MakeImage(int w, int h);

	// Frees the memory allocated to store the image data.
	void    DestroyImage();

	// Reads an image from file #name and stores it in the buffer pointed out by #pixels;
	// the image format is "guessed" from the file name extension.
	BOOL    ReadImage(char * name);

	// Writes the current image to the file given by #name;
	// the image format is "guessed" from the file name extension.
	BOOL    WriteImage(char * name);

	// Creates an image buffer of size w x h x sizeof(T) 
	// and initializes it with the data in the buffer pointed by data.
	void    SetPixels(int w, int h, T *data);
	
	// Returns a pointer to the actual image buffer.
	T*      GetPixels() { return pixels[0]; }

	// Returns a pointer to the actual image buffer.
	T**     GetPixels2D() { return pixels; }

	// Returns the image width.
	int     GetWidth() const { return width; }

	// Returns the image height.
	int     GetHeight() const { return height; }

	// Returns the image size - w x h.
	int     GetSize() const { return width*height; }

	// Is this validate?
	BOOL    IsValid() const { return (pixels != NULL); }

	// Returns the minimum gray level in the current image.
	T       GetMax();

	// Returns the maximum gray level in the current image.
	T       GetMin();

	// 
	virtual BOOL FromDib(IEDib* pDib);

public:
	// Copy operator
	IEImage< T > &operator=(const IEImage< T > &img); 

	// Tests if two images have the same size and the same content.
	BOOL    operator==(const IEImage< T > &img);

	// Tests if two images are different in size or content.
	BOOL    operator!=(const IEImage< T > &img);

	// Overloaded access operator. Allows the syntax Image[i][j] 
	// for accessing the pixel in the i-th row and j-th column.
	T*      operator[](int i) 
	{
		if ((i > height) || (i < 0))
			return NULL; 
		else	
			return pixels[i];
	}
		
};

#endif // !defined(_IEIMAGE_H_)

⌨️ 快捷键说明

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