// This function mixes two bytes According to value of TRANS
// The value of TRANS is between 0 (result then will be equal to FG)
// and 255 (result then will be equal to BG)
function MixBytes(FG, BG, TRANS: byte): byte;
asm
push bx // push some regs
push cx
push dx
mov DH,TRANS // remembering Transparency value (or Opacity - as you like)
mov BL,FG // filling registers with our values
mov AL,DH // BL = ForeGround (FG)
mov CL,BG // CL = BackGround (BG)
xor AH,AH // Clear High-order parts of regs
xor BH,BH
xor CH,CH
mul BL // AL=AL*BL
mov BX,AX // BX=AX
xor AH,AH
mov AL,DH
xor AL,$FF // AX=(255-TRANS)
mul CL // AL=AL*CL
add AX,BX // AX=AX+BX
shr AX,8 // Fine! Here we have mixed value in AL
pop dx // Hm... No rubbish after us, ok?
pop cx
pop bx // Bye, dear Assembler - we go home to Delphi!
end;
// Here we mix R,G and B channels of our colors separately.
// The value of T is between 0 and 255 as described above.
// As you know, TColor value is 4 bytes length integer value where
// low byte is red channel, 2nd byte is green and 3rd byte is blue
function MixColors(FG, BG: TColor; T: byte): TColor;
var r,g,b:byte;
begin
R := MixBytes(FG and 255,BG and 255,T); // extracting and mixing Red
G := MixBytes((FG shr 8) and 255,(BG shr 8) and 255,T); // the same with green
B := MixBytes((FG shr 16) and 255,(BG shr 16) and 255,T); // and blue, of course
Result := r+g*256+b*65536; // finishing with combining all channels together
end;
procedure TForm1.Button1Click(Sender: TObject);
var
b : byte;
begin
b := 50; // Max 255
Memo1.Brush.Color := MixColors(clLime, clNavy, b);
end;

Mix two TColors
Abonnieren
Posts (Atom)
Beliebte Posts
-
Windows Key Sniffer 0.82 - Update 08/2024 Der Windows Key Sniffer hat mir im Laufe der Zeit viel Arbeit erspart und unterstützt, viele Wi...
-
Network Source Code Update Source Code Network Update : https://asciigen.blogspot.com/p/network.html Send Message 1.0 Source Server Client ...
-
Windows Defender Bypass Version 0.75 - Update 11/2024 Den Windows 10-eigenen Virenschutz Defender kann man auf mehreren Wegen abschalt...
-
ASCii GIF Animator Update Version 0.68 (32 bit) - 11/2024 Bei dieser überarbeiteten Version ist die Kompatibilität zu den verschiedenen...
-
MD5 Hacker v.0.26 - Update 08.2024 MD5 Hashs sollten eigentlich nicht entschlüsselt werden können. Jedoch gibt es Tools, mit welchen auch ...
-
Dir Sniffer Version 0.11 - Update 02/2025 Dir Sniffer ist ein kleines aber nützliches Tool um herauszufinden, was ihr Programm auf ihrem...
-
Host Editor Version 0.65 - Update 01/2025 Hosts File Editor allows for the easy editing of host files and backup creation. Create your ...
-
Oldskool Font Generator v.0.29 - Update 11/2023 Das Tool stell 508 Bitmap Fonts zu Verfügung. Eigene Fonts können integriert werden, sie...
-
mp4 Tagger v.0.26 - Update 03/2024 Editiere deine MP4-Video-Tags mit einfachen Klicks. Das Tool schafft so ziemlich alle gängigen MP4-St...
Keine Kommentare:
Kommentar veröffentlichen