/// <summary> /// Gets the output format. /// </summary> /// <param name="image">The image.</param> /// <param name="outputFormat">The output format.</param> /// <returns>ImageFormat.</returns> private System.Drawing.Imaging.ImageFormat GetOutputFormat(Image image, Model.Drawing.ImageFormat outputFormat) { switch (outputFormat) { case Model.Drawing.ImageFormat.Bmp: return(System.Drawing.Imaging.ImageFormat.Bmp); case Model.Drawing.ImageFormat.Gif: return(System.Drawing.Imaging.ImageFormat.Gif); case Model.Drawing.ImageFormat.Jpg: return(System.Drawing.Imaging.ImageFormat.Jpeg); case Model.Drawing.ImageFormat.Png: return(System.Drawing.Imaging.ImageFormat.Png); default: return(image.RawFormat); } }
/// <summary> /// Gets the cache file path based on a set of parameters /// </summary> private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, Model.Drawing.ImageFormat format, bool addPlayedIndicator, double percentPlayed, int?unwatchedCount, string backgroundColor) { var filename = originalPath; filename += "width=" + outputSize.Width; filename += "height=" + outputSize.Height; filename += "quality=" + quality; filename += "datemodified=" + dateModified.Ticks; filename += "f=" + format; var hasIndicator = false; if (addPlayedIndicator) { filename += "pl=true"; hasIndicator = true; } if (percentPlayed > 0) { filename += "p=" + percentPlayed; hasIndicator = true; } if (unwatchedCount.HasValue) { filename += "p=" + unwatchedCount.Value; hasIndicator = true; } if (hasIndicator) { filename += "iv=" + IndicatorVersion; } if (!string.IsNullOrEmpty(backgroundColor)) { filename += "b=" + backgroundColor; } return(GetCachePath(ResizedImageCachePath, filename, "." + format.ToString().ToLower())); }