Skip to content
This repository was archived by the owner on Mar 21, 2019. It is now read-only.

[Android] Improve images handling #109

Merged
merged 5 commits into from
Feb 28, 2018
Merged

Conversation

DimitarTachev
Copy link

  • scale to exact size (not up to 2x size)
  • rotate the bitmap based on the source image rotation
  • support for keepAspectRation (based on ImageAsset.keepAspectRatio or Image.Stretch != fill)
  • scale properly and optimized based on keepAspectRatio even when only width or height specified (previously the whole image was read in such cases)
  • fixed inSampleSize calculations (the no more than 2x pixels logic was causing issues like getting 1/32 of a picture instead of 1/8)

Dimitar Tachev and others added 5 commits February 26, 2018 15:56
@ADjenkov ADjenkov force-pushed the tachev/improve-images-handling branch from fc3c558 to f369dfd Compare February 27, 2018 07:32
@ADjenkov ADjenkov self-requested a review February 27, 2018 08:21
README.md Outdated
```
npm link tns-core-modules-widgets
```
Build the project with the above-mentioned commands after each change.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing your README.md changes because of Vasko Chimev PR #113

@@ -420,21 +537,14 @@ public static Bitmap decodeSampledBitmapFromFile(String filename,
* that are equal to or greater than the requested width and height
*/
public static Bitmap decodeSampledBitmapFromDescriptor(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion: add @param comment for keepAspectRatio will be would be very useful. For me, as a person who looks at this code for the very first time, the coments and params descriptions were more than welcome

@@ -499,13 +610,14 @@ public static Bitmap decodeSampledBitmapFromByteArray(
* @return The value to be used for inSampleSize
*/
public static int calculateInSampleSize(BitmapFactory.Options options,
int reqWidth, int reqHeight) {
int reqWidth, int reqHeight, boolean keepAspectRatio) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keepsAsprctRatio is not use in this method. Consider using it?

else {
options.inSampleSize = 1;
}
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight, keepAspectRatio);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using this calculateInSampleSize from JS (unify params) and write tests

@ADjenkov ADjenkov merged commit 9d2095c into master Feb 28, 2018
@ADjenkov ADjenkov deleted the tachev/improve-images-handling branch February 28, 2018 12:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants