Scale: Visual Basic Version


'*****************************************************************************
'                                                                            *
'  Scale.frm                                                                 *
'                                                                            *
'  This program demonstrates the Fastgraph for Windows 256-color bitmap      *
'  scaling and shearing functions.                                           *
'                                                                            *
'*****************************************************************************
Const vbWidth = 320
Const vbHeight = 240
Dim hPal As Long
Dim hVB As Long
Dim cxClient As Long, cyClient As Long
Dim Bird(40 * 20) As Byte
Dim ScaledBird(80 * 40) As Byte ' scaled/sheared bird bitmap (80x40 max)
Private Sub Form_Activate()
   Call fg_realize(hPal)
   Refresh
End Sub
Private Sub Form_Load()
   ScaleMode = 3
   Call fg_setdc(hDC)
   hPal = fg_defpal()
   Call fg_realize(hPal)
   Call fg_vbinit
   hVB = fg_vballoc(vbWidth, vbHeight)
   Call fg_vbopen(hVB)
   Call fg_vbcolors
   Call fg_setcolor(20)
   Call fg_fillpage
   Call LoadBird
   ' draw 40x20 bird (original bitmap)
   Call fg_move(6, 80)
   Call fg_drwimage(Bird(0), 40, 20)
   ' draw 50x25 bird
   Call fg_move(48, 80)
   Call fg_scale(Bird(0), ScaledBird(0), 40, 20, 50, 25)
   Call fg_drwimage(ScaledBird(0), 50, 25)
   ' draw 60x30 bird
   Call fg_move(100, 80)
   Call fg_scale(Bird(0), ScaledBird(0), 40, 20, 60, 30)
   Call fg_drwimage(ScaledBird(0), 60, 30)
   ' draw 70x35 bird
   Call fg_move(162, 80)
   Call fg_scale(Bird(0), ScaledBird(0), 40, 20, 70, 35)
   Call fg_drwimage(ScaledBird(0), 70, 35)
   ' draw 80x40 bird
   Call fg_move(234, 80)
   Call fg_scale(Bird(0), ScaledBird(0), 40, 20, 80, 40)
   Call fg_drwimage(ScaledBird(0), 80, 40)
   ' draw 50x20 bird sheared left horizontally
   Call fg_move(55, 160)
   Call fg_shear(Bird(0), ScaledBird(0), 40, 20, 50, 0)
   Call fg_drwimage(ScaledBird(0), 50, 20)
   ' draw 50x20 bird sheared right horizontally
   Call fg_move(115, 160)
   Call fg_shear(Bird(0), ScaledBird(0), 40, 20, 50, 1)
   Call fg_drwimage(ScaledBird(0), 50, 20)
   ' draw 40x30 bird sheared left vertically
   Call fg_move(175, 160)
   Call fg_shear(Bird(0), ScaledBird(0), 40, 20, 30, 2)
   Call fg_drwimage(ScaledBird(0), 40, 30)
   ' draw 40x30 bird sheared left vertically
   Call fg_move(225, 160)
   Call fg_shear(Bird(0), ScaledBird(0), 40, 20, 30, 3)
   Call fg_drwimage(ScaledBird(0), 40, 30)
End Sub
Private Sub Form_Paint()
   Call fg_vbscale(0, vbWidth - 1, 0, vbHeight - 1, 0, cxClient - 1, 0, cyClient - 1)
End Sub
Private Sub Form_Resize()
   cxClient = ScaleWidth
   cyClient = ScaleHeight
   Refresh
End Sub
Private Sub Form_Unload(Cancel As Integer)
   Call fg_vbclose
   Call fg_vbfree(hVB)
   Call fg_vbfin
End Sub
Private Sub LoadBird()
   Dim I As Long
   Open App.Path & "\Bird256.dat" For Input Access Read As #1
   For I = 0 To 40 * 20 - 1
      Input #1, Bird(I)
   Next I
   Close #1
End Sub

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.