-
-
Notifications
You must be signed in to change notification settings - Fork 19
Conversation
DimitarTachev
commented
Nov 30, 2017
- 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)
…ampleSize size -> 4x less pixels)
…ested. Added rotation and scaling while processing images. Added keepAspectRatio property for further flexibility and accuracy.
fc3c558
to
f369dfd
Compare
README.md
Outdated
``` | ||
npm link tns-core-modules-widgets | ||
``` | ||
Build the project with the above-mentioned commands after each change. |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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