【发布时间】:2012-01-31 15:40:58
【问题描述】:
这就是我目前正在做的事情:
- 通过
GetWindowDC获取窗口DC - 用
CreateCompatibleDC创建一个兼容的DC - 在我的兼容 DC 上调用
GetPixel
不幸的是,我所有的 GetPixel 调用都返回 CLR_INVALID。这是我的代码。
bool Gameboard::Refresh()
{
bool ret = false;
HDC context, localContext;
context = GetWindowDC(m_window);
if (context != NULL)
{
localContext = CreateCompatibleDC(context);
if (localContext != NULL)
{
if (BitBlt(localContext, 0, 0, GameboardInfo::BoardWidth, GameboardInfo::BoardHeight,
context, GameboardInfo::TopLeft.x, GameboardInfo::TopLeft.y, SRCCOPY))
{
ret = true;
// several calls to GetPixel which all return CLR_INVALID
}
DeleteDC(localContext);
}
ReleaseDC(m_window, context);
}
return ret;
}
有什么想法吗?
【问题讨论】:
标签: c++ winapi gdi bitblt getpixel