Skip to content

Commit

Permalink
- In InRamImageData.Open don't draw the image unscaled because this c…
Browse files Browse the repository at this point in the history
…an cause the image not to be drawn

- added corresponding test
  • Loading branch information
jany-tenaj committed Jul 27, 2017
1 parent 6e81b44 commit e181a34
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@ Be aware that code written for 1.9 will not work out of the box because DotSpati
- Legend selection to be able to select features of a category (#1008)
- Some errors in SetSelectable plugin (#1008)
- Crash when attempting to use a serial GPS device on Mono
- Clear the selection inside FeatureLayer.RemoveSelectedFeatures so the removed features are no longer contained when IFeatureSet.FeatureRemoved is raised
- Clear the selection inside FeatureLayer.RemoveSelectedFeatures so the removed features are no longer contained when IFeatureSet.FeatureRemoved is raised
- In InRamImageData.Open don't draw the image unscaled because this can cause the image not to be drawn
Binary file not shown.
2 changes: 2 additions & 0 deletions Source/DotSpatial.Data.Tests/DotSpatial.Data.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.XML" />
</ItemGroup>
Expand All @@ -98,6 +99,7 @@
<Compile Include="ExtentTests.cs" />
<Compile Include="FeatureListTests.cs" />
<Compile Include="GeometryTests.cs" />
<Compile Include="InRamImageDataTests.cs" />
<Compile Include="LineShapefileTests.cs" />
<Compile Include="PointShapefileTests.cs" />
<Compile Include="PolygonShapefileTests.cs" />
Expand Down
31 changes: 31 additions & 0 deletions Source/DotSpatial.Data.Tests/InRamImageDataTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) DotSpatial Team. All rights reserved.
// Licensed under the MIT license. See License.txt file in the project root for full license information.

using System.Drawing;
using System.IO;
using NUnit.Framework;

namespace DotSpatial.Data.Tests
{
/// <summary>
/// Contains tests for the InRamImageData class.
/// </summary>
[TestFixture]
public class InRamImageDataTests
{
/// <summary>
/// This checks that the image that gets loaded in InRamImageData(fileName) ctor gets drawn to _inRamImage.
/// </summary>
[Test(Description = "This checks that the image that gets loaded in InRamImageData(fileName) constructor gets drawn to _inRamImage.")]
public void InRamImageDataCtorLoadsImageWithColor()
{
var imagePath = Path.Combine(@"Data\Grids", "Hintergrundkarte.tif");

using (var inram = new InRamImageData(imagePath))
using (var bitmap = inram.GetBitmap())
{
Assert.AreEqual(Color.FromArgb(255, 125, 105, 72), bitmap.GetPixel(300, 300)); // if the image was not drawn correctly GetPixel returns the ARGB values for white
}
}
}
}
2 changes: 1 addition & 1 deletion Source/DotSpatial.Data/InRamImageData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public override void Open()
Width = temp.Width;
Height = temp.Height;
using (var g = Graphics.FromImage(_myImage))
g.DrawImageUnscaled(temp, 0, 0);
g.DrawImage(temp, 0, 0, temp.Width, temp.Height); // don't draw unscaled because then nothing is shown
}

WorldFile = new WorldFile(Filename);
Expand Down

0 comments on commit e181a34

Please sign in to comment.