CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2012
    Posts
    1

    Drawing Text to a decompressed video frame

    I'm trying to draw text to a DIB

    Code:
    void CRenderer::RenderScreen(BYTE* data) 
    {
    
        BITMAPINFOHEADER* pbitmapInfoHeader = (BITMAPINFOHEADER*)data;
        (HBITMAP*)(data+sizeof(BITMAPINFOHEADER));
    
        const char *DemoText = "ABCD0123456789\0"; 
        RECT TextArea = {400, 400, 400, 400}; 
        HFONT fontHandle = CreateFont(60, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH || FF_DONTCARE, "Arial\0");
    
        HDC hdc = CreateDC(m_DispDevice.DeviceName,NULL,NULL,NULL);   // creates a device context (DC) for a device ("\\.\DISPLAY2")
    
        SelectObject ( hdc, fontHandle);     
        SetTextColor( hdc, RGB (128, 128, 128)); 
        SetBkMode( hdc, TRANSPARENT);
    
        DrawDibDraw(m_hDrwScr,hdc,m_ptScrPos.x,m_ptScrPos.y,-1,-1,pbitmapInfoHeader,phbitmap, 0,0,pbitmapInfoHeader->biWidth,pbitmapInfoHeader->biHeight,0);            // draws a DIB to the screen
    
        DrawTextA ( hdc, DemoText, 14, &TextArea, DT_LEFT | DT_SINGLELINE | DT_NOCLIP);                        // draws formatted text in the specified rectangle 
        DeleteObject( fontHandle); 
        DeleteDC(hdc); 
    
    };
    
    (data=(BYTE*)AVIStreamGetFrame(m_pGetFrame,Num);)

    the code is working, but text is flicker because i can't draw text to decompresed frame and after this draws a DIB to the screen

    Any ideas?

    thanks

  2. #2
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Drawing Text to a decompressed video frame

    How are you decompressing the video frames?
    If you are using the Media Foundation SDK, take a look at the example here: http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  3. #3
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Drawing Text to a decompressed video frame

    if you only want the visual appearance of text on top of video but don't need the actual text "in" the bitmap, then you could also have a look at window layering. You basically create a new window place it on top of the videstream, make the window transparent and then just draw what you need to draw (transparently) onto your own window. The Windows WDM will then be responsible for proper painting of everything.


    see http://msdn.microsoft.com/en-us/libr...px#layered_win

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured