How to add watermark.

RVMedia support and discussion (components for displaying and controlling IP cameras, webcams, video conferencing, video chats, recording audio and video files)
Post Reply
tools
Posts: 1
Joined: Fri Jun 24, 2022 6:20 am

How to add watermark.

Post by tools »

I want to add a watermark when recording.

Is there any way?
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: How to add watermark.

Post by Sergey Tkachenko »

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:

Code: Select all

var
  png: TPngImage;
begin
  FLogo := TRVMBitmap.Create;
  png := TPngImage.Create;
  png.LoadFromFile('logo.png');
  FLogo.Assign(png);
  png.Free;
end;
And OnGetImage (drawing at the top right corner):

Code: Select all

procedure TfrmMain.RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);
begin
  img.Draw(img.Width - FLogo.Width, 0, FLogo);
end;
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.
Post Reply