liquanuo87 2021-06-30 17:21 采纳率: 50%
浏览 6

最近项目需要在图片上叠加模拟时钟

编程环境: 系统:win10; IDE:vs2010(旧项目一直使用,所以我就不升级了); 开源渲染库:SDL2.0;

现阶段实现的功能是把win32中HDC数据转为SDL纹理(texture)渲染到显示屏上,通过操作SDL纹理,实现图片背景和时钟的叠加。 需要编写一个借口,DCToTexture,实现的方式是怎么样的,还不知道。

  • 写回答

1条回答 默认 最新

  • 赵4老师 2023-02-23 12:55
    关注

    仅供参考:

    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
    
    
    
    评论

报告相同问题?