Hey all,

I've been spending a lot of time in the Camera code recently trying to
improve it in a number of ways. First off the way we were loading the
entire image into a Bitmap (stored in memory) was causing some
problems. For instance on my Samsung Galaxy Note a picture takes up 30
mb of memory when loaded into a Bitmap. This was causing out of memory
errors in apps that use the camera.

I've gone through the code and made a number of improvements.

1) If the call to get picture does not require a width, height or
quality change we no longer load the image into a Bitmap as it is
unnecessary. Saves a ton of memory.
2) If the call to get picture requires a width and height change we no
longer load the entire image into a Bitmap. First we take advantage of
the input sample size to load a smaller version of the image which is
closer to the width and height of the one requested by the user. For
instance if users calls get picture asking for a 900 x 900 image we
load the image into memory using a sample size of 2 which gives us a
1000 x 1000 image that is resized to 900 x 900. This saves a bunch of
unnecessary memory usage as well as a 2000x2000 image is 15.6 mb while
a 1000x1000 image is only 3.9 mb so the benefit on memory usage is
obvious.
3) I fixed an issue on Samsung devices where a picture is still stored
in the Gallery even if you set saveToPhotoAlbum to false.
4) I fixed the long standing issue where a picture taken in portrait
mode ends up being displayed on it's side in the webview. This is
because the web view just doesn't care about exif orientation
information. Now I rotate all images to the normal orientation. Images
display correctly in the webview, Gallery and on the desktop.

So I really would like to check this in before 1.9.0 is release but
I'd love if someone could look over the code just to make sure my
changes are sane.

https://github.com/macdonst/cordova-android/tree/cam2

Thanks...

Simon Mac Donald
http://hi.im/simonmacdonald

Reply via email to