Label Control to JPEG
Posted
#1
(In Topic #1444)
Trainee

For example if I set the label to Say 'PLS 123.45" with a red background, then simple save the contents of the label as a jpeg.
I could do this in visual basic using a picture box but I seem unable to figure out picture so far on gambas.
Posted
Banned
Code (gambas)
- '' Convert label into a picture,
- '' use TextSize boolean to make the picture be the size of the text or the picture is a copy of the label as seen
- ' size
- Else ' make the picture the size of the label
- Paint.Begin(hPic)
- ' background color
- Paint.FillRect(0, 0, hPic.W, hPic.H, If(hLabel.Background = -1, Color.Background, hLabel.Background))
- ' text color
- ' text
- Paint.DrawText(hLabel.Text, 0, 0, hPic.W, hPic.H, hLabel.Alignment)
- Paint.End
- Return hPic
Posted
Regular

Creare un file immagine dagli oggetti presenti in un Contenitore - Gambas-it.org - Wikipedia
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Guru


For example if I set the label to Say 'PLS 123.45" with a red background, then simple save the contents of the label as a jpeg.
I could do this in visual basic using a picture box but I seem unable to figure out picture so far on gambas.
This can be done with a PictureBox in Gambas, see if this code helps you. You will need a form with TextBox1, Button1 and PictureBox1.
Posted
Trainee

cogier said
For example if I set the label to Say 'PLS 123.45" with a red background, then simple save the contents of the label as a jpeg.
I could do this in visual basic using a picture box but I seem unable to figure out picture so far on gambas.
This can be done with a PictureBox in Gambas, see if this code helps you. You will need a form with TextBox1, Button1 and PictureBox1.
Thats it perfect I thought it would be fairly simple thats a nice elegant solution works perfectly. I am getting users to enter data do some calculations and alterations to the text these then get saved as a picture and overlaid on top of an web page that picks up the data and presents it to other users. I couldn't find a reference to the desktop screen shot.
My visual basic skills used to be very good but everyone seems to be using python to do these things but Im to old to be learning new stuff and when they moved everything to linux I was completely lost. Gambas saves the day . Thank you so much
Posted
Banned
So just a note:
If you use a wayland system you will find you cannot Screenshot areas of the screen like we can in x11.
wayland will only ever pop open the desktops screenshot dialog (like pressing PrtScr button)
If you need to be compatible with wayland systems too because of that limitation then you can use the (only slightly) more complicated picture method
PS. you could just directly use the Picture object that ScreenShot returns…
1 guest and 0 members have just viewed this.



