Android - how to compress or downsize an image? -
imagebutton avatarbutton = (imagebutton) findviewbyid(r.id.imagebutton_avatar); avatarbutton.setimageresource(r.drawable.avatar); stravatarfilename = "image.jpg"; final uri imageuritosavecameraimageto = uri.fromfile(new file(environment.getexternalstoragedirectory()+"/folder/"+stravatarfilename)); avatarbutton.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { intent pictureintent = new intent(android.provider.mediastore.action_image_capture); pictureintent.putextra( mediastore.extra_output, imageuritosavecameraimageto ); startactivityforresult(intent.createchooser(pictureintent, stravatarprompt), take_avatar_camera_request); editor editor = preferences.edit(); editor.putstring(preferences_avatar, imageuritosavecameraimageto.getpath()); editor.commit(); } });
i have code. takes photo , stores in 2 locations, default location on sdcard , /folder/ file want photo stored in also. once taken refresh screen using this...
imagebutton avatarbutton = (imagebutton) findviewbyid(r.id.imagebutton_avatar); string stravataruri = preferences.getstring(preferences_avatar, ""); uri imageuri = uri.parse(stravataruri); avatarbutton.setimageuri(null); avatarbutton.setimageuri(imageuri);
this refreshes image button user can see image have taken. however, appears big , fills screen. there way can compress or downsize image user can see @ reasonable size?
you can mess imagebutton's scaletype properties (to fitxy example, or cropcenter), , setting fixed size layoutpreferences (height , width) you'll set.
Comments
Post a Comment