Changeset 210 for branches/highdpi/Packages/CevoComponents/EOTButton.pas
- Timestamp:
- May 9, 2020, 4:02:07 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Packages/CevoComponents/EOTButton.pas
r180 r210 4 4 5 5 uses 6 ButtonBase, Classes, SysUtils, Graphics, LCLIntf, LCLType, UDpiControls;6 UDpiControls, ButtonBase, Classes, SysUtils, Graphics, LCLIntf, LCLType; 7 7 8 8 const … … 14 14 15 15 type 16 // EndOfTurn button 16 17 TEOTButton = class(TButtonBase) 17 18 public … … 40 41 implementation 41 42 43 uses 44 ScreenTools; 42 45 43 46 procedure Register; 44 47 begin 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]); 98 49 end; 99 50 … … 126 77 begin 127 78 // 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); 130 80 Buffer.Canvas.Draw(0, 0, Back); 131 81 ImageOp_CBC(Buffer, Template, 0, 0, 133, 149 + 48 * Byte(FDown), 48, 48, … … 134 84 ImageOp_CBC(Buffer, Template, 8, 8, 1 + 32 * Byte(FIndex), 246, 32, 32, 135 85 $000000, $FFFFFF); 136 DpiBit Blt(Canvas.Handle, 0, 0, 48, 48, Buffer.Canvas.Handle, 0, 0, SRCCOPY);86 DpiBitCanvas(Canvas, 0, 0, 48, 48, Buffer.Canvas, 0, 0); 137 87 end 138 88 else … … 140 90 Brush.Color := $0000FF; 141 91 FrameRect(Rect(0, 0, 48, 48)) 142 end 92 end; 143 93 end; 144 94 … … 148 98 begin 149 99 FIndex := x; 150 Invalidate 151 end 100 Invalidate; 101 end; 152 102 end; 153 103 … … 160 110 Paint 161 111 except 162 end 163 end 112 end; 113 end; 164 114 end; 165 115 166 116 procedure TEOTButton.SetBack(ca: TDpiCanvas; x, y: integer); 167 117 begin 168 DpiBit Blt(Back.Canvas.Handle, 0, 0, 48, 48, ca.Handle, x, y, SRCCOPY);118 DpiBitCanvas(Back.Canvas, 0, 0, 48, 48, ca, x, y); 169 119 end; 170 120
Note:
See TracChangeset
for help on using the changeset viewer.