I have images stored in my AWS S3 bucket that I would like to use in my LB Application. So essentially, all I have is a list of URL path names to work with. Is it possible to load and display these images without storing them locally?
Post by Chris Iverson on Mar 18, 2021 20:25:18 GMT -5
LB's LOADBMP command, and even most external libraries you can use for loading images, generally ask for a file path, not a pointer to raw file data in memory.
It's most likely easier to store it as a temporary file. That's what a lot of applications do, and that's what the temp folder is for.
You can use a function like this to automatically generate a file path in the user's temp folder, to use for a temporary file. You can delete them later.
Send in a three-letter prefix, and it will make a random file name with that prefix, and return the path to it.
(You can also just make your own names attached to the path from GetFilePathA(), or even subfolders, to keep them organized until they get deleted, if you plan on caching them to reuse them. This is just if you don't care about the names, just to have a place to store temporary data.)
Function GetTempFileName$(prefix$) size = 261 tempPath$ = space$(size)
CallDLL #kernel32, "GetTempPathA",_ size as long, tempPath$ as ptr,_ ret as long
tempPath$ = left$(tempPath$, ret)
size = 261 GetTempFileName$ = space$(size) CallDLL #kernel32, "GetTempFileNameA",_ tempPath$ as ptr, prefix$ as ptr,_ 0 as long, GetTempFileName$ as ptr,_ ret as long
GetTempFileName$ = trim$(GetTempFileName$) End Function
Once you're done with the file, you can use the KILL command to delete it.
If the user runs Disk Cleanup, or any other cleaning utility, it'll delete anything in their temp folder.
I tried using loadbmp with the raw url value but I get a runtime error telling me the parameter is incorrect. I had more luck with HTTPGet$ but I have no idea how to save/draw the returned content.
Post by tenochtitlanuk on Mar 19, 2021 7:32:01 GMT -5
Why do you not want to store them locally anyway? Your LB line has already temporarily stored them locally in a variable. Just save the downloaded images to files! Since they are large images, 24 bit, at 1828x100, you CAN show them in a graphic window. But you would probably want to resize them to fit a smaller window unless you have a very high res. monitor display. I use ImageMagick called from LB to do this kind of thing, but it's even easier to download them and resize to a standard size ( ie thumbnail) for LB to display.It's also easy to programmatically delete the downloaded image files.
myimage$ = HTTPGet$( "https://emea-presales.s3.eu-west-2.amazonaws.com/general/imagelib/image1.bmp") open "imageLocal.bmp" for output as #fOut #fOut, myimage$; close #fOut