Page 1 of 1

How to add watermark.

Posted: Fri Jun 24, 2022 6:23 am
by tools
I want to add a watermark when recording.

Is there any way?

Re: How to add watermark.

Posted: Fri Jun 24, 2022 9:57 am
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.