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

A generic to access sub-byte mask bitmap data. More...

#include <mask_bitmap_access.h>

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

Public Member Functions

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...
 

Protected Attributes

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...
 

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)
 

Detailed Description

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

A generic to access sub-byte mask bitmap data.

Definition at line 83 of file mask_bitmap_access.h.

Constructor & Destructor Documentation

◆ LookupMaskScanner()

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

Definition at line 171 of file mask_bitmap_access.h.

171  :
172  MaskScanner<num_bits>(bitmap)
173  {
174  goTo(x, y);
175  }
void goTo(int x, int y)
Changes current position.
jobject jlong jint jint y
jobject jlong jint x
Beatmup::InternalBitmap * bitmap

Member Function Documentation

◆ getValue() [1/3]

template<const int num_bits, const int lookup>
unsigned char Beatmup::LookupMaskScanner< num_bits, lookup >::getValue ( ) const
inline

Returns 0..MAX_UNNORM_VALUE value at current position.

Definition at line 90 of file mask_bitmap_access.h.

90  {
91  return ((*this->ptr) >> this->bit) & this->MAX_UNNORM_VALUE;
92  }
unsigned char bit
current position bit
unsigned char * ptr
pointer to current pixel

◆ getValue() [2/3]

template<const int num_bits, const int lookup>
unsigned char Beatmup::LookupMaskScanner< num_bits, lookup >::getValue ( int  x,
int  y 
) const
inline

Returns 0..MAX_UNNORM_VALUE value at (x,y) position.

Definition at line 97 of file mask_bitmap_access.h.

97  {
98  msize n = (this->width*y + x);
99  uint8_t
100  *p = this->data + n / pointsPerByte,
101  b = (unsigned char)(n % pointsPerByte);
102  return ((*p) >> (b*num_bits)) & this->MAX_UNNORM_VALUE;
103  }
unsigned char * data
all bitmap data
uint32_t msize
memory size
Definition: basic_types.h:30
jobject jlong jint jint jint jint jint b
Beatmup::IntPoint p((int) x,(int) y)
int n

◆ getValue() [3/3]

template<const int num_bits, const int lookup>
unsigned char Beatmup::LookupMaskScanner< num_bits, lookup >::getValue ( int  i) const
inline

Returns 0..MAX_UNNORM_VALUE value at position shifted by i pixels in scanline order with respect to the current position.

Definition at line 109 of file mask_bitmap_access.h.

109  {
110  int n = this->bit / num_bits + i;
111  uint8_t
112  *p = this->ptr + n / pointsPerByte,
113  b = (unsigned char)(n % pointsPerByte);
114  return ((*p) >> (b*num_bits)) & this->MAX_UNNORM_VALUE;
115  }

◆ operator()() [1/2]

template<const int num_bits, const int lookup>
pixint1 Beatmup::LookupMaskScanner< num_bits, lookup >::operator() ( ) const
inline

Returns 0..255 value at current position.

Definition at line 120 of file mask_bitmap_access.h.

120  {
121  return pixint1{ lookup[getValue()] };
122  }
unsigned char getValue() const
Returns 0..MAX_UNNORM_VALUE value at current position.

◆ operator()() [2/2]

template<const int num_bits, const int lookup>
pixint1 Beatmup::LookupMaskScanner< num_bits, lookup >::operator() ( int  x,
int  y 
) const
inline

Returns 0..255 value at (x,y) position.

Definition at line 127 of file mask_bitmap_access.h.

127  {
128  return pixint1{ lookup[getValue(x, y)] };
129  }

◆ operator[]()

template<const int num_bits, const int lookup>
const pixint1 Beatmup::LookupMaskScanner< num_bits, lookup >::operator[] ( int  i) const
inline

Returns 0..255 value at position shifted by i pixels in scanline order with respect to the current position.

Definition at line 134 of file mask_bitmap_access.h.

134  {
135  return pixint1{ lookup[getValue(i)] };
136  }

◆ operator++()

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskScanner< num_bits, lookup >::operator++ ( int  )
inline

Move the current position ONE PIXEL forward.

Definition at line 141 of file mask_bitmap_access.h.

141  {
142  // int argument here is to declare the postfix increment (a C++ convention)
143  if ((this->bit += num_bits) >= 8) {
144  this->ptr++;
145  this->bit = 0;
146  }
147  }

◆ operator+=()

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskScanner< num_bits, lookup >::operator+= ( const int  N)
inline

Move the current position N pixels forward.

Definition at line 152 of file mask_bitmap_access.h.

152  {
153  this->bit += N*num_bits;
154  this->ptr += this->bit / 8;
155  this->bit = this->bit % 8;
156  }

◆ goTo()

template<const int num_bits, const int lookup>
void Beatmup::LookupMaskScanner< num_bits, lookup >::goTo ( int  x,
int  y 
)
inline

Changes current position.

Definition at line 161 of file mask_bitmap_access.h.

161  {
162 #ifdef BEATMUP_DEBUG
163  DebugAssertion::check(x >= 0 && y >= 0 && x < this->width && y < this->height,
164  "Coordinates outside of image: %d %d (width=%d, height=%d)", x, y, this->width, this->height);
165 #endif
166  msize n = (this->width*y + x);
167  this->ptr = this->data + n / pointsPerByte,
168  this->bit = (unsigned char)(n % pointsPerByte) * num_bits;
169  }
int height
bitmap size in pixels

Member Data Documentation

◆ pointsPerByte

template<const int num_bits, const int lookup>
const int Beatmup::LookupMaskScanner< num_bits, lookup >::pointsPerByte = 8 / num_bits
protected

Definition at line 85 of file mask_bitmap_access.h.


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