如何使用win32 c ++在窗口客户区绘制图像数据?

时间:2017-11-23 14:30:17

标签: winapi visual-c++

我正在使用Visual Studio 12(Windows 10操作系统)并尝试使用StretchDIBits()显示图像缓冲区,但它失败并返回0。

我没有该缓冲区的任何头文件。我不知道如何仅使用缓冲区数据绘制客户区。如果有人知道,请分享您的想法。

我在下面添加了示例代码段:

void DShow::set framebuffer(HDC hDC){
    BITMAPINFO m_bi;
    DWORD result = 0;

    m_bi.bmiHeader.biSize   =     sizeof(BITMAPINFOHEADER);
    m_bi.bmiHeader.biWidth  =     m_curResolutionWidth;
    m_bi.bmiHeader.biHeight =     m_curResolutionHeight;
    m_bi.bmiHeader.biPlanes =     (WORD)1;
    m_bi.bmiHeader.biBitCount =    (WORD)24;
    m_bi.bmiHeader.biCompression = 0;
    m_bi.bmiHeader.biSizeImage =  (m_curResolutionWidth*m_curResolutionHeight)*(24/8);
    m_bi.bmiHeader.biXPelsPerMeter = 0;
    m_bi.bmiHeader.biYPelsPerMeter = 0;
    m_bi.bmiHeader.biClrUsed = 0;
    m_bi.bmiHeader.biClrImportant = 0;

    result = StretchDIBits(hDC,
                         m_TaniaDestRect.left, m_TaniaDestRect.top,
                         m_TaniaDestRect.right - m_TaniaDestRect.left, m_TaniaDestRect.bottom - m_TaniaDestRect.top,
                         0, 0,
                         m_curResolutionWidth, abs(m_curResolutionHeight),
                         g_pBuffer, &m_bi,
                         DIB_RGB_COLORS, SRCCOPY);
}

0 个答案:

没有答案