1

I compiled a wallpaper app from a source code, inserted some 1230x720 pictures, But when I applied the walls using that app, they always get cropped automatically. What should I change in the code to apply at the original size and resolution?

Here's an example: 1.Original Picture: https://i.stack.imgur.com/ziSBt.jpg

2.After applying as an wallpaper using my app: https://i.stack.imgur.com/19xMQ.jpg

Source code: blog.blundell-apps.com/set-phone-wallpaper/

Thanks

EDIT: this code in HeavyLifter.java seems to be the culprit, how do I change it to "Fit the screen resolution"?

private Bitmap getImage(int resourceId) {
    Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resourceId, null);
    Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, manager.getDesiredMinimumWidth(),   manager.getDesiredMinimumHeight(), true);
    bitmap.recycle();
    bitmap = null;
    return scaledBitmap;
}
Rodrigo Borges
  • 474
  • 3
  • 10

1 Answers1

0

The aspect ratio of the image (720x1230) and manager.getDesiredMinimumWidth() to manager.getDesiredMinimumHeight() (720x1280) are not the same and so the image gets distorted.

So eighter provide a image with a fitting aspect ratio or crop the image before applying the scaling operation

Dawnkeeper
  • 2,844
  • 1
  • 25
  • 41
  • Can you please tell me how to keep the aspect ratio. I'm noob :-( – Seiji Dinzuala Nov 10 '14 at 20:37
  • I can fit correctly into my phone's screen from the second answer here http://stackoverflow.com/questions/15440647/scaled-bitmap-maintaining-aspect-ratio?rq=1 But not sure if it will be correct for other phones with different res – Seiji Dinzuala Nov 10 '14 at 21:13
  • yes, that's what you have to do. You might want to replace the 4096 with maximum of width and height from the devices screen size. See [here](http://stackoverflow.com/questions/1016896/get-screen-dimensions-in-pixels) – Dawnkeeper Nov 10 '14 at 21:40