From bae89ee8243fea06ba1e17c1f1ed6da890e9f08c Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Sat, 16 Mar 2013 12:41:49 -0400 Subject: fix duplicate connections on the dashboard --- MediaBrowser.Controller/Drawing/ImageExtensions.cs | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'MediaBrowser.Controller/Drawing/ImageExtensions.cs') diff --git a/MediaBrowser.Controller/Drawing/ImageExtensions.cs b/MediaBrowser.Controller/Drawing/ImageExtensions.cs index cecbfe74a..32268011f 100644 --- a/MediaBrowser.Controller/Drawing/ImageExtensions.cs +++ b/MediaBrowser.Controller/Drawing/ImageExtensions.cs @@ -64,6 +64,39 @@ namespace MediaBrowser.Controller.Drawing return encoders.FirstOrDefault(i => i.MimeType.Equals(mimeType, StringComparison.OrdinalIgnoreCase)) ?? encoders.FirstOrDefault(); } + /// + /// Determines whether [is pixel format supported by graphics object] [the specified format]. + /// + /// The format. + /// true if [is pixel format supported by graphics object] [the specified format]; otherwise, false. + public static bool IsPixelFormatSupportedByGraphicsObject(PixelFormat format) + { + // http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage.aspx + + if (format.HasFlag(PixelFormat.Indexed)) + { + return false; + } + if (format.HasFlag(PixelFormat.Undefined)) + { + return false; + } + if (format.HasFlag(PixelFormat.DontCare)) + { + return false; + } + if (format.HasFlag(PixelFormat.Format16bppArgb1555)) + { + return false; + } + if (format.HasFlag(PixelFormat.Format16bppGrayScale)) + { + return false; + } + + return true; + } + /// /// Crops an image by removing whitespace and transparency from the edges /// -- cgit v1.2.3