Android Question Something about bitmap(Solved)

Discussion in 'Android Questions' started by bjfhs, Jun 26, 2019.

  1. bjfhs

    bjfhs Active Member Licensed User

    I got a bitmap in java inline ,and want to show it in a imageview.
    Java
    Code:
    ByteArrayInputStream bais = new ByteArrayInputStream(frameData);
    Bitmap bitmap= BitmapFactory.decodeStream(bais);
    processBA.raiseEventFromDifferentThread(this,
    null0,"imagerefresh",false,new Object[]{bitmap});
    B4A
    Code:
    Public Sub imagerefresh (img As Bitmap)
        ImageView1.Bitmap=img
      
    End Sub
    I get error
    Code:
    Installing file.
    ** 
    Activity (main) Pause, UserClosed = false **
    PackageAdded: package:b4a.example
    ** 
    Service (starter) Create **
    ** 
    Service (starter) Start **
    ** 
    Activity (main) Create, isFirst = true **
    ** 
    Activity (main) Resume **
    b4a.example.main:_imagerefresh, [android.graphics.Bitmap@ea91473]
    Error occurred on line: 
    47 (Main)
    java.lang.IllegalArgumentException: method b4a.example.main._imagerefresh argument 
    1 has type anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper, got android.graphics.Bitmap
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.shell.Shell.runMethod(
    Shell.java:708)
        at anywheresoftware.b4a.shell.Shell.raiseEventImpl(
    Shell.java:337)
        at anywheresoftware.b4a.shell.Shell.raiseEvent(
    Shell.java:247)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:
    134)
        at anywheresoftware.b4a.BA$
    2.run(BA.java:328)
        at android.os.Handler.handleCallback(Handler.java:
    790)
        at android.os.Handler.dispatchMessage(Handler.java:
    99)
        at android.os.Looper.loop(Looper.java:
    164)
        at android.app.ActivityThread.main(ActivityThread.java:
    6523)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:
    438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    857)
    Error occurred on line: 
    47 (Main)
    java.lang.NullPointerException: Attempt 
    to invoke virtual method 'java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])' on a null object reference
        at anywheresoftware.b4a.shell.Shell.runGoodChain(Shell.java:461)
        at anywheresoftware.b4a.shell.Shell.raiseEventImpl(
    Shell.java:283)
        at anywheresoftware.b4a.shell.Shell.raiseEvent(
    Shell.java:247)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:
    134)
        at anywheresoftware.b4a.BA$
    2.run(BA.java:328)
        at android.os.Handler.handleCallback(Handler.java:
    790)
        at android.os.Handler.dispatchMessage(Handler.java:
    99)
        at android.os.Looper.loop(Looper.java:
    164)
        at android.app.ActivityThread.main(ActivityThread.java:
    6523)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:
    438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    857)
    ** 
    Activity (main) Pause, UserClosed = true **
    ** 
    Activity (main) Resume **
    How can I do with it?
     
  2. bjfhs

    bjfhs Active Member Licensed User

    What is the different between Java and B4A about Bitmap?
     
    Last edited: Jun 26, 2019
  3. Brandsum

    Brandsum Active Member Licensed User

    Give a try, though its untested
    Code:
    Public Sub imagerefresh (img As Object)

        
    Dim b As Bitmap = img
        ImageView1.Bitmap=b
     
    End Sub
     
    OliverA and bjfhs like this.
  4. bjfhs

    bjfhs Active Member Licensed User

    Your are right.Thank you very much.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice