Hi,
I am using the TRVCamRecorder to record videos and just wondering if it's possible to add text to a video, like a caption or timestamp?
Adding text to video recording
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Adding text to video recording
Use TRVCamera.OnGetImage event.
The code below adds a timestamp to the bottom right corner:
Note that this event may be called in a thread context.
If you need to add a static image, like a logo, the recommended way is to prepare it in TRVMBitmap object, and use OnGetImage to draw as img.Draw(X, Y, MyLogoBitmap); You do not need to call img.UpdateData after using this method (if MyLogoBitmap is TRVMBitmap)
The code below adds a timestamp to the bottom right corner:
Code: Select all
procedure TForm1.RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);
var
bmp: TBitmap;
S: String;
Sz: TSize;
begin
bmp := img.GetBitmap;
with bmp.Canvas do
begin
Lock;
try
Brush.Style := bsClear;
Font.PixelsPerInch := 96;
Font.Name := 'Tahoma';
Font.Color := clWhite;
Font.Size := 8;
S := TimeToStr(Now);
Sz := TextExtent(S);
TextOut(bmp.Width - Sz.cx - 2, bmp.Height - Sz.cy - 2, S);
finally
Unlock;
end;
end;
img.UpdateData;
end;
If you need to add a static image, like a logo, the recommended way is to prepare it in TRVMBitmap object, and use OnGetImage to draw as img.Draw(X, Y, MyLogoBitmap); You do not need to call img.UpdateData after using this method (if MyLogoBitmap is TRVMBitmap)