As discussed, the code I listed is intended as a simple replacement for *DISPLAY, with the additional ability to rotate the image. It's not suitable when performance is important (e.g. when dynamically rotating a sprite in a game) because every single time it's called the graphics subsystem is re-initialised, the image is re-read from file, and then everything is closed down again. This makes it self-contained, but wrecks the performance.
Consequently I have now written a pair of highly compatible libraries (imglib.bbc
), one for BB4W and one for BBCSDL, which separate out the various steps. They are necessarily slightly more difficult to use, but should be much more suitable for real-time animation. Each library has four functions/procedures as follows:
- PROC_imgInit: Call just once at the start of your program.
- PROC_imgExit: Call just once at the end of your program (and when exiting on an error).
- FN_imgLoad(): Load an image from a file, returning an integer 'handle'.
- PROC_imgPlot(): Plot an image with a specified position, scale, rotation and flip.
A minimal program using them would be something like this:
Here are the libraries, they require the latest versions of BB4W (v6.13a) and BBCSDL (v1.11a)
Code: Select all
INSTALL @lib$ + "imglib"
ON ERROR PROC_imgExit : OSCLI "REFRESH ON" : : REPORT : END
ON CLOSE PROC_imgExit : QUIT
img%% = FN_imgLoad(@dir$ + "bbc256x.png")
IF img%% = 0 ERROR 100, "Couldn't load bbc256x.png"
a += 0.5
PROC_imgPlot(img%%, 640, 500, 0.7, a, 0)
IF INKEY$(-256) = "W" WAIT 2
If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.