Refresh QuickBadge/ ImageView on a Fragment after taking a picture - android

I want to take a picture in my App, so if I click on my ImageView/QuickBagde on my Fragment.
I'm able to take a picture, after that, I crop it and it return to my App. This is not a big deal and it's working well.
But how can I refresh the ImageView/QuickBadge to show up the taken picture?
I tried with:
//get the returned data
Bitmap thePic = data.getExtras().getParcelable("data");
profilePic.setImageBitmap(thePic);
But it doesn't work.

you can try this
Bitmap bitmap=BitmapFactory.decodeFile(imagepath);
imageview.setImageBitmap(bitmap);

Related

Apps keeps on crashing while adding 4th consecutive image when i use glide with Bitmap or Bitmap drawable

I was wondering about, how to implement Glide along with using Bitmap compression in Kotlin and thought that any of the code below would work. But unfortunately, the app closes as soon as I add an image into any of the imageView for the fourth time.
Here's the code which I tried to implement
val selectedImage = data?.data
val bitmap = MediaStore.Images.Media.getBitmap(contentResolver, selectedImage)
//method 1
Glide.with(this).asBitmap().load(compressBitmap(bitmap,5)).into(imageView!!)
//method 2
var bitmapDrawable = BitmapDrawable( resources , compressBitmap(bitmap,5))
Glide.with(this).load(bitmapDrawable).into(imageView!!)
What would be the correct code, if i'm somewhere wrong here. Thankyou in advance
Try using Recycler View or another component to load the images in. They will handle the load.

Android - pass an image to other activity, resize and keep quality

I have a listview, getting news thumbnail and header from json.
I want to show news body and bigger image in other activity by clicking listview item. The code below send image to other activity.
secilenresim= (ImageView)view.findViewById(R.id.mansetresim);
secilenresim.buildDrawingCache();
Bitmap image= secilenresim.getDrawingCache();
Bundle extras = new Bundle();
extras.putParcelable("imagebitmap", image);
//// the code below gets the image in new activity
haberresim=(ImageView)findViewById(R.id.haberresim);
haberresim.getLayoutParams().height = 300;
haberresim.getLayoutParams().width = 400;
Bundle extras = getIntent().getExtras();
Bitmap bmp = (Bitmap) extras.getParcelable("imagebitmap");
haberresim.setImageBitmap(bmp);
all works fine. but image quality in new activity is too bad. whereas image source (coming from json and loaded by picasso library) is fine, and the image resolution is 600*400 pixels. How can I pass image to other activity and keep quality?
If you are using picasso, your image is downloaded once and then kept in memory or even disc-cache. So you won't have to pass the bitmap via bundle but only the URL to it from your JSON.
In your Detail-Activity you can request the image via picasso again for your larger imageView.
You can check if your image is loaded from cache or network if you enable the picasso debug flag:
picasso.setDebugging(true)
getDrawingCache() may be getting image with low quality.
to change it use:
secilenresim.setDrawingCacheQuality(DRAWING_CACHE_QUALITY_HIGH);
you can check your quality with getDrawingCacheQuality(). It can be one of those:
DRAWING_CACHE_QUALITY_AUTO
DRAWING_CACHE_QUALITY_LOW
DRAWING_CACHE_QUALITY_HIGH
EDIT:
it seems that secilenresim.destroyDrawingCache(); before building it may be also helpful

How to capture camera image thumbnail and full image at the same time

It looks like in camera image capture, one can only capture either thumbnail or full image but not both in one pass because
public void startCamera() {
...
camera.putExtra("output", imageUri); (step 1)
...
needs to be declared before
...
startActivityForResult(camera, IMAGE_CAPTURE); (step 2)
...
Bundle extras = camera.getExtras();
mImageBitmap = (Bitmap) extras.get("data");
imageView.setImageBitmap(mImageBitmap);
...
But once "onActivityResult" returns, the full image is already saved into imageUri and the buffer cleared. But to capture the thumbnail of an image taken, the code needs to be executed after "startActivityForResult". The problem is the image buffer is cleared once the image is saved in step 2. To capture the image thumbnail, one will need to skip saving the full image in step 1 in order to capture the thumbnail image in step 2.
I can use an alternative to save the full image, reload the full image into bitmap, scale the image into a thumbnail size and resave the image but it seems to be redundant. Any idea if I can do both in one pass?
Check out MediaStore.Images.Thumbnails, and specifically getThumbnail (near the bottom): http://developer.android.com/reference/android/provider/MediaStore.Images.Thumbnails.html .
If that doesn't work, yes, you will have to manually re-scale and save the thumbnail yourself.

Android save working bitmap

I have a Bitmap that I chose from gallery that is getting edited
like putting on it stickers, adjusting hue, brightness ..
putting colors etc..
It's a photo editing app...
It's all working fine, my last problem is
How do I make the Bitmap saves so it goes to the next activity
like,,
In my last activity where u share the image u made, there is an imageview, and it's working it shows the bitmap that u imported form the gallery but it's not editied
like it shows the original Bitmap
not the one I edited it..
How do I make when they click the button done in the editing activity the currentBitmap gets saved so in the share activity where done will take them it shows what they did
try this
//create a class in your package
class objectclass{
public static Bitmap bmp;
}
//save your previous activity bitmap like this
....
objectclass.bmp = b;//your bitmap
....
//use in another activity like this
Bitmap b1 = objectclass.bmp;
hope help

Android Camera App with multiple images in a LinearLayout

I'm working on a camera app which displays more than one image dynamically added to a simple LinearLayout as childs. When a specefic image is selected (onClick), it goes to Camera View (camera Intent). The App is supposed to display the new image captured in the right selected ImageView. The thing is, I don't know how to get that specific ImageView to handle it in onActivityResult method. Please help
In your onActivityResult()
if (resultCode == RESULT_OK) {
if (data != null) {
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(thumbnail);
}
}
Where data is the intent.
You can just save the clicked ImageView's reference before you open the Camera app, and use that reference to set the new image.
Update: Just make an ImageView variable in your activity, and before you open the Camera, put the clicked instance in this field, and use this ImageView in my example code.

Categories

Resources