Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
[#4] Android UI doesn't support Portrait and is small - portrait scan…
Browse files Browse the repository at this point in the history
…ning of non-QR codes didn't work
  • Loading branch information
EddyVerbruggen committed Oct 9, 2014
1 parent 20799f1 commit fe77464
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.phonegap.plugins.barcodescanner"
version="1.2.5">
version="1.2.6">

<name>BarcodeScanner</name>
<description>You can use the BarcodeScanner plugin to scan different types of barcodes (using the device's camera) and get the metadata encoded in them for processing within your application.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@ public int compare(Camera.Size a, Camera.Size b) {

WindowManager manager = (WindowManager) this.context.getSystemService(Context.WINDOW_SERVICE);
int rotation = manager.getDefaultDisplay().getRotation();
// don't vertically stretch the camera view on portrait mode
if (rotation == Surface.ROTATION_0) {
if (bestSize.y <= bestSize.x) {
bestSize.y = (int) ((float)bestSize.y / screenAspectRatio * ((float)bestSize.x / (float) bestSize.y));
}
}

Log.i(TAG, "Found best approximate preview size: " + bestSize);
return bestSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,22 +294,31 @@ public synchronized void setManualFramingRect(int width, int height) {
}
}

/**
* A factory method to build the appropriate LuminanceSource object based on the format
* of the preview buffers, as described by Camera.Parameters.
*
* @param data A preview frame.
* @param width The width of the image.
* @param height The height of the image.
* @return A PlanarYUVLuminanceSource instance.
*/
public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) {
// Hack of orientation
Display display = windowManager.getDefaultDisplay();
int rotation = display.getRotation();

byte[] rotatedData = new byte[data.length];
if (rotation == Surface.ROTATION_0) {
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
rotatedData[x * height + height - y - 1] = data[x + y * width];
}
}
int tmp = width;
width = height;
height = tmp;
} else {
rotatedData = null;
}

Rect rect = getFramingRectInPreview();
if (rect == null) {
return null;
}
// Go ahead and assume it's YUV rather than die.
return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
return new PlanarYUVLuminanceSource(rotation == Surface.ROTATION_0 ? rotatedData : data, width, height, rect.left, rect.top,
rect.width(), rect.height(), false);
}
}
Binary file modified src/android/com.google.zxing.client.android.captureactivity.jar
Binary file not shown.

0 comments on commit fe77464

Please sign in to comment.