-
August 31st, 2020, 12:09 AM
#1
mfc dialog display problem
mfc dialog with picture control having display problem.
content of 8 bit capture image buffer is shown somewhat tilted somewhat displayed incorrectly.
Code:
pbmi = (BITMAPINFO*) new BYTE(sizeof(BITMAPINFO) + 256) * sizeof(RGBQUAD)];
pbmi->bmiHeader.bSize=sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biPlanes = 1;
pbmi->bmiHeader.biBitCount = 8;
pbmi->bmiHeader.biCompression = BI_RGB;
pbmi->bmiHeader.biSizeImage = 0;
pbmi->bmiHeader.biXpelsPerMeter = 0;
pbmi->bmiHeader.biYpelsPerMeter = 0;
pbmi->bmiHeader.biClrUsed = 0;
pbmi->bmiHeader.biClrImportant = 0;
pbmi->bmiHeader.biWidth = width;
pbmi->bmiHeader.biHeight = -height;
for (int i = 0; i< 256; i++)
{
pbmi->bmiColors[i].rgbBlue = i;
pbmi->bmiColors[i].rgbGreen = i;
pbmi->bmiColors[i].rgbBRed = i;
pbmi->bmiColors[i].rgbReserved = 0;
}
CClientDC dc(GetDlgItem(IDC_PIC_CONTROL));
CRect rect;
GetDlgItem(IDC_PIC_CONTROL)->GetClientRect(&rect);
SetStrechBltMode(dc.GetSafeHdc(), COLORNOCOLOR);
StretchBIBits(dc.GetSafeHdc(), 0 ,0 , rect.Width, rect.Height, 0,0, width, height, &U8Buf, pbmi,DIB_RGB_COLORS, SRCCOPY);
-
August 31st, 2020, 01:14 AM
#2
Re: mfc dialog display problem
You should put your drawing code within the control's OnPaint handler and use the CPaintDC.
Victor Nijegorodov
-
August 31st, 2020, 09:35 AM
#3
Re: mfc dialog display problem
what it got to do with the image displayed diagonally?. Can you/someone show how the new code should look like?. I will try to follow your suggestion.
-
September 2nd, 2020, 04:26 PM
#4
Re: mfc dialog display problem
I have such a problem too
-
September 2nd, 2020, 07:49 PM
#5
Re: mfc dialog display problem
Is your width a multiple of 4? Some systems require that you pad the BMP scan lines to make them a multiple of 4.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|