Changeset 59 for trunk/Components/EOTButton.pas
- Timestamp:
- Jan 13, 2017, 6:14:46 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Components/EOTButton.pas
r14 r59 4 4 5 5 uses 6 ButtonBase, 7 Classes, Graphics, LCLIntf, LCLType; 6 ButtonBase, Classes, SysUtils, Graphics, LCLIntf, LCLType; 8 7 9 8 const … … 16 15 type 17 16 TEOTButton = class(TButtonBase) 17 public 18 18 constructor Create(aOwner: TComponent); override; 19 19 destructor Destroy; override; … … 51 51 // R channel = Color2 amp 52 52 type 53 T Line = array [0 .. 9999,0 .. 2] of Byte;53 TPixel = array [0 .. 2] of Byte; 54 54 var 55 55 ix, iy, amp0, amp1, trans, Value: integer; 56 SrcLine, DstLine: ^T Line;56 SrcLine, DstLine: ^TPixel; 57 57 begin 58 Src.BeginUpdate; 59 Dst.BeginUpdate; 58 60 for iy := 0 to h - 1 do 59 61 begin 60 SrcLine := Src.ScanLine[ySrc + iy] ;61 DstLine := Dst.ScanLine[yDst + iy] ;62 SrcLine := Src.ScanLine[ySrc + iy] + xSrc * (Src.RawImage.Description.BitsPerPixel shr 3); 63 DstLine := Dst.ScanLine[yDst + iy] + xDst * (Dst.RawImage.Description.BitsPerPixel shr 3); 62 64 for ix := 0 to w - 1 do 63 65 begin 64 trans := SrcLine[ xSrc + ix,0] * 2; // green channel = transparency65 amp0 := SrcLine[ xSrc + ix,1] * 2;66 amp1 := SrcLine[ xSrc + ix,2] * 2;66 trans := SrcLine[0] * 2; // green channel = transparency 67 amp0 := SrcLine[1] * 2; 68 amp1 := SrcLine[2] * 2; 67 69 if trans <> $FF then 68 70 begin 69 Value := (DstLine[ xDst + ix][0] * trans + (Color2 shr 16 and $FF) * amp171 Value := (DstLine[0] * trans + (Color2 shr 16 and $FF) * amp1 70 72 + (Color0 shr 16 and $FF) * amp0) div $FF; 71 73 if Value < 256 then 72 DstLine[ xDst + ix][0] := Value74 DstLine[0] := Value 73 75 else 74 DstLine[ xDst + ix][0] := 255;75 Value := (DstLine[ xDst + ix][1] * trans + (Color2 shr 8 and $FF) * amp176 DstLine[0] := 255; 77 Value := (DstLine[1] * trans + (Color2 shr 8 and $FF) * amp1 76 78 + (Color0 shr 8 and $FF) * amp0) div $FF; 77 79 if Value < 256 then 78 DstLine[ xDst + ix][1] := Value80 DstLine[1] := Value 79 81 else 80 DstLine[ xDst + ix][1] := 255;81 Value := (DstLine[ xDst + ix][2] * trans + (Color2 and $FF) * amp1 +82 DstLine[1] := 255; 83 Value := (DstLine[2] * trans + (Color2 and $FF) * amp1 + 82 84 (Color0 and $FF) * amp0) div $FF; 83 85 if Value < 256 then 84 DstLine[ xDst + ix][2] := Value86 DstLine[2] := Value 85 87 else 86 DstLine[xDst + ix][2] := 255; 87 end 88 end 88 DstLine[2] := 255; 89 end; 90 SrcLine := Pointer(SrcLine) + (Src.RawImage.Description.BitsPerPixel shr 3); 91 DstLine := Pointer(DstLine) + (Dst.RawImage.Description.BitsPerPixel shr 3); 92 end; 89 93 end; 94 Src.EndUpdate; 95 Dst.EndUpdate; 90 96 end; 91 97 92 98 constructor TEOTButton.Create; 93 99 begin 94 inherited Create(aOwner);100 inherited; 95 101 Buffer := TBitmap.Create; 96 102 Buffer.PixelFormat := pf24bit; 97 Buffer. Width := 48;98 Buffer. Height := 48;103 Buffer.SetSize(48, 48); 104 Buffer.Canvas.FillRect(0, 0, Buffer.Width, Buffer.Height); 99 105 Back := TBitmap.Create; 100 106 Back.PixelFormat := pf24bit; 101 Back. Width := 48;102 Back. Height := 48;107 Back.SetSize(48, 48); 108 Back.Canvas.FillRect(0, 0, Back.Width, Back.Height); 103 109 ShowHint := true; 104 110 SetBounds(0, 0, 48, 48); … … 107 113 destructor TEOTButton.Destroy; 108 114 begin 109 Buffer.Free;110 Back.Free;111 inherited Destroy;115 FreeAndNil(Buffer); 116 FreeAndNil(Back); 117 inherited; 112 118 end; 113 119
Note:
See TracChangeset
for help on using the changeset viewer.