Hello,
I need to copy a part of a bitmap and save it in another bitmap (without the use of the canvas.)
I'm using the following code to get the pixels of the current bitmap and save them in a new bitmap.
But i keep getting a java.lang.illegalargumentexception: y+height must be <= bitmap.height OR x+width must be <= bitmap.width.
x: 44
y: 93
w: 214
h: 209
What I want to do is extract a part of the bitmap (from left: 44, top: 93, with; 214, h 209) and place them on a new bitmap with left: 0 top: 0, width 214, height; 209.)
Kind regards,
Tomas
HELP ME!
I need to copy a part of a bitmap and save it in another bitmap (without the use of the canvas.)
I'm using the following code to get the pixels of the current bitmap and save them in a new bitmap.
B4X:
public Bitmap extractBitmap(Bitmap source, int x, int y, int width, int height) {
//Create a same size Bitmap
Bitmap newBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
int[] pixels = new int[width * height];
source.getPixels(pixels, 0, width, x, y, width, height);
newBitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return newBitmap;
}
But i keep getting a java.lang.illegalargumentexception: y+height must be <= bitmap.height OR x+width must be <= bitmap.width.
B4X:
btmpTilt = image.extractBitmap(btmpTilt, x, y, w, h)
x: 44
y: 93
w: 214
h: 209
What I want to do is extract a part of the bitmap (from left: 44, top: 93, with; 214, h 209) and place them on a new bitmap with left: 0 top: 0, width 214, height; 209.)
Kind regards,
Tomas
HELP ME!
Last edited: