android - Bitmap.createScaledBitmap results in a Bitmap sized -1
i try creating a scaled bitmap using that method but once i access the bitmap, my app crashes with the following message:
"java.lang.IllegalArgumentException: y + height must be <= bitmap.height()"
When I debug it, I can see that immediately after calling "createScaledBitmap", the resulting bitmap has a size of -1, -1. if i use "createBitmap" instead, the resulting bitmap does show the size of the original bitmap.
Should nobody here know what the cause of this is... is there maybe a workaround to resize a bitmap differently? I couldn't f开发者_JS百科ind anything in the bitmap class but maybe somebody here knows another way?
First, i want to clarify that you are getting an error from Bitmap.createBitmap method, not from Bitmap.createScaledBitmap. Syntax of createBitmap is as shown below,
Bitmap.createBitmap(Bitmap source, int x, int y, int width, int height, Matrix m, boolean filter)
Parameters
source: The bitmap we are subsetting
x: The x coordinate of the first pixel in source
y: The y coordinate of the first pixel in source
width: The number of pixels in each row
height: The number of rows
m: Optional matrix to be applied to the pixels
filter: true if the source should be filtered. Only applies if the matrix contains more than just translation.
An error is occured because,
x, y, width, height values are outside of the dimensions of the source bitmap.
精彩评论