From 691bddcde619ed5226bffdb7f34b716c06c62451 Mon Sep 17 00:00:00 2001 From: Raymond Date: Sun, 24 Jan 2010 12:26:36 +0000 Subject: [PATCH] Fixed a lil bug in the FontCopy function, and added new method to the bitmap manager -> GetNewIndex. git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@458 3f818213-9676-44b0-a9b4-5e4c4e03d09d --- trunk/Units/MMLCore/bitmaps.pas | 51 ++++++++++++------------------ trunk/Units/MMLCore/fontloader.pas | 3 +- 2 files changed, 22 insertions(+), 32 deletions(-) diff --git a/trunk/Units/MMLCore/bitmaps.pas b/trunk/Units/MMLCore/bitmaps.pas index 8a8627b..282baa5 100644 --- a/trunk/Units/MMLCore/bitmaps.pas +++ b/trunk/Units/MMLCore/bitmaps.pas @@ -96,6 +96,7 @@ type FreeSpots : Array of integer; BmpArray : TMufasaBmpArray; BmpsCurr,BmpsHigh,FreeSpotsHigh,FreeSpotsLen : integer; + function GetNewIndex : integer; public function GetBMP(Index : integer) : TMufasaBitmap; property Bmp[Index : integer]: TMufasaBitmap read GetBMP; @@ -164,6 +165,24 @@ end; { TMBitmaps } +function TMBitmaps.GetNewIndex: integer; +begin + if BmpsCurr < BmpsHigh then + begin; + inc(BmpsCurr); + Result := BmpsCurr; + end else if (FreeSpotsHigh > -1) then + begin; + Result := FreeSpots[FreeSpotsHigh]; + dec(FreeSpotsHigh); + end else + begin; + SetLength(BmpArray, BmpsHigh + 6); + BmpsHigh := BmpsHigh + 5; + inc(BmpsCurr); + Result := BmpsCurr; + end; +end; function TMBitmaps.GetBMP(Index: integer): TMufasaBitmap; begin @@ -177,21 +196,7 @@ end; function TMBitmaps.CreateBMP(w,h : integer): Integer; begin - if BmpsCurr < BmpsHigh then - begin; - inc(BmpsCurr); - Result := BmpsCurr; - end else if (FreeSpotsHigh > -1) then - begin; - Result := FreeSpots[FreeSpotsHigh]; - dec(FreeSpotsHigh); - end else - begin; - SetLength(BmpArray, BmpsHigh + 6); - BmpsHigh := BmpsHigh + 5; - inc(BmpsCurr); - Result := BmpsCurr; - end; + result := GetNewIndex; BmpArray[Result] := TMufasaBitmap.Create; BmpArray[Result].SetSize(w,h); BmpArray[Result].Index:= Result; @@ -199,21 +204,7 @@ end; function TMBitmaps.AddBMP(_bmp: TMufasaBitmap): Integer; begin - if BmpsCurr < BmpsHigh then - begin; - inc(BmpsCurr); - Result := BmpsCurr; - end else if (FreeSpotsHigh > -1) then - begin; - Result := FreeSpots[FreeSpotsHigh]; - dec(FreeSpotsHigh); - end else - begin; - SetLength(BmpArray, BmpsHigh + 6); - BmpsHigh := BmpsHigh + 5; - inc(BmpsCurr); - Result := BmpsCurr; - end; + Result := GetNewIndex; BmpArray[Result] := _bmp; end; diff --git a/trunk/Units/MMLCore/fontloader.pas b/trunk/Units/MMLCore/fontloader.pas index f1a2c09..56d681b 100644 --- a/trunk/Units/MMLCore/fontloader.pas +++ b/trunk/Units/MMLCore/fontloader.pas @@ -92,7 +92,7 @@ var begin Result := TMFont.Create; Result.Name := Self.Name; - Move(Self.Data.ascii[0], Self.Data.ascii[0], length(Self.Data.ascii) * SizeOf(Integer)); + Move(Self.Data.ascii[0], Result.Data.ascii[0], length(Self.Data.ascii) * SizeOf(TocrGlyphMetric)); l := Length(Self.Data.Pos); SetLength(Result.Data.pos, l); for i := 0 to l - 1 do @@ -204,7 +204,6 @@ begin if Shadow then F.Name := F.Name + '_s'; f.Data := ocrdata; - Fonts.Add(f); {$IFDEF FONTDEBUG} writeln('Loaded Font ' + f.Name);