Question and Answer Database FAQ2744D.txt Extracting RGB components of a color. Category :VCL Platform :All Product :All 32 bit Question: How do I extract the Red, Green, and Blue components of a given color? Answer: Use the Window API functions GetRValue(), GetGValue(), and GetBValue(). Example: procedure TForm1.Button1Click(Sender: TObject); begin Form1.Canvas.Pen.Color := clRed; Memo1.Lines.Add('Red := ' + IntToStr(GetRValue(Form1.Canvas.Pen.Color))); Memo1.Lines.Add('Red := ' + IntToStr(GetGValue(Form1.Canvas.Pen.Color))); Memo1.Lines.Add('Blue := ' + IntToStr(GetBValue(Form1.Canvas.Pen.Color))); end; 7/16/98 4:31:28 PM
Last Modified: 01-SEP-99