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

Thread: Drawing text in DirectShow filter

  1. #1
    Join Date
    Mar 2005

    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)

    HRESULT hr = Copy(pIn, pOut);

    BYTE * pOutPtr;

    HDC hdc = CreateCompatibleDC(NULL);

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

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



    return NOERROR;

    } // Transform

    Thanks in advance!

  2. #2
    Join Date
    Oct 2005

    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.

    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)