21 lines
592 B
C#
21 lines
592 B
C#
using OpenCvSharp;
|
|
|
|
namespace Com.Lmc.ShuiYin
|
|
{
|
|
public class ShuiYinUtils
|
|
{
|
|
public static double GetFontScale(Size maxSize, string watermark, HersheyFonts fontFace, int thickness)
|
|
{
|
|
double fontScale = 0.5;
|
|
while (true)
|
|
{
|
|
Size size = Cv2.GetTextSize(watermark, fontFace, fontScale, thickness, out int baseline);
|
|
if (size.Height >= maxSize.Height || size.Width >= maxSize.Width)
|
|
break;
|
|
fontScale += 0.2;
|
|
}
|
|
return fontScale;
|
|
}
|
|
}
|
|
}
|