SelectObject(dc, hBMP) 的作用是什么?
我想我确实明白如果我在“设备连接”中选择“一个对象”,并且该对象是画笔、字体、笔< /em>:这些对象的特征因此用于在设备上下文上进行绘图。
但是,我不明白在设备上下文中选择位图后会发生什么,更不用说为什么有必要这样做了。
我有一个程序,有些人做了
HDC dc = ::GetDC(hWnd);
ffBitmap = ::CreateCompatibleBitmap(dc, windowWidth, windowHeight);
ffMemoryDc = ::CreateCompatibleDC(dc);
hOldBitmap = (HBITMAP) ::SelectObject(ffMemoryDc, ffBitmap);
,然后绘制到 ffMemoryDc 然后 *BitBlt*s 将 ffMemoyDc 放入 窗口的真实设备上下文。
BitBlt ( dc,
0, 0, windowWidth, windowHeight,
ffMemoryDc,
0, 0,
SRCCOPY
);
变量ffBitmap在整个程序中没有被其他地方引用,但是,如果我不选择SelectObject(ffBitmap),则不会绘制任何内容,因此这是必要的。
如果有人能阐明这里发生的事情,我将不胜感激。
I guess I do understand what happens if I select "an object" into a "device contect", and if this object is a brush, font, pen: The charactersicts of these objects are hence forth used for the drawing onto the device context.
However, I don't understand what happens after I select a bitmap into the device context, much less, why it is necessary to do so.
I have a program that somehwere does
HDC dc = ::GetDC(hWnd);
ffBitmap = ::CreateCompatibleBitmap(dc, windowWidth, windowHeight);
ffMemoryDc = ::CreateCompatibleDC(dc);
hOldBitmap = (HBITMAP) ::SelectObject(ffMemoryDc, ffBitmap);
and later draws unto the ffMemoryDc and then *BitBlt*s the ffMemoyDc into the
real device context of a window.
BitBlt ( dc,
0, 0, windowWidth, windowHeight,
ffMemoryDc,
0, 0,
SRCCOPY
);
The variable ffBitmap is referenced nowhere else in the entire program, yet, if I don't SelectObject(ffBitmap), nothing is drawn, so it is necessary.
I'd appreciate if someone could shed some light what happens here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是它的工作原理。您在 DC 中选择的位图是“绘制”的位图。引用 MSDN:
That's how it work. The bitmap you select in the DC is the bitmap that is "painted on". Quoting MSDN: