Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Select pixels from the screen

29 views
Skip to first unread message

Ron Francis

unread,
Apr 26, 2012, 10:18:09 AM4/26/12
to
VC 2005

I'm wanting to be able to select an area anywhere on the screen and sample the pixels from that
area, and not sure how to go about doing it.
Specifically, I want to create an eyedropper that will draw a rectangle anywhere on the screen so I
can average the pixels within the rectangle.
Similar to the 'Snipping Tool' that comes with Vista.

I've done this a couple of different ways within a window, but don't know how to go about doing it
on the screen.
Can anyone point me in the right direction?

Regards
Ron Francis
www.RonaldFrancis.com


Deanna Earley

unread,
Apr 27, 2012, 4:14:33 AM4/27/12
to
This code I posted to StackOverflow allows you to take a screenshot.
http://stackoverflow.com/a/10123008/588306
You can draw this to your own window that you can then add the rubber
band/cropping on.

--
Deanna Earley (dee.e...@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk/icatcher/

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

Ron Francis

unread,
Apr 27, 2012, 9:19:30 AM4/27/12
to
"Deanna Earley" <dee.e...@icode.co.uk> wrote in message news:jndkh7$5gd$1...@speranza.aioe.org...
Thanks Deanna, I appreciate your response.
I should have mentioned that I'm using C++, but I guess it isn't too difficult to translate from VB.
However, I only just got that far with GDI+, only having to use BitBlt from GDI.
That is, I captured a section of the screen and pasted it into my window just before you posted. :)
(By the way, I want an image of the screen rather than the desktop. GetDC(NULL) will do that.)

But I don't want to do the rubberbanding in my own window unless I can create a borderless window
the same size as the screen and BitBlt the screen image to it, making it transparent to the user.
I'm not sure I want to go that way unless I have to.
I want to capture parts of the screen so that I can BitBlt them back again while drawing the
rubberband, probably 4 bitmaps, one for each line.

My problem now is that I don't want to interact with anything outside my window while I'm drawing
it.
I don't want the cursor to change when it leaves my window, and I don't want buttons on other
windows to react to my mouse when passing over them etc.
For example, SetCapture( ) didn't work because it only captures mouse input for events within my
window.
I'm thinking that SetWindowsHook( ) may do it for me. At first glance, it seems that I don't have to
write a DLL to handle system mouse messages.

If anyone thinks I'm going in the wrong direction, please let me know.

Regards
Ron Francis
www.RonaldFrancis.com


Friedel Jantzen

unread,
May 7, 2012, 1:51:00 AM5/7/12
to
Hi,
> ...
> My problem now is that I don't want to interact with anything outside my window while I'm drawing
> it.
> I don't want the cursor to change when it leaves my window, and I don't want buttons on other
> windows to react to my mouse when passing over them etc.
> For example, SetCapture( ) didn't work because it only captures mouse input for events within my
> window.

You could cover the screen completely with a frameless popup which displays
a bitmap of the screen.

Regards,
Friedel

Christian ASTOR

unread,
May 7, 2012, 8:13:07 AM5/7/12
to
Ron Francis a écrit :
> VC 2005
>
> I'm wanting to be able to select an area anywhere on the screen and
> sample the pixels from that area, and not sure how to go about doing it.

The standard way is to create a transparent full screen window
(the 'Snipping Tool' does this...)

Deanna Earley

unread,
May 8, 2012, 6:59:37 AM5/8/12
to
The snipping window isn't transparent, it won't show any changes
underneath it. A test here shows a snapshot at the moment it was started
(or New was pressed).

--
Deanna Earley (dee.e...@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk/icatcher/

Fred

unread,
May 8, 2012, 10:01:51 AM5/8/12
to
"Deanna Earley" <dee.e...@icode.co.uk> a écrit dans le message de news:
joauan$39i$1...@speranza.aioe.org...
> On 07/05/2012 13:13, Christian ASTOR wrote:
>> Ron Francis a écrit :
>>> VC 2005
>>>
>>> I'm wanting to be able to select an area anywhere on the screen and
>>> sample the pixels from that area, and not sure how to go about doing it.
>>
>> The standard way is to create a transparent full screen window
>> (the 'Snipping Tool' does this...)
>
> The snipping window isn't transparent, it won't show any changes
> underneath it. A test here shows a snapshot at the moment it was started
> (or New was pressed).

No, it uses a transparent window to select an area..


Deanna Earley

unread,
May 8, 2012, 11:07:09 AM5/8/12
to
Ok, mine aren't transparent on any of the 6 Win7 machines I have
immediate access to.
The screen behind the snipping tool freezes in media player, task
manager, Direct3D surfaces, etc) while I'm selecting an area.

I guess yours is different.

Friedel Jantzen

unread,
May 9, 2012, 5:17:45 AM5/9/12
to
> ...
> Ok, mine aren't transparent on any of the 6 Win7 machines I have
> immediate access to.
> The screen behind the snipping tool freezes in media player, task
> manager, Direct3D surfaces, etc) while I'm selecting an area.

Same behavior with Vista, too.
And it looks "bleached" to show the user that s/he cannot use the desktop
as usual.
Perhaps this is a popup displaying a modified bitmap of the screen.

Regards,
Friedel

Ron Francis

unread,
May 15, 2012, 9:43:05 PM5/15/12
to
"Ron Francis" <ronfra...@adam.com.au> wrote in message news:jnblhh$hhn$1...@dont-email.me...
I haven't checked in here for a while so missed the responses.
Thank you.

I solved the problem by creating a full screen popup and bit blitting the screen to it.
No transparent window.
On my PC, Vista 32bit, the screen also freezes when the Snipping Tool is active, so I presumed that
used the same technique.

Thanks again.

Regards
Ron Francis
www.RonaldFrancis.com


0 new messages