update image rotation

This commit is contained in:
Luke Pulverenti 2017-09-02 01:44:47 -04:00
parent 78ad5c91f1
commit 0fd4b0ffca

View File

@ -347,16 +347,29 @@ namespace Emby.Drawing.Skia
case SKCodecOrigin.LeftTop: case SKCodecOrigin.LeftTop:
{ {
// TODO: Flip // TODO: Remove dual canvases, had trouble with flipping
var rotated = new SKBitmap(bitmap.Height, bitmap.Width); using (var rotated = new SKBitmap(bitmap.Height, bitmap.Width))
{
using (var surface = new SKCanvas(rotated)) using (var surface = new SKCanvas(rotated))
{ {
surface.Translate(rotated.Width, 0); surface.Translate(rotated.Width, 0);
surface.RotateDegrees(90); surface.RotateDegrees(90);
surface.DrawBitmap(bitmap, 0, 0); surface.DrawBitmap(bitmap, 0, 0);
} }
return rotated; var flippedBitmap = new SKBitmap(rotated.Width, rotated.Height);
using (var flippedCanvas = new SKCanvas(flippedBitmap))
{
flippedCanvas.Translate(flippedBitmap.Width, 0);
flippedCanvas.Scale(-1, 1);
flippedCanvas.DrawBitmap(rotated, 0, 0);
}
return flippedBitmap;
}
} }
case SKCodecOrigin.RightTop: case SKCodecOrigin.RightTop:
@ -374,8 +387,9 @@ namespace Emby.Drawing.Skia
case SKCodecOrigin.RightBottom: case SKCodecOrigin.RightBottom:
{ {
// TODO: Flip // TODO: Remove dual canvases, had trouble with flipping
var rotated = new SKBitmap(bitmap.Height, bitmap.Width); using (var rotated = new SKBitmap(bitmap.Height, bitmap.Width))
{
using (var surface = new SKCanvas(rotated)) using (var surface = new SKCanvas(rotated))
{ {
surface.Translate(0, rotated.Height); surface.Translate(0, rotated.Height);
@ -383,7 +397,16 @@ namespace Emby.Drawing.Skia
surface.DrawBitmap(bitmap, 0, 0); surface.DrawBitmap(bitmap, 0, 0);
} }
return rotated; var flippedBitmap = new SKBitmap(rotated.Width, rotated.Height);
using (var flippedCanvas = new SKCanvas(flippedBitmap))
{
flippedCanvas.Translate(flippedBitmap.Width, 0);
flippedCanvas.Scale(-1, 1);
flippedCanvas.DrawBitmap(rotated, 0, 0);
}
return flippedBitmap;
}
} }
case SKCodecOrigin.LeftBottom: case SKCodecOrigin.LeftBottom: