Beatmup Java package
Beatmup.Android.Bitmap Class Reference

Android bitmap wrapping. More...

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

Public Member Functions

android.graphics.Bitmap getBitmap ()
 
synchronized void dispose ()
 Destroys the native object. More...
 
Bitmap clone ()
 
- Public Member Functions inherited from Beatmup.Bitmap
 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 (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 decodeStream (Context context, InputStream inputStream) throws OutOfMemoryError
 Decodes a bitmap from stream. More...
 
static Bitmap decodeFile (Context context, String path, BitmapFactory.Options options) throws OutOfMemoryError
 Loads a bitmap from file. More...
 
static Bitmap decodeFileDescriptor (Context context, FileDescriptor file, android.graphics.Rect outPadding, BitmapFactory.Options options) throws OutOfMemoryError
 Loads a bitmap from file. More...
 
static Bitmap createColorBitmap (Context context, int width, int height)
 Creates empty ARGB bitmap of specified size. More...
 
static Bitmap createGrayscaleBitmap (Context context, int width, int height)
 Creates empty grayscale bitmap of specified size. More...
 
- Static Public Member Functions inherited from Beatmup.Bitmap
static Bitmap createEmpty (Bitmap bitmap)
 Creates an empty bitmap of the same size and pixel format as a given bitmap. More...
 

Private Member Functions

 Bitmap (Context context, android.graphics.Bitmap bitmap)
 Creates new bitmap from Android bitmap object without memory copy. More...
 

Static Private Member Functions

static Bitmap createEnsuringPixelFormat (Context context, android.graphics.Bitmap bitmap)
 Creates new bitmap from a source Android bitmap converting the data into appropriate pixel format if necessary. More...
 

Private Attributes

android.graphics.Bitmap source
 wrapped Android bitmap More...
 

Additional Inherited Members

- Protected Member Functions inherited from Beatmup.Bitmap
 Bitmap (Context context, android.graphics.Bitmap bitmap) throws BadPixelFormat
 Creates new bitmap from Android bitmap object. More...
 
- Protected Attributes inherited from Beatmup.Object
long handle
 pointer to the native object More...
 

Detailed Description

Android bitmap wrapping.

Enables access to Android bitmaps from inside the Beatmup engine without memory copy.

Definition at line 32 of file Bitmap.java.

Constructor & Destructor Documentation

◆ Bitmap()

Beatmup.Android.Bitmap.Bitmap ( Context  context,
android.graphics.Bitmap  bitmap 
)
inlineprivate

Creates new bitmap from Android bitmap object without memory copy.

Parameters
contextBeatmup context
bitmapsource bitmap

Definition at line 40 of file Bitmap.java.

40  {
41  super(context, bitmap);
42  source = bitmap;
43  }
android.graphics.Bitmap source
wrapped Android bitmap
Definition: Bitmap.java:33

Member Function Documentation

◆ createEnsuringPixelFormat()

static Bitmap Beatmup.Android.Bitmap.createEnsuringPixelFormat ( Context  context,
android.graphics.Bitmap  bitmap 
)
inlinestaticprivate

Creates new bitmap from a source Android bitmap converting the data into appropriate pixel format if necessary.

Parameters
contextthe context handling the new bitmap
bitmapthe source; may be recycled
Returns
new bitmap

Definition at line 51 of file Bitmap.java.

51  {
52  if (bitmap.getConfig() != android.graphics.Bitmap.Config.ALPHA_8 && bitmap.getConfig() != android.graphics.Bitmap.Config.ARGB_8888) {
53  android.graphics.Bitmap copy = bitmap.copy(android.graphics.Bitmap.Config.ARGB_8888, true);
54  bitmap.recycle();
55  return new Bitmap(context, copy);
56  } else
57  return new Bitmap(context, bitmap);
58  }
Bitmap(Context context, android.graphics.Bitmap bitmap)
Creates new bitmap from Android bitmap object without memory copy.
Definition: Bitmap.java:40

◆ decodeStream()

static Bitmap Beatmup.Android.Bitmap.decodeStream ( Context  context,
InputStream  inputStream 
) throws OutOfMemoryError
inlinestatic

Decodes a bitmap from stream.

Parameters
contexta Beatmup context
inputStreamthe stream to decode
Returns
bitmap containing the decoded stream content

Definition at line 66 of file Bitmap.java.

66  {
67  android.graphics.Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
68  if (bitmap == null)
69  return null;
70  return createEnsuringPixelFormat(context, bitmap);
71  }
static Bitmap createEnsuringPixelFormat(Context context, android.graphics.Bitmap bitmap)
Creates new bitmap from a source Android bitmap converting the data into appropriate pixel format if ...
Definition: Bitmap.java:51

◆ decodeFile()

static Bitmap Beatmup.Android.Bitmap.decodeFile ( Context  context,
String  path,
BitmapFactory.Options  options 
) throws OutOfMemoryError
inlinestatic

Loads a bitmap from file.

If the pixel format is not supported, this function tries to convert the source data to a 32-bit color bitmap.

Parameters
contexta Beatmup context
pathpath to the file to decode
optionsbitmap loader options
Returns
bitmap from the file

Definition at line 80 of file Bitmap.java.

80  {
81  android.graphics.Bitmap bitmap = BitmapFactory.decodeFile(path, options);
82  if (bitmap == null)
83  return null;
84  return createEnsuringPixelFormat(context, bitmap);
85  }

◆ decodeFileDescriptor()

static Bitmap Beatmup.Android.Bitmap.decodeFileDescriptor ( Context  context,
FileDescriptor  file,
android.graphics.Rect  outPadding,
BitmapFactory.Options  options 
) throws OutOfMemoryError
inlinestatic

Loads a bitmap from file.

Parameters
contexta Beatmup context
filea file descriptor of the content to decode
outPaddingoutPadding returned by BitmapFactory.decodeFileDescriptor
optionsdecoding options
Returns
bitmap from the file

Definition at line 95 of file Bitmap.java.

101  {
102  android.graphics.Bitmap bitmap = BitmapFactory.decodeFileDescriptor(file, outPadding, options);
103  if (bitmap == null)
104  return null;
105  return createEnsuringPixelFormat(context, bitmap);
106  }

◆ createColorBitmap()

static Bitmap Beatmup.Android.Bitmap.createColorBitmap ( Context  context,
int  width,
int  height 
)
inlinestatic

Creates empty ARGB bitmap of specified size.

Parameters
contexta Beatmup context
widthwidth of the new bitmap in pixels
heightheight of the new bitmap in pixels
Returns
the new bitmap

Definition at line 115 of file Bitmap.java.

115  {
116  return new Bitmap(context, android.graphics.Bitmap.createBitmap(width, height, android.graphics.Bitmap.Config.ARGB_8888));
117  }

◆ createGrayscaleBitmap()

static Bitmap Beatmup.Android.Bitmap.createGrayscaleBitmap ( Context  context,
int  width,
int  height 
)
inlinestatic

Creates empty grayscale bitmap of specified size.

Parameters
contexta Beatmup context
widthwidth of the new bitmap in pixels
heightheight of the new bitmap in pixels
Returns
the new bitmap

Definition at line 126 of file Bitmap.java.

126  {
127  return new Bitmap(context, android.graphics.Bitmap.createBitmap(width, height, android.graphics.Bitmap.Config.ALPHA_8));
128  }

◆ getBitmap()

android.graphics.Bitmap Beatmup.Android.Bitmap.getBitmap ( )
inline
Returns
the wrapped Android bitmap instance.

Definition at line 133 of file Bitmap.java.

133  {
134  return source;
135  }

◆ dispose()

synchronized void Beatmup.Android.Bitmap.dispose ( )
inline

Destroys the native object.

After the native object is destroyed, its Java counterpart likely becomes unusable.

Reimplemented from Beatmup.Object.

Definition at line 138 of file Bitmap.java.

138  {
139  if (source != null) {
140  source.recycle();
141  source = null;
142  }
143  super.dispose();
144  }
synchronized void dispose()
Destroys the native object.
Definition: Bitmap.java:138

◆ clone()

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

Reimplemented from Beatmup.Bitmap.

Definition at line 149 of file Bitmap.java.

149  {
150  return new Bitmap(context, source.copy(source.getConfig(), true));
151  }

Member Data Documentation

◆ source

android.graphics.Bitmap Beatmup.Android.Bitmap.source
private

wrapped Android bitmap

Definition at line 33 of file Bitmap.java.


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