I want to add a watermark when recording.
Is there any way?
How to add watermark.
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: How to add watermark.
You can use TRVCamera.OnGetImage event.
In this event, you receive a video frame as Img: TRVMBitmap.
You can get this frame as TBitmap: Img.GetBitmap, draw something on this bitmap, then call Img.UpdateData.
However, there is more efficient way: drawing another TRVMBitmap.
For example, you can define in the form: FLogo: TRVMBitmap.
Load logo in this object:
And OnGetImage (drawing at the top right corner):
Unfortunately, the code above does not support transparency.
img.Draw may have two additional parameters allowing to specify a color treated as transparent, but Alpha channel is not supported.
If you need a true semitransparent drawing, use a conversion to TBitmap.
In this event, you receive a video frame as Img: TRVMBitmap.
You can get this frame as TBitmap: Img.GetBitmap, draw something on this bitmap, then call Img.UpdateData.
However, there is more efficient way: drawing another TRVMBitmap.
For example, you can define in the form: FLogo: TRVMBitmap.
Load logo in this object:
Code: Select all
var
png: TPngImage;
begin
FLogo := TRVMBitmap.Create;
png := TPngImage.Create;
png.LoadFromFile('logo.png');
FLogo.Assign(png);
png.Free;
end;
Code: Select all
procedure TfrmMain.RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);
begin
img.Draw(img.Width - FLogo.Width, 0, FLogo);
end;
img.Draw may have two additional parameters allowing to specify a color treated as transparent, but Alpha channel is not supported.
If you need a true semitransparent drawing, use a conversion to TBitmap.