NewbyDeveloper
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2015
11:46 AM
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.
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.
2 REPLIES 2
NewbyDeveloper
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2015
11:47 AM
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.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2015
01:08 PM
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
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)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)