Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 

Centre an Image

Hi

If I use this code:
canvasImg = CreateObject("roAssociativeArray")
canvasImg = [
{
url:imageUrl
TargetRect:{x:0,y:0,w:cw,h:ch}
}]

Regardless of the size of the target image it is scaled up to fit the screen.

And.. If I knew the image size, I could calculate the co-ords to make the image load in the centre of the screen....
...But is there a way to just make Brightscript automatically centre the image -as is- without any scaling - IF - you don't know the size of the target image?

I was looking for HAlign and VAlign properties like you have with TEXT..?

Thanks in advance if anyone can advise.
0 Kudos
2 Replies

Re: Centre an Image

Sorry - I should add in the above code cw and ch are canvas width and height that has been calculated to be screen size.
0 Kudos
TheEndless
Level 7

Re: Centre an Image

No, there are not image alignment options on the roImageCanvas. You'll need to specify the exact dimensions and location.

There's some sample code in this thread that might help: viewtopic.php?f=34&t=84194
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