Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalArgumentException: x + width must be <= bitmap.width() #40

Closed
athkalia opened this issue Dec 28, 2015 · 12 comments
Closed

Comments

@athkalia
Copy link

Hello,

I am getting this exception:

java.lang.IllegalArgumentException: x + width must be <= bitmap.width()
 at android.graphics.Bitmap.createBitmap(Bitmap.java:698)
 at com.isseiaoki.simplecropview.CropImageView.getCroppedBitmap(SourceFile:1012)
 at bci.onClick(SourceFile:1064)
 at android.view.View.performClick(View.java:4463)
 at android.view.View$PerformClick.run(View.java:18801)
 at android.os.Handler.handleCallback(Handler.java:808)
 at android.os.Handler.dispatchMessage(Handler.java:103)
 at android.os.Looper.loop(Looper.java:193)
 at android.app.ActivityThread.main(ActivityThread.java:5299)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:515)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
 at dalvik.system.NativeStart.main(Native Method)

every once in a while. Any idea on what's happening there?

Cheers,
Sakis

@igreenwood
Copy link
Owner

Hi,

Which version are you using?
This bug caused by float precision.
I fixed this bug in ver.1.0.10.
If you are using ver.1.0.10 or newer version,
I have to fix it again...

@athkalia
Copy link
Author

Unfortunately I am using 1.0.10 : >

@igreenwood
Copy link
Owner

OK, I will fix it : )

Can you tell me more specific?

In the previous case, the exception occured when the frame size and the original image size looks equal.
(But the frame size actually was little bigger than original image by the error of float.)

@athkalia
Copy link
Author

Sorry, I can't replicate it locally, it happened to some of my users and I just saw the stacktrace in play store. If I manage to replicate it, I'll post again.

@igreenwood
Copy link
Owner

Hi,

I can't replicate it too, but I added code for checking frame size before cropping the image.
Please try a new version 1.0.15 : )

@andrijans
Copy link

I have this issue on 1.0.13 also but its happening random. I will test 1.0.15 now

@andrijans
Copy link

I got it on 1.0.15 again

@andrijans
Copy link

I found a case. so i load image and i just pull one of right handles to the end of image but without moving frame on screen. As soon as i move frame on screen it works

Update:
In getCroppedBitmap() on line

Bitmap cropped = Bitmap.createBitmap(source, x, y, w, h, null, false);

source width is 2988 and my x is 374 and w is 2615 which is 2989 and that is problem. probably because of some rounding.

In your check for frame size you should check if(x+w>source.getWidth) not if(w>source.getWidth())

@athkalia
Copy link
Author

Well played!

@athkalia
Copy link
Author

So you'll be releasing a 1.0.16 any time soon ? :D

andrijans pushed a commit to andrijans/SimpleCropView that referenced this issue Jan 14, 2016
igreenwood added a commit that referenced this issue Jan 15, 2016
fixed issue #40  x + width must be <= bitmap.width
@igreenwood
Copy link
Owner

@andrijans Thank you for your PR. I merged your PR and updated.

New version has been released. Please use version 1.0.16.

@igreenwood
Copy link
Owner

Hi,

Sorry for late response.

Version 1.1.0 has been released.
It contains bug fix for crop algorithm.
Please try sample.

2016-04-03 20:59 GMT+09:00 Zahar notifications@github.com:

I hae this issues again in version 1.0.16 =(


You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHub
#40 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants