aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Emby.Drawing.Skia/StripCollageBuilder.cs24
-rw-r--r--Emby.Drawing/NullImageEncoder.cs5
-rw-r--r--MediaBrowser.Controller/Drawing/IImageEncoder.cs2
-rw-r--r--MediaBrowser.ServerApplication/ImageEncoderHelper.cs4
4 files changed, 27 insertions, 8 deletions
diff --git a/Emby.Drawing.Skia/StripCollageBuilder.cs b/Emby.Drawing.Skia/StripCollageBuilder.cs
index 0ffc6df10..605677aab 100644
--- a/Emby.Drawing.Skia/StripCollageBuilder.cs
+++ b/Emby.Drawing.Skia/StripCollageBuilder.cs
@@ -72,7 +72,8 @@ namespace Emby.Drawing.Skia
{
canvas.Clear(SKColors.Black);
- var iSlice = Convert.ToInt32(width * 0.24125);
+ // determine sizes for each image that will composited into the final image
+ var iSlice = Convert.ToInt32(width * 0.23475);
int iTrans = Convert.ToInt32(height * .25);
int iHeight = Convert.ToInt32(height * .70);
var horizontalImagePadding = Convert.ToInt32(width * 0.0125);
@@ -83,42 +84,53 @@ namespace Emby.Drawing.Skia
{
using (var currentBitmap = SKBitmap.Decode(paths[imageIndex]))
{
+ // resize to the same aspect as the original
int iWidth = (int)Math.Abs(iHeight * currentBitmap.Width / currentBitmap.Height);
using (var resizeBitmap = new SKBitmap(iWidth, iHeight, currentBitmap.ColorType, currentBitmap.AlphaType))
{
currentBitmap.Resize(resizeBitmap, SKBitmapResizeMethod.Lanczos3);
+ // determine how much to crop
int ix = (int)Math.Abs((iWidth - iSlice) / 2);
using (var image = SKImage.FromBitmap(resizeBitmap))
{
+ // crop image
using (var subset = image.Subset(SKRectI.Create(ix, 0, iSlice, iHeight)))
{
- canvas.DrawImage(subset, (horizontalImagePadding * (i + 1)) + (iSlice * i), 0);
+ // draw image onto canvas
+ canvas.DrawImage(subset, (horizontalImagePadding * (i + 1)) + (iSlice * i), verticalSpacing);
using (var croppedBitmap = SKBitmap.FromImage(subset))
{
+ // create reflection of image below the drawn image
using (var reflectionBitmap = new SKBitmap(croppedBitmap.Width, croppedBitmap.Height / 2, croppedBitmap.ColorType, croppedBitmap.AlphaType))
{
+ // resize to half height
croppedBitmap.Resize(reflectionBitmap, SKBitmapResizeMethod.Lanczos3);
- using (var flippedBitmap = new SKBitmap(reflectionBitmap.Width, reflectionBitmap.Height))
+ using (var flippedBitmap = new SKBitmap(reflectionBitmap.Width, reflectionBitmap.Height, reflectionBitmap.ColorType, reflectionBitmap.AlphaType))
{
using (var flippedCanvas = new SKCanvas(flippedBitmap))
{
+ // flip image vertically
var matrix = SKMatrix.MakeScale(1, -1);
matrix.SetScaleTranslate(1, -1, 0, flippedBitmap.Height);
flippedCanvas.SetMatrix(matrix);
flippedCanvas.DrawBitmap(reflectionBitmap, 0, 0);
flippedCanvas.ResetMatrix();
+ // create gradient to make image appear as a reflection
+ var remainingHeight = height - (iHeight + (2 * verticalSpacing));
+ flippedCanvas.ClipRect(SKRect.Create(reflectionBitmap.Width, remainingHeight));
using (var gradient = new SKPaint())
{
gradient.IsAntialias = true;
- gradient.BlendMode = SKBlendMode.SrcATop;
- gradient.Shader = SKShader.CreateLinearGradient(new SKPoint(0, 0), new SKPoint(0, flippedBitmap.Height), new[] { new SKColor(0, 0, 0, 0), new SKColor(0, 0, 0, 255) }, null, SKShaderTileMode.Clamp);
+ gradient.BlendMode = SKBlendMode.SrcOver;
+ gradient.Shader = SKShader.CreateLinearGradient(new SKPoint(0, 0), new SKPoint(0, remainingHeight), new[] { new SKColor(0, 0, 0, 128), new SKColor(0, 0, 0, 208), new SKColor(0, 0, 0, 240), new SKColor(0, 0, 0, 255) }, null, SKShaderTileMode.Clamp);
flippedCanvas.DrawPaint(gradient);
}
- canvas.DrawBitmap(flippedBitmap, (horizontalImagePadding * (i + 1)) + (iSlice * i), iHeight + verticalSpacing);
+ // finally draw reflection onto canvas
+ canvas.DrawBitmap(flippedBitmap, (horizontalImagePadding * (i + 1)) + (iSlice * i), iHeight + (2 * verticalSpacing));
}
}
}
diff --git a/Emby.Drawing/NullImageEncoder.cs b/Emby.Drawing/NullImageEncoder.cs
index 4fa18ce55..c7d365fb2 100644
--- a/Emby.Drawing/NullImageEncoder.cs
+++ b/Emby.Drawing/NullImageEncoder.cs
@@ -57,6 +57,11 @@ namespace Emby.Drawing
get { return false; }
}
+ public ImageSize GetImageSize(string path)
+ {
+ throw new NotImplementedException();
+ }
+
public void Dispose()
{
}
diff --git a/MediaBrowser.Controller/Drawing/IImageEncoder.cs b/MediaBrowser.Controller/Drawing/IImageEncoder.cs
index ecc99caf9..830093fcf 100644
--- a/MediaBrowser.Controller/Drawing/IImageEncoder.cs
+++ b/MediaBrowser.Controller/Drawing/IImageEncoder.cs
@@ -50,5 +50,7 @@ namespace MediaBrowser.Controller.Drawing
/// </summary>
/// <value><c>true</c> if [supports image encoding]; otherwise, <c>false</c>.</value>
bool SupportsImageEncoding { get; }
+
+ ImageSize GetImageSize(string path);
}
}
diff --git a/MediaBrowser.ServerApplication/ImageEncoderHelper.cs b/MediaBrowser.ServerApplication/ImageEncoderHelper.cs
index 8c3d8d213..b8fa097d6 100644
--- a/MediaBrowser.ServerApplication/ImageEncoderHelper.cs
+++ b/MediaBrowser.ServerApplication/ImageEncoderHelper.cs
@@ -26,11 +26,11 @@ namespace MediaBrowser.Server.Startup.Common
{
try
{
- return new SkiaEncoder(logManager.GetLogger("ImageMagick"), appPaths, httpClient, fileSystem);
+ return new SkiaEncoder(logManager.GetLogger("Skia"), appPaths, httpClient, fileSystem);
}
catch
{
- logger.Error("Error loading ImageMagick. Will revert to GDI.");
+ logger.Error("Error loading Skia. Will revert to ImageMagick.");
}
try