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))
{ {
surface.Translate(rotated.Width, 0); using (var surface = new SKCanvas(rotated))
surface.RotateDegrees(90); {
surface.DrawBitmap(bitmap, 0, 0); surface.Translate(rotated.Width, 0);
}
return rotated; surface.RotateDegrees(90);
surface.DrawBitmap(bitmap, 0, 0);
}
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,16 +387,26 @@ 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))
{ {
surface.Translate(0, rotated.Height); using (var surface = new SKCanvas(rotated))
surface.RotateDegrees(270); {
surface.DrawBitmap(bitmap, 0, 0); surface.Translate(0, rotated.Height);
} surface.RotateDegrees(270);
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: