Simba Code:
type
TCharSet = record
Path : String;
BMP : Integer;
Characters : array [0..255] of Integer;
Spacing : TPoint;
end;
const
FONT_PATH = '';
CHARSET_HIGH = 0;
var
CharSet : array [0..CHARSET_HIGH] of TCharSet;
function GetSpacing(var Bitmap : Integer) : TPoint;
var
W, H : Integer;
begin
GetBitmapSize(Bitmap, W, H);
Result := Point(W div 16, H div 16);
end;
procedure LoadCharsets;
var
I : Integer;
begin
for I := 0 to CHARSET_HIGH do
begin
with CharSet[I] do
begin
Path := FONT_PATH + IntToStr(I) + '.png';
if FileExists(Path) then
BMP := LoadBitmap(Path)
else
begin
WriteLn(FONT_PATH + IntToStr(I) + '.png, does not exist!');
TerminateScript;
end;
Spacing := GetSpacing(BMP);
end;
end;
end;
procedure ExtractCharacters;
var
I, C,
W, H,
X, Y, sX, sY,
Col, t : Integer;
begin
for I := 0 to CHARSET_HIGH do
begin
t := GetSystemTime;
GetBitmapSize(CharSet[I].BMP, W, H);
for C := 0 to 255 do // Extended ASCII Table.
begin
CharSet[I].Characters[C] := CreateBitmap(CharSet[I].Spacing.X, CharSet[I].Spacing.Y);
FastDrawClear(CharSet[I].Characters[C], clBlack);
for Y := 0 to CharSet[I].Spacing.X-1 do
for X := 0 to CharSet[I].Spacing.Y-1 do
begin
sX := ((C mod CharSet[I].Spacing.X)*CharSet[I].Spacing.X) + X;
sY := ((C div CharSet[I].Spacing.Y)*CharSet[I].Spacing.Y) + Y;
try
Col := FastGetPixel(CharSet[I].BMP, sX, sY);
FastSetPixel(Charset[I].Characters[C], X, Y, Col);
except end;
end;
end;
WriteLn(GetSystemTime - t);
end;
end;
procedure SaveCharacters;
var
I, J : Integer;
begin
if not DirectoryExists(FONT_PATH + 'Extracted') then
CreateDirectory(FONT_PATH + 'Extracted');
for I := 0 to CHARSET_HIGH do
begin
if not DirectoryExists(FONT_PATH + 'Extracted\' + IntToStr(I)) then
CreateDirectory(FONT_PATH + 'Extracted\' + IntToStr(I));
for J := 0 to 255 do
SaveBitmap(CharSet[I].Characters[J], FONT_PATH + 'Extracted\' + IntToStr(I) + '\' + IntToStr(J) + '.bmp');
end;
end;
procedure FreeCharsets;
var
I, J : Integer;
begin
for I := 0 to CHARSET_HIGH do
begin
FreeBitmap(CharSet[I].BMP);
for J := 0 to 255 do
FreeBitmap(CharSet[I].Characters[J]);
end;
end;
begin
LoadCharsets;
ExtractCharacters;
SaveCharacters;
FreeCharsets;
end.
Using this script, I've been able to turn the RuneScape UpText into a folder in only 3 seconds, and we might be able to make it even faster.