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
Related
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.
Whenever I try to show large size(1 MB) bitmap in imageview, system throw OutOfMemory exception.
If I place 7-8 MB image, gallery can easily show that image.
Just want to know How device default gallery is able to show large image in easy way?
Which mechanism is used by device gallery?
Generally speaking, they subsample the image. A 1MB PNG or JPEG file will be much higher resolution than the screen, and so it is wasteful to load the whole image in. Subsampling allows you to load the image in much closer to the actual size of the ImageView you will use, allowing it to fit in memory better. A simple approach to subsampling involves using inSampleSize on BitmapFactory.Options; Dave Morrissey's SubsamplingScaleImageView offers pinch-to-zoom and such while peforming subsampling (note: I have not tried this component, as I just ran across it a minute ago).
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.
I don't want to display the bitmap on the screen. Just trying to create a max square image out of the original image from sdcard and then uploading to server. Is there a way to crop an image without loading the image into memory? or load the image in chunks and then save to file?
I don't know if I understand well the question but this could help:
http://developer.android.com/reference/android/graphics/BitmapRegionDecoder.html
BitmapRegionDecoder can be used to decode a rectangle region from an image. BitmapRegionDecoder is particularly useful when an original image is large and you only need parts of the image.
Hope to help :)
I am using the Camera activity to capture the JPEG image. After image is saved and the controll is returned back to my application activity I would like to to determine the captured JPEG image dimensions without loading the whole image into memory via Bitmap object - can it be easily done somehow?
Is there any class, which reads the JPEG header and give me such information? I would like to avoid OOM conditions - but might be it is not a problem to load the whole image into memory - is it?
After knowing the dimensions I would like to use BitmapFactory to scale the image.
Thanks a lot
Kind Regards,
STeN
Perhaps a work-around (see 2nd approach) by setting the quality?
bmp.compress(CompressFormat.JPEG, 75,
pfos);
You would have to do a trial run to see what size the quality gets you though...
*The first approach creates a log file to get the width and height but not sure if you wanted the extra step of looking at a log file.
You can use the ExifInterface class to read the image width and height.