Ignore:
Timestamp:
May 9, 2020, 4:02:07 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved HighDPI branch. Imported new changes from trunk branch.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/Packages/CevoComponents/EOTButton.pas

    r180 r210  
    44
    55uses
    6   ButtonBase, Classes, SysUtils, Graphics, LCLIntf, LCLType, UDpiControls;
     6  UDpiControls, ButtonBase, Classes, SysUtils, Graphics, LCLIntf, LCLType;
    77
    88const
     
    1414
    1515type
     16  // EndOfTurn button
    1617  TEOTButton = class(TButtonBase)
    1718  public
     
    4041implementation
    4142
     43uses
     44  ScreenTools;
    4245
    4346procedure Register;
    4447begin
    45   RegisterComponents('Samples', [TEOTButton]);
    46 end;
    47 
    48 procedure ImageOp_CBC(Dst, Src: TDpiBitmap; xDst, yDst, xSrc, ySrc, w, h, Color0,
    49   Color2: integer);
    50 // Src is template
    51 // B channel = Color0 amp
    52 // G channel = background amp (old Dst content), 128=original brightness
    53 // R channel = Color2 amp
    54 type
    55   TPixel = array [0 .. 2] of Byte;
    56 var
    57   ix, iy, amp0, amp1, trans, Value: integer;
    58   SrcLine, DstLine: ^TPixel;
    59 begin
    60   Src.BeginUpdate;
    61   Dst.BeginUpdate;
    62   for iy := 0 to h - 1 do
    63   begin
    64     SrcLine := Src.ScanLine[ySrc + iy] + xSrc * (Src.RawImage.Description.BitsPerPixel shr 3);
    65     DstLine := Dst.ScanLine[yDst + iy] + xDst * (Dst.RawImage.Description.BitsPerPixel shr 3);
    66     for ix := 0 to w - 1 do
    67     begin
    68       trans := SrcLine[0] * 2; // green channel = transparency
    69       amp0 := SrcLine[1] * 2;
    70       amp1 := SrcLine[2] * 2;
    71       if trans <> $FF then
    72       begin
    73         Value := (DstLine[0] * trans + (Color2 shr 16 and $FF) * amp1
    74           + (Color0 shr 16 and $FF) * amp0) div $FF;
    75         if Value < 256 then
    76           DstLine[0] := Value
    77         else
    78           DstLine[0] := 255;
    79         Value := (DstLine[1] * trans + (Color2 shr 8 and $FF) * amp1
    80           + (Color0 shr 8 and $FF) * amp0) div $FF;
    81         if Value < 256 then
    82           DstLine[1] := Value
    83         else
    84           DstLine[1] := 255;
    85         Value := (DstLine[2] * trans + (Color2 and $FF) * amp1 +
    86           (Color0 and $FF) * amp0) div $FF;
    87         if Value < 256 then
    88           DstLine[2] := Value
    89         else
    90           DstLine[2] := 255;
    91       end;
    92       SrcLine := Pointer(SrcLine) + (Src.RawImage.Description.BitsPerPixel shr 3);
    93       DstLine := Pointer(DstLine) + (Dst.RawImage.Description.BitsPerPixel shr 3);
    94     end;
    95   end;
    96   Src.EndUpdate;
    97   Dst.EndUpdate;
     48  RegisterComponents('C-evo', [TEOTButton]);
    9849end;
    9950
     
    12677    begin
    12778      // TODO: For some reason BitBlt is not working with gray background here
    128       //DpiBitBlt(Buffer.Canvas.Handle, 0, 0, 48, 48, Back.Canvas.Handle, 0,
    129       //  0, SRCCOPY);
     79      //DpiBitCanvas(Buffer.Canvas, 0, 0, 48, 48, Back.Canvas, 0, 0);
    13080      Buffer.Canvas.Draw(0, 0, Back);
    13181      ImageOp_CBC(Buffer, Template, 0, 0, 133, 149 + 48 * Byte(FDown), 48, 48,
     
    13484        ImageOp_CBC(Buffer, Template, 8, 8, 1 + 32 * Byte(FIndex), 246, 32, 32,
    13585          $000000, $FFFFFF);
    136       DpiBitBlt(Canvas.Handle, 0, 0, 48, 48, Buffer.Canvas.Handle, 0, 0, SRCCOPY);
     86      DpiBitCanvas(Canvas, 0, 0, 48, 48, Buffer.Canvas, 0, 0);
    13787    end
    13888    else
     
    14090      Brush.Color := $0000FF;
    14191      FrameRect(Rect(0, 0, 48, 48))
    142     end
     92    end;
    14393end;
    14494
     
    14898  begin
    14999    FIndex := x;
    150     Invalidate
    151   end
     100    Invalidate;
     101  end;
    152102end;
    153103
     
    160110      Paint
    161111    except
    162     end
    163   end
     112    end;
     113  end;
    164114end;
    165115
    166116procedure TEOTButton.SetBack(ca: TDpiCanvas; x, y: integer);
    167117begin
    168   DpiBitBlt(Back.Canvas.Handle, 0, 0, 48, 48, ca.Handle, x, y, SRCCOPY);
     118  DpiBitCanvas(Back.Canvas, 0, 0, 48, 48, ca, x, y);
    169119end;
    170120
Note: See TracChangeset for help on using the changeset viewer.