lugre_bitmask.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef LUGRE_BITMASK_H
00025 #define LUGRE_BITMASK_H
00026
00027 #include "lugre_smartptr.h"
00028 #include <Ogre.h>
00029
00030 class lua_State;
00031
00032 namespace Lugre {
00033
00035 class cBitMask : public cSmartPointable { public:
00036 char* mpData;
00037 int miW;
00038 int miH;
00039 bool mbWrap;
00040 cBitMask ();
00041 virtual ~cBitMask ();
00042 void SetDataFromOgreImage (Ogre::Image& pImage,float fMinAlpha=0.5);
00043 void SetDataFrom16BitImage (const short *pImageData16Bit,const int w,const int h);
00044 void Reset ();
00045 void BlankData (const int w,const int h);
00046 inline bool GetWrap () { return mbWrap; }
00047 inline void SetWrap (const bool bWrap) { mbWrap = bWrap; }
00048 inline bool TestBit (int x,int y) {
00049 if (mbWrap) {
00050 while (x < 0) x += miW; x = x % miW;
00051 while (y < 0) y += miH; y = y % miH;
00052 } else if (x < 0 || x >= miW || y < 0 || y >= miH) return false;
00053 int iPixelOffset = y*miW+x;
00054 return mpData[iPixelOffset/8] & (1<<(iPixelOffset%8));
00055 }
00056
00057
00058 static void LuaRegister (lua_State *L);
00059 };
00060
00061 };
00062
00063 #endif