I have an image which is intended to be a background image, which fills the whole screen. The problem I am having is that the image displayed on the phone is of a much poorer quality than the original image. I have saved the image as a 320x480 jpg image, as my phone's display resolution is 320x480 also, so it is not related to the re-sizing of the image.
Here is a picture of what I'm seeing. On the left is the image opened on my desktop, on the right is a screenshot taken from my android phone.
The image quality on the phone can be improved by adding dither, but it is still not ideal. I'm struggling to understand what is going on. It appears as though the image is being loaded with reduced fidelity. It's almost as if the image is being draw in RGB_565 format, even though the phone is capable of 16m colors and should be able to display the image fine
Lots of people have similar problems with gradients. Try putting this in your activity:
#Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
What directory contains your image?
You should be careful with densities.
For example, if density of your screen is low and you put image to the drawable-mdpi, it will be blurred even if it has size exactly like screen one.
Try to put image to drawable-nodpi.
It could be the result of the jpg compression, which is lossy, which means you lose quality everytime you save it as a jpg, try using a png instead.
Related
I have png images that have drop shadow. There is no unproportional images scaling problem, scaling are according to the aspect ratio.
When I using Image.asset() for placing images on phone screen, they're and their shadows looks low quality and not soft.
Original image looks: http://prnt.sc/p93vo2
Image on Android App: https://prnt.sc/p93vz3
Example images are same and 700x400, 96dpi.
You should see quality difference between images.
There is also a strange stuation. The shadow density on right and bottom side is more than shadow of original image on android app.
I've tried FilterQuality.high but no change, how to fix it?
In my case, the problem was due to a bad configuration of the image resolution system.
Full answer SO: Images loose quality when using image.asset in flutter
.
I have a image (resolution 8328x3987). And I want to load that image in my app with zoom controls for better viewing.
As we all know that Android will not load large images directly on device (like in my example). So Android system suggested us to scale down the image to load large images. I have tried this and scale my image upto four times as:
options.inSampleSize = 4;
Using this way my image will displayed on screen, but when I zoom-in the image then this image becomes unreadable (text becomes very blurry), this is because, maybe I scale down the image before showing?
But when I see that image in to device's default gallery app (Android Lollipop, Photos app), then this image looks like a mapview (only visible portion is readable and outside is blurry, and when I move the image then visible area becomes readable) when I zoomed in at max level. So my questions is:
Is Android lollipop added any new way to load large files that looks like mapview?
If not, then do you have an idea how that apps do this or any example?
Reducing the sample size of an image that big will not work at all.(very very bad resolution and memory consumption)
I suggest you to divide image to tiles and recycle the views just like map views do.
This library may help you. Or you can do it your way too.
Is it possible to scale image without loosing its quality?I have seen posts that say to use Ninepatch images but how can we download an image and convert it to ninepatch image so that i can show it in ImageView.
Is there any other way so that my images with smaller size can be scaled like in whats app
Everytime you scale an image it's losing quality, the only thing you can do to keep the quality is keeping a copy of the original image (which doesn't make much sense since you can just load it again from resources).
If you mean the problem was that android was scaling your images (and changing the quality) you can put images on a folder named "raw" inside res.
Ninepatch images can be made manually by you, you just paint an image that has two extra pixels on width and two on height, and when you save it , name it something.9.png
if you want to know how to draw them correctly follow this: http://developer.android.com/tools/help/draw9patch.html
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.
As part of this application I am making, I want to change my wallpaper on my android device based on a bitmap that the user has selected.
I am able to change the background. However, the background is a completely distorted version of the bitmap. Any idea as to why this would happen?Here is my code:
Bitmap bitmap = ((BitmapDrawable)currentDrawable).getBitmap();
this.setWallpaper(bitmap);
My bitmap has a width of 240px and height of 180px. My emulator is of a size 480px by 800px.
I can scale my bitmap to 480px. However, the bitmap still ends up being distorted on the android wallpaper. Any thoughts on how this can be fixed?
Thanks in advance
You should create multiple images, for each potential (and common) resolution. You don't want any scaling, or the image will be distorted.
UPDATE:
Here is a ton of good information on support multiple screen sizes:
http://developer.android.com/guide/practices/screens_support.html
The wallpaper used by the default Launcher is bigger than the actual screen, that's why you can scroll the content and the wallpaper too.