Android Question [SOLVED] How to pass a Bitmap array to an inline function

rosippc64a

Active Member
Licensed User
Longtime User
Hi All!
I need using inline java. That worked well, but now I have to transform one of Bitmap parameter to Bitmap[].
Here is the called function header:
B4X:
public void printinvoice( BA ba,String s, Bitmap[]  bmp)
I thought to pass arguments like:
B4X:
MEJo.RunMethod("printinvoice", Array(GetBA,text,Array(bmp)))
I compiled well, but when I test I got:
B4X:
java.lang.RuntimeException: Method: printinvoice not matched.
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:130)
    at b4a.mypos.myposclass._printinvtext(myposclass.java:380)
What is the correct calling?
Thanks in advance
Steven
 

rosippc64a

Active Member
Licensed User
Longtime User
Sorry @Erel , but I have more question related this. Now I would like to pass a real bitmap array to mentioned java function.
B4X:
Public Sub printInvText2(text As String,bmp() As Bitmap)
    Dim bmpArray As JavaObject
    bmpArray.InitializeArray("android.graphics.Bitmap", bmp)
    If bmp .Length = 0 Then
        Log("printinvtext kép nélkül")
        MEJo.RunMethod("printinvoice", Array(GetBA,text,bmpArray))
    Else
        Log("printinvtext képpel")
        MEJo.RunMethod("printinvoice", Array(GetBA,text,bmpArray))
    End If
End Sub
The calling code:
B4X:
    Dim bmp,bmp1 As B4XBitmap
    effects.Initialize
    bmp = LoadBitmapResize(File.DirAssets,"rafi_szines.png",500dip,500dip,True)
    bmp1 = LoadBitmapResize(File.DirAssets,"iqom.png",500dip,500dip,True)
    Dim szoveg As String = $"Kép előtt${mp.PR_PICT_PLACE}kép után.${mp.PR_PICT_PLACE}Másik kép után."$
    mp.printInvText2(szoveg,Array As Bitmap(effects.GreyScale(bmp).As(Bitmap),effects.GreyScale(bmp1).As(Bitmap)))
Compiled well, give error:
B4X:
** Activity (main) Resume **
myposclass_printinvtext2 (java line: 396)
java.lang.IllegalArgumentException: Array has incompatible type: class [Landroid.graphics.Bitmap;
    at java.lang.reflect.Array.incompatibleType(Array.java:827)
    at java.lang.reflect.Array.set(Array.java:477)
    at anywheresoftware.b4j.object.JavaObject.InitializeArray(JavaObject.java:109)
How can I pass correctly a bitmap array?
 
Upvote 0

teddybear

Well-Known Member
Licensed User
B4X:
Public Sub printInvText2(text As String,bmp() As Bitmap)
    Dim bmpArray As JavaObject
    bmpArray.InitializeArray("android.graphics.Bitmap", bmp)
End Sub
bmpArray.InitializeArray("android.graphics.Bitmap", Array(bmp))
You omitted Array.
 
Upvote 0

rosippc64a

Active Member
Licensed User
Longtime User
The same error :-(
I omitted it because the parameter is an array, so array(bmp) would actually be array(array(bmp) ).
 
Upvote 0

rosippc64a

Active Member
Licensed User
Longtime User
Here is the final solution:
B4X:
Public Sub printInvText2(text As String,bmp() As Object)
    Dim bmpArray As JavaObject
    bmpArray.InitializeArray("android.graphics.Bitmap", bmp)
    If bmp .Length = 0 Then
        Log("printinvtext kép nélkül")
        MEJo.RunMethod("printinvoice", Array(GetBA,text,bmpArray))
    Else
        Log("printinvtext képpel")
        MEJo.RunMethod("printinvoice", Array(GetBA,text,bmpArray))
    End If
End Sub
 
Upvote 0
Top