DynamicImageResponse.cs 1012 B

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