Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to crop Bitmap?

Tags:

android

I have retrevied Bitmap from fragment & I placed bitmap(decoded bytearray) in Imageview, I want to crop this bitmap

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fr_editcrop, container, false);


    cropphoto = (ImageView)view.findViewById(R.id.cropphoto);
    title = (TextView)view.findViewById(R.id.title);
    title.setText("Crop");

    crop = (Button)view.findViewById(R.id.crop);
    cancel = (Button)view.findViewById(R.id.cancel);

    tmp = getArguments().getString("PHOTO");

    byte [] encodeByte=Base64.decode(tmp,Base64.DEFAULT);
    bmp=BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length);
    cropphoto.setImageBitmap(bmp);

    Width = cropphoto.getWidth();
    Height = cropphoto.getHeight();
like image 998
Narendra Sorathiya Avatar asked Sep 07 '25 22:09

Narendra Sorathiya


1 Answers

Call Bitmap.createBitmap(Bitmap source, int x, int y, int width, int height)

See reference.

like image 160
Randy Sugianto 'Yuku' Avatar answered Sep 10 '25 11:09

Randy Sugianto 'Yuku'