[Gambas-user] Grab command

trat50 trat50 at ...67...
Sun Apr 22 23:53:49 CEST 2012


How to prevent part of an image from getting blacked out if it extends off
the edge of the screen:
Here's how I synchronized Sky (a displayed PictureBox) with Sky1 (an
undisplayed Picture):
This allows DRAWING ON and SAVING - using the undisplayed Drawing, while
seeing the results in the PictureBox.

                        This interface uses a PictureBox instead of a
DrawingArea to display the generated calendar:
http://old.nabble.com/file/p33730377/Interface.jpg 
                                     The PictureBox "Sky" is displaying a
scaled down copy of the calendar we just made.

' This is from Fmain.class
' Gambas class file
PUBLIC Calendar AS Picture     'This is the base calendar picture we load
in.
PUBLIC Sky1 AS Picture           'This is the undisplayed picture that we
will draw on.   
PUBLIC monimage AS String     'The file name of the picture "Calendar" loads
in.

PUBLIC SUB Form_Open()
  monimage = "Cala1.png"           'This is a generic calendar that is
loaded & displayed at start up.
  Calendar = Picture[monimage]    'This loads our generic startup calendar
into "Calendar".
  Sky1 = Picture(Calendar)            'This loads our generic startup
calendar into the undisplayed picture "Sky1",
                                                ' and MUST be included or
Sky1 is a "Null object" and can't be drawn to.
  Render()
END 


PUBLIC SUB Render()           'This SUB will display our base calendar and
draw the month title.
DIM MonthName AS String
   Draw.Begin(Sky1)
   Draw.Picture(Calendar, 0, 0, 1099, 849)
   MonthName = Textbox1.text                     'This is the month title
the user types in.
      
   Draw.Font.Bold = TRUE            'This stuff modifies the text displayed
for the month title. 
   Draw.Font.Size = 60
   Draw.ForeColor = 33000000010
   Draw.Text(MonthName, 30, 0, 1040, 90, 3)  'This draws the month title
onto "Sky1".
                                                                'Drawing
coordinates = xy to xy = 30,0 to 1040,90
                                                                'and the
number '3' centers our month title text. 
   Draw.End
   Sky.Picture = Sky1                 'This copies "Sky1" (the undisplayed
picture) into "Sky" (the PictureBox).
END

PUBLIC SUB ToggleButton1_Click()      'This SUB monitors the SAVE CALENDAR
button
DIM HolyCal AS NEW Picture
  IF ToggleButton1.Value = TRUE          
      TextLabel4.Enabled = TRUE             'Displays text telling 'where to
enter a month title'.
      TextBox2.Enabled = TRUE               'Displays Textbox to enter a
month title into.
  ELSE IF ToggleButton1.Value = FALSE
      TextLabel4.Enabled = FALSE            'Hides text telling 'where to
enter a month title'.
      TextBox2.Enabled = FALSE              'Hides Textbox to enter a month
title into. 
  ENDIF  

  Sky1.Save("HolyCal.jpg")          'This saves the displayed calendar as a
JPG file.
 'Sky.Grab().Save("HolyCal.jpg")   <~~~...or you can do this if you want to
save a REALLY SMALL calendar.
END
-- 
View this message in context: http://old.nabble.com/Grab-command-tp33715676p33730377.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list