DynamicImageResponse.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.IO;
  3. using MediaBrowser.Model.Drawing;
  4. using MediaBrowser.Model.MediaInfo;
  5. namespace MediaBrowser.Controller.Providers
  6. {
  7. public class DynamicImageResponse
  8. {
  9. public string Path { get; set; }
  10. public MediaProtocol Protocol { get; set; }
  11. public Stream Stream { get; set; }
  12. public ImageFormat Format { get; set; }
  13. public bool HasImage { get; set; }
  14. public string InternalCacheKey { get; set; }
  15. public void SetFormatFromMimeType(string mimeType)
  16. {
  17. if (mimeType.EndsWith("gif", StringComparison.OrdinalIgnoreCase))
  18. {
  19. Format = ImageFormat.Gif;
  20. }
  21. else if (mimeType.EndsWith("bmp", StringComparison.OrdinalIgnoreCase))
  22. {
  23. Format = ImageFormat.Bmp;
  24. }
  25. else if (mimeType.EndsWith("png", StringComparison.OrdinalIgnoreCase))
  26. {
  27. Format = ImageFormat.Png;
  28. }
  29. else
  30. {
  31. Format = ImageFormat.Jpg;
  32. }
  33. }
  34. }
  35. }