Good morning,
I know this is Xojo 101 but how to I retrieve a picture.
I have a sqlite table and one of the fields is the name of the picture. Now I want to retrieve that picture from a folder and put it in a canvas. I got this code but I get a compile error because I am telling that f is a string instead of a picture.
Dim currentFolder As FolderItem
currentFolder = GetFolderItem("").child("fotos")
Dim f as Picture
msgbox currentFolder.name
f = currentFolder.name + rs.Column("pic1").StringValue
canvas2.Backdrop = f
You need to read the data of a folderitem into a binarystream. Then you use FromData to make a picture.
Dim currentFolder As FolderItem = GetFolderItem("").child("fotos")
dim PictureFolderitem as Folderitem = currentFolder.child(rs.Column("pic1").StringValue)
dim b as BinaryStream = Binarystream.Open(PictureFolderitem)
dim data as String = b.read(b.length)
canvas2.Backdrop = Picture.FromData(data)
Picture.Open is what I use, I was not aware that you could open it as a binary stream to do the same thing. But Picture.Open seems to be much easier to read the code.