diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index 96cc43e..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index e7bedf3..0000000
--- a/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index ba7052b..99202cc 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,11 +5,12 @@
@@ -24,7 +25,7 @@
-
+
diff --git a/libraryzxing/src/main/java/com/google/zxing/client/android/CaptureActivity.java b/libraryzxing/src/main/java/com/google/zxing/client/android/CaptureActivity.java
index 7ba3499..48319f4 100755
--- a/libraryzxing/src/main/java/com/google/zxing/client/android/CaptureActivity.java
+++ b/libraryzxing/src/main/java/com/google/zxing/client/android/CaptureActivity.java
@@ -216,6 +216,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
new Thread(new Runnable() {
@Override
public void run() {
+ //需要压缩图片
Bitmap bitmapChoose = ZXingUtils.decodeUriAsBitmap(CaptureActivity.this, uri);
if (bitmapChoose != null) {
final String decodeQRCodeFromBitmap = ZXingUtils.syncDecodeQRCode(bitmapChoose);
diff --git a/libraryzxing/src/main/java/com/google/zxing/client/android/utils/ZXingUtils.java b/libraryzxing/src/main/java/com/google/zxing/client/android/utils/ZXingUtils.java
index 1b42927..6cf4da8 100644
--- a/libraryzxing/src/main/java/com/google/zxing/client/android/utils/ZXingUtils.java
+++ b/libraryzxing/src/main/java/com/google/zxing/client/android/utils/ZXingUtils.java
@@ -271,7 +271,14 @@ public static String recode(String str) {
public static Bitmap decodeUriAsBitmap(Context context, Uri uri) {
Bitmap bitmap = null;
try {
- bitmap = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri));
+// bitmap = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri));
+ //压缩图片
+ final BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inJustDecodeBounds = true;
+ BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri), null, options);
+ options.inSampleSize = calculateInSampleSize(options, 720, 1280);
+ options.inJustDecodeBounds = false;
+ bitmap = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri), null, options);
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
@@ -279,4 +286,21 @@ public static Bitmap decodeUriAsBitmap(Context context, Uri uri) {
return bitmap;
}
+ //计算图片的缩放值
+ public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
+ final int height = options.outHeight;
+ final int width = options.outWidth;
+ int inSampleSize = 1;
+ if (height > reqHeight || width > reqWidth) {
+ //使用需要的宽高的最大值来计算比率
+ final int suitedValue = reqHeight > reqWidth ? reqHeight : reqWidth;
+ final int heightRatio = Math.round((float) height / (float) suitedValue);
+ final int widthRatio = Math.round((float) width / (float) suitedValue);
+
+ inSampleSize = heightRatio > widthRatio ? heightRatio : widthRatio;//用最大
+ }
+ return inSampleSize;
+ }
+
+
}
diff --git a/libraryzxing/src/main/res/drawable/mn_scan_dialog_bg.xml b/libraryzxing/src/main/res/drawable/mn_scan_dialog_bg.xml
index 2e558e4..f90c1ca 100644
--- a/libraryzxing/src/main/res/drawable/mn_scan_dialog_bg.xml
+++ b/libraryzxing/src/main/res/drawable/mn_scan_dialog_bg.xml
@@ -15,19 +15,4 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/libraryzxing/src/main/res/layout/mn_scan_capture.xml b/libraryzxing/src/main/res/layout/mn_scan_capture.xml
index e6ce357..9184155 100755
--- a/libraryzxing/src/main/res/layout/mn_scan_capture.xml
+++ b/libraryzxing/src/main/res/layout/mn_scan_capture.xml
@@ -103,8 +103,8 @@
android:visibility="visible">
-
-