aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Providers/DynamicImageResponse.cs
blob: 11c7ccbe500e3ab5e4a8384a5dfa6293d588beeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.IO;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.MediaInfo;

namespace MediaBrowser.Controller.Providers
{
    public class DynamicImageResponse
    {
        public string Path { get; set; }
        public MediaProtocol Protocol { get; set; }
        public Stream Stream { get; set; }
        public ImageFormat Format { get; set; }
        public bool HasImage { get; set; }

        public void SetFormatFromMimeType(string mimeType)
        {
            if (mimeType.EndsWith("gif", StringComparison.OrdinalIgnoreCase))
            {
                Format = ImageFormat.Gif;
            }
            else if (mimeType.EndsWith("bmp", StringComparison.OrdinalIgnoreCase))
            {
                Format = ImageFormat.Bmp;
            }
            else if (mimeType.EndsWith("png", StringComparison.OrdinalIgnoreCase))
            {
                Format = ImageFormat.Png;
            }
            else
            {
                Format = ImageFormat.Jpg;
            }
        }
    }
}