2014-11-29 20:51:30 +01:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Model.Drawing;
|
2014-01-28 19:37:01 +01:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2014-02-11 22:41:01 +01:00
|
|
|
|
using System;
|
2014-01-28 19:37:01 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
2014-01-29 17:16:24 +01:00
|
|
|
|
using System.Threading;
|
2014-01-28 19:37:01 +01:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Providers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This is just a marker interface
|
|
|
|
|
/// </summary>
|
|
|
|
|
public interface ILocalImageProvider : IImageProvider
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-08 21:02:35 +01:00
|
|
|
|
public interface ILocalImageFileProvider : ILocalImageProvider
|
2014-01-28 19:37:01 +01:00
|
|
|
|
{
|
2014-02-10 19:39:41 +01:00
|
|
|
|
List<LocalImageInfo> GetImages(IHasImages item, IDirectoryService directoryService);
|
2014-01-28 19:37:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class LocalImageInfo
|
|
|
|
|
{
|
2014-03-12 20:56:12 +01:00
|
|
|
|
public FileSystemInfo FileInfo { get; set; }
|
2014-01-28 19:37:01 +01:00
|
|
|
|
public ImageType Type { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-04 21:19:29 +01:00
|
|
|
|
public interface IDynamicImageProvider : IImageProvider
|
2014-01-28 19:37:01 +01:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2014-01-29 17:16:24 +01:00
|
|
|
|
/// Gets the supported images.
|
2014-01-28 19:37:01 +01:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
2014-01-29 17:16:24 +01:00
|
|
|
|
/// <returns>IEnumerable{ImageType}.</returns>
|
|
|
|
|
IEnumerable<ImageType> GetSupportedImages(IHasImages item);
|
2014-01-28 19:37:01 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the image.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
2014-01-29 17:16:24 +01:00
|
|
|
|
/// <param name="type">The type.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
2014-01-28 19:37:01 +01:00
|
|
|
|
/// <returns>Task{DynamicImageResponse}.</returns>
|
2014-01-29 17:16:24 +01:00
|
|
|
|
Task<DynamicImageResponse> GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken);
|
2014-01-28 19:37:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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; }
|
2014-01-29 17:16:24 +01:00
|
|
|
|
public bool HasImage { get; set; }
|
|
|
|
|
|
|
|
|
|
public void SetFormatFromMimeType(string mimeType)
|
|
|
|
|
{
|
2014-02-11 22:41:01 +01:00
|
|
|
|
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;
|
|
|
|
|
}
|
2014-01-29 17:16:24 +01:00
|
|
|
|
}
|
2014-01-28 19:37:01 +01:00
|
|
|
|
}
|
|
|
|
|
}
|