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
 Eyedropper component?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

859 Posts

Posted - Mar 30 2021 :  18:17:07  Show Profile  Reply
Does IE have an EYEDROPPER (PIPETTE) component which can pick up a color from any clicked pixel on the whole screen, on any monitor, with the additional feature of showing a zoomed preview of the region around the mouse pointer, with the additional feature of not only picking up the single color from a single-pixel but also the average color from the region around the mouse pointer?

xequte

38176 Posts

Posted - Mar 30 2021 :  23:23:34  Show Profile  Reply
Hi Peter

For a Eye dropper use the miColorPicker interaction:

https://www.imageen.com/help/TImageEnView.MouseInteractGeneral.html

And monitor the ieiColorPickerClick events of OnUserInteraction to handle the clicking (and optionally the hovering):

https://www.imageen.com/help/TImageEnView.OnUserInteraction.html

Regarding the zoomed view, see the Magnify2 demo:

\Demos\Display\Magnify2\Magnify2.dpr

http://www.imageen.com/files/demos/run/Display/Magnify2/Magnify2.exe

Which you would position and size using the ieiColorPickerHover event.

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

xequte

38176 Posts

Posted - Mar 30 2021 :  23:25:20  Show Profile  Reply
Sorry, I just realized you said the whole screen. That is much harder to do and outside of the functionality of ImageEn.

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

PeterPanino

859 Posts

Posted - Mar 31 2021 :  10:45:31  Show Profile  Reply
Thanks, Nigel.

I have tried ImageEnView1.Proc.GetTransparentColors, but that method does not exist.

So how can I GET the multiple colors that have been set to transparent by ImageEnView1.Proc.SetTransparentColors?

And for example: I have set the colors clGreen, clBlue, and clYellow to transparent by using Proc.SetTransparentColors. How can I set clBlue to be no more transparent afterward?
Go to Top of Page

PeterPanino

859 Posts

Posted - Mar 31 2021 :  11:23:47  Show Profile  Reply
Can I reset a specific color from transparent to opaque with this code?

ImageEnView1.Proc.SetTransparentColors(TColor2TRGB(clBlue), 0, -255);
Go to Top of Page

xequte

38176 Posts

Posted - Mar 31 2021 :  16:56:34  Show Profile  Reply
Hi

You should be able to reset it as follows:

ImageEnView1.Proc.SetTransparentColors(TColor2TRGB(clBlue), 0, 255);

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

PeterPanino

859 Posts

Posted - Apr 02 2021 :  03:49:53  Show Profile  Reply
As the Make Transparent Demo shows, loading the same image from file again, cancels the transparency in the previous image. So, the color transparency is an inherent property of the image, not of the ImageEnView control.

So, is there a method to GET the transparent colors from the image? (Proc.GetTransparentColors)
Go to Top of Page

PeterPanino

859 Posts

Posted - Apr 02 2021 :  14:13:43  Show Profile  Reply
Hi Nigel,

I wrote this code to get the color from the pixel at screen-mouseposition:

function GetPixelColourFromScreenAsColor(const PixelCoords: TPoint): TColor;
var
  dc: HDC;
begin
  dc := GetDC(0);
  Result := GetPixel(dc, PixelCoords.X, PixelCoords.Y);
end;

FStopGettingPixelColorFromScreen := False;
repeat
  GetCursorPos(P);
  lblHoverColorProps.Color := GetPixelColourFromScreenAsColor(P);
  Application.ProcessMessages;
until FStopGettingPixelColorFromScreen;
CodeSite.Send('TformMain.btnColorDialogClick: FINISHED');


The repeat-loop exits when I press the ESC key in the OnKeyDown event-handler. But for that, my application must have the focus.

What do you say about this code? Is it "evil" using Application.ProcessMessages inside the repeat-loop?
Go to Top of Page

xequte

38176 Posts

Posted - Apr 02 2021 :  14:44:32  Show Profile  Reply
Hi

That looks like it would use a lot of CPU. Can you not put the check into a timer (e.g. every 1/4 second) or implement a delay?

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

PeterPanino

859 Posts

Posted - Apr 03 2021 :  10:06:59  Show Profile  Reply
Hi Nigel,

I have tested it: The CPU activity is NOT being increased in the loop.

However, I have now implemented another solution that works very fine.
Go to Top of Page

PeterPanino

859 Posts

Posted - Apr 03 2021 :  18:19:14  Show Profile  Reply
So, is there a method to GET the transparent colors from the image? (Proc.GetTransparentColors)
Go to Top of Page

xequte

38176 Posts

Posted - Apr 03 2021 :  18:31:51  Show Profile  Reply
Hi Peter

> So how can I GET the multiple colors that have been set to transparent
> by ImageEnView1.Proc.SetTransparentColors?

SetTransparentColors just changes the alpha channel of an image TIEBitmap.AlphaChannel, it does not change the image colors (the TIEBitmap).

The AlphaChannel is itself just a TIEBitmap of ieg8 format (i.e. grayscale with pixel values from 0 to 255):

https://www.imageen.com/help/TIEBitmap.AlphaChannel.html

So you can just iterate through the scanlines of the AlphaChannel and where the pixel value is <255 (i.e. partially to fully transparent) look up the matching pixel in the TIEBitmap.Scanline to get the color.

https://www.imageen.com/help/TIEBitmap.ScanLine.html


Note: A simpler way, e.g. to test the concept, is to use Pixels instead of Scanlines, i.e.

Alpha: ImageEnView1.IEBitmap.AlphaChannel.Pixels_ie8[x, y];
Color: ImageEnView1.IEBitmap.Pixels[x, y];

But that will much slower than scanlines, so you are better to look at the Scanline examples.

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