Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why android lose image quality when displaying a png file?

Tags:

android

image

I want to display a png image on android. This is the image file:

enter image description here

The right end is a bit darker than left.

But the quality of image lost on android application(using ImageView):

enter image description here

Please note part in the red frame. The color is not changing smoothly.

But if I use the browser of my android phone, it plays good(so it's not reason of the phone screen):

enter image description here

This is my android code, which is pretty simple:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">
    <ImageView android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:background="@drawable/hhh"/>
</LinearLayout>

where hhh is my first image posted here, which is under res/drawable.

I test it on my android phone(android 2.3.6) and android simulator(with android 2.2/2.3/4.0), all do not display good. But it plays good on my android pad(android 4.0.3).

What's the problem, and how to fix it?

like image 639
Freewind Avatar asked Oct 30 '12 11:10

Freewind


1 Answers

Images in res/drawable are compressed. This is supposed to be lossless, but I've heard of similar issues in the past.

Move it into res/raw, and give it a go.

like image 99
Richard Taylor Avatar answered Nov 14 '22 23:11

Richard Taylor