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

📄 pixelbuf.h

📁 hl2 source code. Do not use it illegal.
💻 H
字号:
//-----------------------------------------------------------------------------
// --------------------
// File ....: pixelbuf.h
// --------------------
// Author...: Tom Hudson
// Date ....: Dec. 09, 1995
// Descr....: Pixel Buffer Classes
// Usage....: These templated classes let you set up a buffer for pixels that
//            will automatically clean itself up when it goes out of scope.
//
// History .: Dec. 09 1995 - Started file
//            
//-----------------------------------------------------------------------------

#ifndef __PIXBUF_H__

#define __PIXBUF_H__

// Handy-dandy pixel buffer classes:

template <class T> class PixelBufT {
private:
     T *buf;
     int width;
public:
     inline               PixelBufT(int width) { buf = (T *)calloc(width,sizeof(T)); this->width=width; };
     inline               ~PixelBufT() { if(buf) free(buf); };
     inline   T*          Ptr() { return buf; };
	 inline   T&          operator[](int i) { return buf[i]; }
           int            Fill(int start, int count, T color) {
                          int ix,jx=start+count;
                          if(jx >= width)
                             return 0;
                          for(ix=start; ix<jx; buf[ix++]=color);
                          return 1;
                          };
     };

typedef PixelBufT<UBYTE> PixelBuf8;
typedef PixelBufT<USHORT> PixelBuf16;
typedef PixelBufT<BMM_Color_24> PixelBuf24;
typedef PixelBufT<BMM_Color_32> PixelBuf32;
typedef PixelBufT<BMM_Color_48> PixelBuf48;
typedef PixelBufT<BMM_Color_64> PixelBuf64;

#endif // __PIXBUF_H__

⌨️ 快捷键说明

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