I want to create a Bitmap
that its content is a part of another Bitmap
For example:
I have a Bitmap of (400x900)
width = 400
height = 900
I want to trim it in dimensions (400x400) in order to leave the height equal to width by ignoring the rest of the image.
The result should look like this:
I've mounted this algorithm, but it takes a long time to execute:
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;
}
Is there a faster way to do this using Canvas or some other class that works with Images?