如何从HBITMAP中获取字节数组
how can i get byte-array from HBITMAP
我的环境:
win32
visual c++
directx
我需要将另一个应用程序的脸映射到我的应用程序的纹理
例如,我的Internet Explorer屏幕显示在DirectX Cube的纹理上,并且它是实时更新的
我的方法是下一个:
//in DirectX Rendering Loop...
HWND hSrc = FindWindow(NULL, _T("application's classname"));
HDC hdc = GetDC(hSrc);
RECT targetRect;
GetClientRect(hSrc, &targetRect);
HBITMAP hBitmap = CreateCompatibleBitmap(hdc,targetRect.right,targetRect.bottom);
//now, target application's window is 'hBitmap'
LPDIRECT3DTEXTURE9 ptxt = NULL; //my destination texture
if( SUCCEEDED(D3DXCreateTexture(gpDevice,targetRect.right, targetRect.bottom,
0, 0, D3DFMT_A8B8G8R8, D3DPOOL_MANAGED,&ptxt)))
{
D3DLOCKED_RECT lr;
HRESULT hr = ptxt->LockRect(0,&lr,NULL,D3DLOCK_DISCARD);
//TODO : memcpy(lr.pBits , 'Start pointer of Bit-Array' , targetRect.right*targetRect.bottom*4); //mydesktop's color is 32bit truecolor (= *4)
ptxt->UnlockRect(0);
}
问题:
如何从HBITMAP格式中获取字节数组
win32api中有这样的方法吗
GetByteArray(HBITMAP,无效**)
或者可以使用其他方法的组成来完成此操作?
CreateCompatibleBitmap创建一个DDB,您无法访问这些位。请尝试使用CreateDIBSection。
还要注意,在编写时,您还没有在位图中实际绘制任何内容。
相关文章:
- 如何使用Crypto++并为RSA返回可打印的字节/字符数组
- 如何将字节数组元素替换为修改的十六进制 ASCII 符号?
- 基于字节数组生成静态范围整数值
- 将字节数组转换为带有字节序问题的指针
- 找到一种有效的方法,在 2 个巨大的缓冲区上执行 MAX,每字节字节
- 使用 stbi_write_png,如何将 0 和 1 的矩形字节数组转换为单色 png 文件?
- 字节数组初始化会导致 DirectX 崩溃
- 使用 swig 追加到字节数组
- C++ 替换字节数组中项的顺序
- QDataStream 读取和写入的字节数比 QFile::length() 报告要多
- 如何从保存在 Java 中C++的字节数组中读取数字?
- 如何通过libpq c api插入字节的数组
- i2c中的字节指针数组
- 以 C++ 为单位递增 16 字节字符数组
- new[] 一个包含构造函数的字节对象数组没有错,对吧?
- 创建未知长度的字节/字符数组
- 我如何将bitset转换为字节/uint8数组
- C++ <--> C# 修改字节编组数组
- 将m个字节的数组拆分为n个字节的块
- c++到c#:有3个元素的字节指针数组等于什么?