Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
534 views
in Technique[技术] by (71.8m points)

android - How to crop the image using four (x,y) coordinates

In my application ,I am going to crop the image using four (x,y) coordinates and also I need to show the cropped image in another activity screen. For example, In the below image, i want to crop the white layer itself. so any one provide the solution to accomplish this technique in my project.

Example image

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Using an instance of the Bitmap class, you can use the Bitmap.creatBitmap(); method passing the original image x y (for the top left corner) and then width and height.

see documentation here.

in your original example it would be:

Bitmap newBitmap=Bitmap.createBitmap(oldBitmap,10,20,70,80);

Edit

The Bitmap class also allows you to access an array of pixel int's representing color. if you know the shape you want to crop in terms of co-ordinates of each point. you could iterate through the array and set alpha to full on the ones that are outside your shape.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...