journeyapps / zxing-android-embedded

Barcode scanner library for Android, based on the ZXing decoder
https://journeyapps.com/
Apache License 2.0
5.75k stars 1.27k forks source link

Crash after applying setOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); #63

Closed hishammalik closed 9 years ago

hishammalik commented 9 years ago

The barcode scanning screen crashes on Samsung S4 (haven't tried on others) after I used the setOrientation function in the v2 library. Exception is as follows:

java.lang.IllegalArgumentException: Crop rectangle does not fit within image data.
at com.google.zxing.PlanarYUVLuminanceSource.<init>(PlanarYUVLuminanceSource.java:50)
at com.google.zxing.client.android.camera.CameraManager.buildLuminanceSource(CameraManager.java:331)
at com.google.zxing.client.android.DecodeHandler.decode(DecodeHandler.java:76)
at com.google.zxing.client.android.DecodeHandler.handleMessage(DecodeHandler.java:56)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at com.google.zxing.client.android.DecodeThread.run(DecodeThread.java:87)

Code setting up barcode scanning is:

IntentIntegrator integrator = new IntentIntegrator(this);
integrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES);
integrator.setPrompt("Scan a barcode");
integrator.setResultDisplayDuration(0);
integrator.setWide();  // Wide scanning rectangle, may work better for 1D barcodes
integrator.setCameraId(0);  // Use a specific camera of the device
integrator.setOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
integrator.initiateScan();
rkistner commented 9 years ago

Try using the latest version of the lib - the logic for handling different orientations changed completely. Note that the API for also changed - see the new readme.

On Saturday, June 27, 2015, Hisham Malik notifications@github.com wrote:

The barcode scanning screen crashes on Samsung S4 (haven't tried on others) after I used the setOrientation function. Exception is as follows:

java.lang.IllegalArgumentException: Crop rectangle does not fit within image data. at com.google.zxing.PlanarYUVLuminanceSource.(PlanarYUVLuminanceSource.java:50) at com.google.zxing.client.android.camera.CameraManager.buildLuminanceSource(CameraManager.java:331) at com.google.zxing.client.android.DecodeHandler.decode(DecodeHandler.java:76) at com.google.zxing.client.android.DecodeHandler.handleMessage(DecodeHandler.java:56) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at com.google.zxing.client.android.DecodeThread.run(DecodeThread.java:87)

Code setting up barcode scanning is: IntentIntegrator integrator = new IntentIntegrator(this); integrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES); integrator.setPrompt("Scan a barcode"); integrator.setResultDisplayDuration(0); integrator.setWide(); // Wide scanning rectangle, may work better for 1D barcodes integrator.setCameraId(0); // Use a specific camera of the device integrator.setOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); integrator.initiateScan();

— Reply to this email directly or view it on GitHub https://github.com/journeyapps/zxing-android-embedded/issues/63.

hishammalik commented 9 years ago

Works well with Version 3 @rkistner. Thanks.