1

我正在使用 StretchDIBits 函数,在显示位图期间,我可以看到它以两种不同的方式显示,如下所示:

模糊的 BMP 像素 BMP

我唯一要做的就是在获得新数据时更新 BMP 缓冲区。

请在下面找到用于显示位图的相关代码。

if (pBMPBuffer)
{
    LPBITMAPINFO pBmpInfo;
    pBmpInfo = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)];

    pBmpInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    pBmpInfo->bmiHeader.biWidth = m_iZSize;
    pBmpInfo->bmiHeader.biHeight = m_iXSize;
    pBmpInfo->bmiHeader.biPlanes = 1;
    pBmpInfo->bmiHeader.biBitCount = 32;
    pBmpInfo->bmiHeader.biCompression = BI_RGB;
    pBmpInfo->bmiHeader.biSizeImage = m_iXSize * m_iZSize;
    pBmpInfo->bmiHeader.biXPelsPerMeter = 0;
    pBmpInfo->bmiHeader.biYPelsPerMeter = 0;
    pBmpInfo->bmiHeader.biClrUsed = 0;
    pBmpInfo->bmiHeader.biClrImportant = 0;

    SetStretchBltMode(pDC->m_hDC, STRETCH_HALFTONE);
    StretchDIBits(pDC->m_hDC,
                  rectBMP.left,
                  rectBMP.top,
                  rectBMP.Width(),
                  rectBMP.Height(),
                  0,
                  0,
                  m_iZSize,
                  m_iXSize,
                  pBMPBuffer,
                  pBmpInfo,
                  DIB_RGB_COLORS,
                  SRCCOPY);

    delete[] pBmpInfo;
}

我希望位图始终具有“模糊”的外观。提前致谢。

4

1 回答 1

1

you could use GDI+ instead of GDI and select a bicubic interpolation algorithm to be used when images are scaled or rotated. See Gdiplus::Graphics::SetInterpolationMode

Notice that GDI+ is going to be slower than GDI.. Another option would be using OpenGL for example...

于 2014-09-18T12:52:57.510 回答