You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/03/14 23:42:49 UTC

[GitHub] infil00p closed pull request #245: Handle OutOfMemoryError exception when scaling a picture

infil00p closed pull request #245: Handle OutOfMemoryError exception when scaling a picture
URL: https://github.com/apache/cordova-plugin-camera/pull/245
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java
index e3ee20b5..93b4e203 100644
--- a/src/android/CameraLauncher.java
+++ b/src/android/CameraLauncher.java
@@ -1066,7 +1066,13 @@ private Bitmap getScaledAndRotatedBitmap(String imageUrl) throws IOException {
             int scaledWidth = (!rotated) ? widthHeight[0] : widthHeight[1];
             int scaledHeight = (!rotated) ? widthHeight[1] : widthHeight[0];
 
-            Bitmap scaledBitmap = Bitmap.createScaledBitmap(unscaledBitmap, scaledWidth, scaledHeight, true);
+            Bitmap scaledBitmap;
+            try {
+                scaledBitmap = Bitmap.createScaledBitmap(unscaledBitmap, scaledWidth, scaledHeight, true);
+            }
+            catch (Error e) { // Throws OutOfMemoryError on some low-end devices
+                scaledBitmap = unscaledBitmap;
+            }
             if (scaledBitmap != unscaledBitmap) {
                 unscaledBitmap.recycle();
                 unscaledBitmap = null;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org