2
0

DynamicImageResponse.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 void SetFormatFromMimeType(string mimeType)
  15. {
  16. if (mimeType.EndsWith("gif", StringComparison.OrdinalIgnoreCase))
  17. {
  18. Format = ImageFormat.Gif;
  19. }
  20. else if (mimeType.EndsWith("bmp", StringComparison.OrdinalIgnoreCase))
  21. {
  22. Format = ImageFormat.Bmp;
  23. }
  24. else if (mimeType.EndsWith("png", StringComparison.OrdinalIgnoreCase))
  25. {
  26. Format = ImageFormat.Png;
  27. }
  28. else
  29. {
  30. Format = ImageFormat.Jpg;
  31. }
  32. }
  33. }
  34. }