Changeset 472 for GraphicTest/Packages/bgrabitmap/bgraslicescaling.pas
- Timestamp:
- Apr 9, 2015, 9:58:36 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/Packages/bgrabitmap/bgraslicescaling.pas
r452 r472 66 66 // or as a local owned copy in other cases 67 67 constructor Create(ABitmap: TBGRABitmap; 68 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer );68 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer; ABitmapOwner: boolean = false); 69 69 constructor Create(ABitmap: TBitmap; 70 70 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer); 71 71 constructor Create(AFilename: string; 72 72 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer); 73 constructor Create(AFilename: string; AIsUtf8: boolean; 74 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer); 73 75 constructor Create(AStream: TStream; 74 76 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer); 75 constructor Create(ABitmap: TBGRABitmap );77 constructor Create(ABitmap: TBGRABitmap; ABitmapOwner: boolean = false); 76 78 constructor Create(ABitmap: TBitmap); 77 79 constructor Create(AFilename: string); 80 constructor Create(AFilename: string; AIsUtf8: boolean); 78 81 constructor Create(AStream: TStream); 79 82 constructor Create; … … 121 124 constructor Create(ABitmap: TBGRABitmap; 122 125 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, NumberOfItems: integer; 123 Direction: TSliceScalingDirection );126 Direction: TSliceScalingDirection; ABitmapOwner: boolean = false); 124 127 constructor Create(ABitmap: TBitmap; 125 128 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, NumberOfItems: integer; 126 129 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; 128 134 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, NumberOfItems: integer; 129 135 Direction: TSliceScalingDirection); … … 132 138 Direction: TSliceScalingDirection); 133 139 destructor Destroy; override; 134 constructor Create( Filename, Section: string);140 constructor Create(AIniFilename, ASection: string; AIsUtf8Filename: boolean= false); 135 141 public 136 142 procedure Draw(ItemNumber: integer; ABitmap: TBGRABitmap; … … 166 172 constructor TBGRAMultiSliceScaling.Create(ABitmap: TBGRABitmap; 167 173 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, NumberOfItems: integer; 168 Direction: TSliceScalingDirection );174 Direction: TSliceScalingDirection; ABitmapOwner: boolean = false); 169 175 var 170 176 i: integer; … … 172 178 begin 173 179 FBitmap := ABitmap; 174 FBitmapOwned := false;180 FBitmapOwned := ABitmapOwner; 175 181 ItemWidth := ABitmap.Width; 176 182 ItemHeight := ABitmap.Height; … … 203 209 begin 204 210 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); 212 end; 213 214 constructor TBGRAMultiSliceScaling.Create(ABitmapFilename: string; 210 215 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, NumberOfItems: integer; 211 216 Direction: TSliceScalingDirection); 212 217 begin 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); 220 end; 221 222 constructor TBGRAMultiSliceScaling.Create(ABitmapFilename: string; AIsUtf8: boolean; 223 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, NumberOfItems: integer; 224 Direction: TSliceScalingDirection); 225 begin 226 Create(TBGRABitmap.Create(ABitmapFilename,AIsUtf8), AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, 227 NumberOfItems, Direction, True); 216 228 end; 217 229 … … 221 233 begin 222 234 Create(TBGRABitmap.Create(AStream), AMarginTop, AMarginRight, AMarginBottom, AMarginLeft, 223 NumberOfItems, Direction); 224 FBitmapOwned := true; 235 NumberOfItems, Direction, True); 225 236 end; 226 237 … … 236 247 end; 237 248 238 constructor TBGRAMultiSliceScaling.Create(Filename, Section: string); 249 constructor TBGRAMultiSliceScaling.Create(AIniFilename, ASection: string; 250 AIsUtf8Filename: boolean); 239 251 var 240 252 i: integer; … … 242 254 Direction: TSliceScalingDirection; 243 255 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; 257 begin 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; 274 292 end; 275 293 … … 582 600 583 601 constructor TBGRASliceScaling.Create(ABitmap: TBGRABitmap; 602 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer; ABitmapOwner: boolean = false); 603 begin 604 Create(ABitmap, ABitmapOwner); 605 SetMargins(AMarginTop, AMarginRight, AMarginBottom, AMarginLeft); 606 end; 607 608 constructor TBGRASliceScaling.Create(ABitmap: TBitmap; 584 609 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer); 585 610 begin … … 588 613 end; 589 614 590 constructor TBGRASliceScaling.Create(ABitmap: TBitmap;591 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer);592 begin593 Create(ABitmap);594 SetMargins(AMarginTop, AMarginRight, AMarginBottom, AMarginLeft);595 end;596 597 615 constructor TBGRASliceScaling.Create(AFilename: string; 598 616 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer); … … 602 620 end; 603 621 622 constructor TBGRASliceScaling.Create(AFilename: string; AIsUtf8: boolean; 623 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer); 624 begin 625 Create(AFilename, AIsUtf8); 626 SetMargins(AMarginTop, AMarginRight, AMarginBottom, AMarginLeft); 627 end; 628 604 629 constructor TBGRASliceScaling.Create(AStream: TStream; 605 630 AMarginTop, AMarginRight, AMarginBottom, AMarginLeft: integer); … … 609 634 end; 610 635 611 constructor TBGRASliceScaling.Create(ABitmap: TBGRABitmap );636 constructor TBGRASliceScaling.Create(ABitmap: TBGRABitmap; ABitmapOwner: boolean = false); 612 637 begin 613 638 Init; 614 639 FBitmap := ABitmap; 615 FBitmapOwned := False;640 FBitmapOwned := ABitmapOwner; 616 641 FBitmapSourceRect := rect(0,0,FBitmap.Width,FBitmap.Height); 617 642 end; … … 629 654 Init; 630 655 FBitmap := TBGRABitmap.Create(AFilename); 656 FBitmapOwned := True; 657 FBitmapSourceRect := rect(0,0,FBitmap.Width,FBitmap.Height); 658 end; 659 660 constructor TBGRASliceScaling.Create(AFilename: string; AIsUtf8: boolean); 661 begin 662 Init; 663 FBitmap := TBGRABitmap.Create(AFilename,AIsUtf8); 631 664 FBitmapOwned := True; 632 665 FBitmapSourceRect := rect(0,0,FBitmap.Width,FBitmap.Height);
Note:
See TracChangeset
for help on using the changeset viewer.