was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

35 Visitors Online


 
...zwei Fraben mittels Transparenez Koeffizient vermischen?
Autor: Yurii Zhukow
Homepage: http://www.infoteh.ru/yz
[ Tip ausdrucken ]  

Tip Bewertung (19):  
     


// 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;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners