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
 run Colorize after picking a color from a colordialog.
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

More-Majorum

France
17 Posts

Posted - Jul 30 2022 :  06:03:17  Show Profile  Reply
Hello,

I would like to run "ImageEnView.Proc.Colorize" after picking a color from a colordialog.
The problem is that I don't know how to convert the color chosen in the colordialog.


The code below obviously does not work :)

procedure TForm1.Button1Click(Sender: TObject);
Var
  H, S, L : double;
begin
  if colordialog1.execute then
  begin
    ColorToHSL(colordialog1.Color, H, S, L);
    ImageEnView.Proc.Colorize(H, S, L);
  end;
end;


Thank you in advance for your help.

xequte

38608 Posts

Posted - Jul 31 2022 :  00:18:41  Show Profile  Reply
Hi

In what way doesn't it work?

(ColorToHSL() is in the hyieutils unit).

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

More-Majorum

France
17 Posts

Posted - Jul 31 2022 :  01:07:53  Show Profile  Reply
Hello,

An example with red from the colordialog:
When converted with ColorToHSL :

procedure TForm1.Button1Click(Sender: TObject);
Var
  H, S, L : double;
begin
  if colordialog1.execute then
  begin
    ColorToHSL(colordialog1.Color, H, S, L);
    ImageEnView1.Proc.Colorize(round(H), round(S), L);
    Caption := 'H :  ' + floattostr(H) + '    S :  ' + floattostr(S)  + '    L :  ' + floattostr(L);
  end;
end;




When converted with ColorToHSL, I get the values H=0, S=1, L=0.5.
ImageEnView1.Proc.Colorize(0, 1, 0.5);

I get a gray image :)
Go to Top of Page

More-Majorum

France
17 Posts

Posted - Jul 31 2022 :  01:37:00  Show Profile  Reply
Overall, Imageen online help is excellent (with lots of examples), which saves me from asking noob questions on the forum.

Unfortunately, regarding Proc.Colorize and ColorToHSL there is no example on how to get the values to pass in Colorize.
Go to Top of Page

xequte

38608 Posts

Posted - Jul 31 2022 :  02:18:08  Show Profile  Reply
Hi

What is it that you are looking for Colorize to do?

Colorize is the same as setting the HSV value for each pixel with your specified hue and saturation, and the value based on the gray-scale conversion of each pixel multiplied by your luminosity value.
[code]

// Load test image
ImageEnView1.IO.LoadFromFile( 'D:\TestImage.jpg' );



// Colorize the image with a sepia look
ImageEnView1.Proc.Colorize( 40, 50, 1.1 );



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

38608 Posts

Posted - Jul 31 2022 :  02:33:56  Show Profile  Reply
Is this what you are looking for?

  // Colorize the image based on the user's selection of a color
  if IEPromptForColor( cl ) then
  begin
    ColorToHSV( cl, h, s, v );
    ImageEnView1.Proc.Colorize( h, s, 1.0 );
  end;



// User selected Red...




Nigel
Xequte Software
www.imageen.com
Go to Top of Page

More-Majorum

France
17 Posts

Posted - Jul 31 2022 :  02:45:24  Show Profile  Reply
I have several frames (which I provide in white) in my application.



I would like the user to be able to change the color of these frames through a colordialog.

attach/More-Majorum/202273124515_16-9-H.png
Go to Top of Page

xequte

38608 Posts

Posted - Jul 31 2022 :  02:49:21  Show Profile  Reply
The above method should work:




Nigel
Xequte Software
www.imageen.com
Go to Top of Page

More-Majorum

France
17 Posts

Posted - Jul 31 2022 :  02:58:34  Show Profile  Reply
Thank you very much for all these examples.
I will try as soon as possible.
Go to Top of Page

More-Majorum

France
17 Posts

Posted - Jul 31 2022 :  03:16:49  Show Profile  Reply
It works !
Thanks again for the quick help ;
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: