INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Graphical Techniques in QB

The fastest way to save a graphic screen to disk using Qbasic
Posted: 13 Jul 00

By popular demand, here is your BSAVE and BLOAD programming example.

'Set the graphics mode...
SCREEN 8 '640 x 200 Resolution
'Set up an array large enough to store the contents of the screen
REDIM GraphBlock(1 TO 31266)
'You determine the required size of the graphics array with:
'Bytes = 4 + INT(((X2-X1+1)*(Bits/pixel/plane)+7)/8)*planes*((Y2-Y1)+1)
'In SCREEN 8 that would be 62532 bytes for an array size of 31266.
'Draw a graphic....
X = 150: Y = 2
DO
    CIRCLE (X, Y), Y / 4, (Y / 16) + 1
    CIRCLE (X - Y, Y), Y / 4, (Y / 16) + 1
    CIRCLE (X + Y, Y), Y / 4, (Y / 16) + 1
    IF Y > 200 THEN EXIT DO
    X = X + LOG(X * Y) / Y
    Y = Y + LOG(Y) / 10
LOOP

'Place the contents of the screen in the array...
GET (0, 0)-(639, 199), GraphBlock
'Set the memory segment to first element of the array
DEF SEG = VARSEG(GraphBlock(1))
BSAVE "Screen.Img", VARPTR(GraphBlock(1)), 62532
'save it to a file
DEF SEG 'Reset the default memory segment to the Qbasic area
CLS 'To show that this actually works, clear the screen...
'and erase the array.
ERASE GraphBlock
PRINT "Press a key to load screen..."
DO WHILE INKEY$ = ""
LOOP
REDIM GraphBlock(1 TO 31266)
DEF SEG = VARSEG(GraphBlock(1))
BLOAD "Screen.Img", VARPTR(GraphBlock(1))
DEF SEG
PUT (0, 0), GraphBlock, PSET

The graphic has returned to the screen. A lot quicker the second time, eh?


Back to QBasic FAQ Index
Back to QBasic Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close