public static void CreateDefaultThemes() { // Define list of effects to be applied to source logo, order matters here. Add only effects that are enabled by configuration. List<AbstractEffect> effects = new List<AbstractEffect> { new EffectAutoCrop(), new EffectResize {TargetSize = new Size(200, 110), MaxSize = new Size(200, 110)}, // new EffectGlow {Color = Color.Red, Radius = 15}, new EffectShadow {Color = Color.FromArgb(200, 0, 0, 0), Radius = 5, ShadowXOffset = 5, ShadowYOffset = 5}, new EffectOuterGlow {Color = Color.Black, Width = 1, Transparency = 0.8f} }; ThemeHandler themeHandler = new ThemeHandler(); string theme = string.Format("{0}-{1}", DESIGN, THEMES[0]); if (!File.Exists(theme)) { Theme themeModern = new Theme { DesignName = DESIGN, ThemeName = THEMES[0] }; themeHandler.Save(theme, themeModern); } theme = string.Format("{0}-{1}", DESIGN, THEMES[1]); if (!File.Exists(theme)) { Theme themeModernMaxEffects = new Theme { DesignName = DESIGN, ThemeName = THEMES[1], Effects = effects }; themeHandler.Save(theme, themeModernMaxEffects); } }
/// <summary> /// Creates a logo image for the given <paramref name="logoStream"/> using the <paramref name="theme"/>. The final result will be saved to <paramref name="saveFileName"/>. /// Note: /// Exceptions are not caught in this method, so caller needs to handle them accordingly. /// </summary> /// <param name="theme">Theme.</param> /// <param name="logoStream">Stream with logo bitmap to process.</param> /// <param name="saveFileName">Target filename to save.</param> /// <returns><c>true</c> if successful</returns> public bool CreateLogo(Theme theme, Stream logoStream, string saveFileName) { return CreateLogo(theme.DesignName, logoStream, saveFileName, theme.Effects); }
static async Task ProcessStream(LogoProcessor processor, Task<Stream> logo, string channelName, Theme theme) { var saveFileName = BuildFileName(channelName, theme); Stream logoStream = await logo; using (logoStream) processor.CreateLogo(theme, logoStream, saveFileName); }
static void ProcessStream(LogoProcessor processor, Stream logo, string channelName, Theme theme) { var saveFileName = BuildFileName(channelName, theme); using (logo) processor.CreateLogo(theme, logo, saveFileName); }
static void ProcessFile(LogoProcessor processor, string channelName, Theme theme) { string logoFile = string.Format("..\\..\\Example\\{0}.png", channelName); // Source file var saveFileName = BuildFileName(channelName, theme); processor.CreateLogo(theme, logoFile, saveFileName); }
private static string BuildFileName(string channelName, Theme theme) { return string.Format("{0}-{1}_{2}.png", theme.DesignName, theme.ThemeName, channelName); // Processed file }