Updated the Android Test app to use a wider viewfinder, to save images as PNGs instea...
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Fri, 26 Jun 2009 18:48:14 +0000 (18:48 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Fri, 26 Jun 2009 18:48:14 +0000 (18:48 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@996 59b500cc-1b3d-0410-9834-0bbf25fbcc57

androidtest/res/values/strings.xml
androidtest/src/com/google/zxing/client/androidtest/CameraManager.java
androidtest/src/com/google/zxing/client/androidtest/CameraTestActivity.java
androidtest/src/com/google/zxing/client/androidtest/SaveThread.java

index 18773c1..ac53797 100755 (executable)
   <string name="result_failed">No barcode found</string>
   <string name="result_failed_why">"The user gave up and pressed Back"</string>
   <string name="result_succeeded">Found barcode</string>
   <string name="result_failed">No barcode found</string>
   <string name="result_failed_why">"The user gave up and pressed Back"</string>
   <string name="result_succeeded">Found barcode</string>
-  <string name="status_message">Press the shutter button to save images to the SD card for testing purposes. Press DPAD_CENTER to trigger autofocus.</string>
+  <string name="status_message">Press the shutter button or Search to save test images to the
+    SD card. Press DPAD_CENTER to trigger autofocus.</string>
   <string name="save_succeeded">Save succeeded</string>
   <string name="save_failed">Save failed - is the SD card installed?</string>
   <string name="share_via_barcode">Share via barcode</string>
 
   <string name="benchmark_name">ZXing Benchmark</string>
   <string name="save_succeeded">Save succeeded</string>
   <string name="save_failed">Save failed - is the SD card installed?</string>
   <string name="share_via_barcode">Share via barcode</string>
 
   <string name="benchmark_name">ZXing Benchmark</string>
-  <string name="benchmark_help">Place images in /sdcard/zxingbenchmark, then check \"adb logcat\" for results. Turn on Airplane Mode first for more reliable results.</string>
+  <string name="benchmark_help">Place images in /sdcard/zxingbenchmark, then check \"adb logcat\"
+    for results. Turn on Airplane Mode first for more reliable results.</string>
   <string name="benchmark_run">Run benchmark</string>
   <string name="benchmark_running">Benchmark running...\u2026</string>
 </resources>
   <string name="benchmark_run">Run benchmark</string>
   <string name="benchmark_running">Benchmark running...\u2026</string>
 </resources>
index 723a021..865d03b 100755 (executable)
@@ -132,11 +132,11 @@ final class CameraManager {
    */
   public Rect getFramingRect() {
     if (mFramingRect == null) {
    */
   public Rect getFramingRect() {
     if (mFramingRect == null) {
-      int size = ((mScreenResolution.x < mScreenResolution.y) ? mScreenResolution.x :
-          mScreenResolution.y) * 3 / 4;
-      int leftOffset = (mScreenResolution.x - size) / 2;
-      int topOffset = (mScreenResolution.y - size) / 2;
-      mFramingRect = new Rect(leftOffset, topOffset, leftOffset + size, topOffset + size);
+      int width = mScreenResolution.x;
+      int height = mScreenResolution.y * 3 / 4;
+      int leftOffset = (mScreenResolution.x - width) / 2;
+      int topOffset = (mScreenResolution.y - height) / 2;
+      mFramingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);
     }
     return mFramingRect;
   }
     }
     return mFramingRect;
   }
index 0ea89ac..c23bec1 100755 (executable)
@@ -101,7 +101,7 @@ public final class CameraTestActivity extends Activity implements SurfaceHolder.
         CameraManager.get().requestAutoFocus(mHandler, R.id.auto_focus);
       }
       return true;
         CameraManager.get().requestAutoFocus(mHandler, R.id.auto_focus);
       }
       return true;
-    } else if (keyCode == KeyEvent.KEYCODE_CAMERA) {
+    } else if (keyCode == KeyEvent.KEYCODE_CAMERA || keyCode == KeyEvent.KEYCODE_SEARCH) {
       if (event.getRepeatCount() == 0) {
         CameraManager.get().requestPreviewFrame(mSaveThread.mHandler, R.id.save);
       }
       if (event.getRepeatCount() == 0) {
         CameraManager.get().requestPreviewFrame(mSaveThread.mHandler, R.id.save);
       }
index 698d6ef..166e495 100755 (executable)
@@ -63,7 +63,7 @@ final class SaveThread extends Thread {
     Looper.loop();
   }
 
     Looper.loop();
   }
 
-  // Save the center rectangle of the Y channel as a greyscale JPEG to the SD card
+  // Save the center rectangle of the Y channel as a greyscale PNG to the SD card.
   private void save(byte[] data, int width, int height) {
     int framingWidth = mFramingRect.width();
     int framingHeight = mFramingRect.height();
   private void save(byte[] data, int width, int height) {
     int framingWidth = mFramingRect.width();
     int framingHeight = mFramingRect.height();
@@ -88,7 +88,7 @@ final class SaveThread extends Thread {
         Bitmap.Config.ARGB_8888);
     OutputStream outStream = getNewPhotoOutputStream();
     if (outStream != null) {
         Bitmap.Config.ARGB_8888);
     OutputStream outStream = getNewPhotoOutputStream();
     if (outStream != null) {
-      bitmap.compress(Bitmap.CompressFormat.JPEG, 80, outStream);
+      bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
       try {
         outStream.close();
         Message message = Message.obtain(mActivity.mHandler, R.id.save_succeeded);
       try {
         outStream.close();
         Message message = Message.obtain(mActivity.mHandler, R.id.save_succeeded);
@@ -119,7 +119,7 @@ final class SaveThread extends Thread {
         }
       }
       Date now = new Date();
         }
       }
       Date now = new Date();
-      String fileName = now.getTime() + ".jpg";
+      String fileName = now.getTime() + ".png";
       try {
         return new FileOutputStream(new File(barcodes, fileName));
       } catch (FileNotFoundException e) {
       try {
         return new FileOutputStream(new File(barcodes, fileName));
       } catch (FileNotFoundException e) {