using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Providers
{
///
/// This is just a marker interface
///
public interface ILocalImageProvider : IImageProvider
{
}
public interface ILocalImageFileProvider : ILocalImageProvider
{
List GetImages(IHasImages item, IDirectoryService directoryService);
}
public class LocalImageInfo
{
public FileSystemInfo FileInfo { get; set; }
public ImageType Type { get; set; }
}
public interface IDynamicImageProvider : IImageProvider
{
///
/// Gets the supported images.
///
/// The item.
/// IEnumerable{ImageType}.
IEnumerable GetSupportedImages(IHasImages item);
///
/// Gets the image.
///
/// The item.
/// The type.
/// The cancellation token.
/// Task{DynamicImageResponse}.
Task GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken);
}
public class DynamicImageInfo
{
public string ImageId { get; set; }
public ImageType Type { get; set; }
}
public class DynamicImageResponse
{
public string Path { 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;
}
}
}
}