Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pixel Colour Again

Status
Not open for further replies.

gareth1

Programmer
Mar 16, 2000
9
GB
Thanks for the replies... here is a bit more detail.<br><br>The system is operating in W95, at 800x600 and in 256 colours.&nbsp;&nbsp;The target is a Pentium 2 system, with an AGP graphics card.&nbsp;&nbsp;What I require is a routine to return the colour of any pixel on the screen that I specify.<br><br>If you need any more info, let me know.<br><br>Gareth
 
Have you tried the Windows API function GetPixel??<br>This isn't really an assembler question mainly because most asm programmers don't do windows.(Accessing the Video buffer directly like you do in DOS in a NO-NO in Windoze)<br>So try the API fuction GetPixel. If it isn't fast enough for you, you'll have to try DirectX calls. (Out of MY league) Below is a site that has info on accessing Win API calls from VB:<br><A HREF=" TARGET="_new"> GetPixel function retrieves the red, green, blue (RGB) color value of the pixel at the specified coordinates. <br><br>COLORREF GetPixel(<br><br>&nbsp;&nbsp;&nbsp;&nbsp;HDC hdc, // handle of device context&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;int XPos, // x-coordinate of pixel <br>&nbsp;&nbsp;&nbsp;&nbsp;int nYPos // y-coordinate of pixel <br>&nbsp;&nbsp;&nbsp;); <br>Parameters<br><br>hdc<br><br>Identifies the device context. <br><br>nXPos<br><br>Specifies the logical x-coordinate of the pixel to be examined. <br><br>nYPos<br><br>Specifies the logical y-coordinate of the pixel to be examined. <br><br> <p> <br><a href=mailto:Kim_Christensen@telus.net>Kim_Christensen@telus.net</a><br><a href= Page</a><br>
 
I don't think that will help Gareth1, zBuilder. The GetPixel function only works on a clip region. Correct me when I'm wrong, please... can it be coerced to get the RGB values from the entire screen? <p> <br><a href=mailto:InterruptX@excite.com>InterruptX@excite.com</a><br><a href= Contingency Implementation</a><br>Send me suggestions or comments on my current software project.
 
Alt255:<br><br>Yes... You can get the whole screen (Minus taskbar I think) by doing the following:<br><br>zhdc = GetDC(NULL); // Get device context of the Whole screen<br>YourPixel = GetPixel(zhdc, x, y);&nbsp;&nbsp;// Get any pixel on the screen pointed by x & y<br>ReleaseDC(NULL, zhdc);<br> <p> <br><a href=mailto:Kim_Christensen@telus.net>Kim_Christensen@telus.net</a><br><a href= Page</a><br>
 
Thanks!&nbsp;&nbsp;GetPixel does the job perfectly, I forgot to check the Taskbar part, but I don't need that anyway.&nbsp;&nbsp;For assembly programmers you know more about VB than the VB forums.<br><br>Gareth
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top