Updated the Android Test app to use a wider viewfinder, to save images as PNGs instea...
[zxing.git] / androidtest / src / com / google / zxing / client / androidtest / SaveThread.java
index 1692858..166e495 100755 (executable)
@@ -63,12 +63,13 @@ final class SaveThread extends Thread {
     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();
-    assert (framingWidth <= width);
-    assert (framingHeight <= height);
+    if (framingWidth > width || framingHeight > height) {
+      throw new IllegalArgumentException();
+    }
 
     int leftOffset = mFramingRect.left;
     int topOffset = mFramingRect.top;
@@ -87,7 +88,7 @@ final class SaveThread extends Thread {
         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);
@@ -118,7 +119,7 @@ final class SaveThread extends Thread {
         }
       }
       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) {