document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. \' Gambas class file
  2.  
  3.  
  4. Public Sub Form_Open()
  5. \'ponemos fondo del area de dibujo en blanco
  6.   DrawingArea1.Background = Color.white
  7.  
  8. End
  9.  
  10. Public Sub DrawingArea1_Draw()
  11.  
  12.   \'subrutina dibujar cada vez que salte el evento _draw()
  13.   dibujar()
  14.  
  15. End
  16.  
  17. Private Sub dibujar()
  18.  
  19.   Dim X, Y, W, H As Float
  20.   Dim hBrush As PaintBrush
  21.   Dim hImage As Image
  22.  
  23.   \'dibujamos un rectangulo
  24.  
  25.   Paint.Brush = Paint.Color(Color.RGB(128, 128, 255))
  26.  
  27.   Paint.Rectangle(10, 10, 200, 150)
  28.   Paint.Stroke
  29.  
  30.   \' dibujamos texto
  31.   Paint.Brush = Paint.Color(Color.Orange)
  32.   Paint.Font.Name = "Sans"
  33.   Paint.Font.Size = 50
  34.   Paint.Font.Bold = True
  35.   Paint.MoveTo(210, 135)
  36.   Paint.Text("Hola!")
  37.   Paint.Fill
  38.   Paint.Stroke
  39.  
  40.   hImage = Image.Load("clovis.jpg")
  41.  
  42.   X = 80
  43.   Y = 30
  44.   W = 200
  45.   H = 200
  46.  
  47.   hBrush = Paint.Image(hImage)
  48.   hBrush.Translate(X, Y)
  49.   hBrush.Scale(W / hImage.W / 2, H / hImage.H / 2)
  50.   Paint.Brush = hBrush
  51.   Paint.Rectangle(X, Y, W / 2, H / 2)
  52.   Paint.Fill
  53.  
  54. End
  55.  
  56. Public Sub ButtonGuardarImagen_Click()
  57.  
  58.   Dim fichero As Picture
  59.  
  60.   fichero = New Picture(drawingArea1.w, drawingArea1.h, Color.Transparent) \'probar...
  61.  
  62.   If CheckBoxFondo.value = True Then
  63.     \'al definir color.transparent, el fondo de la imagen es transparente
  64.   Else
  65.  
  66.     fichero.fill(color.white) \'fondo del fichero lo ponemos en blanco
  67.   Endif
  68.  
  69.   Paint.begin(fichero)
  70.   \'aqui se llamarian a la  subrutina de dibujo
  71.   dibujar()
  72.   paint.end
  73.  
  74.   \'salvamos el archivo
  75.   fichero.save(user.home & "/" & "pruebas.png")
  76.   Label1.text = "Imagen guardada en: " & user.home & "/" & "pruebas.png"
  77.  
  78.   PictureBox1.Picture = Picture.Load(user.home & "/" & "pruebas.png")
  79.  
  80. End
');