getThumbnail method returning blurry thumbnails? - android

I want to show Thumbnails for images present on device in a GridView and I'm using getThumbnail method to get thumbnails. But for some reason when I set returned thumbnails to ImageViews in gridview, they are not clear(blurry). For example, if there's a text in an image then I'm not able to read that text in my app whereas I can read it in the native android gallery app. I hope this gives a idea of what my problem is. I think its probably because the imageview size is greater than image size.
I have tried to use methods like extractThumbnail in conjunction with BitmapFactory.Options inSampleSize but sometimes it generate OutOfMemoryException.
What should I do to resolve this issue so that the thumbnails are as clear as they appear in android native gallery application?

If I remember correctly, getThumbnail will return a scaled image. If you are then scaling that image back up to fit in your GridView, then that would account for the blurriness.
You can try scaling the images to the correct size yourself, then displaying it to the GridView.
You may also want to look at UIL. It is an awesome Open Source project that helps with Image Loading and can fix your memory issue.

Related

How to increase Image Memory using Bitmap Factory option

I want to use Big Size Image In Back Ground so How Can I do And i want to It's Working For All Device
As per your requirement, I guess that you are getting image from server end. Some time big size Bitmap throw OutOfMemoryException. So do one thing. Use this library to compress image and then show it to ImageView.
https://github.com/zetbaitsu/Compressor
You can also use Library. It provide you facility to fix image size and quality. so it won't be problem for you.
Nostra Image Loader

Load a very large Image in android

Assumes I have a picture, it very large images or other sets of content where you are only looking at small bits at a time, because you can start seeing your content without having to load it all into memory at once.
In iOs we can use CATiledLayer to repeatedly draw tiles to fill up view’s background
In Android I can see Google Map, It also load each part of map when you scroll but I don't understand what is solution of them.
I want know what is the solution same CATiledLayer in Android or other to load very large Image
you can actually scale down the bitmap according to the size of the image view.
Don't give wrap_content in width and height try to give a relative width and height.
use
ImageView.getheight()
ImageView.getWidth()
get the size and load according to it
see this link
http://developer.android.com/training/displaying-bitmaps/load-bitmap.html#read-bitmap
You can use a library load images efficiently and manage caching them instead of downloading them again. I suggest Picasso or Glide. This tutorial compares between them and explains few features.
I hope it's useful.

Android imageview image quality matter?

I am writing a Android app which need to display some high quality picture(took from professional DSLR). The problem is it can't be display from gallery.
I choose a photo in Gallery first. The target picture is 2464*1632 JPEG, roughly 4.5M;
Then I just need to compress it to 800*600 and display it in imageview:
image.setImageBitmap(this.bmp);
Thing is that I have tested other image I downloaded form internet(really low quality), and it works without any problem. Can anybody tell me why it can't be displayed? I will be really appericiated
Large images are tricky to handle due to limited memory. You have several choices:
Use a WebView (this allows you to have pinch and zoom functionality to make use of those extra pixels
Decode the image down to the size of the display and then put it in an ImageView using BitmapOpts http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html and changing inSampleSize. It seems you may be having difficulty with that, so consider using createScaledBitmap which just needs the dest width and height.

Android Efficient Bitmap processing

My scenario:
In my activity, I have to show 2 galleries, 1 with large image and another is a thumbnail(same exactly like default Gallery application).
My doubts:
I am planning to save as 2 images(1 with large size and another one with thumbnail size) in sdcard for fast processing. Is that good practice? since it will increase the size.
Or Shall I resize the large image during the getView method of BaseAdapter to small size for displaying in thumbnail gallery?
Which one is the good practice? I don't want to slow down my app.
See this example.
I will suggest you that, put only your large image inside your sdcard. But at runtime, Android provides a good facility to get Thumbnails using MediaStore.Images.Thumbnails.
Edit:
You can also get use Loading Sample Sized Bitmap. This will first create a sample size of your requirement. Then will give you a Thumbnail sized Bitmap.
StackOverflowAnswers:
1) Get thumbnail of image on SD card

How to know whether an image is displayed in ImageView?

I am trying to display some images in one ImageView to obtain the functionality of slide show.
I am registering an Animation Listener to the imageview for changing each picture.
When slide show is displaying, some of the images are not visible, but its memory is allocating.
I am converting images from URL to bitmap. After doing inSampleSize = 4, I am setting the bitmap to ImageView.
Why these images are not visible? the images with below 100 Kb are visible, but with 500kb has the problem.
Thanks..
EDITED
Actually when the application launches, the images from the URL are converted to bytes and it is stored in the DB. And when we click on the Slide show button in another activity, these bytes are converted to bitmap and showed by the ImageView.
If your images are larger than a few kB, it is best practice to use a ContentProvider rather than loading these images directly from storage. This may be your problem.
http://developer.android.com/guide/topics/providers/content-providers.html#querying
Give this a read and try the ContentResolver.openInputStream and Cursor.getBlob() method of retrieving images, and see if it works any better for you.
Hope this helps!
Sorry all,
Finally I figured out the problem.
I increase the duration of animation according to image size.
Now all images are displaying fine.

Categories

Resources