Multiple pictures in controls

Post

Posted
Rating:
#1 (In Topic #1442)
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
 Some time ago BruceS (IIRC) showed me how to combine several pictures into one,so I could use them as the, for example TabPanel1[X].Picture
Damned if I can find it and the Search doesn't help (just keeps saying "too many common terms")

Would appreciate a reminder.
tia
b

Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
So make a new Picture using New(W, H, True) ' give width/height and make transparent

Then paint both pictures to it.

Code (gambas)

  1.  
  2. Dim hPic As Picture = New Picture(64, 32, True)
  3.  
  4. Dim hLeftPic As Picture = Picture["icon:/32/gambas"]
  5. Dim hRightPic As Picture = Picture["icon:/32/linux"]
  6.  
  7. Paint.Begin(hPic)
  8. Paint.DrawPicture(hLeftPic, 0, 0, 32, 32)
  9. Paint.DrawPicture(hRightPic, 32, 0, 32, 32)
  10. Paint.End
  11.  
  12. TabPanel1[X].Picture = hPic
  13.  
  14.  
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
Thanks matey!

This time I want to make it 3 or 4  or 200,000,000  pics wide.  :ugeek:
Will return if I can't get it going.

b

Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
No worries :)

Here's my function from my VBoxMounter program that does it dynamically adding an svg logo icon and maybe a couple of other icons if required.
The picture is then used in a the GridView

Code (gambas)

  1.  
  2. Public Sub GetImage(VM As VBoxUnit) As Picture
  3.  
  4.   Dim sFind As String = vm.Name &/ vm.Path
  5.   Dim sp As SvgImage
  6.   Dim p, pRet As Picture
  7.  
  8.   Select sFind
  9.     Case Like "*deb*"
  10.       sp = SvgImage.Load("./icons/debian.svg")
  11.     Case Like "*mint*"
  12.       sp = SvgImage.Load("./icons/linuxmint.svg")
  13.     Case Like "*ubuntu*"
  14.       sp = SvgImage.Load("./icons/ubuntu.svg")
  15.     Case Like "*suse*"
  16.       sp = SvgImage.Load("./icons/suse.svg")
  17.     Case Like "*manjaro*"
  18.       sp = SvgImage.Load("./icons/manjaro.svg")
  19.     Case Like "*fedora*"
  20.       p = Picture.Load("./icons/fedora.png").Stretch(16, 16)
  21.     Case Else
  22.       sp = SvgImage.Load("./icons/linux-tux.svg")
  23.  
  24.   If sp Then ' convert svg to picture
  25.     sp.Resize(16, 16)
  26.     p = New Picture(16, 16, True)
  27.     Paint.Begin(p)
  28.     sp.Paint(0, 0, 16, 16)
  29.     Paint.End
  30.  
  31. ' dynamically assign width
  32.   Dim W As Integer = 16, X As Integer
  33.   If vm.HasSnapshot Then w += 16 + Desktop.Scale
  34.   If vm.StoredData.Count Then w += 16 + Desktop.Scale
  35.  
  36.   pRet = New Picture(W, 16, True)
  37.   Paint.Begin(pRet)
  38.  
  39.   Paint.DrawPicture(p, 0, 0, 16, 16) ' add logo
  40.  
  41.   If vm.HasSnapshot Then ' add snapshot icon if exists
  42.     X += 16 + Desktop.Scale
  43.     Paint.DrawPicture(Picture["icon:/16/camera"], X, 0, 16, 16)
  44.  
  45.   If vm.StoredData.Count Then ' add info icon if info exists
  46.     X += 16 + Desktop.Scale
  47.     Paint.DrawPicture(Picture["icon:/16/info"], X, 0, 16, 16)
  48.   Paint.End
  49.  
  50.   Return pRet
  51.  
  52.  
  53.  
  54.  

Image

(Click to enlarge)

Online now: No Back to the top
1 guest and 0 members have just viewed this.