-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
101 changed files
with
2,321 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// BaseTest.cs | ||
// | ||
// Author: | ||
// Jonathan Pobst <monkey@jpobst.com> | ||
// | ||
// Copyright (c) 2012 Jonathan Pobst | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Drawing; | ||
using System.IO; | ||
|
||
namespace Pinta.ImageManipulation.UnitTests | ||
{ | ||
public abstract class BaseTest | ||
{ | ||
protected Bitmap GetSourceImage (string name) | ||
{ | ||
var bitmap = new Bitmap (Path.Combine ("SourceBitmaps", name)); | ||
|
||
return bitmap; | ||
} | ||
|
||
protected Bitmap GetExpectedImage (string name) | ||
{ | ||
var bitmap = new Bitmap (Path.Combine ("ExpectedBitmaps", name)); | ||
|
||
return bitmap; | ||
} | ||
|
||
protected unsafe void Compare (Bitmap actual, string expected) | ||
{ | ||
if (!File.Exists (Path.Combine ("ExpectedBitmaps", expected))) { | ||
actual.Save (Path.Combine (@"C:\Users\Jonathan\Desktop\Bitmaps", expected)); | ||
return; | ||
} | ||
|
||
var exp_img = GetExpectedImage (expected); | ||
|
||
var act_data = actual.LockBits (new System.Drawing.Rectangle (0, 0, actual.Width, actual.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); | ||
var exp_data = exp_img.LockBits (new System.Drawing.Rectangle (0, 0, actual.Width, actual.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); | ||
|
||
var act_ptr = (ColorBgra*)act_data.Scan0; | ||
var exp_ptr = (ColorBgra*)exp_data.Scan0; | ||
|
||
var diff = 0; | ||
|
||
for (var i = 0; i < actual.Width * actual.Height; i++) | ||
if (*(act_ptr++) != *(exp_ptr++)) | ||
diff++; | ||
|
||
actual.UnlockBits (act_data); | ||
exp_img.UnlockBits (exp_data); | ||
|
||
Assert.AreEqual (0, diff); | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
Pinta.ImageManipulation.UnitTests/Effects/AutoLevelEffectTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// AutoLevelEffectTest.cs | ||
// | ||
// Author: | ||
// Jonathan Pobst <monkey@jpobst.com> | ||
// | ||
// Copyright (c) 2012 Jonathan Pobst | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Pinta.ImageManipulation.Effects; | ||
|
||
namespace Pinta.ImageManipulation.UnitTests.Effects | ||
{ | ||
[TestClass] | ||
public class AutoLevelEffectTest : BaseTest | ||
{ | ||
[TestMethod] | ||
public void AutoLevelEffect1 () | ||
{ | ||
var src = GetSourceImage ("input.png"); | ||
|
||
var effect = new AutoLevelEffect (); | ||
effect.Render (src); | ||
|
||
Compare (src, "autolevel1.png"); | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
Pinta.ImageManipulation.UnitTests/Effects/BlackAndWhiteEffectTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// BlackAndWhiteEffectTest.cs | ||
// | ||
// Author: | ||
// Jonathan Pobst <monkey@jpobst.com> | ||
// | ||
// Copyright (c) 2012 Jonathan Pobst | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Pinta.ImageManipulation.Effects; | ||
|
||
namespace Pinta.ImageManipulation.UnitTests.Effects | ||
{ | ||
[TestClass] | ||
public class BlackAndWhiteEffectTest : BaseTest | ||
{ | ||
[TestMethod] | ||
public void BlackAndWhiteEffect1 () | ||
{ | ||
var src = GetSourceImage ("input.png"); | ||
|
||
var effect = new BlackAndWhiteEffect (); | ||
effect.Render (src); | ||
|
||
Compare (src, "blackandwhite1.png"); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
Pinta.ImageManipulation.UnitTests/Effects/BrightnessContrastEffectTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// BrightnessContrastEffectTest.cs | ||
// | ||
// Author: | ||
// Jonathan Pobst <monkey@jpobst.com> | ||
// | ||
// Copyright (c) 2012 Jonathan Pobst | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Pinta.ImageManipulation.Effects; | ||
|
||
namespace Pinta.ImageManipulation.UnitTests.Effects | ||
{ | ||
[TestClass] | ||
public class BrightnessContrastEffectTest : BaseTest | ||
{ | ||
[TestMethod] | ||
public void BrightnessContrastEffect1 () | ||
{ | ||
var src = GetSourceImage ("input.png"); | ||
|
||
var effect = new BrightnessContrastEffect (); | ||
effect.Render (src); | ||
|
||
Compare (src, "brightnesscontrast1.png"); | ||
} | ||
|
||
[TestMethod] | ||
public void BrightnessContrastEffect2 () | ||
{ | ||
var src = GetSourceImage ("input.png"); | ||
|
||
var effect = new BrightnessContrastEffect (80, 20); | ||
effect.Render (src); | ||
|
||
Compare (src, "brightnesscontrast2.png"); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
Pinta.ImageManipulation.UnitTests/Effects/BulgeEffectTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// BulgeEffectTest.cs | ||
// | ||
// Author: | ||
// Jonathan Pobst <monkey@jpobst.com> | ||
// | ||
// Copyright (c) 2012 Jonathan Pobst | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Pinta.ImageManipulation.Effects; | ||
|
||
namespace Pinta.ImageManipulation.UnitTests.Effects | ||
{ | ||
[TestClass] | ||
public class BulgeEffectTest : BaseTest | ||
{ | ||
[TestMethod] | ||
public void BulgeEffect1 () | ||
{ | ||
var src = GetSourceImage ("input.png"); | ||
|
||
var effect = new BulgeEffect (); | ||
effect.Render (src); | ||
|
||
Compare (src, "bulge1.png"); | ||
} | ||
|
||
[TestMethod] | ||
public void BulgeEffect2 () | ||
{ | ||
var src = GetSourceImage ("input.png"); | ||
|
||
var effect = new BulgeEffect (12, new PointD (20, -20)); | ||
effect.Render (src); | ||
|
||
Compare (src, "bulge2.png"); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
Pinta.ImageManipulation.UnitTests/Effects/EdgeDetectEffectTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// EdgeDetectEffectTest.cs | ||
// | ||
// Author: | ||
// Jonathan Pobst <monkey@jpobst.com> | ||
// | ||
// Copyright (c) 2012 Jonathan Pobst | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Pinta.ImageManipulation.Effects; | ||
|
||
namespace Pinta.ImageManipulation.UnitTests.Effects | ||
{ | ||
[TestClass] | ||
public class EdgeDetectEffectTest : BaseTest | ||
{ | ||
[TestMethod] | ||
public void EdgeDetectEffect1 () | ||
{ | ||
var src = GetSourceImage ("input.png"); | ||
|
||
var effect = new EdgeDetectEffect (); | ||
effect.Render (src); | ||
|
||
Compare (src, "edgedetect1.png"); | ||
} | ||
|
||
[TestMethod] | ||
public void EdgeDetectEffect2 () | ||
{ | ||
var src = GetSourceImage ("input.png"); | ||
|
||
var effect = new EdgeDetectEffect (90); | ||
effect.Render (src); | ||
|
||
Compare (src, "edgedetect2.png"); | ||
} | ||
} | ||
} |
Oops, something went wrong.