Forum Discussion

NewbyDeveloper's avatar
11 years ago

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.

2 Replies

  • Sorry - I should add in the above code cw and ch are canvas width and height that has been calculated to be screen size.
  • 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