ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 IEColorPalette walk through colours and test for match
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

andyhill

Australia
133 Posts

Posted - Feb 23 2023 :  15:54:54  Show Profile  Reply
I have a ColorPalette with 500 assigned colors.

I want to iterate the colors and test for a match, if found I want to set SelectedIndex accordingly.

I tried rows and cols but same problem.

for i:= 0 to ColorPalette1.ColorCount-1 do begin
  if ColorPalette1.Color[i] = MyColor then begin
    ColorPalette1.SelectedIndex:= i;
    Break;
  end;
end;


Andy

xequte

38255 Posts

Posted - Feb 23 2023 :  21:11:39  Show Profile  Reply
Hi Andy

You can just use:

ColorPalette1.SelectedColor := MyColor;

Of course if the color is not in your list of 500 colors nothing will be selected.

In the coming update you can use:

ColorPalette1.SelectNearestColor( clBlue );

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: