Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image blurry on another device

First of all, I want to apologize in advance since I'm sure that this kind of question has been asked before, but even though I was looking for about 2 weeks at those questions I could not figure out what I'm doing wrong.

This is where I load the image in the activity:

ImageView image = (ImageView) findViewById(R.id.shop_Image) ;
image.setScaleType(ImageView.ScaleType.CENTER_CROP) ;

String mDrawableName = data.vec.elementAt(id).fuenf ;
if ( mDrawableName.equals("leer") )
    mDrawableName = "ic_launcher" ;
int resID = getResources().getIdentifier(mDrawableName , "drawable", etPackageName());
image.setImageResource(resID) ;

And this is the xml-file:

    <LinearLayout
    android:id="@+id/shop_Layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#FDFDFD"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/shop_Image"
        android:contentDescription="@string/shop_image"
        android:layout_width="match_parent"
        android:layout_height="400dp"
        android:scaleType="centerCrop"
        android:adjustViewBounds="true"
        android:src="@drawable/ic_launcher" />
    [...]

And these are the results:

On a Galaxy Nexus, Nexus 5 or Samsung S3 it looks like this:

http://abload.de/img/2014-06-0419.23.52ojuo4.png

And on a Razr I or HTC Desire X it looks like this:

http://abload.de/img/2014-05-2514.19.482ju01.png

I'm aware that the above devices, which display the image correct have a display with at least 4,7 inches while the both with the blurry images have 4,3 inches or 4 inches.

And even though I have put those images in the different drawable folders, I still get these unpleasant results.

If further code-examples are needed, please let me know.

PS: Sorry for the missing highlighting, I'm still a newbie :)

like image 226
VollNoob Avatar asked Jun 07 '14 19:06

VollNoob


People also ask

Why do pictures go blurry when I send them?

The most common reason for a blurry photo is an incorrect use of shutter speed. The faster your shutter speed is, the less chance there is for camera shake. This is particularly true when shooting handheld. There is no way that anyone will be able to handhold a camera steady enough at slow shutter speeds.

Why are my pictures blurry on my new phone?

One of the biggest culprits of blurry photos is camera shake. This happens when the phone moves too much while the picture is being taken, resulting in motion blur on the object you are photographing.

Why are my pictures blurry when I send them iPhone?

Your iPhone has a setting that limits the resolution and quality of an image sent from iMessage. The iPhone does that to save storage space and internet bandwidth. However, this can cause blurry images in some instances.

Why are my pictures blurry on Android to iPhone?

Once you send something via SMS, your carrier gets involved and that data gets terribly compressed. While data compression affects all images and videos, it typically impacts larger or high-quality images the most. Videos are also heavily affected, and usually, end up extremely blurry and unwatchable.


1 Answers

A quick search on Google let me know these facts:

Desire X specs: 480 x 800 pixels, 4.0 inches (~233 ppi pixel density) - So, it's an hdpi device Samsung S3 specs: 720 x 1280 pixels, 4.8 inches (~306 ppi pixel density) - So, it's an xhdpi device

Now, you should read this: developer.android.com/guide/practices/screens_support.html.

A very quick fix could be: put the image in the /res/drawable-xhdpi folder (if you don't have the folder, just create it).


Also consider that:

The images should be saved at the proper dpi resolution.
A common error is to leave them at the standard (insufficient) resolution of 72 dpi or 96 dpi.

hdpi images resolution should be 240 dpi and xhdpi images resolution should be 320 dpi, to display properly and scale well.

So, what to do?

Change the resolution of the bigger image, without changing its size (which is automatically scaled when you touch the resolution - so, reset it to 1280*800).
Then make the smaller image out of this one, by changing the resolution (it should scale down to the correct size 480*854 - just cut out the exceeding 54 pixel - 27 from the top and 27 from the bottom).

Once you put the right images into their proper folders, everything should now fit well.

like image 157
Phantômaxx Avatar answered Oct 04 '22 21:10

Phantômaxx