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;
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);
}
}
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) {