X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=androidtest%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fclient%2Fandroidtest%2FSaveThread.java;h=166e495cbfc9607f2c6d0fddbd89a4fe094d2e86;hb=37298b5275c5f7ada23bfa10ac861fa8ea2dfe4b;hp=16928589c55626133ed88f650547adcf2ee2feda;hpb=96659a17aec334f4cf0df76914c229b079705acc;p=zxing.git diff --git a/androidtest/src/com/google/zxing/client/androidtest/SaveThread.java b/androidtest/src/com/google/zxing/client/androidtest/SaveThread.java index 16928589..166e495c 100755 --- a/androidtest/src/com/google/zxing/client/androidtest/SaveThread.java +++ b/androidtest/src/com/google/zxing/client/androidtest/SaveThread.java @@ -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) {