Beatmup
Beatmup::CustomBitmapScanner< pixel, num_channels > Class Template Reference

A generic to access bitmap data. More...

#include <bitmap_access.h>

Public Types

typedef pixel pixvaltype
 

Public Member Functions

bool operator< (const CustomBitmapScanner &another) const
 
pixel * operator* () const
 
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...
 
int getWidth () const
 Returns bitmap width in pixels. More...
 
int getHeight () const
 Returns bitmap height in pixels. More...
 
 CustomBitmapScanner (const AbstractBitmap &bitmap, int x=0, int y=0)
 

Public Attributes

const int NUMBER_OF_CHANNELS = num_channels
 

Protected Member Functions

pixel * jump (int x, int y) const
 Retrieves pixel address at a given position;. More...
 

Protected Attributes

pixel * data
 bitmap data More...
 
pixel * ptr
 pointer to the current pixel More...
 
int width
 
int height
 bitmap sizes in pixels More...
 

Detailed Description

template<typename pixel, const int num_channels>
class Beatmup::CustomBitmapScanner< pixel, num_channels >

A generic to access bitmap data.

Definition at line 66 of file bitmap_access.h.

Member Typedef Documentation

◆ pixvaltype

template<typename pixel , const int num_channels>
typedef pixel Beatmup::CustomBitmapScanner< pixel, num_channels >::pixvaltype

Definition at line 79 of file bitmap_access.h.

Constructor & Destructor Documentation

◆ CustomBitmapScanner()

template<typename pixel , const int num_channels>
Beatmup::CustomBitmapScanner< pixel, num_channels >::CustomBitmapScanner ( const AbstractBitmap bitmap,
int  x = 0,
int  y = 0 
)
inline

Definition at line 130 of file bitmap_access.h.

130  {
131 #ifdef BEATMUP_DEBUG
132  DebugAssertion::check(
133  bitmap.getBitsPerPixel() == 8* num_channels * sizeof(pixel),
134  "Invalid bitmap scanner"
135  );
136 #endif
137  width = bitmap.getWidth();
138  height = bitmap.getHeight();
139  data = (pixel*)bitmap.getData(0, 0);
140  goTo(x, y);
141  }
const unsigned char getBitsPerPixel() const
Returns number of bits per pixel stored in each bitmap.
void goTo(int x, int y)
Changes current position.
pixel * data
bitmap data
Definition: bitmap_access.h:68
int height
bitmap sizes in pixels
Definition: bitmap_access.h:70
const pixbyte * getData(int x, int y) const
Returns a pointer to given pixel.
const int getHeight() const
Height of the texture in pixels.
const int getWidth() const
Width of the texture in pixels.
jobject jlong jint jint y
jobject jlong jint x
Beatmup::InternalBitmap * bitmap

Member Function Documentation

◆ jump()

template<typename pixel , const int num_channels>
pixel* Beatmup::CustomBitmapScanner< pixel, num_channels >::jump ( int  x,
int  y 
) const
inlineprotected

Retrieves pixel address at a given position;.

Definition at line 75 of file bitmap_access.h.

75  {
76  return data + num_channels*(width*y + x);
77  }

◆ operator<()

template<typename pixel , const int num_channels>
bool Beatmup::CustomBitmapScanner< pixel, num_channels >::operator< ( const CustomBitmapScanner< pixel, num_channels > &  another) const
inline

Definition at line 83 of file bitmap_access.h.

83  {
84  return ptr < another.ptr;
85  }
pixel * ptr
pointer to the current pixel
Definition: bitmap_access.h:69

◆ operator*()

template<typename pixel , const int num_channels>
pixel* Beatmup::CustomBitmapScanner< pixel, num_channels >::operator* ( ) const
inline

Definition at line 87 of file bitmap_access.h.

87  {
88  return ptr;
89  }

◆ operator++()

template<typename pixel , const int num_channels>
void Beatmup::CustomBitmapScanner< pixel, num_channels >::operator++ ( int  )
inline

Move the current position ONE PIXEL forward.

Definition at line 94 of file bitmap_access.h.

94  {
95  // int argument here is to declare the postfix increment (a C++ convention)
96  ptr += num_channels;
97  }

◆ operator+=()

template<typename pixel , const int num_channels>
void Beatmup::CustomBitmapScanner< pixel, num_channels >::operator+= ( const int  n)
inline

Move the current position N pixels forward.

Definition at line 102 of file bitmap_access.h.

102  {
103  ptr += num_channels * n;
104  }
int n

◆ goTo()

template<typename pixel , const int num_channels>
void Beatmup::CustomBitmapScanner< pixel, num_channels >::goTo ( int  x,
int  y 
)
inline

Changes current position.

Definition at line 109 of file bitmap_access.h.

109  {
110 #ifdef BEATMUP_DEBUG
111  DebugAssertion::check(x >= 0 && y >= 0 && x < width && y < height, "Coordinates outside of image: %d %d (width=%d, height=%d)", x, y, width, height);
112 #endif
113  ptr = data + num_channels*(width*y + x);
114  }

◆ getWidth()

template<typename pixel , const int num_channels>
int Beatmup::CustomBitmapScanner< pixel, num_channels >::getWidth ( ) const
inline

Returns bitmap width in pixels.

Definition at line 119 of file bitmap_access.h.

119  {
120  return width;
121  }

◆ getHeight()

template<typename pixel , const int num_channels>
int Beatmup::CustomBitmapScanner< pixel, num_channels >::getHeight ( ) const
inline

Returns bitmap height in pixels.

Definition at line 126 of file bitmap_access.h.

126  {
127  return height;
128  }

Member Data Documentation

◆ data

template<typename pixel , const int num_channels>
pixel* Beatmup::CustomBitmapScanner< pixel, num_channels >::data
protected

bitmap data

Definition at line 68 of file bitmap_access.h.

◆ ptr

template<typename pixel , const int num_channels>
pixel* Beatmup::CustomBitmapScanner< pixel, num_channels >::ptr
protected

pointer to the current pixel

Definition at line 69 of file bitmap_access.h.

◆ width

template<typename pixel , const int num_channels>
int Beatmup::CustomBitmapScanner< pixel, num_channels >::width
protected

Definition at line 70 of file bitmap_access.h.

◆ height

template<typename pixel , const int num_channels>
int Beatmup::CustomBitmapScanner< pixel, num_channels >::height
protected

bitmap sizes in pixels

Definition at line 70 of file bitmap_access.h.

◆ NUMBER_OF_CHANNELS

template<typename pixel , const int num_channels>
const int Beatmup::CustomBitmapScanner< pixel, num_channels >::NUMBER_OF_CHANNELS = num_channels

Definition at line 81 of file bitmap_access.h.


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