Solved

GetPixel() returning wrong value (Windows API)

Posted on 2004-09-22
1
964 Views
Last Modified: 2010-05-18
I'm using GetDC() to get a device context for the entire screen followed by GetPixel() to check the color of a pixel within a DirectX application.  Most frequently the color returned is the correct, expected value.  However, occasionally when no colors have changed GetPixel() performed on the same x and y will return an incorrect, completely unrelated value and I'm having a hard time pinpointing why.  The only thing I can come up with is that GetPixel() is returning values from the back buffer occasionally while it's still being rendered in memory, but I'm not sure on that at all.

So, any idea what's causing this behavior, and if so, how would I go about preventing it?
0
Comment
Question by:Rezer
1 Comment
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 250 total points
ID: 12127743
It is not recommended to use GetPixel with DirectX or OpenGL, them not synchornize graphic data with the DC.
You must get a DibSection pointer an access graphics buffer directly. Since it is a hard job, I recommend to use some DirectX library like this:
http://www.chilkatsoft.com/ChilkatDx/ChilkatDx.asp
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
seriesUp challenge 7 107
Controlling which port to download from 4 59
java constructor error 8 87
Not needed 13 55
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to implement Singleton Design Pattern in Java.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now