library rstext; {$mode objfpc}{$H+} {$macro on} {$inline on} {$modeswitch advancedrecords} {$DEFINE callconv:= {$IFDEF WINDOWS}{$IFDEF CPU32}cdecl;{$ELSE}{$ENDIF}{$ENDIF} {$IFDEF LINUX}{$IFDEF CPU32}cdecl;{$ELSE}{$ENDIF}{$ENDIF} } uses SysUtils, Math, Classes, Windows, Graphics, LCLType, LCLIntf, FPImage, IntfGraphics, graphtype, {buckload of units from SCARExt} XT_Types, XT_Standard, XT_TPointList, XT_Sorting, XT_Math, XT_Matrix, XT_ColorMath, XT_HashTable, XT_Numeric, XT_Imaging, XT_Randomize, XT_Points, XT_Finder; var OldMemoryManager: TMemoryManager; memisset: Boolean = False; {$Include string.pas} {$Include bitmap.pas} {$Include RS_OCR.pas} function ocr_AboutText: String; callconv begin Result := 'Copyright (c) 2013, Jarl K. Holta || https://github.com/WarPie'; end; {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=] Export our functions, name, information etc... All that is needed for scar to see this as a DLL. [=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=} function GetPluginABIVersion: Integer; callconv export; begin Result := 2; end; procedure SetPluginMemManager(MemMgr : TMemoryManager); callconv export; begin if memisset then exit; GetMemoryManager(OldMemoryManager); SetMemoryManager(MemMgr); memisset := True; end; procedure OnDetach; callconv export; begin SetMemoryManager(OldMemoryManager); end; //Count of functions that will be exported... function GetFunctionCount: Integer; callconv export; begin Result := 10; end; //Information about our functions... function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; callconv export; begin case x of 0:begin ProcAddr := @ocr_LoadFont; StrPCopy(ProcDef, 'function ocr_LoadFont(FontPath:String): TCharsN;'); end; 1:begin ProcAddr := @ocr_FreeFont; StrPCopy(ProcDef, 'procedure ocr_FreeFont(Font:TCharsN);'); end; 2:begin ProcAddr := @ocr_ReadText; StrPCopy(ProcDef, 'function ocr_ReadText(Chars: TCharsN): AnsiString;'); end; 3:begin ProcAddr := @ocr_ReadTextEx; StrPCopy(ProcDef, 'function ocr_ReadTextEx(Chars: TCharsN; SpaceMod,MaxSpace: Integer): AnsiString; overload;'); end; 4:begin ProcAddr := @ocr_ReadTextEx2; StrPCopy(ProcDef, 'function ocr_ReadTextEx(Chars: TCharsN; SpaceMod,MaxSpace: Integer; EndAt:AnsiString): AnsiString; overalod;'); end; 5:begin ProcAddr := @ocr_IsText; StrPCopy(ProcDef, 'function ocr_IsText(Text: String; Chars: TCharsN): Boolean; overload;'); end; 6:begin ProcAddr := @ocr_IsTextMulti; StrPCopy(ProcDef, 'function ocr_IsText(TextArr: TStringArray; Chars: TCharsN): Boolean; overalod;'); end; 7:begin ProcAddr := @ocr_IsTextEx; StrPCopy(ProcDef, 'function ocr_IsTextEx(TextPtrn: String; Sensitive: Boolean; Chars: TCharsN): Boolean;'); end; 8:begin ProcAddr := @ocr_SetClient; StrPCopy(ProcDef, 'procedure ocr_SetClient(ATIA: T2DIntegerArray);'); end; 9:begin ProcAddr := @ocr_AboutText; StrPCopy(ProcDef, 'function ocr_AboutText: String;'); end; else x := -1; end; Result := x; end; function GetTypeCount(): Integer; callconv export; begin Result := 2; end; function GetTypeInfo(x: Integer; var name, def: PChar): integer; callconv export; begin case x of 0: begin StrPCopy(name, 'TCharN'); StrPCopy(def, 'record Pts,Shadows: TPointArray; Height,Width: Integer; end'); end; 1: begin StrPCopy(name,'TCharsN'); StrPCopy(def, 'Array of TCharN'); end; else Result := -1; end; Result := x; end; exports GetPluginABIVersion; exports SetPluginMemManager; exports GetTypeCount; exports GetTypeInfo; exports GetFunctionCount; exports GetFunctionInfo; exports OnDetach; begin end.