21 import android.graphics.Bitmap.Config;
22 import android.util.Log;
24 import Beatmup.Context;
25 import Beatmup.Geometry.IntRectangle;
26 import Beatmup.Imaging.PixelFormat;
36 private native
static long newInternalBitmap(
Context context,
int width,
int height,
int pixelFormat);
38 protected native
static long newNativeBitmap(
Context context, android.graphics.Bitmap bitmap);
45 private native
void crop(
long handle,
long outputHandle,
int x1,
int y1,
int x2,
int y2,
int outLeft,
int outTop);
51 private static long createNativeBitmapEnsuringPixelFormat(
Context context, android.graphics.Bitmap bitmap)
throws BadPixelFormat {
52 if (bitmap.getConfig() != android.graphics.Bitmap.Config.ALPHA_8 && bitmap.getConfig() != android.graphics.Bitmap.Config.ARGB_8888)
54 return newNativeBitmap(context, bitmap);
60 this.context = context;
72 super(createNativeBitmapEnsuringPixelFormat(context, bitmap));
73 this.context = context;
86 super(newInternalBitmap(context, width, height, pixelFormat.ordinal()));
87 this.context = context;
101 int pixPerByte = 8 / pixelFormat.getBitsPerPixel();
103 minWidth = ((minWidth + pixPerByte - 1) / pixPerByte) * pixPerByte;
104 return new Bitmap(context, minWidth, height, pixelFormat);
114 return new Bitmap(bitmap.context, bitmap.getWidth(), bitmap.getHeight(), bitmap.getPixelFormat());
157 public static void recycle(
Bitmap bitmap) {
175 return context.copyBitmap(
this, pixelFormat);
186 if (copy.getWidth() != region.getWidth())
188 crop(
handle, copy.
handle, region.x1, region.y1, region.x2, region.y2, 0, 0);
199 crop(
handle, bitmap.
handle, left, top, left+bitmap.getWidth(), top+bitmap.getHeight(), 0, 0);
221 super(
"Pixel format not supported: " + (config ==
null ?
"config is null" : config.toString()));
void zero()
Sets all bitmap pixels to zero.
PixelFormat getPixelFormat()
static Bitmap createEmpty(Bitmap bitmap)
Creates an empty bitmap of the same size and pixel format as a given bitmap.
void invert()
Pixelwise bitmap inversion.
IntRectangle clientRectangle()
void pullPixels()
Transfers pixel data from GPU to CPU.
Bitmap clone(PixelFormat pixelFormat)
void projectOn(Bitmap bitmap, int left, int top)
Copies a rectangular area to another bitmap.
Bitmap copyRegion(IntRectangle region)
Creates a bitmap containing a copy of a rectangular region.
Bitmap(Context context, android.graphics.Bitmap bitmap)
Creates new bitmap from Android bitmap object.
Bitmap(Context context, int width, int height, PixelFormat pixelFormat)
Creates new internally managed bitmap.
void watchBitmap(Bitmap bitmap)
Adds a bitmap to the watch list.
Integer-valued rectangle.
Base class for objects natively managed by Beatmup.
long handle
pointer to the native object
synchronized void dispose()
Destroys the native object.