I have recently started to learn android application development. Now I have some troubles in the image insertion. When i use the default images (launcher_background) my application seems to work fine. But any time I try to insert a HD image the application seems to stop. This has been going on for quite a while now.
Mybe it's because your image size is too big if your image is too big you should change image width and height to size of the image view or device display
There are thred party libaries you can use like :
https://github.com/Piasy/BigImageViewer
For more information see the links below :
https://developer.android.com/topic/performance/graphics/load-bitmap.html
https://android.jlelse.eu/loading-large-bitmaps-efficiently-in-android-66826cd4ad53
Related
I created application which has a background image.
I tested this application with Profile GPU Rendering and found out app works smoothly without an image in the background. Even when the size of my image is less than 10kb it takes time to execute display list as you can see in image which shows long red bars which represents execute display list operation. Screen shot of my app with Profile GPU Rendering
How can I use image in my app's background with less performance hit?
You can use glide https://github.com/bumptech/glide follow this. It will increase performance. It will really help when u load large number of images as well
since ShowCaseView development is discontinued, i chose for another way to make the First Tour in my Application, the way is:
i took 7 screen shots from my Galaxy G4 for each screen and made some text in it and display it in a imageView in the first run.
But when i change the image (the user click in a next tip button), it take ages to change and buggy the app, in the tablet(10.1) it work well(i dont know why since the tablet has low processor than the g4)
the images are in a good quality(HD), size is 720:1280, if i change the size to something like 500x600 or smaller, it change faster, but in the tablet the image looks horrible ugly
im using this to change;
btnNextTip.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
tipImages.setImageResource(bImage);
}
});
is there any way to do this? or another good library to do a first tour? or change the images but it not look VGA screenshots ?
thanks
setImageResource() method is bit slow because it does decoding on UI thread, We can solve this problem using worker thread or AsyncTaks, but a simple and ready made solution is available for that. Which is Glide library. You just need to add it's dependency to your gradle file as:
compile 'com.github.bumptech.glide:glide:3.7.0'
and then set drawable image using it's id as:
Glide.with(context).load(bImage).into(tipImages);
Also may be other image libraries like Picasso provide this option.
(You can use the latest version of Glide library instead of 3.7.0)
A good approach would be to seperate your Image Resources so that one with Higher Quality are used for Tablet and one with Lower resolution for your Phones.
You App can detect the screen size of the Device that your App is installed on and based on that, it will choose which image resolution to display.
Check here for details:
Supporting Multiple Screen sizes - Android Developer
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.
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 am using a WebView in an Android Activity to show a simple html who has a single jpg inside. When the jpg height is smaller than 3000 pixels, there is no problem, it show perfectly, but when the jpg is above 3000 pixels, it does not show. Can be this a limitation? Or memory issue? I am using Android 2.3 to test.
Your problem is that you're using a huge image, so the device can't handle that much data.
In order to display it properly and nicely mi advice is to use an html table wich each cell containing a slice of the image.
The browser will just render the parts of the table being displayed, so your image will be loaded properly.
I used this approach on a project and worked perfectly.
Regards.