1

I have app. I want to crop my picture that shown in imageview. I want crop with spesific length and width. can you help me? I have code but, that code crop direct from gallery.

I just want crop imageview with spesific length and width. Where length and width just input manual from user.

2
  • possible duplicate of stackoverflow.com/questions/13992535/… Commented Sep 28, 2013 at 9:07
  • No.... i am not to do centercrop. i want the length and width that input manual by user. just like input with inputbox on Java. can this work? Commented Sep 28, 2013 at 9:16

1 Answer 1

0

If you don't mind adding a new Library to your project just to do image loading for you, you can easily add Glide to crop your local drawables or images from the web.

In your build.gradle (module app)

compile 'com.github.bumptech.glide:glide:3.6.0'

You can crop the image with this below:

 final ImageView myImage = (ImageView) findViewById(R.id.myimageview);

        final int myWidth = 210;
        final int myHeight = 80;
        Glide.with(getApplicationContext())
                .load(R.drawable.example_drawable) // you can add any drawable or url of an image here
                .asBitmap()
                .into(new SimpleTarget<Bitmap>(myWidth, myHeight) {
                    @Override
                    public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
                        // Do something with bitmap here.
                        Bitmap bm = Bitmap.createBitmap(bitmap, 0, 0, myWidth, myHeight);
                        myImage.setImageBitmap(bm);
                    }
                });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.