Reputation: 39
Added a picture control to my MFC dialog. Set its type to Frame. Need to display 8 bit buffer (NOT LOADED From file) on the picture control. The image is scaled down, repeated , tilted diagonally. Not correct. I could not make it fit the control properly. resized the control but still the same problem.
w = 750;
h = 850;
bpp = 8
void CDispDlg::BuildINfoAndDisp(int w, int h)
{
m_pbmi = (BITMAPINFO*) new BYTE[sizeof(BITMAPINFO) + 256) * sizeof(RGBQUAD)];
m_pbmi->bmiHeader.bSize=sizeof(BITMAPINFOHEADER);
m_pbmi->bmiHeader.biPlanes = 1;
m_pbmi->bmiHeader.biBitCount = bpp;
m_pbmi->bmiHeader.biCompression = BI_RGB;
m_pbmi->bmiHeader.biSizeImage = 0;
m_pbmi->bmiHeader.biXpelsPerMeter = 0;
m_pbmi->bmiHeader.biYpelsPerMeter = 0;
m_pbmi->bmiHeader.biClrUsed = 0;
m_pbmi->bmiHeader.biClrImportant = 0;
for (int i = 0; i< 256; i++)
{
m_pbmi->bmiColors[i].rgbBlue = i;
m_pbmi->bmiColors[i].rgbGreen = i;
m_pbmi->bmiColors[i].rgbBRed = i;
m_pbmi->bmiColors[i].rgbReserved = 0;
}
m_pbmi->bmiHeader.biWidth = w;
m_pbmi->bmiHeader.biHeight = -h;
CClientDC dc(GetDlgItem(IDC_PicCntrl_DSIP));
CRect rect;
GetDlgItem(IDC_PicCntrl_DSIP)->GetClientRect(&rect);
SetStrechBltMode(dc.GetSafeHdc(), COLORNOCOLOR);
StretchBIBits(dc.GetSafeHdc(), 0 ,0 , rect.Width, rect.Height, 0,0, m_wImage, m_hImage, &m_U8imageBuf, m_pbmi,DIB_RGB_COLORS, SRCCOPY);
}
Upvotes: 1
Views: 102