Form Background Picture - Scale or Tile

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
User avatar
Askjerry
Posts: 47
Joined: Saturday 18th August 2018 9:06pm
Location: Kyle, Texas, USA
Contact:

Form Background Picture - Scale or Tile

Post by Askjerry » Sunday 03rd April 2022 5:35pm

I have an image that is much larger than my form... I want to scale it so that it is always the size of the form no matter what.
I tried...
  FMain.Picture.Width = FMain.Width
  FMain.Picture.Height = FMain.Height
But that failed.... so how can I resize it? I didn't see anything in the properties like "Stretch" or "Tile"... unless I blatantly missed it.
I also have textures like graph paper that I use in my web pages... it would be nice to tile them as a form background.

I would be happy to just tell it to center the image... but I can't seem to do anything other than specify which image to use.

I would think it could be installed here...
Public Sub Form_Open()

' Update background image here... somehow...

End
How?

vuott
Posts: 112
Joined: Wednesday 05th April 2017 6:07pm
Location: European Union

Re: Form Background Picture - Scale or Tile

Post by vuott » Sunday 03rd April 2022 8:17pm

Askjerry wrote:
Sunday 03rd April 2022 5:35pm
But that failed.... so how can I resize it? I didn't see anything in the properties like "Stretch"
Well, ...why not ?

Exemplum:
Public Sub Form_Open()

  Dim pc As Picture

  pc = Picture.Load("/path/of/image/file")

  Me.Picture = pc.Stretch(Me.W, Me.H)

End
I am a European.

Amare memorentes atque deflentes ad mortem silenter labimur.

User avatar
Askjerry
Posts: 47
Joined: Saturday 18th August 2018 9:06pm
Location: Kyle, Texas, USA
Contact:

Re: Form Background Picture - Scale or Tile

Post by Askjerry » Tuesday 12th April 2022 5:54am

unknown symbol 'stretch' in class 'picture' in FMain:7.

vuott
Posts: 112
Joined: Wednesday 05th April 2017 6:07pm
Location: European Union

Re: Form Background Picture - Scale or Tile

Post by vuott » Tuesday 12th April 2022 11:22am

The ".Stretch()" Method exists since version 3.16:

https://gambaswiki.org/wiki/comp/gb.qt4/picture/stretch
I am a European.

Amare memorentes atque deflentes ad mortem silenter labimur.

User avatar
Askjerry
Posts: 47
Joined: Saturday 18th August 2018 9:06pm
Location: Kyle, Texas, USA
Contact:

Re: Form Background Picture - Scale or Tile

Post by Askjerry » Thursday 14th April 2022 1:06am

This says Version 3.12.2 so I will see if i can update it.

--> I went to the synaptic package manager... I did not see any versions beyond what i already have.

Thanks,
Jerry

User avatar
cogier
Site Admin
Posts: 875
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Form Background Picture - Scale or Tile

Post by cogier » Thursday 14th April 2022 7:54am

Hi Jerry, what distro are you using?

User avatar
Askjerry
Posts: 47
Joined: Saturday 18th August 2018 9:06pm
Location: Kyle, Texas, USA
Contact:

Re: Form Background Picture - Scale or Tile

Post by Askjerry » Saturday 16th April 2022 8:51pm

I'm not really sure... it is that latest package that was installed to this desktop from LinuxCNC as i was going to use this machine for CNC control.
I am developing my GAMBAS skills here... then I will migrate to the Raspberry Pi B3+ as I have several and will be building some teaching devices such as the Wind Tunnel project that I have been learning graphics for. I've created quite the GUI already.

My Raspberry Pi also appears to be running 3.12.2 so I will need to stick with that as my YouTube viewers will likely get the sme version and the software I create must work on all the platforms. In the Raspberry Pi I am also using piGPIO to control things such as motors, steppers, servos, etc.

Not sure how to find the distro... not like I can find an "ABOUT" button to click.

Jerry

User avatar
cogier
Site Admin
Posts: 875
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Form Background Picture - Scale or Tile

Post by cogier » Sunday 17th April 2022 6:17pm

On your main computer I think you are running a Debian distribution. If you open Terminal and type lsb_release -a I suspect you will be told you are running Debian buster. I may be wrong!

Debian buster has Gambas 3.12.2 in its repos.

I have just uploaded the latest recommended Raspbian OS (32 bit) on my pi 4, it is now based on Debian bullseye. Gambas 3.15.2 is in the repo.

Image.Stretch() is a valid command in 3.15.2

Not sure if that helps, but that's what I have discovered so far.

User avatar
Askjerry
Posts: 47
Joined: Saturday 18th August 2018 9:06pm
Location: Kyle, Texas, USA
Contact:

Re: Form Background Picture - Scale or Tile

Post by Askjerry » Thursday 28th April 2022 10:30pm

I found an easy work around, I just set an image box on the form, place the picture into it with "STRETCH" set to "TRUE".
Then, I set it to be the same size as the background form... for what I'm doing... it works a charm.
Control Panel Demo.png
Control Panel Demo.png (200.49 KiB) Viewed 289 times
Thanks,
Jerry

User avatar
tincho
Posts: 48
Joined: Wednesday 10th July 2019 1:12pm

Re: Form Background Picture - Scale or Tile

Post by tincho » Tuesday 03rd May 2022 10:00am

Hi Jerry,
Also you can stretch the image then conver it to picture, like:
  Dim oImage As Image
  oImage = Image.Load("/path/of/image/file")
  Me.Picture = oImage.Stretch(Me.W, Me.H).Picture
Regards

Post Reply