Changeset 77 for trunk/Packages/Common


Ignore:
Timestamp:
May 19, 2021, 11:30:41 AM (4 years ago)
Author:
chronos
Message:
  • Added: Control icons for Pause, Play and Fast forward.
  • Modified: Image buttons changed to custom TImage control with Enabled property supported.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/UPixelPointer.pas

    r76 r77  
    5353  procedure BitmapSwapRedBlue(Bitmap:TRasterImage);
    5454  procedure BitmapInvert(Bitmap: TRasterImage);
     55  procedure BitmapBlendColor(Bitmap: TRasterImage; Color: TColor32);
     56  function Color32(A, R, G, B: Byte): TColor32;
     57  function Color32ToPixel32(Color: TColor32): TPixel32;
     58  function Pixel32ToColor32(Color: TPixel32): TColor32;
    5559
    5660implementation
     
    237241end;
    238242
     243procedure BitmapBlendColor(Bitmap: TRasterImage; Color: TColor32);
     244var
     245  X, Y: Integer;
     246  Ptr: TPixelPointer;
     247  A, R, G, B: Word;
     248  Pixel: TPixel32;
     249begin
     250  Pixel := Color32ToPixel32(Color);
     251  Bitmap.BeginUpdate(True);
     252  Ptr := PixelPointer(Bitmap);
     253  for Y := 0 to Bitmap.Height - 1 do begin
     254    for X := 0 to Bitmap.Width - 1 do begin
     255      A := Ptr.Pixel^.A; //(Ptr.Pixel^.A + Pixel.A) shr 1;
     256      R := (Ptr.Pixel^.R + Pixel.R) shr 1;
     257      G := (Ptr.Pixel^.G + Pixel.G) shr 1;
     258      B := (Ptr.Pixel^.B + Pixel.B) shr 1;
     259      Ptr.Pixel^.ARGB := Color32(A, R, G, B);
     260      Ptr.NextPixel;
     261    end;
     262    Ptr.NextLine;
     263  end;
     264  Bitmap.EndUpdate;
     265end;
     266
     267function Color32(A, R, G, B: Byte): TColor32;
     268begin
     269  Result := ((A and $ff) shl 24) or ((R and $ff) shl 16) or
     270    ((G and $ff) shl 8) or ((B and $ff) shl 0);
     271end;
     272
     273function Color32ToPixel32(Color: TColor32): TPixel32;
     274begin
     275  Result.ARGB := Color;
     276end;
     277
     278function Pixel32ToColor32(Color: TPixel32): TColor32;
     279begin
     280  Result := Color.ARGB;
     281end;
     282
    239283function PixelPointer(Bitmap: TRasterImage; BaseX: Integer;
    240284  BaseY: Integer): TPixelPointer;
Note: See TracChangeset for help on using the changeset viewer.