Small improvement

pull/217/head
M66B 9 months ago
parent 5b93854656
commit 6f828dc8af

@ -548,7 +548,7 @@ public class ContactInfo {
"." + info.type +
(info.verified ? "_verified" : ""));
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(output))) {
info.bitmap.compress(Bitmap.CompressFormat.PNG, 90, os);
info.bitmap.compress(Bitmap.CompressFormat.PNG, ImageHelper.DEFAULT_PNG_COMPRESSION, os);
}
Log.i("Avatar to cache=" + output.getName());
}
@ -614,7 +614,7 @@ public class ContactInfo {
// Add to cache
File output = new File(dir, etag + "." + info.type);
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(output))) {
info.bitmap.compress(Bitmap.CompressFormat.PNG, 90, os);
info.bitmap.compress(Bitmap.CompressFormat.PNG, ImageHelper.DEFAULT_PNG_COMPRESSION, os);
} catch (IOException ex) {
Log.e(ex);
}

@ -328,7 +328,6 @@ public class FragmentCompose extends FragmentBase {
private int searchIndex = 0;
static final int REDUCED_IMAGE_SIZE = 1440; // pixels
private static final int REDUCED_IMAGE_QUALITY = 90; // percent
// http://regex.info/blog/lightroom-goodies/jpeg-quality
private static final int COPY_ATTACHMENT_TIMEOUT = 60; // seconds
@ -5590,7 +5589,7 @@ public class FragmentCompose extends FragmentBase {
File tmp = new File(file.getAbsolutePath() + ".tmp");
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(tmp))) {
if (!resized.compress(format, REDUCED_IMAGE_QUALITY, out))
if (!resized.compress(format, ImageHelper.DEFAULT_PNG_COMPRESSION, out))
throw new IOException("compress");
} catch (Throwable ex) {
Log.w(ex);

@ -121,7 +121,7 @@ public class FragmentDialogEditImage extends FragmentDialogBase {
File file = attachment.getFile(context);
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
bm.compress(Bitmap.CompressFormat.PNG, 90, os);
bm.compress(Bitmap.CompressFormat.PNG, ImageHelper.DEFAULT_PNG_COMPRESSION, os);
}
db.attachment().setName(id, attachment.name, "image/png", file.length());

@ -370,7 +370,7 @@ public class FragmentDialogPrint extends FragmentDialogBase {
d.draw(canvas);
Helper.ByteArrayInOutStream bos = new Helper.ByteArrayInOutStream();
bm.compress(Bitmap.CompressFormat.PNG, 90, bos);
bm.compress(Bitmap.CompressFormat.PNG, ImageHelper.DEFAULT_PNG_COMPRESSION, bos);
uri = ImageHelper.getDataUri(bos.getInputStream(), "image/png");
}
} catch (Throwable ex) {

@ -83,6 +83,7 @@ import java.util.concurrent.Semaphore;
class ImageHelper {
static final int DOWNLOAD_TIMEOUT = 15; // seconds
static final int DEFAULT_PNG_COMPRESSION = 90;
private static final int MAX_PROBE = 128 * 1024; // bytes
private static final int SLOW_CONNECTION = 2 * 1024; // Kbps
private static final int MAX_BITMAP_SIZE = 100 * 1024 * 1024; // RecordingCanvas.MAX_BITMAP_SIZE
@ -765,7 +766,7 @@ class ImageHelper {
if (id >= 0) {
File file = getCacheFile(context, id, source, ".png");
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
bm.compress(Bitmap.CompressFormat.PNG, 90, os);
bm.compress(Bitmap.CompressFormat.PNG, ImageHelper.DEFAULT_PNG_COMPRESSION, os);
}
}

@ -311,7 +311,7 @@ public class OpenAI {
try (InputStream is = new FileInputStream(file)) {
Bitmap bm = ImageHelper.getScaledBitmap(is, null, null, SCALE2PIXELS);
Helper.ByteArrayInOutStream bos = new Helper.ByteArrayInOutStream();
bm.compress(Bitmap.CompressFormat.PNG, 90, bos);
bm.compress(Bitmap.CompressFormat.PNG, ImageHelper.DEFAULT_PNG_COMPRESSION, bos);
url = ImageHelper.getDataUri(bos.getInputStream(), "image/png");
} catch (Throwable ex) {
Log.w(ex);

Loading…
Cancel
Save