source: golgotha/src/maxtool/sdk_inc/pixelbuf.h @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 12 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1//-----------------------------------------------------------------------------
2// --------------------
3// File ....: pixelbuf.h
4// --------------------
5// Author...: Tom Hudson
6// Date ....: Dec. 09, 1995
7// Descr....: Pixel Buffer Classes
8// Usage....: These templated classes let you set up a buffer for pixels that
9//            will automatically clean itself up when it goes out of scope.
10//
11// History .: Dec. 09 1995 - Started file
12//           
13//-----------------------------------------------------------------------------
14
15#ifndef __PIXBUF_H__
16
17#define __PIXBUF_H__
18
19// Handy-dandy pixel buffer classes:
20
21template <class T> class PixelBufT {
22private:
23     T *buf;
24     int width;
25public:
26     inline               PixelBufT(int width) { buf = (T *)calloc(width,sizeof(T)); this->width=width; };
27     inline               ~PixelBufT() { if(buf) free(buf); };
28     inline   T*          Ptr() { return buf; };
29         inline   T&          operator[](int i) { return buf[i]; }
30           int            Fill(int start, int count, T color) {
31                          int ix,jx=start+count;
32                          if(jx >= width)
33                             return 0;
34                          for(ix=start; ix<jx; buf[ix++]=color);
35                          return 1;
36                          };
37     };
38
39typedef PixelBufT<UBYTE> PixelBuf8;
40typedef PixelBufT<USHORT> PixelBuf16;
41typedef PixelBufT<BMM_Color_24> PixelBuf24;
42typedef PixelBufT<BMM_Color_32> PixelBuf32;
43typedef PixelBufT<BMM_Color_48> PixelBuf48;
44typedef PixelBufT<BMM_Color_64> PixelBuf64;
45
46#endif // __PIXBUF_H__
Note: See TracBrowser for help on using the repository browser.