Large Graphics Using FreeBASIC

FreeBASIC is a fun language for playing around with algorithms. You can do a lot with it, but it’s still lightweight enough that a few lines of code are sufficient to start doing what you want.

I recently discovered that FBIDE will work with 64-bit versions of fbc.exe (the FreeBASIC compiler), so even the 32-bit memory limitation is a thing of the past. Arrays and other structures can now be as large as system memory permits.

Every new expansion of capabilities, however, always leads to discoveries of new limitations and questions about how to circumvent those. The next natural limitation I came across was working with graphics files the same size as or larger than the available screen real estate (1920×1080, in my case, less a bit for the window widgets.)

As it turns out, though, FreeBASIC has this covered, as well. All of the graphics routines (pset, line, circle, etc) can work with memory buffers as well as drawing directly to the screen. (After all, the screen buffer is itself just a block of memory.) All you need to do is create an image buffer of the appropriate size using ImageCreate, and then draw to this using the usual commands.

It seemed to me that it would be nice to both draw on the screen and to a scaled-up buffer with a single command, so I wrote some routines to do that. (There’s a file link below the examples.)

Saved from the screen buffer.
Low-res (800×600)
Higher-res (1600x1200 here), saved from the high-res image buffer. This isn't displayed on the screen, and so can be made more or less arbitrarily large.
High-res (1600×1200 here, but could be made as large as memory permits)

Share and enjoy! (CC-BY-NC-SA)

This entry was posted in BASIC, Coding. Bookmark the permalink.

Leave a Reply