Conv-Color to Sepia

From Vectorlab
Jump to: navigation, search


Converts a RGB-16 triplet (range 0-65535) to sepia. Returns the modified RGB triplet. By Orso B. Schmid


{ Orso *********************************************** }
{ converts a rgb-16 (range 0-65535) triplet to sepia }
{ based upon Zach Smith, 2007: http://blogs.techrepublic.com.com/howdoi/?p=120 }
PROCEDURE C_Sepia(VAR r, g, b: LONGINT);
	VAR
		r1, g1, b1 : LONGINT;
	BEGIN
		r1 := Min(r*0.393 + g*0.769 + b*0.189, 65535);
		g1 := Min(r*0.349 + g*0.686 + b*0.168, 65535);
		b1 := Min(r*0.272 + g*0.534 + b*0.131, 65535);
		
		r := r1;
		g := g1;
		b := b1;
	END;