Form Background Picture - Scale or Tile

Post

Posted
Rating:
#1 (In Topic #837)
Avatar
Regular
Askjerry is in the usergroup ‘Regular’
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…

Code (gambas)

  1.   FMain.Picture.Width = FMain.Width
  2.   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…

Code (gambas)

  1. Public Sub Form_Open()
  2.  
  3. ' Update background image here... somehow...
  4.  

How?
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’

Askjerry said

But that failed…. so how can I resize it? I didn't see anything in the properties like "Stretch"
Well, …why not ?

Exemplum:

Code (gambas)

  1. Public Sub Form_Open()
  2.  
  3.   Dim pc As Picture
  4.  
  5.   pc = Picture.Load("/path/of/image/file")
  6.  
  7.   Me.Picture = pc.Stretch(Me.W, Me.H)
  8.  

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Regular
Askjerry is in the usergroup ‘Regular’
<COLOR color="#BF0000">unknown symbol 'stretch' in class 'picture' in FMain:7.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
vuott is in the usergroup ‘Regular’
The ".Stretch()" Method exists since version 3.16:

   /comp/gb.qt4/picture/stretch - Gambas Documentation

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
Askjerry is in the usergroup ‘Regular’
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
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Guru
cogier is in the usergroup ‘Guru’
Hi Jerry, what distro are you using?
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Regular
Askjerry is in the usergroup ‘Regular’
 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
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Guru
cogier is in the usergroup ‘Guru’
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.
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Regular
Askjerry is in the usergroup ‘Regular’
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.
Image

(Click to enlarge)


Thanks,
Jerry
Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Regular
tincho is in the usergroup ‘Regular’
Hi Jerry,
Also you can stretch the image then conver it to picture, like:

Code (gambas)

  1.   Dim oImage As Image
  2.   oImage = Image.Load("/path/of/image/file")
  3.   Me.Picture = oImage.Stretch(Me.W, Me.H).Picture
  4.  
Regards
Online now: No Back to the top
1 guest and 0 members have just viewed this.