I want a user of my app to be able to modify an image at run time. The user should be able to modify the image height and width by tapping on the corner of the image-view and dragging it as illustrated in the following diagram:
I have spent a lot of time researching this and I found Making Sense of Multitouch and Resize a large bitmap file to scaled output file something like Pinch Zoom but none of these quite match my requirements.
currently i am resizing bitmap using this below finction and changing width in onprogress change method of seekbar instead of frame. by using this function changing image size is not working smooth.
public static Bitmap decodeFile(File f,int WIDTH,int HIGHT){
try {
//Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FileInputStream(f),null,o);
//The new size we want to scale to
final int REQUIRED_WIDTH=WIDTH;
final int REQUIRED_HIGHT=HIGHT;
//Find the correct scale value. It should be the power of 2.
int scale=1;
while(o.outWidth/scale/2>=REQUIRED_WIDTH && o.outHeight/scale/2>=REQUIRED_HIGHT)
scale*=2;
//Decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize=scale;
return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
}
catch (FileNotFoundException e) {}
return null;
}
UPDATE :
Now working smoothly using drawing bitmap in canvas using accepted answer of this question .
now reaming part is setting frame around image as something like crop frame.
Please help me to achieve this.
Tap the image you want to adjust. You can adjust the size of an image or rotate it: Resize: Touch and drag the squares along the edges. Rotate: Touch and drag the circle attached to the image.
ImageView class is used to display any kind of image resource in the android application either it can be android. graphics. Bitmap or android. graphics. drawable.
you can accomplish this using this library use cropimageview3 and set your image in float drawable and you are done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With