Changeset 331 for trunk/Packages/CevoComponents
- Timestamp:
- Mar 26, 2021, 3:24:15 PM (4 years ago)
- Location:
- trunk/Packages/CevoComponents
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/CevoComponents/ScreenTools.pas
r323 r331 42 42 function LoadGraphicSet2(const Name: string): TGraphicSet; 43 43 procedure Dump(dst: TBitmap; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer); 44 procedure BitmapReplaceColor(Dst: TBitmap; X, Y, Width, Height: Integer; OldColor, NewColor: TColor); 44 45 procedure Sprite(Canvas: TCanvas; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer); 45 46 overload; … … 567 568 end; 568 569 570 procedure BitmapReplaceColor(Dst: TBitmap; X, Y, Width, Height: Integer; OldColor, NewColor: TColor); 571 var 572 XX, YY: Integer; 573 PixelPtr: TPixelPointer; 574 begin 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; 587 end; 588 569 589 procedure MakeBlue(Dst: TBitmap; X, Y, Width, Height: Integer); 570 590 var -
trunk/Packages/CevoComponents/UPixelPointer.pas
r230 r331 9 9 TColor32 = type Cardinal; 10 10 TColor32Component = (ccBlue, ccGreen, ccRed, ccAlpha); 11 12 { TPixel32 } 13 11 14 TPixel32 = packed record 15 private 16 function GetRGB: Cardinal; 17 procedure SetRGB(AValue: Cardinal); 18 public 19 property RGB: Cardinal read GetRGB write SetRGB; 12 20 case Integer of 13 21 0: (B, G, R, A: Byte); … … 37 45 38 46 function PixelPointer(Bitmap: TRasterImage; BaseX: Integer = 0; BaseY: Integer = 0): TPixelPointer; inline; 39 47 function SwapRedBlue(Color: TColor32): TColor32; 40 48 41 49 implementation 50 51 { TPixel32 } 52 53 function TPixel32.GetRGB: Cardinal; 54 begin 55 Result := ARGB and $ffffff; 56 end; 57 58 procedure TPixel32.SetRGB(AValue: Cardinal); 59 begin 60 R := (AValue shr 16) and $ff; 61 G := (AValue shr 8) and $ff; 62 B := (AValue shr 0) and $ff; 63 end; 42 64 43 65 { TPixelPointer } … … 86 108 end; 87 109 110 function SwapRedBlue(Color: TColor32): TColor32; 111 begin 112 Result := (Color and $ff00ff00) or ((Color and $ff) shl 16) or ((Color shr 16) and $ff); 113 end; 114 88 115 89 116 end.
Note:
See TracChangeset
for help on using the changeset viewer.