Blending 2 colours

Hvordan blande to TColor er sammen med en spesifisert styrke (Opacity) .function BlendColors (Farge1, COLOR2: TColor; Gjennomsiktighet: Byte): TColor; Var jeg: Integer; VAL1, VAL2: Byte; RGB1, RGB2: PByteArray; begynne //først sørge for at de er RGB snarere enn en windows farge Farge1: = ColorToRGB (Farge1); COLOR2: = ColorToRGB (COLOR2); //Pek våre Byte arrays til 2 farger RGB1: = @ Farge1; RGB2: = @ COLOR2; //Bland B, G, R for jeg: = 0-2 gjør begynne VAL1: = RGB1 [I] * (255 - Opacity) div 255; VAL2: = RGB2 [I] * Opacity div 255; RGB1 [I]: = VAL1 + VAL2; slutt; //Sett farge flagg for å spesifisere $ 01 = faktiske RGB farge RGB1 [3]: = 1; Resultat: = Farge1; end;



Previous:
Next Page: