From d15af6eb35c782b0f150fc67bf0f2b0566d86edc Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Thu, 3 Jan 2019 21:29:48 +0100 Subject: Removed all old and unused ImageEncoders. Remove solution platform cruft. --- Emby.Drawing.Net/DynamicImageHelpers.cs | 110 ----------- Emby.Drawing.Net/Emby.Drawing.Net.csproj | 17 -- Emby.Drawing.Net/GDIImageEncoder.cs | 282 ---------------------------- Emby.Drawing.Net/ImageExtensions.cs | 217 --------------------- Emby.Drawing.Net/ImageHelpers.cs | 43 ----- Emby.Drawing.Net/PercentPlayedDrawer.cs | 34 ---- Emby.Drawing.Net/PlayedIndicatorDrawer.cs | 32 ---- Emby.Drawing.Net/Properties/AssemblyInfo.cs | 36 ---- Emby.Drawing.Net/UnplayedCountIndicator.cs | 50 ----- Emby.Drawing.Net/empty.png | Bin 68 -> 0 bytes 10 files changed, 821 deletions(-) delete mode 100644 Emby.Drawing.Net/DynamicImageHelpers.cs delete mode 100644 Emby.Drawing.Net/Emby.Drawing.Net.csproj delete mode 100644 Emby.Drawing.Net/GDIImageEncoder.cs delete mode 100644 Emby.Drawing.Net/ImageExtensions.cs delete mode 100644 Emby.Drawing.Net/ImageHelpers.cs delete mode 100644 Emby.Drawing.Net/PercentPlayedDrawer.cs delete mode 100644 Emby.Drawing.Net/PlayedIndicatorDrawer.cs delete mode 100644 Emby.Drawing.Net/Properties/AssemblyInfo.cs delete mode 100644 Emby.Drawing.Net/UnplayedCountIndicator.cs delete mode 100644 Emby.Drawing.Net/empty.png (limited to 'Emby.Drawing.Net') diff --git a/Emby.Drawing.Net/DynamicImageHelpers.cs b/Emby.Drawing.Net/DynamicImageHelpers.cs deleted file mode 100644 index 1910f7840d..0000000000 --- a/Emby.Drawing.Net/DynamicImageHelpers.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Imaging; -using System.IO; -using MediaBrowser.Common.IO; -using MediaBrowser.Controller.IO; -using MediaBrowser.Model.IO; - -namespace Emby.Drawing.Net -{ - public static class DynamicImageHelpers - { - public static void CreateThumbCollage(List files, - IFileSystem fileSystem, - string file, - int width, - int height) - { - const int numStrips = 4; - files = ImageHelpers.ProjectPaths(files, numStrips); - - const int rows = 1; - int cols = numStrips; - - int cellWidth = 2 * (width / 3); - int cellHeight = height; - var index = 0; - - using (var img = new Bitmap(width, height, PixelFormat.Format32bppPArgb)) - { - using (var graphics = Graphics.FromImage(img)) - { - graphics.CompositingQuality = CompositingQuality.HighQuality; - graphics.SmoothingMode = SmoothingMode.HighQuality; - graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; - graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; - - // SourceCopy causes the image to be blank in OSX - //graphics.CompositingMode = CompositingMode.SourceCopy; - - for (var row = 0; row < rows; row++) - { - for (var col = 0; col < cols; col++) - { - var x = col * (cellWidth / 2); - var y = row * cellHeight; - - if (files.Count > index) - { - using (var imgtemp = Image.FromFile(files[index])) - { - graphics.DrawImage(imgtemp, x, y, cellWidth, cellHeight); - } - } - - index++; - } - } - img.Save(file); - } - } - } - - public static void CreateSquareCollage(List files, - IFileSystem fileSystem, - string file, - int width, - int height) - { - files = ImageHelpers.ProjectPaths(files, 4); - - const int rows = 2; - const int cols = 2; - - int singleSize = width / 2; - var index = 0; - - using (var img = new Bitmap(width, height, PixelFormat.Format32bppPArgb)) - { - using (var graphics = Graphics.FromImage(img)) - { - graphics.CompositingQuality = CompositingQuality.HighQuality; - graphics.SmoothingMode = SmoothingMode.HighQuality; - graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; - graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; - - // SourceCopy causes the image to be blank in OSX - //graphics.CompositingMode = CompositingMode.SourceCopy; - - for (var row = 0; row < rows; row++) - { - for (var col = 0; col < cols; col++) - { - var x = col * singleSize; - var y = row * singleSize; - - using (var imgtemp = Image.FromFile(files[index])) - { - graphics.DrawImage(imgtemp, x, y, singleSize, singleSize); - } - index++; - } - } - img.Save(file); - } - } - } - } -} diff --git a/Emby.Drawing.Net/Emby.Drawing.Net.csproj b/Emby.Drawing.Net/Emby.Drawing.Net.csproj deleted file mode 100644 index dc9d35dcaf..0000000000 --- a/Emby.Drawing.Net/Emby.Drawing.Net.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - netstandard2.0 - - - - - - - diff --git a/Emby.Drawing.Net/GDIImageEncoder.cs b/Emby.Drawing.Net/GDIImageEncoder.cs deleted file mode 100644 index 1639125d37..0000000000 --- a/Emby.Drawing.Net/GDIImageEncoder.cs +++ /dev/null @@ -1,282 +0,0 @@ -using MediaBrowser.Controller.Drawing; -using MediaBrowser.Model.Drawing; -using Microsoft.Extensions.Logging; -using System; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Imaging; -using System.IO; -using System.Linq; -using MediaBrowser.Common.IO; -using MediaBrowser.Controller.IO; -using MediaBrowser.Model.IO; -using ImageFormat = MediaBrowser.Model.Drawing.ImageFormat; -using Emby.Drawing; - -namespace Emby.Drawing.Net -{ - public class GDIImageEncoder : IImageEncoder - { - private readonly IFileSystem _fileSystem; - private readonly ILogger _logger; - - public GDIImageEncoder(IFileSystem fileSystem, ILogger logger) - { - _fileSystem = fileSystem; - _logger = logger; - - LogInfo(); - } - - private void LogInfo() - { - _logger.LogInformation("GDIImageEncoder starting"); - using (var stream = GetType().Assembly.GetManifestResourceStream(GetType().Namespace + ".empty.png")) - { - using (var img = Image.FromStream(stream)) - { - - } - } - _logger.LogInformation("GDIImageEncoder started"); - } - - public string[] SupportedInputFormats - { - get - { - return new[] - { - "png", - "jpeg", - "jpg", - "gif", - "bmp" - }; - } - } - - public ImageFormat[] SupportedOutputFormats - { - get - { - return new[] { ImageFormat.Gif, ImageFormat.Jpg, ImageFormat.Png }; - } - } - - public ImageSize GetImageSize(string path) - { - using (var image = Image.FromFile(path)) - { - return new ImageSize - { - Width = image.Width, - Height = image.Height - }; - } - } - - private Image GetImage(string path, bool cropWhitespace) - { - if (cropWhitespace) - { - using (var originalImage = (Bitmap)Image.FromFile(path)) - { - return originalImage.CropWhitespace(); - } - } - - return Image.FromFile(path); - } - - public void EncodeImage(string inputPath, ImageSize? originalImageSize, string outputPath, bool autoOrient, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat) - { - using (var originalImage = GetImage(inputPath, options.CropWhiteSpace)) - { - if (options.CropWhiteSpace || !originalImageSize.HasValue) - { - originalImageSize = new ImageSize(originalImage.Width, originalImage.Height); - } - - var newImageSize = ImageHelper.GetNewImageSize(options, originalImageSize); - - var newWidth = Convert.ToInt32(Math.Round(newImageSize.Width)); - var newHeight = Convert.ToInt32(Math.Round(newImageSize.Height)); - - // Graphics.FromImage will throw an exception if the PixelFormat is Indexed, so we need to handle that here - // Also, Webp only supports Format32bppArgb and Format32bppRgb - var pixelFormat = selectedOutputFormat == ImageFormat.Webp - ? PixelFormat.Format32bppArgb - : PixelFormat.Format32bppPArgb; - - using (var thumbnail = new Bitmap(newWidth, newHeight, pixelFormat)) - { - // Mono throw an exeception if assign 0 to SetResolution - if (originalImage.HorizontalResolution > 0 && originalImage.VerticalResolution > 0) - { - // Preserve the original resolution - thumbnail.SetResolution(originalImage.HorizontalResolution, originalImage.VerticalResolution); - } - - using (var thumbnailGraph = Graphics.FromImage(thumbnail)) - { - thumbnailGraph.CompositingQuality = CompositingQuality.HighQuality; - thumbnailGraph.SmoothingMode = SmoothingMode.HighQuality; - thumbnailGraph.InterpolationMode = InterpolationMode.HighQualityBicubic; - thumbnailGraph.PixelOffsetMode = PixelOffsetMode.HighQuality; - - // SourceCopy causes the image to be blank in OSX - //thumbnailGraph.CompositingMode = !hasPostProcessing ? - // CompositingMode.SourceCopy : - // CompositingMode.SourceOver; - - SetBackgroundColor(thumbnailGraph, options); - - thumbnailGraph.DrawImage(originalImage, 0, 0, newWidth, newHeight); - - DrawIndicator(thumbnailGraph, newWidth, newHeight, options); - - var outputFormat = GetOutputFormat(originalImage, selectedOutputFormat); - - // Save to the cache location - using (var cacheFileStream = _fileSystem.GetFileStream(outputPath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, false)) - { - // Save to the memory stream - thumbnail.Save(outputFormat, cacheFileStream, quality); - } - } - } - - } - } - - /// - /// Sets the color of the background. - /// - /// The graphics. - /// The options. - private void SetBackgroundColor(Graphics graphics, ImageProcessingOptions options) - { - var color = options.BackgroundColor; - - if (!string.IsNullOrEmpty(color)) - { - Color drawingColor; - - try - { - drawingColor = ColorTranslator.FromHtml(color); - } - catch - { - drawingColor = ColorTranslator.FromHtml("#" + color); - } - - graphics.Clear(drawingColor); - } - } - - /// - /// Draws the indicator. - /// - /// The graphics. - /// Width of the image. - /// Height of the image. - /// The options. - private void DrawIndicator(Graphics graphics, int imageWidth, int imageHeight, ImageProcessingOptions options) - { - if (!options.AddPlayedIndicator && !options.UnplayedCount.HasValue && options.PercentPlayed.Equals(0)) - { - return; - } - - try - { - if (options.AddPlayedIndicator) - { - var currentImageSize = new Size(imageWidth, imageHeight); - - new PlayedIndicatorDrawer().DrawPlayedIndicator(graphics, currentImageSize); - } - else if (options.UnplayedCount.HasValue) - { - var currentImageSize = new Size(imageWidth, imageHeight); - - new UnplayedCountIndicator().DrawUnplayedCountIndicator(graphics, currentImageSize, options.UnplayedCount.Value); - } - - if (options.PercentPlayed > 0) - { - var currentImageSize = new Size(imageWidth, imageHeight); - - new PercentPlayedDrawer().Process(graphics, currentImageSize, options.PercentPlayed); - } - } - catch (Exception ex) - { - _logger.LogError(ex, "Error drawing indicator overlay"); - } - } - - /// - /// Gets the output format. - /// - /// The image. - /// The output format. - /// ImageFormat. - private System.Drawing.Imaging.ImageFormat GetOutputFormat(Image image, ImageFormat outputFormat) - { - switch (outputFormat) - { - case ImageFormat.Bmp: - return System.Drawing.Imaging.ImageFormat.Bmp; - case ImageFormat.Gif: - return System.Drawing.Imaging.ImageFormat.Gif; - case ImageFormat.Jpg: - return System.Drawing.Imaging.ImageFormat.Jpeg; - case ImageFormat.Png: - return System.Drawing.Imaging.ImageFormat.Png; - default: - return image.RawFormat; - } - } - - public void CreateImageCollage(ImageCollageOptions options) - { - double ratio = options.Width; - ratio /= options.Height; - - if (ratio >= 1.4) - { - DynamicImageHelpers.CreateThumbCollage(options.InputPaths.ToList(), _fileSystem, options.OutputPath, options.Width, options.Height); - } - else if (ratio >= .9) - { - DynamicImageHelpers.CreateSquareCollage(options.InputPaths.ToList(), _fileSystem, options.OutputPath, options.Width, options.Height); - } - else - { - DynamicImageHelpers.CreateSquareCollage(options.InputPaths.ToList(), _fileSystem, options.OutputPath, options.Width, options.Width); - } - } - - public void Dispose() - { - } - - public string Name - { - get { return "GDI"; } - } - - public bool SupportsImageCollageCreation - { - get { return true; } - } - - public bool SupportsImageEncoding - { - get { return true; } - } - } -} diff --git a/Emby.Drawing.Net/ImageExtensions.cs b/Emby.Drawing.Net/ImageExtensions.cs deleted file mode 100644 index dec2613d0f..0000000000 --- a/Emby.Drawing.Net/ImageExtensions.cs +++ /dev/null @@ -1,217 +0,0 @@ -using System; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Imaging; -using System.IO; - -namespace Emby.Drawing.Net -{ - public static class ImageExtensions - { - /// - /// Saves the image. - /// - /// The output format. - /// The image. - /// To stream. - /// The quality. - public static void Save(this Image image, ImageFormat outputFormat, Stream toStream, int quality) - { - // Use special save methods for jpeg and png that will result in a much higher quality image - // All other formats use the generic Image.Save - if (ImageFormat.Jpeg.Equals(outputFormat)) - { - SaveAsJpeg(image, toStream, quality); - } - else if (ImageFormat.Png.Equals(outputFormat)) - { - image.Save(toStream, ImageFormat.Png); - } - else - { - image.Save(toStream, outputFormat); - } - } - - /// - /// Saves the JPEG. - /// - /// The image. - /// The target. - /// The quality. - public static void SaveAsJpeg(this Image image, Stream target, int quality) - { - using (var encoderParameters = new EncoderParameters(1)) - { - encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, quality); - image.Save(target, GetImageCodecInfo("image/jpeg"), encoderParameters); - } - } - - private static readonly ImageCodecInfo[] Encoders = ImageCodecInfo.GetImageEncoders(); - - /// - /// Gets the image codec info. - /// - /// Type of the MIME. - /// ImageCodecInfo. - private static ImageCodecInfo GetImageCodecInfo(string mimeType) - { - foreach (var encoder in Encoders) - { - if (string.Equals(encoder.MimeType, mimeType, StringComparison.OrdinalIgnoreCase)) - { - return encoder; - } - } - - return Encoders.Length == 0 ? null : Encoders[0]; - } - - /// - /// Crops an image by removing whitespace and transparency from the edges - /// - /// The BMP. - /// Bitmap. - /// - public static Bitmap CropWhitespace(this Bitmap bmp) - { - var width = bmp.Width; - var height = bmp.Height; - - var topmost = 0; - for (int row = 0; row < height; ++row) - { - if (IsAllWhiteRow(bmp, row, width)) - topmost = row; - else break; - } - - int bottommost = 0; - for (int row = height - 1; row >= 0; --row) - { - if (IsAllWhiteRow(bmp, row, width)) - bottommost = row; - else break; - } - - int leftmost = 0, rightmost = 0; - for (int col = 0; col < width; ++col) - { - if (IsAllWhiteColumn(bmp, col, height)) - leftmost = col; - else - break; - } - - for (int col = width - 1; col >= 0; --col) - { - if (IsAllWhiteColumn(bmp, col, height)) - rightmost = col; - else - break; - } - - if (rightmost == 0) rightmost = width; // As reached left - if (bottommost == 0) bottommost = height; // As reached top. - - var croppedWidth = rightmost - leftmost; - var croppedHeight = bottommost - topmost; - - if (croppedWidth == 0) // No border on left or right - { - leftmost = 0; - croppedWidth = width; - } - - if (croppedHeight == 0) // No border on top or bottom - { - topmost = 0; - croppedHeight = height; - } - - // Graphics.FromImage will throw an exception if the PixelFormat is Indexed, so we need to handle that here - var thumbnail = new Bitmap(croppedWidth, croppedHeight, PixelFormat.Format32bppPArgb); - - // Preserve the original resolution - TrySetResolution(thumbnail, bmp.HorizontalResolution, bmp.VerticalResolution); - - using (var thumbnailGraph = Graphics.FromImage(thumbnail)) - { - thumbnailGraph.CompositingQuality = CompositingQuality.HighQuality; - thumbnailGraph.SmoothingMode = SmoothingMode.HighQuality; - thumbnailGraph.InterpolationMode = InterpolationMode.HighQualityBicubic; - thumbnailGraph.PixelOffsetMode = PixelOffsetMode.HighQuality; - thumbnailGraph.CompositingMode = CompositingMode.SourceCopy; - - thumbnailGraph.DrawImage(bmp, - new RectangleF(0, 0, croppedWidth, croppedHeight), - new RectangleF(leftmost, topmost, croppedWidth, croppedHeight), - GraphicsUnit.Pixel); - } - return thumbnail; - } - - /// - /// Tries the set resolution. - /// - /// The BMP. - /// The x. - /// The y. - private static void TrySetResolution(Bitmap bmp, float x, float y) - { - if (x > 0 && y > 0) - { - bmp.SetResolution(x, y); - } - } - - /// - /// Determines whether or not a row of pixels is all whitespace - /// - /// The BMP. - /// The row. - /// The width. - /// true if [is all white row] [the specified BMP]; otherwise, false. - private static bool IsAllWhiteRow(Bitmap bmp, int row, int width) - { - for (var i = 0; i < width; ++i) - { - if (!IsWhiteSpace(bmp.GetPixel(i, row))) - { - return false; - } - } - return true; - } - - /// - /// Determines whether or not a column of pixels is all whitespace - /// - /// The BMP. - /// The col. - /// The height. - /// true if [is all white column] [the specified BMP]; otherwise, false. - private static bool IsAllWhiteColumn(Bitmap bmp, int col, int height) - { - for (var i = 0; i < height; ++i) - { - if (!IsWhiteSpace(bmp.GetPixel(col, i))) - { - return false; - } - } - return true; - } - - /// - /// Determines if a color is whitespace - /// - /// The color. - /// true if [is white space] [the specified color]; otherwise, false. - private static bool IsWhiteSpace(Color color) - { - return (color.R == 255 && color.G == 255 && color.B == 255) || color.A == 0; - } - } -} diff --git a/Emby.Drawing.Net/ImageHelpers.cs b/Emby.Drawing.Net/ImageHelpers.cs deleted file mode 100644 index 1afc47cd03..0000000000 --- a/Emby.Drawing.Net/ImageHelpers.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Emby.Drawing.Net -{ - internal static class ImageHelpers - { - internal static List ProjectPaths(List paths, int count) - { - if (count <= 0) - { - throw new ArgumentOutOfRangeException("count"); - } - if (paths.Count == 0) - { - throw new ArgumentOutOfRangeException("paths"); - } - - var list = new List(); - - AddToList(list, paths, count); - - return list.Take(count).ToList(); - } - - private static void AddToList(List list, List paths, int count) - { - while (list.Count < count) - { - foreach (var path in paths) - { - list.Add(path); - - if (list.Count >= count) - { - return; - } - } - } - } - } -} diff --git a/Emby.Drawing.Net/PercentPlayedDrawer.cs b/Emby.Drawing.Net/PercentPlayedDrawer.cs deleted file mode 100644 index fac15ba47a..0000000000 --- a/Emby.Drawing.Net/PercentPlayedDrawer.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Drawing; - -namespace Emby.Drawing.Net -{ - public class PercentPlayedDrawer - { - private const int IndicatorHeight = 8; - - public void Process(Graphics graphics, Size imageSize, double percent) - { - var y = imageSize.Height - IndicatorHeight; - - using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 0, 0, 0))) - { - const int innerX = 0; - var innerY = y; - var innerWidth = imageSize.Width; - var innerHeight = imageSize.Height; - - graphics.FillRectangle(backdroundBrush, innerX, innerY, innerWidth, innerHeight); - - using (var foregroundBrush = new SolidBrush(Color.FromArgb(82, 181, 75))) - { - double foregroundWidth = innerWidth; - foregroundWidth *= percent; - foregroundWidth /= 100; - - graphics.FillRectangle(foregroundBrush, innerX, innerY, Convert.ToInt32(Math.Round(foregroundWidth)), innerHeight); - } - } - } - } -} diff --git a/Emby.Drawing.Net/PlayedIndicatorDrawer.cs b/Emby.Drawing.Net/PlayedIndicatorDrawer.cs deleted file mode 100644 index 53683e6f45..0000000000 --- a/Emby.Drawing.Net/PlayedIndicatorDrawer.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Drawing; - -namespace Emby.Drawing.Net -{ - public class PlayedIndicatorDrawer - { - private const int IndicatorHeight = 40; - public const int IndicatorWidth = 40; - private const int FontSize = 40; - private const int OffsetFromTopRightCorner = 10; - - public void DrawPlayedIndicator(Graphics graphics, Size imageSize) - { - var x = imageSize.Width - IndicatorWidth - OffsetFromTopRightCorner; - - using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 82, 181, 75))) - { - graphics.FillEllipse(backdroundBrush, x, OffsetFromTopRightCorner, IndicatorWidth, IndicatorHeight); - - x = imageSize.Width - 45 - OffsetFromTopRightCorner; - - using (var font = new Font("Webdings", FontSize, FontStyle.Regular, GraphicsUnit.Pixel)) - { - using (var fontBrush = new SolidBrush(Color.White)) - { - graphics.DrawString("a", font, fontBrush, x, OffsetFromTopRightCorner - 2); - } - } - } - } - } -} diff --git a/Emby.Drawing.Net/Properties/AssemblyInfo.cs b/Emby.Drawing.Net/Properties/AssemblyInfo.cs deleted file mode 100644 index 321c3a297c..0000000000 --- a/Emby.Drawing.Net/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Emby.Drawing.Net")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Emby.Drawing.Net")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c97a239e-a96c-4d64-a844-ccf8cc30aecb")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Emby.Drawing.Net/UnplayedCountIndicator.cs b/Emby.Drawing.Net/UnplayedCountIndicator.cs deleted file mode 100644 index a38abeb324..0000000000 --- a/Emby.Drawing.Net/UnplayedCountIndicator.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Drawing; - -namespace Emby.Drawing.Net -{ - public class UnplayedCountIndicator - { - private const int IndicatorHeight = 41; - public const int IndicatorWidth = 41; - private const int OffsetFromTopRightCorner = 10; - - public void DrawUnplayedCountIndicator(Graphics graphics, Size imageSize, int count) - { - var x = imageSize.Width - IndicatorWidth - OffsetFromTopRightCorner; - - using (var backdroundBrush = new SolidBrush(Color.FromArgb(225, 82, 181, 75))) - { - graphics.FillEllipse(backdroundBrush, x, OffsetFromTopRightCorner, IndicatorWidth, IndicatorHeight); - - var text = count.ToString(); - - x = imageSize.Width - IndicatorWidth - OffsetFromTopRightCorner; - var y = OffsetFromTopRightCorner + 6; - var fontSize = 24; - - if (text.Length == 1) - { - x += 10; - } - else if (text.Length == 2) - { - x += 3; - } - else if (text.Length == 3) - { - x += 1; - y += 1; - fontSize = 20; - } - - using (var font = new Font("Sans-Serif", fontSize, FontStyle.Regular, GraphicsUnit.Pixel)) - { - using (var fontBrush = new SolidBrush(Color.White)) - { - graphics.DrawString(text, font, fontBrush, x, y); - } - } - } - } - } -} diff --git a/Emby.Drawing.Net/empty.png b/Emby.Drawing.Net/empty.png deleted file mode 100644 index 34b25c436e..0000000000 Binary files a/Emby.Drawing.Net/empty.png and /dev/null differ -- cgit v1.2.3