Beatmup
Beatmup::LookupMaskWriter< num_bits, lookup > Class Template Reference

A generic to write mask bitmap data lookup tables for masks values. More...

#include <mask_bitmap_access.h>

Inheritance diagram for Beatmup::LookupMaskWriter< num_bits, lookup >:
Beatmup::LookupMaskScanner< num_bits, lookup > Beatmup::BitmapContentModifier Beatmup::MaskScanner< num_bits >

Public Member Functions

void putValue (unsigned char x)
 Puts a properly scaled (0..MAX_UNNORM_VALUE) value at the current position. More...
 
unsigned char assign (int x)
 Puts an unscaled (0..255) value at the current position. More...
 
unsigned char assign (int r, int g, int b)
 
unsigned char assign (int r, int g, int b, int a)
 
unsigned char assign (float x)
 
unsigned char assign (float r, float g, float b)
 
unsigned char assign (float r, float g, float b, float a)
 
void operator<< (const pixint1 &P)
 
void operator<< (const pixint3 &P)
 
void operator<< (const pixint4 &P)
 
void operator<< (const pixfloat1 &P)
 
void operator<< (const pixfloat3 &P)
 
void operator<< (const pixfloat4 &P)
 
void operator= (const pixint1 &P)
 
void operator= (const pixint3 &P)
 
void operator= (const pixint4 &P)
 
void operator= (const pixfloat1 &P)
 
void operator= (const pixfloat3 &P)
 
void operator= (const pixfloat4 &P)
 
 LookupMaskWriter (AbstractBitmap &bitmap, int x=0, int y=0)
 
- Public Member Functions inherited from Beatmup::LookupMaskScanner< num_bits, lookup >
unsigned char getValue () const
 Returns 0..MAX_UNNORM_VALUE value at current position. More...
 
unsigned char getValue (int x, int y) const
 Returns 0..MAX_UNNORM_VALUE value at (x,y) position. More...
 
unsigned char getValue (int i) const
 Returns 0..MAX_UNNORM_VALUE value at position shifted by i pixels in scanline order with respect to the current position. More...
 
pixint1 operator() () const
 Returns 0..255 value at current position. More...
 
pixint1 operator() (int x, int y) const
 Returns 0..255 value at (x,y) position. More...
 
const pixint1 operator[] (int i) const
 Returns 0..255 value at position shifted by i pixels in scanline order with respect to the current position. More...
 
void operator++ (int)
 Move the current position ONE PIXEL forward. More...
 
void operator+= (const int N)
 Move the current position N pixels forward. More...
 
void goTo (int x, int y)
 Changes current position. More...
 
 LookupMaskScanner (const AbstractBitmap &bitmap, int x=0, int y=0)
 
- Public Member Functions inherited from Beatmup::MaskScanner< num_bits >
bool operator< (const MaskScanner &another) const
 
pixtypeoperator* () const
 
int getWidth () const
 Returns bitmap width in pixels. More...
 
int getHeight () const
 Returns bitmap height in pixels. More...
 

Additional Inherited Members

- Public Types inherited from Beatmup::MaskScanner< num_bits >
typedef unsigned char pixvaltype
 
typedef pixint1 pixtype
 
- Public Attributes inherited from Beatmup::MaskScanner< num_bits >
const int NUMBER_OF_CHANNELS = 1
 
const int NUMBER_OF_BITS = num_bits
 
const int MAX_VALUE = 255
 
const int MAX_UNNORM_VALUE = (1 << num_bits) - 1
 
- Protected Member Functions inherited from Beatmup::MaskScanner< num_bits >
 MaskScanner (const AbstractBitmap &bitmap)
 
- Protected Attributes inherited from Beatmup::LookupMaskScanner< num_bits, lookup >
const int pointsPerByte = 8 / num_bits
 
- Protected Attributes inherited from Beatmup::MaskScanner< num_bits >
unsigned char * data
 all bitmap data More...
 
unsigned char * ptr
 pointer to current pixel More...
 
unsigned char bit
 current position bit More...
 
int width
 
int height
 bitmap size in pixels More...
 
- Private Member Functions inherited from Beatmup::BitmapContentModifier
 BitmapContentModifier (AbstractBitmap &bitmap)
 

Detailed Description

template<const int num_bits, const int lookup>
class Beatmup::LookupMaskWriter< num_bits, lookup >

A generic to write mask bitmap data lookup tables for masks values.

Definition at line 182 of file mask_bitmap_access.h.

Constructor & Destructor Documentation

◆ LookupMaskWriter()

template<const int num_bits, const int lookup>
Beatmup::LookupMaskWriter< num_bits, lookup >::LookupMaskWriter ( AbstractBitmap bitmap,
int  x = 0,
int  y = 0 
)
inline

Definition at line 271 of file mask_bitmap_access.h.

271 : LookupMaskScanner < num_bits, lookup >(bitmap, x, y), BitmapContentModifier(bitmap) {}
BitmapContentModifier(AbstractBitmap &bitmap)
Definition: bitmap_access.h:60
jobject jlong jint jint y
jobject jlong jint x
Beatmup::InternalBitmap * bitmap

Member Function Documentation

◆ putValue()

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskWriter< num_bits, lookup >::putValue ( unsigned char  x)
inline

Puts a properly scaled (0..MAX_UNNORM_VALUE) value at the current position.

Definition at line 187 of file mask_bitmap_access.h.

187  {
188  *this->ptr = (*this->ptr & ~(this->MAX_UNNORM_VALUE << this->bit)) + (x << this->bit);
189  }
unsigned char bit
current position bit
unsigned char * ptr
pointer to current pixel

◆ assign() [1/6]

template<const int num_bits, const int lookup>
unsigned char Beatmup::LookupMaskWriter< num_bits, lookup >::assign ( int  x)
inline

Puts an unscaled (0..255) value at the current position.

Returns
properly scaled value put into the mask.

Definition at line 195 of file mask_bitmap_access.h.

195  {
196  unsigned char v = x > 0 ? (x < 256 ? x * this->MAX_UNNORM_VALUE / 255 : this->MAX_UNNORM_VALUE) : 0;
197  putValue(v);
198  return v;
199  }
void putValue(unsigned char x)
Puts a properly scaled (0..MAX_UNNORM_VALUE) value at the current position.
JNIEnv jlong jfloat jfloat jfloat v

◆ assign() [2/6]

template<const int num_bits, const int lookup>
unsigned char Beatmup::LookupMaskWriter< num_bits, lookup >::assign ( int  r,
int  g,
int  b 
)
inline

Definition at line 201 of file mask_bitmap_access.h.

201  {
202  return assign((r + g + b) / 3);
203  }
unsigned char assign(int x)
Puts an unscaled (0..255) value at the current position.
jobject jlong jint jint jint jint g
jobject jlong jint jint jint jint jint b
jobject jlong jint jint jint r

◆ assign() [3/6]

template<const int num_bits, const int lookup>
unsigned char Beatmup::LookupMaskWriter< num_bits, lookup >::assign ( int  r,
int  g,
int  b,
int  a 
)
inline

Definition at line 205 of file mask_bitmap_access.h.

205  {
206  return assign(a);
207  }
jobject jlong jint jint jint jint jint jint a

◆ assign() [4/6]

template<const int num_bits, const int lookup>
unsigned char Beatmup::LookupMaskWriter< num_bits, lookup >::assign ( float  x)
inline

Definition at line 209 of file mask_bitmap_access.h.

209  {
210  unsigned char v = x > 0.0f ? (x < 1.0f ? (unsigned char)roundf(x * this->MAX_UNNORM_VALUE) : this->MAX_UNNORM_VALUE) : 0;
211  putValue(v);
212  return v;
213  }

◆ assign() [5/6]

template<const int num_bits, const int lookup>
unsigned char Beatmup::LookupMaskWriter< num_bits, lookup >::assign ( float  r,
float  g,
float  b 
)
inline

Definition at line 215 of file mask_bitmap_access.h.

215  {
216  return assign((r + g + b) / 3);
217  }

◆ assign() [6/6]

template<const int num_bits, const int lookup>
unsigned char Beatmup::LookupMaskWriter< num_bits, lookup >::assign ( float  r,
float  g,
float  b,
float  a 
)
inline

Definition at line 219 of file mask_bitmap_access.h.

219  {
220  return assign(a);
221  }

◆ operator<<() [1/6]

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskWriter< num_bits, lookup >::operator<< ( const pixint1 P)
inline

Definition at line 223 of file mask_bitmap_access.h.

223  {
224  assign(P.x);
225  }

◆ operator<<() [2/6]

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskWriter< num_bits, lookup >::operator<< ( const pixint3 P)
inline

Definition at line 227 of file mask_bitmap_access.h.

227  {
228  assign(P.r, P.g, P.b);
229  }

◆ operator<<() [3/6]

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskWriter< num_bits, lookup >::operator<< ( const pixint4 P)
inline

Definition at line 231 of file mask_bitmap_access.h.

231  {
232  *this->ptr = clipPixint(((P.r + P.g + P.b) * P.a + *this->ptr * (255 - P.a) * 3) / 765);
233  }
pixbyte clipPixint(int x)
Clips an integer pixel value to 0..255 range.

◆ operator<<() [4/6]

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskWriter< num_bits, lookup >::operator<< ( const pixfloat1 P)
inline

Definition at line 235 of file mask_bitmap_access.h.

235  {
236  assign(P.x);
237  }

◆ operator<<() [5/6]

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskWriter< num_bits, lookup >::operator<< ( const pixfloat3 P)
inline

Definition at line 239 of file mask_bitmap_access.h.

239  {
240  assign(P.r, P.g, P.b);
241  }

◆ operator<<() [6/6]

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskWriter< num_bits, lookup >::operator<< ( const pixfloat4 P)
inline

Definition at line 243 of file mask_bitmap_access.h.

243  {
244  *this->ptr = pixfloat2pixbyte((P.r + P.g + P.b) * P.a / 3 + *this->ptr * (1 - P.a));
245  }
pixbyte pixfloat2pixbyte(pixfloat x)
Converts a floating point pixel value to a 0..255 integer.

◆ operator=() [1/6]

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskWriter< num_bits, lookup >::operator= ( const pixint1 P)
inline

Definition at line 247 of file mask_bitmap_access.h.

247  {
248  assign(P.x);
249  }

◆ operator=() [2/6]

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskWriter< num_bits, lookup >::operator= ( const pixint3 P)
inline

Definition at line 251 of file mask_bitmap_access.h.

251  {
252  assign(P.r, P.g, P.b);
253  }

◆ operator=() [3/6]

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskWriter< num_bits, lookup >::operator= ( const pixint4 P)
inline

Definition at line 255 of file mask_bitmap_access.h.

255  {
256  assign(P.r, P.g, P.b, P.a);
257  }

◆ operator=() [4/6]

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskWriter< num_bits, lookup >::operator= ( const pixfloat1 P)
inline

Definition at line 259 of file mask_bitmap_access.h.

259  {
260  assign(P.x);
261  }

◆ operator=() [5/6]

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskWriter< num_bits, lookup >::operator= ( const pixfloat3 P)
inline

Definition at line 263 of file mask_bitmap_access.h.

263  {
264  assign(P.r, P.g, P.b);
265  }

◆ operator=() [6/6]

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskWriter< num_bits, lookup >::operator= ( const pixfloat4 P)
inline

Definition at line 267 of file mask_bitmap_access.h.

267  {
268  assign(P.r, P.g, P.b, P.a);
269  }

The documentation for this class was generated from the following file: