Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why my home screen wallpaper is damaged?

Tags:

android

Hi i am coding to set a Home Screen Wallpaper. It's working fine. But my image pixel is totally damaged and then my wallpaper is not fit with the actual size of the home screen. I am try to workout different size of images. Unfortunately it's not working for me. How to solve it.

My code is here

WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Drawable drawable = getResources().getDrawable(R.drawable.newimage);
Bitmap wallpaper = ((BitmapDrawable) drawable).getBitmap();           
try 
{
    wallpaperManager.setBitmap(wallpaper);
} 
catch (IOException e) 
{
    e.printStackTrace();
}

My Screenshot Original Image
enter image description here

My Screenshot Android Emulator Home Screen
enter image description here

Why my original image is damaged here.
How to display My Original Image based on the Emulator Size.

like image 792
Sekar Avatar asked Jun 28 '12 08:06

Sekar


People also ask

Why is my home screen wallpaper moving?

This is to make the zoom out effect possible on the wallpaper when you open the notification tray (swipe down from the top of the screen).

Why did my lock screen wallpaper change?

1 Solution. Go to dynamic lock screen settings and turn off auto update.

How do I get back to my original home screen wallpaper?

With a custom launcher installed, tap Settings > Select Default Launcher or similar to reset back to your original home screen. Remove apps and widgets by holding your finger to them and tapping Uninstall or Remove. Reset your wallpaper by holding a finger to the home screen and tapping Wallpaper.


1 Answers

You can try this:

WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Drawable drawable = getResources().getDrawable(R.drawable.newimage);
Bitmap wallpaper_source = ((BitmapDrawable) drawable).getBitmap();           
try {
    int w = wallpaperManager.getDesiredMinimumWidth();
    int h = wallpaperManager.getDesiredMinimumHeight();
    int x = (w-wallpaper_source.getWidth())/2;
    int y = (h-wallpaper_source.getHeight())/2;
    Bitmap wallpaper = Bitmap.createBitmap(w, h, Config.ARGB_8888);
    Canvas c = new Canvas(wallpaper);
    c.drawBitmap(wallpaper_source, x,y, null);
    wallpaperManager.setBitmap(wallpaper);
} 
catch (IOException e) 
{
    e.printStackTrace();
}
like image 75
ALiGOTec Avatar answered Nov 15 '22 13:11

ALiGOTec