CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: mfc dialog display problem

  1. #1
    Join Date
    Aug 2019
    Posts
    7

    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);

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,824

    Re: mfc dialog display problem

    You should put your drawing code within the control's OnPaint handler and use the CPaintDC.
    Victor Nijegorodov

  3. #3
    Join Date
    Aug 2019
    Posts
    7

    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.

  4. #4
    Join Date
    Sep 2020
    Posts
    3

    Re: mfc dialog display problem

    I have such a problem too

  5. #5
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,718

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)