public void BasicNoScaleReturnsOriginalSize() { var info = new ResizeImageInfo(); info.Filename = "images/camera.svg"; var tools = new SkiaSharpSvgTools(info, Logger); var dpiPath = new DpiPath("", 1); tools.Resize(dpiPath, DestinationFilename); using var resultImage = SKBitmap.Decode(DestinationFilename); Assert.Equal(1792, resultImage.Width); Assert.Equal(1792, resultImage.Height); using var pixmap = resultImage.PeekPixels(); Assert.Equal(SKColors.Empty, pixmap.GetPixelColor(10, 10)); Assert.Equal(SKColors.White, pixmap.GetPixelColor(350, 350)); }
public void ColorsInCssCanBeUsed() { var info = new ResizeImageInfo(); info.Filename = "images/not_working.svg"; var tools = new SkiaSharpSvgTools(info, Logger); var dpiPath = new DpiPath("", 1); tools.Resize(dpiPath, DestinationFilename); using var resultImage = SKBitmap.Decode(DestinationFilename); Assert.Equal(24, resultImage.Width); Assert.Equal(24, resultImage.Height); using var pixmap = resultImage.PeekPixels(); Assert.Equal(SKColors.Empty, pixmap.GetPixelColor(2, 2)); Assert.Equal(0xFF71559B, pixmap.GetPixelColor(2, 6)); }
public void ColorizedWithNamedReturnsColored() { var info = new SharedImageInfo(); info.Filename = "images/camera.svg"; info.TintColor = Color.FromName("Red"); var tools = new SkiaSharpSvgTools(info, Logger); var dpiPath = new DpiPath("", 1); tools.Resize(dpiPath, DestinationFilename); using var resultImage = SKBitmap.Decode(DestinationFilename); Assert.Equal(1792, resultImage.Width); Assert.Equal(1792, resultImage.Height); using var pixmap = resultImage.PeekPixels(); Assert.Equal(SKColors.Empty, pixmap.GetPixelColor(10, 10)); Assert.Equal(SKColors.Red, pixmap.GetPixelColor(350, 350)); }
public void BasicWithColorsKeepsColors() { var info = new SharedImageInfo(); info.Filename = "images/camera_color.svg"; var tools = new SkiaSharpSvgTools(info, Logger); var dpiPath = new DpiPath("", 1); tools.Resize(dpiPath, DestinationFilename); using var resultImage = SKBitmap.Decode(DestinationFilename); Assert.Equal(256, resultImage.Width); Assert.Equal(256, resultImage.Height); using var pixmap = resultImage.PeekPixels(); Assert.Equal(SKColors.Empty, pixmap.GetPixelColor(10, 10)); Assert.Equal(SKColors.Red, pixmap.GetPixelColor(37, 137)); Assert.Equal(SKColors.Lime, pixmap.GetPixelColor(81, 137)); Assert.Equal(SKColors.Blue, pixmap.GetPixelColor(125, 137)); }
public void ColorizedWithAlphaWithColorsReplacesColors() { var info = new SharedImageInfo(); info.Filename = "images/camera_color.svg"; info.TintColor = Color.FromArgb(127, Color.Red); var tools = new SkiaSharpSvgTools(info, Logger); var dpiPath = new DpiPath("", 1); tools.Resize(dpiPath, DestinationFilename); using var resultImage = SKBitmap.Decode(DestinationFilename); Assert.Equal(256, resultImage.Width); Assert.Equal(256, resultImage.Height); using var pixmap = resultImage.PeekPixels(); Assert.Equal(SKColors.Empty, pixmap.GetPixelColor(10, 10)); Assert.Equal(SKColors.Red.WithAlpha(127), pixmap.GetPixelColor(37, 137)); Assert.Equal(SKColors.Red.WithAlpha(127), pixmap.GetPixelColor(81, 137)); Assert.Equal(SKColors.Red.WithAlpha(127), pixmap.GetPixelColor(125, 137)); }
public void WithBaseSizeResizes() { var info = new SharedImageInfo(); info.Filename = "images/camera_color.svg"; info.BaseSize = new Size(512, 512); var tools = new SkiaSharpSvgTools(info, Logger); var dpiPath = new DpiPath("", 1); tools.Resize(dpiPath, DestinationFilename); using var resultImage = SKBitmap.Decode(DestinationFilename); Assert.Equal(512, resultImage.Width); Assert.Equal(512, resultImage.Height); using var pixmap = resultImage.PeekPixels(); Assert.Equal(SKColors.Empty, pixmap.GetPixelColor(10, 10)); Assert.Equal(SKColors.Red, pixmap.GetPixelColor(74, 274)); Assert.Equal(SKColors.Lime, pixmap.GetPixelColor(162, 274)); Assert.Equal(SKColors.Blue, pixmap.GetPixelColor(250, 274)); }