Mega Code Archive

 
Categories / Delphi / Graphic
 

Color Selector

Title: Color Selector Question: I need a color selector for all colors, not just the 16 colors in colorgrid. Answer: Simple But Effective Colour selector. I spent a while looking for a good colour selection component without luck. It may or may not be an original idea, but need being the mother of invention this is what I came up with...... Drop two Panels and one TImage on a form. Screen capture from just about any Photo or painting package the colour selector. Resize and crop the capture to the size you require. Save it as a BMP and then load it into the Image Component. Create a MouseMove event as below.... procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin Panel1.Color := Image1.Canvas.Pixels[X,Y]; end; Create an OnClick event for the Image as below.... procedure TForm1.Image1Click(Sender: TObject); begin Panel2.Color := Panel1.Color; end; As you move the mouse over the Image the colour on Panel one will change. Click on the Image and Panel two will show the selected colour.