If GDI functions can be used, you can prepare a memory Dc and attach the captured image to the memory DC. Then Draw the timestamp text to the memory DC, using TextOut or DrawText. After Textout to the memory DC, Read bitmap and it will provide the captured image with the text.
1) Prepare a memory DC.
HDC hdc = ::GetDC(NULL);
CDC MemDc;
MemDc.CreateCompatibleDC( GetDC() );
2) Prepare a Bitmap with the captured image.
CBitmap m_BitmapObject;
HBITMAP hbmDest = ::CreateCompatibleBitmap(hdc, m_nImageWidth, m_nImageHeight);
BITMAPINFO stBitmapInfo;
stBitmapInfo.bmiHeader.biClrImportant = 0;
stBitmapInfo.bmiHeader.biClrUsed = 0;
stBitmapInfo.bmiHeader.biCompression = 0;
stBitmapInfo.bmiHeader.biPlanes = 1;
stBitmapInfo.bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
stBitmapInfo.bmiHeader.biXPelsPerMeter = 0;
stBitmapInfo.bmiHeader.biYPelsPerMeter = 0;
stBitmapInfo.bmiHeader.biBitCount = 3 * 8;
stBitmapInfo.bmiHeader.biSizeImage = m_nImageWidth * m_nImageHeight;
stBitmapInfo.bmiHeader.biHeight = m_nImageHeight;
stBitmapInfo.bmiHeader.biWidth = m_nImageWidth;
stBitmapInfo.bmiColors[0].rgbBlue = 0x0;
stBitmapInfo.bmiColors[0].rgbGreen = 0x0;
stBitmapInfo.bmiColors[0].rgbRed = 0x0;
stBitmapInfo.bmiColors[0].rgbReserved = 0x0;
if (hbmDest)
{
if (SetDIBits(hdc, hbmDest, 0, m_nImageHeight, m_pbyImageData, &stBitmapInfo, DIB_RGB_COLORS))
{
m_BitmapObject.DeleteObject();
m_BitmapObject.Attach( hbmDest );
}
}
3) Attach the Bitmap with the memory DC.
MemDc.SelectObject( m_BitmapObject );
4) Prepare time stamp text by calling gettime() and other string formatting functions.
5) Call TextOut() with the time stamp text to the DC.
BOOL b = MemDc.TextOut( 0,0, szTimestampText );
6) Read contents of the bitmap.// This bitmap will have the captured image and the timestamp text.
GetDIBits( MemDc.m_hDC, (HBITMAP)m_BitmapObject.m_hObject, 0, m_nImageHeight, pbyData, &stBitmapInfo, DIB_RGB_COLORS );