Android Question OutOfMemory Bitmap CameraEx

doogal

Member
Licensed User
Longtime User
Hi all,

I am getting OutOfMemory Errors when using the CameraEx Class. I have a spinner that has two photos taken with the camera and when I go to load the second photo I get the error and the program crashes. What can I do to prevent this? Clear the image view, make the photo smaller.

All suggestions welcome.

Thank you,
Douglas
 

doogal

Member
Licensed User
Longtime User
Thank you for the response. Here is a little more about the problem I am having. The app loads ok, takes a picture and fills the spinner. I can choose the picture from the spinner and the picture loads great if i let it load without rotation. The problem comes in when I use this code:
B4X:
Sub ShowImage(bmp As Bitmap)
If bmp.width>bmp.height Then          
      Dim rbmp As RSImageProcessing
      mBmp=rbmp.rotateBitmap(bmp, -90)

end if
So why does the program crash when I do a rotation.
 
Upvote 0

doogal

Member
Licensed User
Longtime User
Hi and Thank you for your interest. Here is my project and the error log. I tried using LoadBitmapSample, but didn't understand how to use it since it was coming from a sql blob and not a text field that just didn't give the path. Anyway, here are the files.

B4X:
LogCat connected to: 430088c447f4a08f
--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (picture) Create, isFirst = true **
** Activity (picture) Resume **
90
[Height=768, IsInitialized=false, Width=1024
]
test.png
/storage/emulated/0/Android/data/pattern.Inv.com/files
** Activity (picture) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (picture) Create, isFirst = false **
** Activity (picture) Resume **
90
[Height=768, IsInitialized=false, Width=1024
]
test1.png
/storage/emulated/0/Android/data/pattern.Inv.com/files
** Activity (picture) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Value:test
mBMP:(Bitmap): 1920 x 2560
Value:test1
java.lang.OutOfMemoryError
    at android.graphics.Bitmap.nativeCreate(Native Method)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:928)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:901)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:833)
    at com.rootsoft.imageprocessing.RSImageProcessing.rotateBitmap(RSImageProcessing.java:46)
    at pattern.Inv.com.main._spnpics_itemclick(main.java:471)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
    at anywheresoftware.b4a.BA$2.run(BA.java:284)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:146)
    at android.app.ActivityThread.main(ActivityThread.java:5487)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)

    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
    at dalvik.system.NativeStart.main(Native Method)
 

Attachments

  • Camera.zip
    13.8 KB · Views: 112
Upvote 0

doogal

Member
Licensed User
Longtime User
Ok, I understand now how to use the LoadBitmapSample. it just took me a few tries, but I still don't get how I can rotate the image using the RSImageProcessing Library. Maybe another way would be easier??? would exif data help?
 
Upvote 0

doogal

Member
Licensed User
Longtime User
Wow, Thank you so much for that. it works now.
What is the purpose of the rotation?
whenever I take a picture with camera and load it into an Imageview it almost always comes out in landscape mode and even in a full panel. I want the image to come out just the way it was taken and most times it is in Portrait mode.

This is going to be a Pattern Inventory app and all the patterns show in portrait mode. I still need to more, but the image rotation had me puzzled.

Again Thank you.
 

Attachments

  • 2257.jpg
    203.5 KB · Views: 135
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…