Solved

GetPixel() returning wrong value (Windows API)

Posted on 2004-09-22
1
978 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
no14 challenge 14 76
pre4 challenge 19 116
seriesUp challenge 7 200
Visual studio community prompts to sign in and how to use without signing in\is there a different way to set up. 7 293
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

734 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