GetDIBits中的HDC是什么? [英] What is the HDC for in GetDIBits?

查看:95
本文介绍了GetDIBits中的HDC是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用GetDIBits将位图数据从与屏幕兼容的设备上下文中转换为某种格式的DIB.我给人的印象是,当源位图为每像素8位或更少时,DC仅对于合成颜色表是必需的.由于我的源位图是完整的32位彩色图像,并且这是一个一次性程序,并且我没有方便的屏幕DC,因此我将HDC参数设置为NULL.这没用.我抓住屏幕DC并将其传递进去后,它确实开始工作.

I was using GetDIBits to get bitmap data from a screen compatible device context into a DIB of a certain format. I was under the impression that the DC was necessary only for synthesizing a color table when the source bitmap is 8 bits-per-pixel or less. Since my source bitmap was a full 32-bit color image and this was a one-off program and I didn't have the screen DC handy, I set the HDC parameter to NULL. This didn't work. Once I grabbed the screen DC and passed it in, it did start working.

这让我想知道为什么GetDIBits需要设备上下文.它是做什么用的?

That left me wondering why GetDIBits requires the device context. What is it used for?

推荐答案

在:

int SetDIBits(
  __in  HDC hdc,
  __in  HBITMAP hbmp,
  __in  UINT uStartScan,
  __in  UINT cScanLines,
  __in  const VOID *lpvBits,
  __in  const BITMAPINFO *lpbmi,
  __in  UINT fuColorUse
);

第二个参数hbmp是与设备有关的位图,将使用与设备无关的位图中的颜色信息对其进行更改. hdc是该(依赖于设备的)位图所依赖的设备上下文的句柄.进行呼叫时,Windows使用此设备上下文中的信息来决定如何执行转换.

The second argument hbmp is the device dependent bitmap that will be altered using the color information from the device independent bitmap. The hdc is a handle to the device context on which this (device dependent) bitmap depends. When the call is made, Windows uses information from this device context to decide how to perform the transformation.

这篇关于GetDIBits中的HDC是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆