编程环境: 系统:win10; IDE:vs2010(旧项目一直使用,所以我就不升级了); 开源渲染库:SDL2.0;
现阶段实现的功能是把win32中HDC数据转为SDL纹理(texture)渲染到显示屏上,通过操作SDL纹理,实现图片背景和时钟的叠加。 需要编写一个借口,DCToTexture,实现的方式是怎么样的,还不知道。
仅供参考:
HWND hWnd;
HDC hdc;
CRect rect;
GetClientRect(hWnd,&rect);
int W = rect.Width();
int H = rect.Height();
hdc=pWnd->GetDC()->GetSafeHdc()
HBITMAP bmp=CreateCompatibleBitmap(hdc,W,H);
CString filePath;
filePath.Format(_T("D:\\test.bmp"));
Bitmap bitmap(bmp,NULL);
CLSID bmpClsid;
GetEncoderClsid(L"image/bmp", &bmpClsid);
#ifdef UNICODE
bitmap.Save(filePath, &bmpClsid, NULL);
#else
wchar_t wfilePath[256];
swprintf(wfilePath,L"%S",filePath.GetBuffer());
bitmap.Save(wfilePath, &bmpClsid, NULL);
#endif