Search code examples
androidbitmapwallpaperimage-resizing

Type Bitmap is not applicable for the arguments (int, int, int, boolean)


I get this error on the 3rd line of code in Eclipse:

The method createScaledBitmap(Bitmap, int, int, boolean) in the type Bitmap is not applicable for the arguments (int, int, int, boolean)

Here is the code:

int newWidth = myWallpaperManager.getDesiredMinimumWidth();
int newHeight = myWallpaperManager.getDesiredMinimumHeight();

Bitmap resizedBitmap = Bitmap.createScaledBitmap(R.drawable.kabacloseup, newWidth, newHeight, false);

myWallpaperManager.setResource(resizedBitmap);

Can you tell me how to make createScaledBitmap accept the arguments?

I also get this error on the 4th line:

The method setResource(int) in the type WallpaperManager is not applicable for the arguments (Bitmap)

Update:

BitmapFactory.Options opt = new BitmapFactory.Options();
opt.outWidth = myWallpaperManager.getDesiredMinimumWidth();
opt.outHeight = myWallpaperManager.getDesiredMinimumHeight();
Bitmap b = BitmapFactory.decodeResource(context.getResources(), R.drawable.kabacloseup, opt);

try {
    myWallpaperManager.setBitmap(b);
    myCurrentImageName = "kabacloseup";

} catch (IOException e) {
    e.printStackTrace();
}

Solution

  • Try this

    BitmapFactory.Options opt = new BitmapFactory.Options();
    opt.outWidth = myWallpaperManager.getDesiredMinimumWidth();
    opt.outHeight = myWallpaperManager.getDesiredMinimumHeight();
    Bitmap b = BitmapFactory.decodeResource(context.getResources(), R.drawable.kabacloseup, opt);