Add width/height options
This commit is contained in:
parent
8e22168c3b
commit
e064bab7db
|
@ -61,6 +61,9 @@ public class ResolveTakenPictureAsyncTask extends AsyncTask<Void, Void, Writable
|
|||
|
||||
try {
|
||||
if (inputStream != null) {
|
||||
if (mOptions.hasKey("width") && mOptions.hasKey("height")) {
|
||||
mBitmap = resizeBitmap(mBitmap, mOptions.getInteger("width"), mOptions.getInteger("height"));
|
||||
}
|
||||
ExifInterface exifInterface = new ExifInterface(inputStream);
|
||||
// Get orientation of the image from mImageData via inputStream
|
||||
int orientation = exifInterface.getAttributeInt(
|
||||
|
@ -137,6 +140,20 @@ public class ResolveTakenPictureAsyncTask extends AsyncTask<Void, Void, Writable
|
|||
return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
|
||||
}
|
||||
|
||||
public Bitmap resizeBitmap(Bitmap bm, int newWidth, int newHeight) {
|
||||
int width = bm.getWidth();
|
||||
int height = bm.getHeight();
|
||||
float scaleWidth = ((float) newWidth) / width;
|
||||
float scaleHeight = ((float) newHeight) / height;
|
||||
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.postScale(scaleWidth, scaleHeight);
|
||||
|
||||
Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
|
||||
bm.recycle();
|
||||
return resizedBitmap;
|
||||
}
|
||||
|
||||
private Bitmap flipHorizontally(Bitmap source) {
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.preScale(-1.0f, 1.0f);
|
||||
|
|
Loading…
Reference in New Issue