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: 
csPlay
Visitor

roScreen/roImageCanvas Image Fitting Problem

Hi,

I am currently using asyngettofile to download the image locally to the tmp:/ storage. However, the image returned differs in size. Essentially, I would like to do the "scale to fit" display mode functionality in roScreen or roImageCanvas for better customization instead of using the roSlideshowscreen. Has anyone encountered this problem before? Any share of approach or information is greatly appreciated.

Thanks in advance.
0 Kudos
5 REPLIES 5
TheEndless
Channel Surfer

Re: roScreen/roImageCanvas Image Fitting Problem

For roScreen, you'll need to calculate the scale based on the current screen resolution and use the DrawScaledObject method. For roImageCanvas, just specify the TargetRect with the width/height you want to scale to and you should be good to go. Regardless of which way you go, you'll need to calculate the scale yourself. There is no built-in "scale-to-fit" option for those screens.
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
csPlay
Visitor

Re: roScreen/roImageCanvas Image Fitting Problem

Hi,

Thanks for the prompt reply and your input. One problem of not being able to draw the scaled object is because of the unknown width and height of the image returned from the server. The image is a binary file which I used gettofile urltransfer method to store it directly to tmp:/ storage and then display it by point the url to the tmp:/ storage. In this case, since I do not know the width and height of that image, how can I determine the scale of the object?

If I was to put the image in roSlideShow, it has no problem of putting the image to its scale option. I guess if my question can be more specific on how does the roSlideShowScreen determine the width and height of the image and scale it to the right size.

Thanks.
0 Kudos
MSGreg
Visitor

Re: roScreen/roImageCanvas Image Fitting Problem

With roScreen you would read the binary file into a roBitmap, then use DrawScaleObject with bm.GetWidth() and bm.GetHeight()
With roImageCanvas you would use TargetRect. Which should work if already have the aspect ratio. You can get width and height and calculate aspect ratio of a local image file through roImageMetadata

Let us know how that works.
0 Kudos
csPlay
Visitor

Re: roScreen/roImageCanvas Image Fitting Problem

Thanks man, exactly what I needed.
0 Kudos
ljunkie
Visitor

Re: roScreen/roImageCanvas Image Fitting Problem

Useful info! Many thanks.

note: updated link - roImageMetadata

"MSGreg" wrote:
With roScreen you would read the binary file into a roBitmap, then use DrawScaleObject with bm.GetWidth() and bm.GetHeight()
With roImageCanvas you would use TargetRect. Which should work if already have the aspect ratio. You can get width and height and calculate aspect ratio of a local image file through roImageMetadata]roImageMetadata

Let us know how that works.
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.