B4J Question B4XBitmap - WriteToStream - ReadFromStream

LucaMs

Expert
Licensed User
Longtime User
The second method, ReadFromStream, does not exist.

I suppose for technical problems. Anyway, I have to search for a way to "realize" it :(


Found this Erel's routine (Snippets forum):
B4X:
Sub FileToBytes (Dir As String, FileName As String) As Byte()
   Return Bit.InputStreamToBytes(File.OpenInput(Dir, FileName))
End Sub

Of course it will work, I have not tried, but... even if the question is correct (how come the WriteToStream method exists and not its reciprocal ReadFromStream), I already have an array of bytes and I have to load them into a B4XBitmap (B4J) .

Searching again :):(
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Ok, solved šŸ˜“ (but with the help by @LordZenzo )

B4X:
Dim img As Image
Dim InStream As InputStream
InStream.InitializeFromBytesArray(arrByte, 0, arrByte.Length)
img.Initialize2(InStream)
B4XView1.SetBitmap(img)

(changed the variable names, here. B4XView1 "contains" a B4J ImageView).
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I can do it too, but the problem is how to "pass" that B4XBitmap to an ImageView.
It is much simpler; although the SetBitmap method of B4XView (a B4J ImageView) requires an Image type object, it accepts a B4XBitmp too.
 
Upvote 0
Top