Skip to content Skip to sidebar Skip to footer

Y + Height Must Be <= Bitmap.height() In Android

I want to create a bitmap form another but for each try it's a crash, this the error message java.lang.IllegalArgumentException: y + height must be <= bitmap.height()

Solution 1:

Try

Bitmapresult= Bitmap.createBitmap(bitmapToSave, 0, 0, view.getWidth(), view.getHeight());

I think the issue is view.getTop is a value greater than 0. So view.GetTop + view.getHeight() is not less than bitmap.height.

Solution 2:

In your code, in the second BitmapCreate:

Bitmapresult= Bitmap.createBitmap(bitmapToSave, 0, view.getTop(), view.getWidth(), view.getWidth());

The height argument (the last one) is set to be View.getWidth(). However, nowhere in the code have you checked that the width of the view, added to the Top of the view, is not greater than the height of bitmapToSave. A check to this effect should go in.

Post a Comment for "Y + Height Must Be <= Bitmap.height() In Android"