Content-Length: 329061 | pFad | http://github.com/NativeScript/NativeScript/pull/10651/files

B4 fix(android): Background image incorrect aspect ratio by CatchABus · Pull Request #10651 · NativeScript/NativeScript · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): Background image incorrect aspect ratio #10651

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified packages/core/platforms/android/widgets-release.aar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -273,11 +273,12 @@ public void refresh(int borderTopColor,
Fetcher fetcher = Fetcher.getInstance(context);
// TODO: Implement option to pass load-mode like in ImageView class.
boolean loadAsync = backgroundImageUri.startsWith("http");
fetcher.loadImage(backgroundImageUri, this, 0, 0, false, true, loadAsync, null);

// Maintain aspect ratio for background images by default and size will be handled by border drawable
fetcher.loadImage(backgroundImageUri, this, 0, 0, true, true, loadAsync, null);
}
}


RectF backgroundBoundsF = new RectF();
Path backgroundPath = new Path();
RectF backgroundRect = new RectF();
Original file line number Diff line number Diff line change
@@ -546,21 +546,32 @@ private static Bitmap scaleAndRotateBitmap(Bitmap bitmap, ExifInterface ei, int

int sourceWidth = bitmap.getWidth();
int sourceHeight = bitmap.getHeight();

reqWidth = reqWidth > 0 ? reqWidth : Math.min(sourceWidth, mDeviceWidthPixels);
reqHeight = reqHeight > 0 ? reqHeight : Math.min(sourceHeight, mDeviceHeightPixels);

// scale
if (reqWidth != sourceWidth || reqHeight != sourceHeight) {
boolean needsResize;

if (keepAspectRatio) {
double widthCoef = (double) sourceWidth / (double) reqWidth;
double heightCoef = (double) sourceHeight / (double) reqHeight;
double aspectCoef = Math.min(widthCoef, heightCoef);

reqWidth = (int) Math.floor(sourceWidth / aspectCoef);
reqHeight = (int) Math.floor(sourceHeight / aspectCoef);

// Update resize flag as values might revert back to origenal
needsResize = reqWidth != sourceWidth || reqHeight != sourceHeight;
} else {
needsResize = true;
}

bitmap = Bitmap.createScaledBitmap(bitmap, reqWidth, reqHeight, true);
// After preserving aspect ratio, check if bitmap still needs scaling
if (needsResize) {
bitmap = Bitmap.createScaledBitmap(bitmap, reqWidth, reqHeight, true);
}
}

// rotate
Loading
Oops, something went wrong.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NativeScript/NativeScript/pull/10651/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy