Please help: Advice on keeping images scaled properly

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Please help: Advice on keeping images scaled properly

Postby dreamdelerium » Mon Feb 08, 2010 3:51 am

hi everyone. i have another question. I have a game that displays playing cards in a view (they're drawn onto a canvas). I developed the game on a window size of 320X480. the image i use are sized 112X57. when i ran this program on a smaller screen, it didnt display correctly. so, im trying to scale the images but when i do, the process makes the images look really bad. how should i go about keeping the images at the appropriate size but not sacrifice quality?
dreamdelerium
Developer
Developer
 
Posts: 30
Joined: Fri Jan 01, 2010 11:19 pm

Top

Re: Please help: Advice on keeping images scaled properly

Postby Rahul » Mon Feb 08, 2010 7:36 am

Scaling images to a larger extend will have an impact on its clarity.May be if these are static images you can try using them from your drawable folder and you can have three different images for three different screen resolutions

in the res folder you could see three folders named drawbale-hdpi,drawable-mdpi,drawable-ldpi

keep the high density image in hdpi,medium density image in mdpi and low density image in ldpi. Android should automatically take up the respective image from the respective screen resolution.


dreamdelerium wrote:hi everyone. i have another question. I have a game that displays playing cards in a view (they're drawn onto a canvas). I developed the game on a window size of 320X480. the image i use are sized 112X57. when i ran this program on a smaller screen, it didnt display correctly. so, im trying to scale the images but when i do, the process makes the images look really bad. how should i go about keeping the images at the appropriate size but not sacrifice quality?
Rahul
Experienced Developer
Experienced Developer
 
Posts: 89
Joined: Wed Oct 01, 2008 11:16 am

Thanks but...

Postby dreamdelerium » Mon Feb 08, 2010 5:14 pm

thank you for your advice. the problem is that if i run this program using Android 1.1 or 1.5, eclipse complains about the extra folder (it draws a warning underline under the folders and wont compile). What do you suggest?
dreamdelerium
Developer
Developer
 
Posts: 30
Joined: Fri Jan 01, 2010 11:19 pm

Re: Thanks but...

Postby jagtap.jj1 » Mon Feb 08, 2010 7:42 pm

The images in Android can shrink and stretch by using
"Options" http://developer.android.com/reference/ ... tions.html

e.g. For shrink image
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;

Bitmap mBitmap = BitmapFactory.decodeResource(Resources res, int id, BitmapFactory.Options opts);

Here you will get image bitmap which is half of original image.

Like this you can stretch image using Options;
java-android developer
User avatar
jagtap.jj1
Senior Developer
Senior Developer
 
Posts: 124
Joined: Fri Aug 22, 2008 11:52 am
Location: India(Mumbai)

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests