Changeset 417 for trunk/Packages/CevoComponents/ScreenTools.pas
- Timestamp:
- Nov 17, 2021, 11:11:01 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/CevoComponents/ScreenTools.pas
r380 r417 29 29 function ExtractFileNameWithoutExt(const Filename: string): string; 30 30 function LoadGraphicFile(Bmp: TBitmap; FileName: string; Options: TLoadGraphicFileOptions = []): boolean; 31 function LoadGraphicSet(const Name: string): TGraphicSet; 32 function LoadGraphicSet2(const Name: string): TGraphicSet; 31 function LoadGraphicSet(const Name: string; Transparency: Boolean = True): TGraphicSet; 33 32 procedure Dump(dst: TBitmap; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer); 34 33 procedure BitmapReplaceColor(Dst: TBitmap; X, Y, Width, Height: Integer; OldColor, NewColor: TColor); … … 151 150 Phrases2: TStringTable; 152 151 GrExt: TGraphicSets; 152 153 153 HGrSystem: TGraphicSet; 154 HGrSystem2: TGraphicSet;155 ClickFrameColor: Integer;156 MainTexture: TTexture;157 Templates: TGraphicSet;158 Colors: TBitmap;159 Paper: TBitmap;160 BigImp: TBitmap;161 LogoBuffer: TBitmap;162 FullScreen: Boolean;163 GenerateNames: Boolean;164 InitOrnamentDone: Boolean;165 Phrases2FallenBackToEnglish: Boolean;166 167 // Graphic set items168 154 CityMark1: TGraphicSetItem; 169 155 CityMark2: TGraphicSetItem; 156 157 HGrSystem2: TGraphicSet; 170 158 Ornament: TGraphicSetItem; 159 GBrainNoTerm: TGraphicSetItem; 160 GBrainSuperVirtual: TGraphicSetItem; 161 GBrainTerm: TGraphicSetItem; 162 GBrainRandom: TGraphicSetItem; 163 164 Templates: TGraphicSet; 171 165 Logo: TGraphicSetItem; 172 166 BigBook: TGraphicSetItem; … … 181 175 WeightOn: TGraphicSetItem; 182 176 WeightOff: TGraphicSetItem; 177 178 ClickFrameColor: Integer; 179 MainTexture: TTexture; 180 Colors: TBitmap; 181 Paper: TBitmap; 182 BigImp: TBitmap; 183 LogoBuffer: TBitmap; 184 FullScreen: Boolean; 185 GenerateNames: Boolean; 186 InitOrnamentDone: Boolean; 187 Phrases2FallenBackToEnglish: Boolean; 183 188 184 189 UniFont: array [TFontType] of TFont; … … 485 490 end; 486 491 487 function LoadGraphicSet(const Name: string ): TGraphicSet;492 function LoadGraphicSet(const Name: string; Transparency: Boolean = True): TGraphicSet; 488 493 var 489 494 x: Integer; … … 510 515 Result.ResetPixUsed; 511 516 512 Result.Mask.SetSize(Result.Data.Width, Result.Data.Height); 513 514 Result.Data.BeginUpdate; 515 Result.Mask.BeginUpdate; 516 DataPixel := PixelPointer(Result.Data); 517 MaskPixel := PixelPointer(Result.Mask); 518 for y := 0 to ScaleToNative(Result.Data.Height) - 1 do begin 519 for x := 0 to ScaleToNative(Result.Data.Width) - 1 do begin 520 OriginalColor := DataPixel.Pixel^.ARGB and $FFFFFF; 521 if (OriginalColor = TransparentColor1) or (OriginalColor = TransparentColor2) then begin 522 MaskPixel.Pixel^.R := $FF; 523 MaskPixel.Pixel^.G := $FF; 524 MaskPixel.Pixel^.B := $FF; 525 DataPixel.Pixel^.R := 0; 526 DataPixel.Pixel^.G := 0; 527 DataPixel.Pixel^.B := 0; 528 end else begin 529 MaskPixel.Pixel^.R := $00; 530 MaskPixel.Pixel^.G := $00; 531 MaskPixel.Pixel^.B := $00; 517 if Transparency then begin 518 Result.Mask.SetSize(Result.Data.Width, Result.Data.Height); 519 520 Result.Data.BeginUpdate; 521 Result.Mask.BeginUpdate; 522 DataPixel := PixelPointer(Result.Data); 523 MaskPixel := PixelPointer(Result.Mask); 524 for y := 0 to ScaleToNative(Result.Data.Height) - 1 do begin 525 for x := 0 to ScaleToNative(Result.Data.Width) - 1 do begin 526 OriginalColor := DataPixel.Pixel^.ARGB and $FFFFFF; 527 if (OriginalColor = TransparentColor1) or (OriginalColor = TransparentColor2) then begin 528 MaskPixel.Pixel^.R := $FF; 529 MaskPixel.Pixel^.G := $FF; 530 MaskPixel.Pixel^.B := $FF; 531 DataPixel.Pixel^.R := 0; 532 DataPixel.Pixel^.G := 0; 533 DataPixel.Pixel^.B := 0; 534 end else begin 535 MaskPixel.Pixel^.R := $00; 536 MaskPixel.Pixel^.G := $00; 537 MaskPixel.Pixel^.B := $00; 538 end; 539 DataPixel.NextPixel; 540 MaskPixel.NextPixel; 532 541 end; 533 DataPixel.Next Pixel;534 MaskPixel.Next Pixel;542 DataPixel.NextLine; 543 MaskPixel.NextLine; 535 544 end; 536 DataPixel.NextLine; 537 MaskPixel.NextLine; 538 end; 539 Result.Data.EndUpdate; 540 Result.Mask.EndUpdate; 541 542 if Gamma <> 100 then 543 ApplyGammaToBitmap(Result.Data); 544 end; 545 end; 546 547 function LoadGraphicSet2(const Name: string): TGraphicSet; 548 var 549 FileName: string; 550 begin 551 Result := GrExt.SearchByName(Name); 552 if not Assigned(Result) then begin 553 Result := GrExt.AddNew(Name); 554 FileName := GetGraphicsDir + DirectorySeparator + Name; 555 if not LoadGraphicFile(Result.Data, FileName, [gfNoGamma]) then begin 556 Result := nil; 557 Exit; 558 end; 559 560 FileName := ExtractFileNameWithoutExt(FileName) + GraphicSetFileExt; 561 if FileExists(FileName) then 562 Result.LoadFromFile(FileName); 563 564 Result.ResetPixUsed; 545 Result.Data.EndUpdate; 546 Result.Mask.EndUpdate; 547 548 if Gamma <> 100 then 549 ApplyGammaToBitmap(Result.Data); 550 end; 565 551 end; 566 552 end; … … 1050 1036 MainTexture.ColorBevelLight and $FCFCFC shr 2); 1051 1037 HGrSystem2.Data.BeginUpdate; 1052 PixelPtr := PixelPointer(HGrSystem2.Data, ScaleToNative(Ornament.Left), ScaleToNative(Ornament.Top)); 1038 PixelPtr := PixelPointer(HGrSystem2.Data, ScaleToNative(Ornament.Left), 1039 ScaleToNative(Ornament.Top)); 1053 1040 if PixelPtr.BytesPerPixel = 3 then begin 1054 1041 for Y := 0 to ScaleToNative(Ornament.Height) - 1 do begin … … 1740 1727 LoadPhrases; 1741 1728 LoadFonts; 1742 Templates := LoadGraphicSet 2('Templates.png');1729 Templates := LoadGraphicSet('Templates.png', False); 1743 1730 with Templates do begin 1744 1731 Logo := GetItem('Logo'); … … 1779 1766 1780 1767 HGrSystem := LoadGraphicSet('System.png'); 1781 CityMark1 := HGrSystem.GetItem('CityMark1'); 1782 CityMark2 := HGrSystem.GetItem('CityMark2'); 1768 with HGrSystem do begin 1769 CityMark1 := GetItem('CityMark1'); 1770 CityMark2 := GetItem('CityMark2'); 1771 end; 1783 1772 1784 1773 HGrSystem2 := LoadGraphicSet('System2.png'); 1785 Ornament := HGrSystem2.GetItem('Ornament'); 1774 with HGrSystem2 do begin 1775 Ornament := GetItem('Ornament'); 1776 GBrainNoTerm := GetItem('BrainNoTerm'); 1777 GBrainSuperVirtual := GetItem('BrainSuperVirtual'); 1778 GBrainTerm := GetItem('BrainTerm'); 1779 GBrainRandom := GetItem('BrainRandom'); 1780 end; 1786 1781 1787 1782 Colors := TBitmap.Create;
Note:
See TracChangeset
for help on using the changeset viewer.