"reading" a pixel on the monitor screen

G

grogerteal

Hello,

I am pretty new to programming and would like someone to help me get
started on the program that I need to make.

I hope it is not hard to do, but what I would like is a simple app that
has a label which returns the color of a pixel that is in position x,y on
the screen (i.e. the desktop @ 1024 x 768 pixels), where x and y are of
course variable.

if someone could post the code that i should put in my program i would be
very grateful
 
J

John Harrison

grogerteal said:
Hello,

I am pretty new to programming and would like someone to help me get
started on the program that I need to make.

I hope it is not hard to do, but what I would like is a simple app that
has a label which returns the color of a pixel that is in position x,y on
the screen (i.e. the desktop @ 1024 x 768 pixels), where x and y are of
course variable.

if someone could post the code that i should put in my program i would be
very grateful

C++ has no facilities for reading pixels. You have to use your operating
system or a third party library to do that. So you should ask this question
again on a group dedicated to your particular operating system. For instance
if you are programming using Windows you could ask on
This group's welcome message will
give you more idea about what we discuss on this group,
http://www.slack.net/~shiva/welcome.txt.

john
 
J

JKop

grogerteal posted:
Hello,

I am pretty new to programming and would like someone to help me get
started on the program that I need to make.

I hope it is not hard to do, but what I would like is a simple app that
has a label which returns the color of a pixel that is in position x,y on
the screen (i.e. the desktop @ 1024 x 768 pixels), where x and y are of
course variable.

if someone could post the code that i should put in my program i would be
very grateful


For Windows...


go to msdn.microsoft.com and search for "GetPixel" and/or "GetPixelV".


-JKop
 
M

Mabden

JKop said:
grogerteal posted:



For Windows...


go to msdn.microsoft.com and search for "GetPixel" and/or "GetPixelV".

That answer seems somewhat helpful to the poster. This behaviour is
off-topic in this newsgroup.
 
T

Thomas Matthews

grogerteal said:
Hello,

I am pretty new to programming and would like someone to help me get
started on the program that I need to make.

I hope it is not hard to do, but what I would like is a simple app that
has a label which returns the color of a pixel that is in position x,y on
the screen (i.e. the desktop @ 1024 x 768 pixels), where x and y are of
course variable.
Here are some issues as to why the C++ language does not include
support for graphics.

1. Definition of a pixel.
Yes, we know that a pixel is a picture element. But that seems to
be the best we can do.
Is the pixel color, black/white or grayscale?
How is the pixel represented?
One bit?
8 bits?
24 bits?
How many bits per color?
What is the order of the color?
What is the color space? (RGB? CMYK? HSB?)
What is the physical size of the pixel?
Is the pixel round or rectangular?

2. A Screen is commonly a collection of rows of pixels.
Are the rows interlaced in memory or contiguous?
How many pixels in the row are visible?
How many pixels per unit distance? (dots per inch?)

3. Accessing the pixels.
Are the pixels memory mapped or device (I/O) mapped?
If memory mapped, are they in the user's memory space?
If device mapped, how are they accessed?
Does a One turn on the pixel or turn it off?
Does the pixel have other attributes, such as intensity?, Blinking?
Can one read a pixel or is it a Write-Only Memory?

All of the above issues are different on each platform, including
those platforms that don't have screens (such as a dishwasher,
and a vending machine). Some platforms even have screens that
use vectors instead of pixels.

This is why many of the people in this newsgroup direct
questions about graphics to the platform specific newsgroups.

Read the FAQs and welcome.txt below.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top