Bitmap: Visual Basic Version
In the Visual Basic version, the load event handler calls the program's LoadBird() function to read the bird bitmap data from the Bird256.dat file.
'*****************************************************************************
' *
' Bitmap.frm *
' *
' This program demonstrates the Fastgraph for Windows 256-color bitmap *
' display functions. *
' *
'*****************************************************************************
Const vbWidth = 320
Const vbHeight = 240
Dim Bird(40 * 20) As Byte
Dim hPal As Long
Dim hVB As Long
Dim cxClient As Long, cyClient As Long
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
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 mnuClpimage_Click()
Call fg_fillpage
Call fg_move(-20, vbHeight / 2 + 10)
Call fg_clpimage(Bird(0), 40, 20)
Call fg_vbscale(0, vbWidth - 1, 0, vbHeight - 1, 0, cxClient - 1, 0, cyClient - 1)
End Sub
Private Sub mnuDrwimage_Click()
Call fg_fillpage
Call fg_move(vbWidth / 2 - 20, vbHeight / 2 + 10)
Call fg_drwimage(Bird(0), 40, 20)
Call fg_vbscale(0, vbWidth - 1, 0, vbHeight - 1, 0, cxClient - 1, 0, cyClient - 1)
End Sub
Private Sub mnuFlpimage_Click()
Call fg_fillpage
Call fg_move(vbWidth - 20, vbHeight / 2 + 10)
Call fg_flpimage(Bird(0), 40, 20)
Call fg_vbscale(0, vbWidth - 1, 0, vbHeight - 1, 0, cxClient - 1, 0, cyClient - 1)
End Sub
Private Sub mnuPutimage_Click()
Call fg_fillpage
Call fg_move(vbWidth / 2 - 20, vbHeight / 2 + 10)
Call fg_putimage(Bird(0), 40, 20)
Call fg_vbscale(0, vbWidth - 1, 0, vbHeight - 1, 0, cxClient - 1, 0, cyClient - 1)
End Sub
Private Sub mnuRevimage_Click()
Call fg_fillpage
Call fg_move(vbWidth / 2 - 20, vbHeight / 2 + 10)
Call fg_revimage(Bird(0), 40, 20)
Call fg_vbscale(0, vbWidth - 1, 0, vbHeight - 1, 0, cxClient - 1, 0, cyClient - 1)
End Sub
Private Sub mnuExit_Click()
Unload Me
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
|