mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-21 04:37:47 +03:00
Add a couple more deskew tests
This commit is contained in:
parent
86c59a1831
commit
ea5098885a
@ -1,13 +1,12 @@
|
||||
using NAPS2.Images;
|
||||
using NAPS2.Images.Storage;
|
||||
using NAPS2.Sdk.Tests.Asserts;
|
||||
using Xunit;
|
||||
|
||||
namespace NAPS2.Sdk.Tests.Images
|
||||
{
|
||||
public class DeskewTests
|
||||
public class DeskewTests : ContextualTexts
|
||||
{
|
||||
// Just a sanity check...
|
||||
// TODO: More thorough deskew performance testing.
|
||||
[Fact]
|
||||
public void Deskew()
|
||||
{
|
||||
@ -25,5 +24,26 @@ namespace NAPS2.Sdk.Tests.Images
|
||||
var skewAngle = Deskewer.GetSkewAngle(image);
|
||||
Assert.InRange(skewAngle, 15.5, 16.5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeskewTransform()
|
||||
{
|
||||
var image = new GdiImage(DeskewTestsData.skewed);
|
||||
var expectedImage = new GdiImage(DeskewTestsData.deskewed);
|
||||
Assert.Equal(StoragePixelFormat.RGB24, image.PixelFormat);
|
||||
var transform = Deskewer.GetDeskewTransform(image);
|
||||
var deskewedImage = ImageContext.PerformTransform(image, transform);
|
||||
ImageAsserts.Similar(expectedImage, deskewedImage, 3.5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NoSkewAngle()
|
||||
{
|
||||
// The cat picture doesn't have consistent lines, so deskewing should be a no-op
|
||||
var image = new GdiImage(DeskewTestsData.stock_cat);
|
||||
Assert.Equal(StoragePixelFormat.RGB24, image.PixelFormat);
|
||||
var skewAngle = Deskewer.GetSkewAngle(image);
|
||||
Assert.Equal(0, skewAngle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
32
NAPS2.Sdk.Tests/Images/DeskewTestsData.Designer.cs
generated
32
NAPS2.Sdk.Tests/Images/DeskewTestsData.Designer.cs
generated
@ -19,10 +19,10 @@ namespace NAPS2.Sdk.Tests.Images {
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class DeskewTestsData {
|
||||
public class DeskewTestsData {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
@ -36,7 +36,7 @@ namespace NAPS2.Sdk.Tests.Images {
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NAPS2.Sdk.Tests.Images.DeskewTestsData", typeof(DeskewTestsData).Assembly);
|
||||
@ -51,7 +51,7 @@ namespace NAPS2.Sdk.Tests.Images {
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
@ -63,7 +63,17 @@ namespace NAPS2.Sdk.Tests.Images {
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap skewed {
|
||||
public static System.Drawing.Bitmap deskewed {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("deskewed", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
public static System.Drawing.Bitmap skewed {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("skewed", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
@ -73,11 +83,21 @@ namespace NAPS2.Sdk.Tests.Images {
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap skewed_bw {
|
||||
public static System.Drawing.Bitmap skewed_bw {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("skewed_bw", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
public static System.Drawing.Bitmap stock_cat {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("stock_cat", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,10 +118,16 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="deskewed" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\deskewed.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="skewed" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\skewed.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="skewed_bw" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\skewed_bw.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="stock_cat" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\stock-cat.jpeg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
NAPS2.Sdk.Tests/Resources/deskewed.jpg
Normal file
BIN
NAPS2.Sdk.Tests/Resources/deskewed.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 437 KiB |
Loading…
Reference in New Issue
Block a user