mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-15 18:53:27 +01:00
Change image dimentions from double to int
Rename ImageSize -> ImageDimensions
This commit is contained in:
@@ -44,6 +44,6 @@ namespace MediaBrowser.Controller.Drawing
|
||||
/// <value><c>true</c> if [supports image encoding]; otherwise, <c>false</c>.</value>
|
||||
bool SupportsImageEncoding { get; }
|
||||
|
||||
ImageSize GetImageSize(string path);
|
||||
ImageDimensions GetImageSize(string path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,16 +26,16 @@ namespace MediaBrowser.Controller.Drawing
|
||||
/// <value>The image enhancers.</value>
|
||||
IImageEnhancer[] ImageEnhancers { get; }
|
||||
|
||||
ImageSize GetImageSize(string path);
|
||||
ImageDimensions GetImageSize(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the image.
|
||||
/// </summary>
|
||||
/// <param name="info">The information.</param>
|
||||
/// <returns>ImageSize.</returns>
|
||||
ImageSize GetImageSize(BaseItem item, ItemImageInfo info);
|
||||
ImageDimensions GetImageSize(BaseItem item, ItemImageInfo info);
|
||||
|
||||
ImageSize GetImageSize(BaseItem item, ItemImageInfo info, bool updateItem);
|
||||
ImageDimensions GetImageSize(BaseItem item, ItemImageInfo info, bool updateItem);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the parts.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Drawing;
|
||||
using MediaBrowser.Model.Entities;
|
||||
@@ -6,7 +7,7 @@ namespace MediaBrowser.Controller.Drawing
|
||||
{
|
||||
public static class ImageHelper
|
||||
{
|
||||
public static ImageSize GetNewImageSize(ImageProcessingOptions options, ImageSize? originalImageSize)
|
||||
public static ImageDimensions GetNewImageSize(ImageProcessingOptions options, ImageDimensions? originalImageSize)
|
||||
{
|
||||
if (originalImageSize.HasValue)
|
||||
{
|
||||
@@ -20,26 +21,26 @@ namespace MediaBrowser.Controller.Drawing
|
||||
|
||||
public static IImageProcessor ImageProcessor { get; set; }
|
||||
|
||||
private static ImageSize GetSizeEstimate(ImageProcessingOptions options)
|
||||
private static ImageDimensions GetSizeEstimate(ImageProcessingOptions options)
|
||||
{
|
||||
if (options.Width.HasValue && options.Height.HasValue)
|
||||
{
|
||||
return new ImageSize(options.Width.Value, options.Height.Value);
|
||||
return new ImageDimensions(options.Width.Value, options.Height.Value);
|
||||
}
|
||||
|
||||
var aspect = GetEstimatedAspectRatio(options.Image.Type, options.Item);
|
||||
double aspect = GetEstimatedAspectRatio(options.Image.Type, options.Item);
|
||||
|
||||
var width = options.Width ?? options.MaxWidth;
|
||||
int? width = options.Width ?? options.MaxWidth;
|
||||
|
||||
if (width.HasValue)
|
||||
{
|
||||
var heightValue = width.Value / aspect;
|
||||
return new ImageSize(width.Value, heightValue);
|
||||
int heightValue = Convert.ToInt32((double)width.Value / aspect);
|
||||
return new ImageDimensions(width.Value, heightValue);
|
||||
}
|
||||
|
||||
var height = options.Height ?? options.MaxHeight ?? 200;
|
||||
var widthValue = aspect * height;
|
||||
return new ImageSize(widthValue, height);
|
||||
int widthValue = Convert.ToInt32(aspect * height);
|
||||
return new ImageDimensions(widthValue, height);
|
||||
}
|
||||
|
||||
private static double GetEstimatedAspectRatio(ImageType type, BaseItem item)
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace MediaBrowser.Controller.Drawing
|
||||
!MaxHeight.HasValue;
|
||||
}
|
||||
|
||||
public bool HasDefaultOptions(string originalImagePath, ImageSize? size)
|
||||
public bool HasDefaultOptions(string originalImagePath, ImageDimensions? size)
|
||||
{
|
||||
if (!size.HasValue)
|
||||
{
|
||||
|
||||
@@ -2235,11 +2235,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </exception>
|
||||
/// <exception cref="ArgumentNullException">item</exception>
|
||||
public string GetImagePath(ImageType imageType, int imageIndex)
|
||||
{
|
||||
var info = GetImageInfo(imageType, imageIndex);
|
||||
|
||||
return info == null ? null : info.Path;
|
||||
}
|
||||
=> GetImageInfo(imageType, imageIndex)?.Path;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image information.
|
||||
|
||||
@@ -424,11 +424,9 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
if (state.VideoStream != null && state.VideoStream.Width.HasValue)
|
||||
{
|
||||
// This is hacky but not sure how to get the exact subtitle resolution
|
||||
double height = state.VideoStream.Width.Value;
|
||||
height /= 16;
|
||||
height *= 9;
|
||||
int height = Convert.ToInt32((double)state.VideoStream.Width.Value / 16.0 * 9.0);
|
||||
|
||||
arg += string.Format(" -canvas_size {0}:{1}", state.VideoStream.Width.Value.ToString(CultureInfo.InvariantCulture), Convert.ToInt32(height).ToString(CultureInfo.InvariantCulture));
|
||||
arg += string.Format(" -canvas_size {0}:{1}", state.VideoStream.Width.Value.ToString(CultureInfo.InvariantCulture), height.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
var subtitlePath = state.SubtitleStream.Path;
|
||||
|
||||
@@ -319,7 +319,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
if (VideoStream != null && VideoStream.Width.HasValue && VideoStream.Height.HasValue)
|
||||
{
|
||||
var size = new ImageSize
|
||||
var size = new ImageDimensions
|
||||
{
|
||||
Width = VideoStream.Width.Value,
|
||||
Height = VideoStream.Height.Value
|
||||
@@ -331,7 +331,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
BaseRequest.MaxWidth ?? 0,
|
||||
BaseRequest.MaxHeight ?? 0);
|
||||
|
||||
return Convert.ToInt32(newSize.Width);
|
||||
return newSize.Width;
|
||||
}
|
||||
|
||||
if (!IsVideoRequest)
|
||||
@@ -349,7 +349,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
if (VideoStream != null && VideoStream.Width.HasValue && VideoStream.Height.HasValue)
|
||||
{
|
||||
var size = new ImageSize
|
||||
var size = new ImageDimensions
|
||||
{
|
||||
Width = VideoStream.Width.Value,
|
||||
Height = VideoStream.Height.Value
|
||||
@@ -361,7 +361,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
BaseRequest.MaxWidth ?? 0,
|
||||
BaseRequest.MaxHeight ?? 0);
|
||||
|
||||
return Convert.ToInt32(newSize.Height);
|
||||
return newSize.Height;
|
||||
}
|
||||
|
||||
if (!IsVideoRequest)
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// <param name="imageIndex">Index of the image.</param>
|
||||
/// <param name="originalImageSize">Size of the original image.</param>
|
||||
/// <returns>ImageSize.</returns>
|
||||
ImageSize GetEnhancedImageSize(BaseItem item, ImageType imageType, int imageIndex, ImageSize originalImageSize);
|
||||
ImageDimensions GetEnhancedImageSize(BaseItem item, ImageType imageType, int imageIndex, ImageDimensions originalImageSize);
|
||||
|
||||
EnhancedImageInfo GetEnhancedImageInfo(BaseItem item, string inputFile, ImageType imageType, int imageIndex);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user