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
 IEvolution Get Pixel Color
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

cyberfly

USA
7 Posts

Posted - Aug 24 2022 :  20:51:44  Show Profile  Reply
I am trying to get the RGB values of a pixel. I know I have to use GetPixel to get it but it is not clear how it is used. Is there an example using GetPixel to get an RGB value?

I have the following code but I don't know what the 3rd parameter "color" is supposed to be.

private void ieViewer1_MouseMove(object sender, MouseEventArgs e)
{
int PixelXpos = ieViewer1.XClientToBitmap(e.X);
int PixelYpos = ieViewer1.YClientToBitmap(e.Y);
Color ColorOfPixel;
ColorOfPixel = ieViewer1.Image.GetPixel(PixelXpos, PixelYpos, Color);
}


Kevin Cary-Grimm

xequte

38611 Posts

Posted - Aug 24 2022 :  21:49:54  Show Profile  Reply
Hi Kevin

You should use the IERGBA overload:

https://www.imageen.com/ievolutionhelp/html/1f36614a-2892-e825-2837-2ef4a3ad078b.htm

Which will make it much simpler.


int PixelXpos = ieViewer1.XClientToBitmap(e.X);
int PixelYpos = ieViewer1.YClientToBitmap(e.Y);
IERGBA PixRGBA;
ieViewer1.Image.GetPixel(PixelXpos, PixelYpos, PixRGBA);

...Do something with PixRGBA.r... PixRGBA.g... PixRGBA.g...


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

cyberfly

USA
7 Posts

Posted - Aug 24 2022 :  21:54:26  Show Profile  Reply
Thank you so much for the help.

Kevin Cary-Grimm
Go to Top of Page

cyberfly

USA
7 Posts

Posted - Aug 24 2022 :  22:19:45  Show Profile  Reply
I am getting an invalid parameter error in C# for "PixRGBA".

IERGBA PixRGBA;
ieViewer1.Image.GetPixel(PixelXpos, PixelYpos, PixRGBA);

Kevin Cary-Grimm
Go to Top of Page

cyberfly

USA
7 Posts

Posted - Aug 26 2022 :  18:35:29  Show Profile  Reply
I've got it now. This is actually what works. The PixRGB variable must be initialized and passed by reference.

IERGBA PixRGBA;
PixRGBA.r = 0;
PixRGBA.b = 0;
PixRGBA.g = 0;
PixRGBA.a = 0;
ieViewer1.Image.GetPixel(PixelXpos, PixelYpos, ref PixRGBA);

Kevin Cary-Grimm
Go to Top of Page

xequte

38611 Posts

Posted - Aug 28 2022 :  00:20:50  Show Profile  Reply
Nice one, Kevin

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