ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder
ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Eyedropper component?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Format  BoldItalicizedUnderline Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailBrowse for an image to attach to your post Browse for a zip to attach to your post Insert CodeInsert QuoteInsert List


Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

Check here to subscribe to this topic.

T O P I C    R E V I E W
PeterPanino Posted - Mar 30 2021 : 18:17:07
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?
11   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Apr 03 2021 : 18:31:51
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):

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.

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.

Xequte Software
PeterPanino Posted - Apr 03 2021 : 18:19:14
So, is there a method to GET the transparent colors from the image? (Proc.GetTransparentColors)
PeterPanino Posted - Apr 03 2021 : 10:06:59
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.
xequte Posted - Apr 02 2021 : 14:44:32

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?

Xequte Software
PeterPanino Posted - Apr 02 2021 : 14:13:43
Hi Nigel,

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

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

FStopGettingPixelColorFromScreen := False;
  lblHoverColorProps.Color := GetPixelColourFromScreenAsColor(P);
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?
PeterPanino Posted - Apr 02 2021 : 03:49:53
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)
xequte Posted - Mar 31 2021 : 16:56:34

You should be able to reset it as follows:

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

Xequte Software
PeterPanino Posted - Mar 31 2021 : 11:23:47
Can I reset a specific color from transparent to opaque with this code?

ImageEnView1.Proc.SetTransparentColors(TColor2TRGB(clBlue), 0, -255);
PeterPanino Posted - Mar 31 2021 : 10:45:31
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?
xequte Posted - Mar 30 2021 : 23:25:20
Sorry, I just realized you said the whole screen. That is much harder to do and outside of the functionality of ImageEn.

Xequte Software
xequte Posted - Mar 30 2021 : 23:23:34
Hi Peter

For a Eye dropper use the miColorPicker interaction:

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

Regarding the zoomed view, see the Magnify2 demo:


Which you would position and size using the ieiColorPickerHover event.

Xequte Software