@@ -10,11 +10,25 @@ public class ChannelLogoGenerator : IChannelLogoGenerator
|
||||
public const string GetRoute = "/iptv/logos/gen";
|
||||
public const string GetRouteQueryParamName = "text";
|
||||
|
||||
private readonly string _fontPath;
|
||||
private readonly ILogger _logger;
|
||||
private readonly string _overlayImagePath;
|
||||
|
||||
public ChannelLogoGenerator(
|
||||
ILogger<ChannelLogoGenerator> logger) =>
|
||||
ILogger<ChannelLogoGenerator> logger)
|
||||
: this(logger, DefaultOverlayImagePath(), DefaultFontPath())
|
||||
{
|
||||
}
|
||||
|
||||
public ChannelLogoGenerator(
|
||||
ILogger<ChannelLogoGenerator> logger,
|
||||
string overlayImagePath,
|
||||
string fontPath)
|
||||
{
|
||||
_logger = logger;
|
||||
_overlayImagePath = overlayImagePath;
|
||||
_fontPath = fontPath;
|
||||
}
|
||||
|
||||
public Either<BaseError, byte[]> GenerateChannelLogo(
|
||||
string text,
|
||||
@@ -29,13 +43,11 @@ public class ChannelLogoGenerator : IChannelLogoGenerator
|
||||
canvas.Clear(SKColors.Black);
|
||||
|
||||
//etv logo
|
||||
string overlayImagePath = Path.Combine("wwwroot", "images", "ersatztv-500.png");
|
||||
using var overlayImage = SKBitmap.Decode(overlayImagePath);
|
||||
using var overlayImage = SKBitmap.Decode(_overlayImagePath);
|
||||
canvas.DrawBitmap(overlayImage, new SKRect(155, 60, 205, 110));
|
||||
|
||||
//Custom Font
|
||||
string fontPath = Path.Combine(FileSystemLayout.ResourcesCacheFolder, "Sen.ttf");
|
||||
using var fontTypeface = SKTypeface.FromFile(fontPath);
|
||||
using var fontTypeface = SKTypeface.FromFile(_fontPath);
|
||||
var fontSize = 30;
|
||||
var font = new SKFont
|
||||
{
|
||||
@@ -80,4 +92,10 @@ public class ChannelLogoGenerator : IChannelLogoGenerator
|
||||
|
||||
public static string GenerateChannelLogoUrl(Channel channel) =>
|
||||
$"http://localhost:{Settings.StreamingPort}{GetRoute}?{GetRouteQueryParamName}={channel.WebEncodedName}";
|
||||
|
||||
private static string DefaultFontPath() =>
|
||||
Path.Combine(FileSystemLayout.ResourcesCacheFolder, "Sen.ttf");
|
||||
|
||||
private static string DefaultOverlayImagePath() =>
|
||||
Path.Combine("wwwroot", "images", "ersatztv-500.png");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user