4
I want to create a Bitmap
that its content is a part of another Bitmap
For example:
I have a Bitmap (400x900)
width = 400
height = 900
I want to cut it in the dimensions (400x400) in order to leave the height equal to the width ignoring the rest of the image.
The result should stay this way:
I built this algorithm, but it takes too long running:
private Bitmap reparteImage(Bitmap bitmap) {
int w = bitmap.getWidth();
//PASSA WIDTH PARA WIDTH E HEIGHT
Bitmap bmp = Bitmap.createBitmap(w, w, Bitmap.Config.ARGB_8888); // this creates a MUTABLE bitmap
for(int x=0;x<bmp.getWidth();x++){
for(int y=0;y<bmp.getHeight();y++){
bmp.setPixel(x, y, bitmap.getPixel(x, y));
}
}
return bmp;
}
There is a faster way to perform this procedure using Canvas or some other class that works with Images?