Getting imageview to read image from sd - android

I have a imageview and a camera button in Activity A. By clicking on the camera button will go to my custom camera activity. After taking a picture and storing it into a folder, how can I reflect this newly picture taken in the imageview after finishing the camera activity? Any help will be appreciated ?
A(main) > B(camera activity) > A(main) Imageview is updated with new picture taken.
Thanks.

According to my understanding of your question, you want to know how to set an image, residing on sdCard, to an ImageView. Well, let's say you can get the image path from your camera activity and then you can do something like below:
String imageInSD = "/sdcard/img.PNG";
Bitmap bitmap = BitmapFactory.decodeFile(imageInSD);
ImageView myImageView = (ImageView)findViewById(R.id.imageview);
myImageView.setImageBitmap(bitmap);
I hope it'll serve the purpose, if this is what you want.

Related

Will the ImageView redo all the process again when the input image is same?

I am wondering when the same image resource is set to the imageView again, will the imageView redo all the processes? (The size of imageView and size of image does not change.)
Like the following scenario
imageview.setImageBitmap(b);
imageview.setImageBitmap(b);

Image crop help using multiple imageview

here's my problem... Would it be possible to load a picture, call the crop activity, and load the cropped images on different imageviews without changing the main image??
I have 3 imageviews. My imageview 1 is for the main image loadout, my imageview 2 is for the result of the crop activity, the same goes with imageview 3.
I am using com.theartofdev.edmodo:android-image-cropper:2.6.0....
The good thing about this one is that it already has lots of functions, but the problem is that what I want to happen is that it would load the image that I have already called in my main imageview.
Get the instances of the Views in the activity class.
Use the method below to get the image source to bitmap
Display bm returned from convertImageViewToBitmap to the second ImageView.
private Bitmap convertImageViewToBitmap(ImageView v){
Bitmap bm =
((BitmapDrawable)v.getDrawable()).getBitmap();
return bm;
}

Extracting Image from a clicked ImageButton from numerous ImageButtons

I am trying to build an Android game in which a user will have choice to select a player from 4 available players. These Players are available as Image Buttons. I want that when a user clicks a image Button, this image will be assigned to a Bitmap variable 'PLAYER' in the Main Activity.java .
Please help me out with codes to extract the Image from clicked button and assign it to the variable PLAYER.
Any help would be grateful. Thanks!!
yor can get bitmap form Imageview by using
Drawable dra = imageview.getDrawable();
BitmapDrawable bmp = (BitmapDrawable) dra;
Bitmap b = bmp.getBitmap();
and set this bitmap to your player object
method of image view.

Android canvas seek bar editing

In my app there is an image that the user imported using the gallery
then doen the imageview where the picture has been inserted
there is two seekbars
the first seekbar controls the picture brightness
and the other controls the picture hue
when I use them they are working, but the problem is they don't save
like ..
I imported the picture then made its brightness its working great
but when I set the picture hue the brightness that i made disappears
and the hue starts
isn't there
iv.save;
or anything like that?
note*
final ImageView iv = (ImageView) findViewById(R.id.picture);
Yes there is.
final ImageView iv = (ImageView) findViewById(R.id.picture);
iv.setDrawingCacheEnabled(true);
Bitmap bmp=iv.getDrawingCache();
Now you can save this Bitmap to your sdcard in jpg or png format.

How do I set the background of an image button to a picture the user took?

I want to be able to set the background of an image button in an xml file to be the picture the user took on the phone.
I have the picture set as cameraBitmap.
cameraBitmap = (Bitmap) intent.getExtras().get("data");
and I want to pass that picture to be the bakground of the imagebutton. The problem is, the method: setBackgroundDrawable() only can pass in a drawable. How do I go about changing that Bitmap to a drawable picture and making it the background?
I currently have:
private ImageButton theImageButton;
theImageButton.setBackgroundDrawable(cameraBitmap);
If you are using ImageButton why can't you use this
theImageButton.setImageBitmap(cameraBitmap)

Categories

Resources