=============== Problem description ====================
Bitmap android. graphics. Bitmap. createBitmap (Bitmap source, int x, int y, int width, int height)
This method cannot be used.
What do the four parameters mean?
Isn't it a rectangle's x, y, width and height/
Why do I pass in this:
Bitmap bitmap = Bitmap. createBitmap (b1, 0, 20, b1.getWidth (),
B1.getHeight ());
I mean, from the height of 20 till the end of the image.
Report this error to me.
Java. lang. IllegalArgumentException: y + height must be <= bitmap. height ()
Do I need to fill in a negative number...
============= Solution 1 ======================
This method is very difficult.
The memory overflows ..
Recommended
Bitmap dragimg = Bitmap. createScaledBitmap (bmp, lockWidth, lockWidth, true );
Method
The input values are
Converted image object
Width and height
The last parameter is whether to guarantee the equality ratio.
============= Solution 2 ======================
Reply to reference siyehua on the second floor:
Quote: reference the reply of AA5279AA on the first floor:
This method is very difficult.
The memory overflows ..
Recommended
Bitmap dragimg = Bitmap. createScaledBitmap (bmp, lockWidth, lockWidth, true );
Method
The input values are
Converted image object
Width and height
The last parameter is whether to guarantee the equality ratio.
Yes. I don't want the whole picture. I only want some, that is, I don't want the top picture...
Let's take a look at the folder in which you put the images.
If you put
In the xxhdpi folder, the image is smaller than the actual one. Possible errors are listed by you.
============= Solution 3 ======================
Reply to reference siyehua on the 4th floor:
Quote: reference the reply of AA5279AA on the third floor:
Quote: reference the reply from siyehua on the second floor:
Quote: reference the reply of AA5279AA on the first floor:
This method is very difficult.
The memory overflows ..
Recommended
Bitmap dragimg = Bitmap. createScaledBitmap (bmp, lockWidth, lockWidth, true );
Method
The input values are
Converted image object
Width and height
The last parameter is whether to guarantee the equality ratio.
Yes. I don't want the whole picture. I only want some, that is, I don't want the top picture...
Let's take a look at the folder in which you put the images.
If you put
In the xxhdpi folder, the image is smaller than the actual one. Possible errors are listed by you.
I am actually a screenshot. I get a Bitmap that includes the status bar. The problem status bar is still white. Now I want to remove the top part of the white and save it.
You get the image bmp
Then bmp. getHeight () is the height of the image, for example, 300
Then the color-changing height is 100.
Set
Bitmap. createBitmap (bmp, 0,100, bmp. getWidht (), 200 );
That's all.
============= Solution 4 ======================
Java. lang. IllegalArgumentException: y + height must be <= bitmap. height ()
It refers to the area where a part of an image is taken from to the end of height. The screenshot in your method is out of the image range.
For example:
Bitmap android. graphics. Bitmap. createBitmap (source, 0, 0,100,100) is from the upper left corner of the image source to the width and height of the image 100 and 100.
============= Solution 5 ======================
Reply to reference siyehua on the 7 th floor:
Quote: reference the reply from scliu0718 on the 6th floor:
Java. lang. IllegalArgumentException: y + height must be <= bitmap. height ()
It refers to the area where a part of an image is taken from to the end of height. The screenshot in your method is out of the image range.
For example:
Bitmap android. graphics. Bitmap. createBitmap (source, 0, 0,100,100) is from the upper left corner of the image source to the width and height of the image 100 and 100.
I know, but what I intercepted is definitely not exceeded.
Mine is: Bitmap. createBitmap (b1, 0, 20, b1.getWidth (), b1.getHeight ());
, The width and height are not exceeded, but the calculation method of this method is: 20 + b1.getHeight (), which must exceed...
So I think there is a problem with the calculation method of this method.
Oh, we are wrong. The last two parameters should be the height and width of the captured image.
Bitmap. createBitmap (Bitmap source, int x, int y, int width, int height)