mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-20 13:17:08 +00:00
Fixed image scaling
This commit is contained in:
parent
7f6a7033a7
commit
130d2149f2
2 changed files with 9 additions and 4 deletions
|
@ -1460,15 +1460,17 @@ public class FragmentCompose extends FragmentBase {
|
||||||
options.inJustDecodeBounds = true;
|
options.inJustDecodeBounds = true;
|
||||||
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
|
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
|
||||||
|
|
||||||
int scaleTo = REDUCED_IMAGE_SIZE;
|
int factor = 1;
|
||||||
int factor = Math.min(options.outWidth / scaleTo, options.outWidth / scaleTo);
|
while (options.outWidth / factor > REDUCED_IMAGE_SIZE ||
|
||||||
|
options.outHeight / factor > REDUCED_IMAGE_SIZE)
|
||||||
|
factor *= 2;
|
||||||
|
|
||||||
if (factor > 1) {
|
if (factor > 1) {
|
||||||
options.inJustDecodeBounds = false;
|
options.inJustDecodeBounds = false;
|
||||||
options.inSampleSize = factor;
|
options.inSampleSize = factor;
|
||||||
|
|
||||||
Bitmap scaled = BitmapFactory.decodeFile(file.getAbsolutePath(), options);
|
Bitmap scaled = BitmapFactory.decodeFile(file.getAbsolutePath(), options);
|
||||||
if (scaled != null) {
|
if (scaled != null) {
|
||||||
|
|
||||||
Log.i("Image target size=" + scaled.getWidth() + "x" + scaled.getHeight());
|
Log.i("Image target size=" + scaled.getWidth() + "x" + scaled.getHeight());
|
||||||
|
|
||||||
OutputStream out = null;
|
OutputStream out = null;
|
||||||
|
|
|
@ -280,7 +280,10 @@ public class HtmlHelper {
|
||||||
is = new URL(source).openStream();
|
is = new URL(source).openStream();
|
||||||
|
|
||||||
int scaleTo = context.getResources().getDisplayMetrics().widthPixels;
|
int scaleTo = context.getResources().getDisplayMetrics().widthPixels;
|
||||||
int factor = Math.min(options.outWidth / scaleTo, options.outWidth / scaleTo);
|
int factor = 1;
|
||||||
|
while (options.outWidth / factor > scaleTo)
|
||||||
|
factor *= 2;
|
||||||
|
|
||||||
if (factor > 1) {
|
if (factor > 1) {
|
||||||
Log.i("Download image factor=" + factor);
|
Log.i("Download image factor=" + factor);
|
||||||
options.inJustDecodeBounds = false;
|
options.inJustDecodeBounds = false;
|
||||||
|
|
Loading…
Reference in a new issue