|
| 1 | +// Copyright (c) Six Labors. |
| 2 | +// Licensed under the Apache License, Version 2.0. |
| 3 | + |
| 4 | +using System; |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.Text; |
| 7 | +using SixLabors.Fonts; |
| 8 | +using SixLabors.ImageSharp.Drawing.Processing; |
| 9 | +using SixLabors.ImageSharp.Drawing.Shapes.Rasterization; |
| 10 | +using SixLabors.ImageSharp.Drawing.Tests.TestUtilities.ImageComparison; |
| 11 | +using SixLabors.ImageSharp.Memory; |
| 12 | +using SixLabors.ImageSharp.PixelFormats; |
| 13 | +using SixLabors.ImageSharp.Processing; |
| 14 | +using Xunit; |
| 15 | + |
| 16 | +namespace SixLabors.ImageSharp.Drawing.Tests.Shapes.Scan |
| 17 | +{ |
| 18 | + public class RasterizerExtensionsTests |
| 19 | + { |
| 20 | + [Fact] |
| 21 | + public void DoesNotOverwriteIsDirtyFlagWhenOnlyFillingSubpixels() |
| 22 | + { |
| 23 | + var scanner = PolygonScanner.Create(new RectangularPolygon(0.3f, 0.2f, 0.7f, 1.423f), 0, 20, 1, IntersectionRule.OddEven, MemoryAllocator.Default); |
| 24 | + |
| 25 | + float[] buffer = new float[12]; |
| 26 | + |
| 27 | + scanner.MoveToNextPixelLine(); // offset |
| 28 | + |
| 29 | + bool isDirty = scanner.ScanCurrentPixelLineInto(0, 0, buffer.AsSpan()); |
| 30 | + |
| 31 | + Assert.True(isDirty); |
| 32 | + } |
| 33 | + |
| 34 | + [Theory] |
| 35 | + [WithSolidFilledImages(400, 75, "White", PixelTypes.Rgba32)] |
| 36 | + public void AntialiasingIsAntialiased<TPixel>(TestImageProvider<TPixel> provider) |
| 37 | + where TPixel : unmanaged, IPixel<TPixel> |
| 38 | + { |
| 39 | + Font font36 = TestFontUtilities.GetFont(TestFonts.OpenSans, 20); |
| 40 | + var textOpt = new TextOptions(font36) |
| 41 | + { |
| 42 | + Dpi = 96, |
| 43 | + Origin = new PointF(0, 0) |
| 44 | + }; |
| 45 | + |
| 46 | + provider.RunValidatingProcessorTest(x => x |
| 47 | + .SetGraphicsOptions(o => o.Antialias = false) |
| 48 | + .DrawText(textOpt, "Hello, World!", Color.Black)); |
| 49 | + } |
| 50 | + } |
| 51 | +} |
0 commit comments