Android Code Snippet [B4X] Bytes To File

sorex

Expert
Licensed User
Longtime User
why don't you use B4A to encrypt the photo and decrypt it before showing it in the app?
 

cambopad

Active Member
Licensed User
Longtime User
why don't you use B4A to encrypt the photo and decrypt it before showing it in the app?
Sorry I don't know how to do it with B4A! Is it fast if using it with picture? What lib can I use for that purpose?
 

DickD

Active Member
Licensed User

You second example of BytesToImage results in a run time error of "error loading bitmap" on the last line: bmp.Initialize(In)
I copied and pasted the code with bytes() being previously defined from an SQL query:
B4X:
Dim bytes() As Byte
Dim In As InputStream
cursor1 = SQL1.ExecQuery("SELECT * FROM PersonalInfo WHERE ID = 1")
cursor1.Position = 0
bytes = cursor1.GetBlob("image")
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
   Dim bmp As Bitmap
   bmp.Initialize2(In)
 

DickD

Active Member
Licensed User
The code is correct. Please start a new thread in the questions forum and post the code that inserts the image to the database.
Ahhhhhh........ For reasons I can't explain this has started working. I had other duties today. When I came in at 6:00 I reran the program and it worked. I made no changes since yesterday. No one else working on this project but me. I have a programmer friend who likes to blame these things on "stray neutrinos".
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…