\' Gambas class file
Public Sub Form_Open()
\'ponemos fondo del area de dibujo en blanco
DrawingArea1.Background = Color.white
End
Public Sub DrawingArea1_Draw()
\'subrutina dibujar cada vez que salte el evento _draw()
dibujar()
End
Private Sub dibujar()
Dim X, Y, W, H As Float
Dim hBrush As PaintBrush
Dim hImage As Image
\'dibujamos un rectangulo
Paint.Brush = Paint.Color(Color.RGB(128, 128, 255))
Paint.Rectangle(10, 10, 200, 150)
Paint.Stroke
\' dibujamos texto
Paint.Brush = Paint.Color(Color.Orange)
Paint.Font.Name = "Sans"
Paint.Font.Size = 50
Paint.Font.Bold = True
Paint.MoveTo(210, 135)
Paint.Text("Hola!")
Paint.Fill
Paint.Stroke
hImage = Image.Load("clovis.jpg")
X = 80
Y = 30
W = 200
H = 200
hBrush = Paint.Image(hImage)
hBrush.Translate(X, Y)
hBrush.Scale(W / hImage.W / 2, H / hImage.H / 2)
Paint.Brush = hBrush
Paint.Rectangle(X, Y, W / 2, H / 2)
Paint.Fill
End
Public Sub ButtonGuardarImagen_Click()
Dim fichero As Picture
fichero = New Picture(drawingArea1.w, drawingArea1.h, Color.Transparent) \'probar...
If CheckBoxFondo.value = True Then
\'al definir color.transparent, el fondo de la imagen es transparente
Else
fichero.fill(color.white) \'fondo del fichero lo ponemos en blanco
Endif
Paint.begin(fichero)
\'aqui se llamarian a la subrutina de dibujo
dibujar()
paint.end
\'salvamos el archivo
fichero.save(user.home & "/" & "pruebas.png")
Label1.text = "Imagen guardada en: " & user.home & "/" & "pruebas.png"
PictureBox1.Picture = Picture.Load(user.home & "/" & "pruebas.png")
End