diff --git a/trunk/Units/MMLAddon/PSInc/Wrappers/ocr.inc b/trunk/Units/MMLAddon/PSInc/Wrappers/ocr.inc index 4483eca..a93deea 100644 --- a/trunk/Units/MMLAddon/PSInc/Wrappers/ocr.inc +++ b/trunk/Units/MMLAddon/PSInc/Wrappers/ocr.inc @@ -22,6 +22,11 @@ begin Result := CurrThread.Client.MOCR.TextToMask(text,font); end; +procedure TPAFromTextWrap(text, font: String;out w,h : integer;out TPA : TPointArray); extdecl; +begin + TPA := CurrThread.Client.MOCR.TextToFontTPA(text, font, w, h); +end; + function TPAFromText(text, font: String;out w,h : integer): TPointArray; extdecl; begin Result := CurrThread.Client.MOCR.TextToFontTPA(text, font, w, h); diff --git a/trunk/Units/MMLAddon/PSInc/Wrappers/other.inc b/trunk/Units/MMLAddon/PSInc/Wrappers/other.inc index 4acbc26..84a75b7 100644 --- a/trunk/Units/MMLAddon/PSInc/Wrappers/other.inc +++ b/trunk/Units/MMLAddon/PSInc/Wrappers/other.inc @@ -90,6 +90,11 @@ begin; result := GetTickCount - CurrThread.StartTime; end; +procedure ps_Quicksort(var Arr : TIntegerArray); extdecl; +begin + QuickSort(Arr,low(arr),high(arr)); +end; + procedure ConvertTime(Time : integer; var h,m,s : integer); extdecl; var x : integer; diff --git a/trunk/Units/MMLAddon/PSInc/psexportedmethods.inc b/trunk/Units/MMLAddon/PSInc/psexportedmethods.inc index d57d902..107bb69 100644 --- a/trunk/Units/MMLAddon/PSInc/psexportedmethods.inc +++ b/trunk/Units/MMLAddon/PSInc/psexportedmethods.inc @@ -212,6 +212,7 @@ AddFunction(@rs_GetUpText, 'function rs_GetUpText: string;'); AddFunction(@rs_GetUpTextAt, 'function rs_GetUpTextAt(x, y : integer): string;'); AddFunction(@BitmapFromText, 'function BitmapFromText(text, font: String): integer;'); AddFunction(@TPAFromText, 'function TPAFromText(text, font: String;out w,h : integer): TPointArray;'); +AddFunction(@TPAFromTextWrap,'procedure TPAFromTextWrap(text, font: String;out w,h : integer;out TPA : TPointArray)'); AddFunction(@MaskFromText, 'function MaskFromText(text, font: String): TMask;'); AddFunction(@GetTextAt,'function GetTextAt(atX, atY, minvspacing, maxvspacing, hspacing,color, tol, len: integer; font: string): string;'); @@ -265,6 +266,7 @@ AddFunction(@DrawATPABitmapEx,'procedure DrawATPABitmapEx(bitmap: integer; ATPA: {tpa} SetCurrSection('TPA'); +AddFunction(@ps_Quicksort,'procedure Quicksort(var Arr : TIntegerArray);'); AddFunction(@tSwap,'procedure tSwap(var a, b: TPoint);'); AddFunction(@tpaSwap,'procedure tpaSwap(var a, b: TPointArray);'); AddFunction(@SwapE,'procedure SwapE(var a, b: Extended);'); diff --git a/trunk/Units/MMLCore/bitmaps.pas b/trunk/Units/MMLCore/bitmaps.pas index 39ebc2a..04adb4e 100644 --- a/trunk/Units/MMLCore/bitmaps.pas +++ b/trunk/Units/MMLCore/bitmaps.pas @@ -762,7 +762,7 @@ begin PtrRet := TIOManager_Abstract(MWindow).ReturnData(xs,ys,wi,hi); for y := 0 to (hi-1) do - Move(PtrRet.Ptr[y * (wi + PtrRet.IncPtrWith)], FData[y * self.w],wi * SizeOf(TRGB32)); + Move(PtrRet.Ptr[y * PtrRet.RowLen], FData[y * self.w],wi * SizeOf(TRGB32)); TIOManager_Abstract(MWindow).FreeReturnData; end; @@ -781,7 +781,7 @@ begin PtrRet := TIOManager_Abstract(MWindow).ReturnData(xs,ys,wi - x,hi - y); for yy := 0 to (hi-1 - y) do - Move(PtrRet.Ptr[yy * (wi - x + PtrRet.IncPtrWith)], FData[(yy + y) * self.w + x],wi * SizeOf(TRGB32)); + Move(PtrRet.Ptr[yy * (PtrRet.RowLen)], FData[(yy + y) * self.w + x],wi * SizeOf(TRGB32)); TIOManager_Abstract(MWindow).FreeReturnData; end; diff --git a/trunk/Units/MMLCore/tpa.pas b/trunk/Units/MMLCore/tpa.pas index 395d29e..0f6f0c6 100644 --- a/trunk/Units/MMLCore/tpa.pas +++ b/trunk/Units/MMLCore/tpa.pas @@ -30,6 +30,7 @@ uses Classes, SysUtils, mufasatypes; function FastTPASort(TPA: TPointArray; Dists: TIntegerArray; maxDist: Integer; CloseFirst: Boolean): TPointArray; +procedure QuickSort(var A: TIntegerArray; iLo, iHi: Integer); //Start Wizzyplugin procedure tSwap(var a, b: TPoint); @@ -174,6 +175,29 @@ Begin // Voila! End; +procedure QuickSort(var A: TIntegerArray; iLo, iHi: Integer) ; +var + Lo, Hi, Pivot, T: Integer; +begin + Lo := iLo; + Hi := iHi; + Pivot := A[(Lo + Hi) div 2]; + repeat + while A[Lo] < Pivot do Inc(Lo) ; + while A[Hi] > Pivot do Dec(Hi) ; + if Lo <= Hi then + begin + T := A[Lo]; + A[Lo] := A[Hi]; + A[Hi] := T; + Inc(Lo) ; + Dec(Hi) ; + end; + until Lo > Hi; + if Hi > iLo then QuickSort(A, iLo, Hi) ; + if Lo < iHi then QuickSort(A, Lo, iHi) ; +end; + const flnC=545947; fsqrtA:single=0.5;