1
0
mirror of https://github.com/moparisthebest/Simba synced 2025-02-07 02:30:19 -05:00

Minor changes + added todo list.

This commit is contained in:
Raymond 2010-04-05 01:36:21 +02:00
parent 72539efffd
commit 2141e1d016
4 changed files with 268 additions and 319 deletions

View File

@ -49,10 +49,12 @@ type
TMFonts = class(TObject)
private
Fonts: TList;
Path: String;
FPath: String;
Client : TObject;
function GetFontIndex(const Name: String): Integer;
function GetFontByIndex(Index : integer): TMfont;
procedure SetPath(const aPath: String);
function GetPath: String;
public
constructor Create(Owner : TObject);
destructor Destroy; override;
@ -60,10 +62,9 @@ type
function FreeFont(const Name: String): Boolean;
function LoadFont(const Name: String; Shadow: Boolean): boolean;
function LoadSystemFont(const SysFont : TFont; const FontName : string) : boolean;
procedure SetPath(const aPath: String);
function GetPath: String;
function Copy(Owner : TObject): TMFonts;
function Count : integer;
property Path : string read GetPath write SetPath;
property Font[Index : integer]: TMfont read GetFontByIndex; default;
end;
@ -155,12 +156,12 @@ end;
procedure TMFonts.SetPath(const aPath: String);
begin
Path := aPath;
FPath := aPath;
end;
function TMFonts.GetPath: String;
begin
Exit(Path);
Exit(FPath);
end;
function TMFonts.GetFontIndex(const Name: String): Integer;
@ -201,9 +202,9 @@ function TMFonts.LoadFont(const Name: String; Shadow: Boolean): boolean;
var
f: TMFont;
begin
if not DirectoryExists(Path + Name) then
if not DirectoryExists(FPath + Name) then
begin
raise Exception.Create('LoadFont: Directory ' + Path + Name + ' does not exists.');
raise Exception.Create('LoadFont: Directory ' + FPath + Name + ' does not exists.');
Exit(False);
end;
@ -211,7 +212,7 @@ begin
f.Name := Name;
if Shadow then
F.Name := F.Name + '_s';
f.Data := InitOCR( LoadGlyphMasks(Path + Name + DS, Shadow));
f.Data := InitOCR( LoadGlyphMasks(FPath + Name + DS, Shadow));
Fonts.Add(f);
{$IFDEF FONTDEBUG}
TClient(Client).Writeln('Loaded Font ' + f.Name);
@ -270,7 +271,7 @@ var
i:integer;
begin
Result := TMFonts.Create(Owner);
Result.Path := Self.GetPath();
Result.Path := FPath;
for i := 0 to Self.Fonts.Count -1 do
Result.Fonts.Add(TMFont(Self.Fonts.Items[i]).Copy());
end;

View File

@ -45,7 +45,7 @@ type
debugbmp: TMufasaBitmap;
{$ENDIF}
function GetFonts:TMFonts;
procedure SetFonts(NewFonts: TMFonts);
procedure SetFonts(const NewFonts: TMFonts);
public
constructor Create(Owner: TObject);
destructor Destroy; override;
@ -139,7 +139,7 @@ var
i: longint;
begin
// We're going to load all fonts now
FFonts.SetPath(path);
FFonts.Path := path;
dirs := GetDirectories(path);
Result := false;
for i := 0 to high(dirs) do
@ -158,7 +158,7 @@ begin
end;
{ Set new Fonts. We set it to a Copy of NewFonts }
procedure TMOCR.SetFonts(NewFonts: TMFonts);
procedure TMOCR.SetFonts(const NewFonts: TMFonts);
begin
Self.FFonts := NewFonts.Copy(Self.Client);
end;

View File

@ -34,14 +34,6 @@ type
TocrDataArray = array of TocrData;
{Begin To be removed}
Tbmp = record
data: array of TRGB32;
width,height: integer;
end;
{End To be removed}
tLab = record
L,a,b: real;
end;
@ -55,7 +47,6 @@ type
function ImageToNorm(src: TRGB32Array; w,h: integer): TNormArray;
function ocrDetect(txt: TNormArray; w,h: integer; var ocrdata: TocrData): string;
function ExtractText(colors: PRGB32;{colors: tRGBArray;} w,h: integer): TNormArray;
function MakeTPAString(str: string): TpointArray;
implementation
uses
@ -64,29 +55,6 @@ uses
graphtype, intfgraphics,graphics;
{End To-Remove unit}
function ReadBMP(path: string): Tbmp;
var
LazIntf : TLazIntfImage;
RawImageDesc : TRawImageDescription;
begin
if FileExists(path) then
begin;
LazIntf := TLazIntfImage.Create(0,0);
RawImageDesc.Init_BPP32_B8G8R8_BIO_TTB(LazIntf.Width,LazIntf.Height);
LazIntf.DataDescription := RawImageDesc;
LazIntf.LoadFromFile(path);
Result.width := LazIntf.Width;
Result.height := LazIntf.Height;
SetLength(result.data,LazIntf.Width*LazIntf.Height);
Move(LazIntf.PixelData[0],result.data[0],LazIntf.Width*LazIntf.Height*sizeOf(TRGB32));
LazIntf.Free;
end;
end;
{initalizes the remaining fields from a TocrGlyphMask and finds the global bounds}
procedure findBounds(glyphs: TocrGlyphMaskArray; out width,height: integer);
var
@ -406,12 +374,9 @@ begin
left:= left + ocrdata.ascii[ord(ascii)].width;
x:= left;
end;
result:= result + ascii;
l:= -1;
r:= -1;
end;
inc(x);
end;
@ -595,32 +560,5 @@ begin
result:= norm;
end;
function MakeTPAString(str: string): TpointArray;
var
i,j,c,off: integer;
bmp: array of Tbmp;
begin
raise Exception.Create('MakeTPAString sucks ass, don''t use it.');
c:= 0;
off:= 0;
SetLength(bmp,length(str));
for i:= 0 to length(str)-1 do
begin
bmp[i]:= ReadBmp('/home/merlijn/Programs/mufasa/Fonts/StatChars/' + inttostr(ord(str[i+1])) + '.bmp');
SetLength(result,c+bmp[i].width*bmp[i].height);
for j:= 0 to bmp[i].width*bmp[i].height - 1 do
begin
if bmp[i].data[j].g = 255 then
begin
result[c].x:= j mod bmp[i].width + off;
result[c].y:= j div bmp[i].width;
inc(c);
end;
end;
off:= off + bmp[i].width;
SetLength(result,c);
end;
end;
end.

10
todo.txt Normal file
View File

@ -0,0 +1,10 @@
- DTM Editor
- BMP Editor
- DTM Features
- SRL Installer
- Extra GUI icons
- Installer
- Test scripts
- DWS
- OCR exceptions + proper implementation of len
- Documentation + wiki