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

Thread: Drawing text in DirectShow filter

  1. #1
    Join Date
    Mar 2005
    Posts
    13

    Smile Drawing text in DirectShow filter

    Hi all,

    I am quite new to DirectShow programming, and I have been overlaying some bitmaps over a video stream, through a DirectShow Transform Filter, writing on the output pointer directly.

    What I would like to do now, but I do not know how, is to write some text, and I thought to do it with GDI+.

    The code I have tried at the moment should paint some red rectangle but does not do anything... Anybode knows what I am doing wrong?

    I am quite newbie...



    HRESULT CTransform::Transform(IMediaSample *pIn, IMediaSample *pOut)
    {
    CheckPointer(pIn,E_POINTER);
    CheckPointer(pOut,E_POINTER);

    HRESULT hr = Copy(pIn, pOut);

    BYTE * pOutPtr;
    pOut->GetPointer(&pOutPtr);

    HDC hdc = CreateCompatibleDC(NULL);

    BITMAPINFO BMPInfo;
    BMPInfo.bmiHeader.biBitCount = 32;
    BMPInfo.bmiHeader.biCompression = BI_RGB;
    BMPInfo.bmiHeader.biPlanes = 1;
    BMPInfo.bmiHeader.biSize = sizeof(BMPInfo.bmiHeader);
    BMPInfo.bmiHeader.biWidth = 640;
    BMPInfo.bmiHeader.biHeight = 512;

    HBITMAP hbmp = CreateDIBSection(hdc,&BMPInfo,DIB_RGB_COLORS,(void**)&pOutPtr,0,0);
    SelectObject(hdc,hbmp);

    HBRUSH hbrush = CreateSolidBrush(RGB(255,0,0));
    SelectObject(hdc,hbrush);
    HPEN hpen = CreatePen(PS_SOLID,5,RGB(0,255,0));
    SelectObject(hdc,hpen);

    Rectangle(hdc,0,0,100,100);

    ReleaseDC(NULL,hdc);

    return NOERROR;

    } // Transform



    Thanks in advance!

  2. #2
    Join Date
    Oct 2005
    Posts
    230

    Re: Drawing text in DirectShow filter

    Hi azzazzel82,

    Also new to DirectShow here (today new actually)

    Anyway it doesn't look like your writing anything to the output pointer in the sample below.. Look at the documentation for CreateDIBSection again, the forth parameter specifically.

    What your currently doing is:

    1) Getting the output buffer (Pointer #1)
    2) Creating the DIB and getting a pointer to the DIB's bit values (Overwriting pointer #1)

    What you need to do is:

    1) Get pointer to output buffer (Pointer #1)
    2) Create the DIB and get the pointer to its bit values (Pointer #2)
    3) Copy the DIB into the output buffer in the required format (i.e. Copy pointer #2 data into pointer #1)

    Note: I dont know any of the specific implementation details but that is your initial problem.

    Regards.
    Learning somthing new every day!

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)