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

Allow loading from image gallery #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions src/Android/com/raananw/ImageResizer/ImageResizePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.net.Uri;
import android.os.Environment;
import android.util.Base64;
import android.util.Log;
Expand Down Expand Up @@ -98,9 +100,9 @@ protected Bitmap getBitmap(String imageData, String imageDataType, BitmapFactory
byte[] blob = Base64.decode(imageData, Base64.DEFAULT);
bmp = BitmapFactory.decodeByteArray(blob, 0, blob.length, options);
} else {
URI uri = new URI(imageData);
File imageFile = new File(uri);
bmp = BitmapFactory.decodeFile(imageFile.getAbsolutePath(), options);
Uri uri = Uri.parse(imageData);
Context context = ImageResizePlugin.this.cordova.getActivity().getApplicationContext();
bmp = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri), null, options);
}
return bmp;
}
Expand Down