3

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.

http://imgur.com/4VwkC

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

Hüseyin Cevizci
  • 895
  • 4
  • 15
user1095142
  • 35
  • 1
  • 6

3 Answers3

0

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.

HighFlyer
  • 1,575
  • 2
  • 14
  • 22
  • I had it in `/drawable` I've tried moving it around the different folders, and in `-nodpi` but still no change – user1095142 Dec 13 '11 at 06:39
  • Image viewers shows image like on desktop? What's your phone? Many devices has display capability only for 262144 colors, not 16 millions. – HighFlyer Dec 13 '11 at 06:51
  • the Ace has 16m, but only has 165 PPI screen density, that may be the reason – Bill Gary Dec 13 '11 at 06:57
  • I don't understand, 480x320 is the number of pixels. This isn't going to change, or be affected by, the screen density? – user1095142 Dec 13 '11 at 07:01
  • PPI is a ratio of screen size to pixels, Pixels Per Inch. the iPhone 1, 2 and 3 were 480x320 with a PPI of 163, the HTC dream is 480x320 with a PPI of 180. – Bill Gary Dec 13 '11 at 07:25
  • so the image will fit both perfectly? just the HTC dream will have a smaller physical display – user1095142 Dec 13 '11 at 07:37
0

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.

Bill Gary
  • 2,989
  • 2
  • 13
  • 19
0

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);
}
Community
  • 1
  • 1
kabuko
  • 35,009
  • 7
  • 75
  • 92
  • Hmm I've tried this, but it doesn't seem to work. Thanks though – user1095142 Dec 13 '11 at 07:53
  • I think this answer is close enough. I managed to solve the issue by adding `holder.setFormat(PixelFormat.RGBA_8888)` to the `onSurfaceChanged(SurfaceHolder holder)` method in my `SurfaceView` class. I perhaps should have mentioned that I was using a surfaceView to draw my image. From what I can understand, the default behavior is to load/modify bitmaps in RGBA_8888 mode. However, by default they are eventually drawn to the screen with a 16bit color depth instead of 24. Even if the device supports 24 bit colors. strange. – user1095142 Dec 14 '11 at 07:09
  • I am having a similar problem while drawing a Bitmap on my SurfaceView, When resizing the image the quality drops, this happens if i resize with canvas.scale, or use a target rectangle in my canvas.drawbitmap method, I try this holder.setFormat(PixelFormat.RGBA_8888) to the onSurfaceChange(SurfaceHolder holder) method, however this just makes my app crash. any ideas? – tantonj Dec 08 '12 at 19:22
  • ok I discovered when using Bitmap.createScaledBitmap if the boolean parameter is set to true the quality degradation doesn't exist – tantonj Dec 08 '12 at 19:48