Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

GetPixel() returning wrong value (Windows API)

Posted on 2004-09-22
1
Medium Priority
?
994 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 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

650 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