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

Crop rectangle does not fit within image data #15

Open
lgabardos opened this issue May 23, 2014 · 6 comments
Open

Crop rectangle does not fit within image data #15

lgabardos opened this issue May 23, 2014 · 6 comments

Comments

@lgabardos
Copy link

Hi,
I updated the library yesterday and, i got this issue...

java.lang.IllegalArgumentException: Crop rectangle does not fit within image data.
at com.google.zxing.PlanarYUVLuminanceSource.(PlanarYUVLuminanceSource.java:50)
at com.welcu.android.zxingfragmentlib.camera.CameraManager.buildLuminanceSource(CameraManager.java:360)
at com.welcu.android.zxingfragmentlib.DecodeHandler.decode(DecodeHandler.java:77)
at com.welcu.android.zxingfragmentlib.DecodeHandler.handleMessage(DecodeHandler.java:56)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at com.welcu.android.zxingfragmentlib.DecodeThread.run(DecodeThread.java:101)

It appears when I use the phone in landscape and open the my BarcodeScannerFragment.

I googled this error and, obviously, it means the device's camera driver has a bug.

BUT, i got the issue on multiple devices... and I don't really how to fix it...

Any clue ? Thanks

Laurent

@lgabardos
Copy link
Author

Hum... Nobody ?

I also notice that sample given with the library crash for the same reason.

Launch it (portrait mode is ok), change the phone's orientation and... Force close with "java.lang.IllegalArgumentException: Crop rectangle does not fit within image data."

@mitoyarzun mitoyarzun mentioned this issue Aug 21, 2014
@mitoyarzun
Copy link
Owner

Hi!

It's working now, but the preview rectangle is a little bit off. I'm working on that, but it scans :)

@nijian81
Copy link

up stair id correct , perfect .i resolve my trubel

@gzp1124
Copy link

gzp1124 commented Jun 14, 2016

in PlanarYUVLuminanceSource 49 line
if (left + width > dataWidth || top + height > dataHeight) { throw new IllegalArgumentException("Crop rectangle does not fit within image data."); }
i change rect calculate
int cameraWidth = cameraManager.getCameraResolution().y; int cameraHeight = cameraManager.getCameraResolution().x;
to
int cameraWidth = isVertical?cameraManager.getCameraResolution().y:cameraManager.getCameraResolution().x; int cameraHeight = isVertical?cameraManager.getCameraResolution().x:cameraManager.getCameraResolution().y;
it worked. :)

@dafeige8
Copy link

Upstairs, your "int cameraWidth = cameraManager.getCameraResolution().y; int cameraHeight = cameraManager.getCameraResolution().x;" in which file, is customized or Zxing comes with?

@soenkegissel
Copy link

I had similar issue. Using zxing-android-embedded (https://github.com/journeyapps/zxing-android-embedded).

Zxing greater version 3.3.0 bring this issue to some users of my app.

Downgrading to 3.3.0 fix it.

dependencies {
implementation('com.journeyapps:zxing-android-embedded:3.6.0')
{ transitive = false }
implementation 'com.google.zxing:core:3.3.0'
}
This version is even compatible down to API level 14.

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

6 participants