Ignore:
Timestamp:
Nov 17, 2021, 11:11:01 AM (2 years ago)
Author:
chronos
Message:
  • Modified: Merged LoadGraphicSet and LoadGraphicSet2 into single method.
  • Modified: Moved brain load picture code into TBrain.LoadPicture method.
  • Added: Brain pictures loaded as TGraphicSetItem.
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/CevoComponents/ScreenTools.pas

    r380 r417  
    2929function ExtractFileNameWithoutExt(const Filename: string): string;
    3030function LoadGraphicFile(Bmp: TBitmap; FileName: string; Options: TLoadGraphicFileOptions = []): boolean;
    31 function LoadGraphicSet(const Name: string): TGraphicSet;
    32 function LoadGraphicSet2(const Name: string): TGraphicSet;
     31function LoadGraphicSet(const Name: string; Transparency: Boolean = True): TGraphicSet;
    3332procedure Dump(dst: TBitmap; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer);
    3433procedure BitmapReplaceColor(Dst: TBitmap; X, Y, Width, Height: Integer; OldColor, NewColor: TColor);
     
    151150  Phrases2: TStringTable;
    152151  GrExt: TGraphicSets;
     152
    153153  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 items
    168154  CityMark1: TGraphicSetItem;
    169155  CityMark2: TGraphicSetItem;
     156
     157  HGrSystem2: TGraphicSet;
    170158  Ornament: TGraphicSetItem;
     159  GBrainNoTerm: TGraphicSetItem;
     160  GBrainSuperVirtual: TGraphicSetItem;
     161  GBrainTerm: TGraphicSetItem;
     162  GBrainRandom: TGraphicSetItem;
     163
     164  Templates: TGraphicSet;
    171165  Logo: TGraphicSetItem;
    172166  BigBook: TGraphicSetItem;
     
    181175  WeightOn: TGraphicSetItem;
    182176  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;
    183188
    184189  UniFont: array [TFontType] of TFont;
     
    485490end;
    486491
    487 function LoadGraphicSet(const Name: string): TGraphicSet;
     492function LoadGraphicSet(const Name: string; Transparency: Boolean = True): TGraphicSet;
    488493var
    489494  x: Integer;
     
    510515    Result.ResetPixUsed;
    511516
    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;
    532541        end;
    533         DataPixel.NextPixel;
    534         MaskPixel.NextPixel;
     542        DataPixel.NextLine;
     543        MaskPixel.NextLine;
    535544      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;
    565551  end;
    566552end;
     
    10501036    MainTexture.ColorBevelLight and $FCFCFC shr 2);
    10511037  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));
    10531040  if PixelPtr.BytesPerPixel = 3 then begin
    10541041    for Y := 0 to ScaleToNative(Ornament.Height) - 1 do begin
     
    17401727  LoadPhrases;
    17411728  LoadFonts;
    1742   Templates := LoadGraphicSet2('Templates.png');
     1729  Templates := LoadGraphicSet('Templates.png', False);
    17431730  with Templates do begin
    17441731    Logo := GetItem('Logo');
     
    17791766
    17801767  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;
    17831772
    17841773  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;
    17861781
    17871782  Colors := TBitmap.Create;
Note: See TracChangeset for help on using the changeset viewer.