BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"Bitmap Font on-the-fly"
, by thechange
Demonstrates the creation (and usage) of a bitmap font completely at run-time using specified font.
Code
; This program should be pretty much self-explanatory. ; If not, email me for more info: TheChange@yahoo.com :) Graphics 640 , 480 Const FontSizeX = 8 Const FontSizeY = 16 ;= Create a Bitmap Font on the fly FontImage = CreateImage ( FontSizeX , FontSizeY , 256 ) FontHandle = LoadFont ( "Blitz" ) SetFont FontHandle For Char = 0 To 255 SetBuffer ImageBuffer ( FontImage , Char ) Color 128 , 255 , 0 ; Shadow text Text 0 , 1 , Chr ( Char ) Color 0 , 255 , 128 ; Main text Text 0 , 0 , Chr ( Char ) Next ;= Generic ASCII based Bitmap Font display function Function PrintText ( ImageHandle , PosX , PosY , Message$ ) For Char = 1 To Len ( Message ) DrawImage ImageHandle , PosX + (Char-1) * FontSizeX , PosY , Asc ( Mid ( Message , Char , 1 ) ) Next End Function ;= Demonstration of ASCII character set SetBuffer FrontBuffer () Char = 0 Repeat PosX = Char Mod 32 ; 32 characters per line PosY = Char / 32 DrawImage FontImage , PosX * FontSizeX , PosY * FontSizeY , Char Char = Char + 1 Until Char = 256 ;= Demonstration of function PrintText FontImage , 0 , GraphicsHeight () - FontSizeY , "Press any key.." ;= Display on screen WaitKey End
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations