Closed manikandan300 closed 2 months ago
Hi! I tested your code, and it works, with the caveat that your BitmapToByteArray function works.
There's a couple things you can check. Firstly, you need to supply a valid image stream to the overlay before starting the recording. Currently it will error out if it's an empty stream or invalid, and it won't retry on update. If you don't want it to show it can be a blank PNG for example, but it must be a valid image.
Secondly, you need to save a reference to your ImageOverlay and use the same instance to call
GetDynamicOptionsBuilder().SetUpdatedOverlay(timestampOverlay ).Apply();
every time you update the timestamp.
Thank for providing fix , it is working fine , I can able to see timestamp after recording, which is useful feature
Recorder _rec;
private ImageOverlay timestampOverlay;
timestampOverlay = new ImageOverlay
{
AnchorPoint = Anchor.BottomLeft,
Offset = new ScreenSize(10, 10),
Size = new ScreenSize(200, 50),
SourcePath = "logo.png",
SourceStream = new MemoryStream(getTimeStamp())
};
recorderOptions.OverlayOptions.Overlays.Add(timestampOverlay);
private byte[] getTimeStamp()
{
using (Bitmap timestampBitmap = new Bitmap(200, 50))
{
using (Graphics g = Graphics.FromImage(timestampBitmap))
{
var currentTime = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss");
g.DrawString(currentTime, new Font("Arial", 14), Brushes.Blue, 0, 0);
}
return BitmapToByteArray(timestampBitmap);
}
}
private byte[] BitmapToByteArray(Bitmap bitmap)
{
using (MemoryStream memoryStream = new MemoryStream())
{
bitmap.Save(memoryStream, ImageFormat.Png);
return memoryStream.ToArray();
}
}
private void UpdateProgress(){
_rec.GetDynamicOptionsBuilder().SetUpdatedOverlay(timestampOverlay).Apply();
}
Hi
, I am trying to add current time in overlay but it is not appearing after recording, please let know how should i record current time in video recording.