Beatmup Java package
Beatmup.Bitmap Class Reference

Bitmap wrapper. More...

Inheritance diagram for Beatmup.Bitmap:
Beatmup.Object Beatmup.Android.Bitmap Beatmup.Android.ExternalBitmap

Classes

class  BadPixelFormat
 CoreException thrown when a native bitmap has incompatible pixel format. More...
 

Public Member Functions

 Bitmap (Context context, int width, int height, PixelFormat pixelFormat)
 Creates new internally managed bitmap. More...
 
int getWidth ()
 
int getHeight ()
 
IntRectangle clientRectangle ()
 
PixelFormat getPixelFormat ()
 
void zero ()
 Sets all bitmap pixels to zero. More...
 
Bitmap clone ()
 
Bitmap clone (PixelFormat pixelFormat)
 
Bitmap copyRegion (IntRectangle region)
 Creates a bitmap containing a copy of a rectangular region. More...
 
void projectOn (Bitmap bitmap, int left, int top)
 Copies a rectangular area to another bitmap. More...
 
void invert ()
 Pixelwise bitmap inversion. More...
 
void pullPixels ()
 Transfers pixel data from GPU to CPU. More...
 

Static Public Member Functions

static Bitmap createEmpty (Bitmap bitmap)
 Creates an empty bitmap of the same size and pixel format as a given bitmap. More...
 

Protected Member Functions

 Bitmap (Context context, android.graphics.Bitmap bitmap) throws BadPixelFormat
 Creates new bitmap from Android bitmap object. More...
 
- Protected Member Functions inherited from Beatmup.Object
synchronized void dispose ()
 Destroys the native object. More...
 

Additional Inherited Members

- Protected Attributes inherited from Beatmup.Object
long handle
 pointer to the native object More...
 

Detailed Description

Bitmap wrapper.

Definition at line 32 of file Bitmap.java.

Constructor & Destructor Documentation

◆ Bitmap() [1/2]

Beatmup.Bitmap.Bitmap ( Context  context,
android.graphics.Bitmap  bitmap 
) throws BadPixelFormat
inlineprotected

Creates new bitmap from Android bitmap object.

NO PIXEL DATA IS COPIED.

Parameters
contextBeatmup context
bitmapsource bitmap
Exceptions
BadPixelFormat

Definition at line 71 of file Bitmap.java.

71  {
72  super(createNativeBitmapEnsuringPixelFormat(context, bitmap));
73  this.context = context;
74  context.watchBitmap(this);
75  }
void watchBitmap(Bitmap bitmap)
Adds a bitmap to the watch list.
Definition: Context.java:230

◆ Bitmap() [2/2]

Beatmup.Bitmap.Bitmap ( Context  context,
int  width,
int  height,
PixelFormat  pixelFormat 
)
inline

Creates new internally managed bitmap.

Parameters
contextBeatmup context
widthbitmap width in pixels
heightbitmap height in pixels
pixelFormatbitmap pixel format

Definition at line 85 of file Bitmap.java.

85  {
86  super(newInternalBitmap(context, width, height, pixelFormat.ordinal()));
87  this.context = context;
88  context.watchBitmap(this);
89  }

Member Function Documentation

◆ createEmpty()

static Bitmap Beatmup.Bitmap.createEmpty ( Bitmap  bitmap)
inlinestatic

Creates an empty bitmap of the same size and pixel format as a given bitmap.

Parameters
bitmapthe bitmap specifying size and pixel format
Returns
the new bitmap

Definition at line 113 of file Bitmap.java.

113  {
114  return new Bitmap(bitmap.context, bitmap.getWidth(), bitmap.getHeight(), bitmap.getPixelFormat());
115  }

◆ getWidth()

int Beatmup.Bitmap.getWidth ( )
inline
Returns
bitmap width in pixels

Definition at line 121 of file Bitmap.java.

121  {
122  return getWidth(handle);
123  }
int getWidth()
Definition: Bitmap.java:121
long handle
pointer to the native object
Definition: Object.java:25

◆ getHeight()

int Beatmup.Bitmap.getHeight ( )
inline
Returns
bitmap height in pixels

Definition at line 129 of file Bitmap.java.

129  {
130  return getHeight(handle);
131  }
int getHeight()
Definition: Bitmap.java:129

◆ clientRectangle()

IntRectangle Beatmup.Bitmap.clientRectangle ( )
inline
Returns
bitmap border rectangle in pixels

Definition at line 137 of file Bitmap.java.

137  {
138  return new IntRectangle(0, 0, getWidth()-1, getHeight()-1);
139  }

◆ getPixelFormat()

PixelFormat Beatmup.Bitmap.getPixelFormat ( )
inline
Returns
bitmap pixel format

Definition at line 145 of file Bitmap.java.

145  {
146  return PixelFormat.values()[ getPixelFormat(handle) ];
147  }
PixelFormat getPixelFormat()
Definition: Bitmap.java:145

◆ zero()

void Beatmup.Bitmap.zero ( )
inline

Sets all bitmap pixels to zero.

Definition at line 153 of file Bitmap.java.

153  {
154  zero(handle);
155  }
void zero()
Sets all bitmap pixels to zero.
Definition: Bitmap.java:153

◆ clone() [1/2]

Bitmap Beatmup.Bitmap.clone ( )
inline
Returns
copy of this bitmap

Reimplemented in Beatmup.Android.Bitmap.

Definition at line 166 of file Bitmap.java.

166  {
167  return context.copyBitmap(this, getPixelFormat());
168  }

◆ clone() [2/2]

Bitmap Beatmup.Bitmap.clone ( PixelFormat  pixelFormat)
inline
Returns
copy of this bitmap with a different pixel format

Definition at line 174 of file Bitmap.java.

174  {
175  return context.copyBitmap(this, pixelFormat);
176  }

◆ copyRegion()

Bitmap Beatmup.Bitmap.copyRegion ( IntRectangle  region)
inline

Creates a bitmap containing a copy of a rectangular region.

Parameters
regionthe region to copy
Returns
the new bitmap

Definition at line 184 of file Bitmap.java.

184  {
185  Bitmap copy = Bitmap.createByteAligned(context, region.getWidth(), region.getHeight(), getPixelFormat());
186  if (copy.getWidth() != region.getWidth())
187  copy.zero();
188  crop(handle, copy.handle, region.x1, region.y1, region.x2, region.y2, 0, 0);
189  return copy;
190  }

◆ projectOn()

void Beatmup.Bitmap.projectOn ( Bitmap  bitmap,
int  left,
int  top 
)
inline

Copies a rectangular area to another bitmap.

The area size is equal to the target bitmap size.

Parameters
bitmapthe target bitmap
leftsource area top-left corner horizontal position in pixels
topsource area top-left corner vertical position in pixels

Definition at line 198 of file Bitmap.java.

198  {
199  crop(handle, bitmap.handle, left, top, left+bitmap.getWidth(), top+bitmap.getHeight(), 0, 0);
200  }

◆ invert()

void Beatmup.Bitmap.invert ( )
inline

Pixelwise bitmap inversion.

Definition at line 205 of file Bitmap.java.

205  {
206  invert(handle);
207  }
void invert()
Pixelwise bitmap inversion.
Definition: Bitmap.java:205

◆ pullPixels()

void Beatmup.Bitmap.pullPixels ( )
inline

Transfers pixel data from GPU to CPU.

Definition at line 212 of file Bitmap.java.

212  {
214  }
void pullPixels()
Transfers pixel data from GPU to CPU.
Definition: Bitmap.java:212

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