Ignore:
Timestamp:
Mar 26, 2021, 3:24:15 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Player border tile preparation code for bitmap color replacement moved to ScreenTools.
File:
1 edited

Legend:

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

    r323 r331  
    4242function LoadGraphicSet2(const Name: string): TGraphicSet;
    4343procedure Dump(dst: TBitmap; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer);
     44procedure BitmapReplaceColor(Dst: TBitmap; X, Y, Width, Height: Integer; OldColor, NewColor: TColor);
    4445procedure Sprite(Canvas: TCanvas; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer);
    4546  overload;
     
    567568end;
    568569
     570procedure BitmapReplaceColor(Dst: TBitmap; X, Y, Width, Height: Integer; OldColor, NewColor: TColor);
     571var
     572  XX, YY: Integer;
     573  PixelPtr: TPixelPointer;
     574begin
     575  Dst.BeginUpdate;
     576  PixelPtr := PixelPointer(Dst, ScaleToNative(X), ScaleToNative(Y));
     577  for YY := 0 to ScaleToNative(Height) - 1 do begin
     578    for XX := 0 to ScaleToNative(Width) - 1 do begin
     579      if PixelPtr.Pixel^.RGB = SwapRedBlue(OldColor) then begin
     580        PixelPtr.Pixel^.RGB := SwapRedBlue(NewColor);
     581      end;
     582      PixelPtr.NextPixel;
     583    end;
     584    PixelPtr.NextLine;
     585  end;
     586  Dst.EndUpdate;
     587end;
     588
    569589procedure MakeBlue(Dst: TBitmap; X, Y, Width, Height: Integer);
    570590var
Note: See TracChangeset for help on using the changeset viewer.