- BITMAP.PAS -
A UNIT for managing bitmaps.
Originally writen for T Pascal V 4.0. There should be no
problems porting it to V 5.0, though I have not yet tried this.
My thanks to Dean Farwell who got me interested in dealing with
large bitmaps originally.
The BITMAP unit exports a group of routines for maintaining
bitmaps of up to MAXINT byte, or well over 500,000 bits for each map.
These routines are writen in assembly language for maximum speed. Maps
may be as small as 1 byte or as large as 65000 bytes. You can
set, clear or toggle any bit in the map, and can also set or
clear all bits in the map.
All calls to bit map pass an array of byte. You must declare
this array and make sure that the array is big enough for the
number of bits you need in the map. The BestMapSize function
returns the number of bytes needed for any given number of bits.
Note that all of these routines write directly to memory, and are
not subject to Turbo's range checking so that failure to ensure
that the map is large enough will result in almost certain system
crash. This is the only real hitch to using these routines.
Example of Initializing a Bitmap
function InitMap(NoBits : longint; var MapSize : word):Pointer
type Map : array[0..MaxInt] of byte;
MapP: ^Map;
var
I : word;
P : MapP;
begin
MapSize := BestMapSize(NoBits);
getmem(P, MapSize);
InitMap := P
|