1

I have bitmap Bitmap bmp=BitmapFactory.decodeFile(path);

I want to select specific part of bitmap (with specific x,y,width,height) and save it as new bitmap.

I tried this but doesnt work (only cropped it)

  public Bitmap getSelectedImage(Bitmap paImage,int,x,int y,int paWidth,int paHeight){

     Bitmap newPicture=Bitmap.createBitmap(paImage,x,y,paWidth,paHeight);
     return newPicture;
     }

Like in this pictureenter image description here

Any idea?

user3934048
  • 39
  • 1
  • 9
  • 1
    Does this answer your question? [cut the portion of bitmap](https://stackoverflow.com/questions/5432495/cut-the-portion-of-bitmap) – Rohan Pawar Mar 02 '20 at 05:48
  • there's nothing wrong with your code. You are returning the copied section, not cropping the original. – John Lord Jan 03 '21 at 05:33

1 Answers1

0

I'm not sure about using this method but you can simply make new bitmap and use two for loops to copy every relevant pixle to new bitmap. Currently I'm not at computer but if u want I can send you code tomorrow. However this is not very fast, but also not much slower then built in methods like the one you are using.