Ignore:
Timestamp:
Apr 9, 2015, 9:58:36 PM (10 years ago)
Author:
chronos
Message:
  • Fixed: Use csOpaque control style also to Image, PaintBox and OpenGLControl.
  • Modified: Change size of test frame with SpinEdits as delayed using timer.
  • Updated: BRGABitmap package to version 8.1.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/Packages/bgrabitmap/bgraslicescaling.pas

    r452 r472  
    6666    // or as a local owned copy in other cases
    6767    constructor Create(ABitmap: TBGRABitmap;
    68       AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer);
     68      AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer; ABitmapOwner: boolean = false);
    6969    constructor Create(ABitmap: TBitmap;
    7070      AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer);
    7171    constructor Create(AFilename: string;
    7272      AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer);
     73    constructor Create(AFilename: string; AIsUtf8: boolean;
     74      AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer);
    7375    constructor Create(AStream: TStream;
    7476      AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer);
    75     constructor Create(ABitmap: TBGRABitmap);
     77    constructor Create(ABitmap: TBGRABitmap; ABitmapOwner: boolean = false);
    7678    constructor Create(ABitmap: TBitmap);
    7779    constructor Create(AFilename: string);
     80    constructor Create(AFilename: string; AIsUtf8: boolean);
    7881    constructor Create(AStream: TStream);
    7982    constructor Create;
     
    121124    constructor Create(ABitmap: TBGRABitmap;
    122125      AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, NumberOfItems: integer;
    123       Direction: TSliceScalingDirection);
     126      Direction: TSliceScalingDirection; ABitmapOwner: boolean = false);
    124127    constructor Create(ABitmap: TBitmap;
    125128      AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, NumberOfItems: integer;
    126129      Direction: TSliceScalingDirection);
    127     constructor Create(AFilename: string;
     130    constructor Create(ABitmapFilename: string;
     131      AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, NumberOfItems: integer;
     132      Direction: TSliceScalingDirection);
     133    constructor Create(ABitmapFilename: string; AIsUtf8: boolean;
    128134      AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, NumberOfItems: integer;
    129135      Direction: TSliceScalingDirection);
     
    132138      Direction: TSliceScalingDirection);
    133139    destructor Destroy; override;
    134     constructor Create(Filename, Section: string);
     140    constructor Create(AIniFilename, ASection: string; AIsUtf8Filename: boolean= false);
    135141  public
    136142    procedure Draw(ItemNumber: integer; ABitmap: TBGRABitmap;
     
    166172constructor TBGRAMultiSliceScaling.Create(ABitmap: TBGRABitmap;
    167173  AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, NumberOfItems: integer;
    168   Direction: TSliceScalingDirection);
     174  Direction: TSliceScalingDirection; ABitmapOwner: boolean = false);
    169175var
    170176  i: integer;
     
    172178begin
    173179  FBitmap := ABitmap;
    174   FBitmapOwned := false;
     180  FBitmapOwned := ABitmapOwner;
    175181  ItemWidth := ABitmap.Width;
    176182  ItemHeight := ABitmap.Height;
     
    203209begin
    204210  Create(TBGRABitmap.Create(ABitmap), AMarginTop, AMarginRight, AMarginBottom, AMarginLeft,
    205     NumberOfItems, Direction);
    206   FBitmapOwned := true;
    207 end;
    208 
    209 constructor TBGRAMultiSliceScaling.Create(AFilename: string;
     211    NumberOfItems, Direction, True);
     212end;
     213
     214constructor TBGRAMultiSliceScaling.Create(ABitmapFilename: string;
    210215  AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, NumberOfItems: integer;
    211216  Direction: TSliceScalingDirection);
    212217begin
    213   Create(TBGRABitmap.Create(AFilename), AMarginTop, AMarginRight, AMarginBottom, AMarginLeft,
    214     NumberOfItems, Direction);
    215   FBitmapOwned := true;
     218  Create(TBGRABitmap.Create(ABitmapFilename), AMarginTop, AMarginRight, AMarginBottom, AMarginLeft,
     219    NumberOfItems, Direction, True);
     220end;
     221
     222constructor TBGRAMultiSliceScaling.Create(ABitmapFilename: string; AIsUtf8: boolean;
     223  AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, NumberOfItems: integer;
     224  Direction: TSliceScalingDirection);
     225begin
     226  Create(TBGRABitmap.Create(ABitmapFilename,AIsUtf8), AMarginTop, AMarginRight, AMarginBottom, AMarginLeft,
     227    NumberOfItems, Direction, True);
    216228end;
    217229
     
    221233begin
    222234  Create(TBGRABitmap.Create(AStream), AMarginTop, AMarginRight, AMarginBottom, AMarginLeft,
    223     NumberOfItems, Direction);
    224   FBitmapOwned := true;
     235    NumberOfItems, Direction, True);
    225236end;
    226237
     
    236247end;
    237248
    238 constructor TBGRAMultiSliceScaling.Create(Filename, Section: string);
     249constructor TBGRAMultiSliceScaling.Create(AIniFilename, ASection: string;
     250  AIsUtf8Filename: boolean);
    239251var
    240252  i: integer;
     
    242254  Direction: TSliceScalingDirection;
    243255  defaultRepeat: string;
    244   IniPath,BitmapFilename: string;
    245 begin
    246   if FileExistsUTF8(Filename) then
    247   begin
    248     temp := TMemIniFile.Create(Filename);
    249     IniPath := ExtractFilePath(Filename);
    250 
    251     if temp.ReadBool(Section, 'HorizontalDirection', False) then
    252       Direction := sdHorizontal
    253     else
    254       Direction := sdVertical;
    255 
    256     BitmapFilename := temp.ReadString(Section, 'Bitmap', '');
    257     if (copy(BitmapFilename,1,2) = '.\') or (copy(BitmapFilename,1,2) = './') then
    258       BitmapFilename := IniPath+copy(BitmapFilename,3,Length(BitmapFilename)-2);
    259     Create(
    260       BitmapFilename,
    261       temp.ReadInteger(Section, 'MarginTop', 0),
    262       temp.ReadInteger(Section, 'MarginRight', 0),
    263       temp.ReadInteger(Section, 'MarginBottom', 0),
    264       temp.ReadInteger(Section, 'MarginLeft', 0),
    265       temp.ReadInteger(Section, 'NumberOfItems', 1),
    266       Direction);
    267 
    268     defaultRepeat := temp.ReadString(Section, 'Repeat', 'Auto');
    269     for i := 0 to High(FSliceScalingArray) do
    270       FSliceScalingArray[i].SliceRepeatAsString := temp.ReadString(Section, 'Repeat'+IntToStr(i+1), defaultRepeat);
    271 
    272     temp.Free;
    273   end;
     256  IniPathUTF8,BitmapFilename: string;
     257begin
     258  if AIsUtf8Filename then
     259  begin
     260    if not FileExistsUTF8(AIniFilename) then exit;
     261    temp := TMemIniFile.Create(UTF8ToSys(AIniFilename));
     262    IniPathUTF8 := ExtractFilePath(AIniFilename);
     263  end else
     264  begin
     265    if not FileExists(AIniFilename) then exit;
     266    temp := TMemIniFile.Create(AIniFilename);
     267    IniPathUTF8 := SysToUTF8(ExtractFilePath(AIniFilename));
     268  end;
     269
     270  if temp.ReadBool(ASection, 'HorizontalDirection', False) then
     271    Direction := sdHorizontal
     272  else
     273    Direction := sdVertical;
     274
     275  BitmapFilename := temp.ReadString(ASection, 'Bitmap', '');
     276  if (copy(BitmapFilename,1,2) = '.\') or (copy(BitmapFilename,1,2) = './') then
     277    BitmapFilename := IniPathUTF8+SysToUTF8(copy(BitmapFilename,3,Length(BitmapFilename)-2));
     278  Create(
     279    BitmapFilename,True,
     280    temp.ReadInteger(ASection, 'MarginTop', 0),
     281    temp.ReadInteger(ASection, 'MarginRight', 0),
     282    temp.ReadInteger(ASection, 'MarginBottom', 0),
     283    temp.ReadInteger(ASection, 'MarginLeft', 0),
     284    temp.ReadInteger(ASection, 'NumberOfItems', 1),
     285    Direction);
     286
     287  defaultRepeat := temp.ReadString(ASection, 'Repeat', 'Auto');
     288  for i := 0 to High(FSliceScalingArray) do
     289    FSliceScalingArray[i].SliceRepeatAsString := temp.ReadString(ASection, 'Repeat'+IntToStr(i+1), defaultRepeat);
     290
     291  temp.Free;
    274292end;
    275293
     
    582600
    583601constructor TBGRASliceScaling.Create(ABitmap: TBGRABitmap;
     602  AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer; ABitmapOwner: boolean = false);
     603begin
     604  Create(ABitmap, ABitmapOwner);
     605  SetMargins(AMarginTop, AMarginRight, AMarginBottom, AMarginLeft);
     606end;
     607
     608constructor TBGRASliceScaling.Create(ABitmap: TBitmap;
    584609  AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer);
    585610begin
     
    588613end;
    589614
    590 constructor TBGRASliceScaling.Create(ABitmap: TBitmap;
    591   AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer);
    592 begin
    593   Create(ABitmap);
    594   SetMargins(AMarginTop, AMarginRight, AMarginBottom, AMarginLeft);
    595 end;
    596 
    597615constructor TBGRASliceScaling.Create(AFilename: string;
    598616  AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer);
     
    602620end;
    603621
     622constructor TBGRASliceScaling.Create(AFilename: string; AIsUtf8: boolean;
     623  AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer);
     624begin
     625  Create(AFilename, AIsUtf8);
     626  SetMargins(AMarginTop, AMarginRight, AMarginBottom, AMarginLeft);
     627end;
     628
    604629constructor TBGRASliceScaling.Create(AStream: TStream;
    605630  AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer);
     
    609634end;
    610635
    611 constructor TBGRASliceScaling.Create(ABitmap: TBGRABitmap);
     636constructor TBGRASliceScaling.Create(ABitmap: TBGRABitmap; ABitmapOwner: boolean = false);
    612637begin
    613638  Init;
    614639  FBitmap := ABitmap;
    615   FBitmapOwned := False;
     640  FBitmapOwned := ABitmapOwner;
    616641  FBitmapSourceRect := rect(0,0,FBitmap.Width,FBitmap.Height);
    617642end;
     
    629654  Init;
    630655  FBitmap := TBGRABitmap.Create(AFilename);
     656  FBitmapOwned := True;
     657  FBitmapSourceRect := rect(0,0,FBitmap.Width,FBitmap.Height);
     658end;
     659
     660constructor TBGRASliceScaling.Create(AFilename: string; AIsUtf8: boolean);
     661begin
     662  Init;
     663  FBitmap := TBGRABitmap.Create(AFilename,AIsUtf8);
    631664  FBitmapOwned := True;
    632665  FBitmapSourceRect := rect(0,0,FBitmap.Width,FBitmap.Height);
Note: See TracChangeset for help on using the changeset viewer.