in my code, i first do a call from native to create a bitmap in java (of size: 800 x 480). This call is made recursively by a callback function and the bitmap is created by created by this function:
public void createBitmap(byte[] buffer, int width, int height)
{
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(buffer));
}
Another native function then calls a java function that is required to select an area of the original bitmap and create a new bitmap. This is done by the function below. It selects the bitmap previously created by the above function and gets a part of it (x, y coordinates) then creates a new bitmap:
public Bitmap getResizedBitmap(int x, int y, int newWidth, int newHeight) {
if (bitmap != null) {
AppLogger.LOGE("check : 1");
AppLogger.LOGE("check : x" + bitmap.getWidth() + " Y : " + bitmap.getHeight());
bm = Bitmap.createBitmap(bitmap, x, y, 10, 1);
AppLogger.LOGE("check : 2");
int width = bm.getWidth();
int height = bm.getHeight();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// CREATE A MATRIX FOR THE MANIPULATION
Matrix matrix = new Matrix();
// RESIZE THE BIT MAP
matrix.postScale(scaleWidth, scaleHeight);
// "RECREATE" THE NEW BITMAP
Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
AppLogger.LOGE("check : 3");
return bm;
} else {
AppLogger.LOGE("check : 4");
bm = Bitmap.createBitmap(newWidth, newHeight, android.graphics.Bitmap.Config.ARGB_8888);
return bm;
}
}
I have however begun getting native out of space errors (at least that is what i think from the extensive search from similar problems). The error occurs on the first bitmap.create where i get part of the original image. Is there an issue with how i have done this? p.s - the bitmap creation is on a loop i.e it is done multiple times. ERROR : Libc FATAL SIGNAL 11