Android Question bmp.RunMethod("createBitmap",...

Giuliano Cucchiarini

Member
Licensed User
Longtime User
Hi
I have a problem with RunMethod "CreateBitmap function" that I use to rotate Images.
In some devices it works well, in others I get a error. What I noticed is that the problem is present with big images (for example 1600x1200 or more) With smaller images it works always well.
Do you know how to overcome this problem?

Sub RotateImage(BM As Bitmap, degree As Float) As Bitmap
Dim matrix As JavaObject
Dim bmp As JavaObject
matrix.InitializeNewInstance("android.graphics.Matrix", Null)
matrix.RunMethod("postRotate",Array As Object(degree))
bmp.InitializeStatic("android.graphics.Bitmap")
Dim NewImage As Bitmap = bmp.RunMethod("createBitmap", Array As Object(BM, 0, 0, BM.Width, BM.Height, matrix, True))
Return NewImage

End Sub


Thank you

Giuliano C.
 

Giuliano Cucchiarini

Member
Licensed User
Longtime User
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:109)
at com.JobController.Photo.picturesview._rotateimage(picturesview.java:1503)
at com.JobController.Photo.picturesview._selectpicture(picturesview.java:1693)
at com.JobController.Photo.picturesview._selectfirstpicture(picturesview.java:1588)
at com.JobController.Photo.picturesview._displaypreviews(picturesview.java:847)
at com.JobController.Photo.picturesview._activity_resume(picturesview.java:486)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
at com.JobController.Photo.picturesview$ResumeMessage.run(picturesview.java:273)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:669)
at android.graphics.Bitmap.createBitmap(Bitmap.java:615)
... 22 more
 
Upvote 0
Top