Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
squirreltown
Roku Guru

preload image

I need to preload an image (jpeg) so its there when the user hits the button to show it and would like to know the basic procedure for doing this.

During a slideshow the user can hit *info to bring up a message dialog with some stats about the current slide. On the dialog is a button to show a "close-up"
This loads a canvas with the close-up detail image. Of course there is a delay while it loads, so I'm thinking I should load the current detail image when the user hits *info so its ready.
I dont see anything in the docs about preloading so I'm guessing it gets downloaded to /temp and then read from there? Or something like that?

Thanks
Kinetics Screensavers
0 Kudos
14 REPLIES 14
destruk
Streaming Star

Re: preload image

This would be tricky to pull off a benefit (in time) - if you are loading the image from the server, the image needs to download and be drawn to the canvas.
If you are loading the image from TMP, then you still need to initially download the image and still draw it onto the canvas.
Basically, use roUrlTransfer to download the file to TMP for your preview, and then when you are setting up the canvas, use the file://tmp:/ for the location of the image to use.
0 Kudos
squirreltown
Roku Guru

Re: preload image

Hey thanks for answering. Its only a couple to a few seconds, but i notice once its been loaded it loads right away the second time. Maybe I'm confused about temp and how fast it is, and actually need to get it into memory and am confusing that with temp.
Perhaps I need a way to force it to load but not show itself ( an invisible canvas?)

thanks
Kinetics Screensavers
0 Kudos
RokuJoel
Binge Watcher

Re: preload image

Part of the speed problem you are seeing is the fact that you are using roImageCanvas. If you use roScreen instead, you can quickly download and draw images without much of the delay that you are currently encountering.

- Joel
0 Kudos
squirreltown
Roku Guru

Re: preload image

Thanks Joel, I'll see if that works for me.

Edit - Ok I've looked at the docs, so which roscreen is supposed to replace the canvas? I need to display a picture and some text. There seems to be no "roscreen" rather a bunch of specialized ro-X-screens.

Thanks.
Kinetics Screensavers
0 Kudos
squirreltown
Roku Guru

Re: preload image

I think i wasnt clear in my first post. I've read about the roScreen and it seems most of the discussion and prodding from moderators is that the canvas is slow in a 60fps sense, the roscreen is for games which need to be fast. What i need is to download a 300k image, so if it doesn't start until the user hits the button, it doesn't matter how fast my one screen draws, its still going to be waiting for the download, especially if the internet is slow at that time/location.
This is what I'm trying to work around , not a slow animation problem.

Thanks
Kinetics Screensavers
0 Kudos
RokuMarkn
Visitor

Re: preload image

You can render your image into an roBitmap, and then use DrawObject to draw that bitmap on the roScreen. The DrawObject will be very fast.

--Mark
0 Kudos
TheEndless
Channel Surfer

Re: preload image

You could use roUrlTransfer.GetToFileAsync to download the image to tmp:, then load it from there. Issue the GetToFileAsync with a known tmp path when the user presses *, and point your image canvas layer to that known path. You can also try setting RequireAllImagesToDraw(False) to prevent the canvas from re-drawing portions of the screen that aren't updating and/or visible.

BTW, I agree that roImageCanvas is the better screen to use for your application.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
squirreltown
Roku Guru

Re: preload image

"TheEndless" wrote:
You could use roUrlTransfer.GetToFileAsync to download the image to tmp:, then load it from there. Issue the GetToFileAsync with a known tmp path when the user presses *, and point your image canvas layer to that known path.


Thank you theEndless. I'm going to try that.
Kinetics Screensavers
0 Kudos
squirreltown
Roku Guru

Re: preload image

Function  GetURL_Image()

http = CreateObject("roUrlTransfer")
http.SetPort(CreateObject("roMessagePort"))
http.SetUrl("http://www.xxx.com/roku/detail/art/big/midtown.jpg")
http.AsyncGetToFile("tmp:/detail.jpg")

End Function


Will calling this get the file into tmp:/ ?
AsyncGetToFile appears in exactly one function in the entire SDK, and it doesnt seem analogous to what i want.
I have to start somewhere, everyone here seems to already know how to do this. Is there a command to have the debugger show the tmp:/ directory so i can see if it got in there?
Currently have this line in the canvas where i want it to end up, of course its not working yet.
url = { url:"tmp:/detail.jpg"  TargetRect:{x:60,y:60,w:1160,h:610}}


Thanks
Kinetics Screensavers
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.