Index: Core/Common/src/Core.Common.Utils/Drawing/ColorAccess.cs =================================================================== diff -u -r569a286badd9b3494f5465cc2767a8cf6a77f618 -r3b51a30f833b58265a599b56920597d656f906c6 --- Core/Common/src/Core.Common.Utils/Drawing/ColorAccess.cs (.../ColorAccess.cs) (revision 569a286badd9b3494f5465cc2767a8cf6a77f618) +++ Core/Common/src/Core.Common.Utils/Drawing/ColorAccess.cs (.../ColorAccess.cs) (revision 3b51a30f833b58265a599b56920597d656f906c6) @@ -20,9 +20,11 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Drawing.Imaging; +using System.Linq; using System.Runtime.InteropServices; using Core.Common.Utils.Properties; @@ -63,12 +65,14 @@ private readonly ColorPalette palette; private readonly Rectangle validRange; + private readonly byte[] buffer; + private ColorAccess(BitmapData data, ColorPalette palette, Rectangle validRange) { stride = data.Stride; - Buffer = new byte[stride * data.Height]; - Marshal.Copy(data.Scan0, Buffer, 0, Buffer.Length); + buffer = new byte[stride * data.Height]; + Marshal.Copy(data.Scan0, buffer, 0, buffer.Length); format = data.PixelFormat; bitsPerPixel = GetPixelSize(format); this.palette = palette; @@ -93,10 +97,10 @@ switch (format) { case PixelFormat.Format1bppIndexed: - return palette.Entries[(Buffer[index] & bitMask[mod]) == 0 ? 0 : 1]; + return palette.Entries[(Buffer.ElementAt(index) & bitMask[mod]) == 0 ? 0 : 1]; case PixelFormat.Format4bppIndexed: - pIndex = Buffer[index]; + pIndex = Buffer.ElementAt(index); mod /= 4; if (mod != 0) { @@ -105,17 +109,17 @@ return palette.Entries[pIndex & 0x7]; case PixelFormat.Format8bppIndexed: - pIndex = Buffer[index]; + pIndex = Buffer.ElementAt(index); return palette.Entries[pIndex]; case PixelFormat.Format24bppRgb: - return Color.FromArgb(Buffer[index + 2], Buffer[index + 1], - Buffer[index]); + return Color.FromArgb(Buffer.ElementAt(index + 2), Buffer.ElementAt(index + 1), + Buffer.ElementAt(index)); case PixelFormat.Format32bppArgb: case PixelFormat.Format32bppRgb: - return Color.FromArgb(Buffer[index + 3], Buffer[index + 2], - Buffer[index + 1], Buffer[index]); + return Color.FromArgb(Buffer.ElementAt(index + 3), Buffer.ElementAt(index + 2), + Buffer.ElementAt(index + 1), Buffer.ElementAt(index)); default: throw new InvalidOperationException($"Indexing image for image format '{format}' isn't supported."); } @@ -130,10 +134,10 @@ int mod; int index = GetIndex(x, y, out mod); - Buffer[index++] = value.B; - Buffer[index++] = value.G; - Buffer[index++] = value.R; - Buffer[index] = value.A; + buffer[index++] = value.B; + buffer[index++] = value.G; + buffer[index++] = value.R; + buffer[index] = value.A; } } @@ -142,7 +146,13 @@ /// can be used to create a new image with the changed data (for example using /// ). /// - public byte[] Buffer { get; } + public IEnumerable Buffer + { + get + { + return buffer; + } + } /// /// Sets the current image back at the original location in @@ -160,7 +170,7 @@ } BitmapData bitmapData = bitmap.LockBits(validRange, ImageLockMode.WriteOnly, bitmap.PixelFormat); - Marshal.Copy(Buffer, 0, bitmapData.Scan0, Buffer.Length); + Marshal.Copy(Buffer.ToArray(), 0, bitmapData.Scan0, Buffer.Count()); bitmap.UnlockBits(bitmapData); } Index: Core/Common/test/Core.Common.TestUtil/WindowsFormsTestHelper.cs =================================================================== diff -u -r6b8f6422c0a6f96f8e563bb6afb82a7a192142b4 -r3b51a30f833b58265a599b56920597d656f906c6 --- Core/Common/test/Core.Common.TestUtil/WindowsFormsTestHelper.cs (.../WindowsFormsTestHelper.cs) (revision 6b8f6422c0a6f96f8e563bb6afb82a7a192142b4) +++ Core/Common/test/Core.Common.TestUtil/WindowsFormsTestHelper.cs (.../WindowsFormsTestHelper.cs) (revision 3b51a30f833b58265a599b56920597d656f906c6) @@ -49,7 +49,7 @@ InitializeComponent(); } - public static object[] PropertyObjects { get; set; } + public static IEnumerable PropertyObjects { get; set; } public PropertyGrid PropertyGrid { get; private set; } Index: Core/Common/test/Core.Common.Utils.Test/Drawing/ColorAccessTest.cs =================================================================== diff -u -r67284323e2785c651633d9c52049ba12a9c70e6a -r3b51a30f833b58265a599b56920597d656f906c6 --- Core/Common/test/Core.Common.Utils.Test/Drawing/ColorAccessTest.cs (.../ColorAccessTest.cs) (revision 67284323e2785c651633d9c52049ba12a9c70e6a) +++ Core/Common/test/Core.Common.Utils.Test/Drawing/ColorAccessTest.cs (.../ColorAccessTest.cs) (revision 3b51a30f833b58265a599b56920597d656f906c6) @@ -21,6 +21,7 @@ using System; using System.Drawing; +using System.Linq; using Core.Common.TestUtil; using Core.Common.Utils.Drawing; using Core.Common.Utils.Test.Properties; @@ -116,10 +117,10 @@ // Assert const int expectedBufferStartIndex = 544; - Assert.AreEqual(Color.AliceBlue.B, colorAccess.Buffer[expectedBufferStartIndex]); - Assert.AreEqual(Color.AliceBlue.G, colorAccess.Buffer[expectedBufferStartIndex + 1]); - Assert.AreEqual(Color.AliceBlue.R, colorAccess.Buffer[expectedBufferStartIndex + 2]); - Assert.AreEqual(Color.AliceBlue.A, colorAccess.Buffer[expectedBufferStartIndex + 3]); + Assert.AreEqual(Color.AliceBlue.B, colorAccess.Buffer.ElementAt(expectedBufferStartIndex)); + Assert.AreEqual(Color.AliceBlue.G, colorAccess.Buffer.ElementAt(expectedBufferStartIndex + 1)); + Assert.AreEqual(Color.AliceBlue.R, colorAccess.Buffer.ElementAt(expectedBufferStartIndex + 2)); + Assert.AreEqual(Color.AliceBlue.A, colorAccess.Buffer.ElementAt(expectedBufferStartIndex + 3)); // ColorAccess should not be capable of changing the source image: TestHelper.AssertImagesAreEqual(Resources.acorn, image); Index: Ringtoets/Common/src/Ringtoets.Common.Data/DikeProfiles/DikeProfile.cs =================================================================== diff -u -r8900f570b33f0de1a512fc5b2509771e1201672c -r3b51a30f833b58265a599b56920597d656f906c6 --- Ringtoets/Common/src/Ringtoets.Common.Data/DikeProfiles/DikeProfile.cs (.../DikeProfile.cs) (revision 8900f570b33f0de1a512fc5b2509771e1201672c) +++ Ringtoets/Common/src/Ringtoets.Common.Data/DikeProfiles/DikeProfile.cs (.../DikeProfile.cs) (revision 3b51a30f833b58265a599b56920597d656f906c6) @@ -176,7 +176,7 @@ /// and the succeeding . The roughness of the last /// point is irrelevant. /// - public RoughnessPoint[] DikeGeometry { get; private set; } + public IEnumerable DikeGeometry { get; private set; } /// /// Gets or sets the height of the dike [m+NAP]. @@ -277,17 +277,17 @@ DikeGeometry = points.Select(p => new RoughnessPoint(p.Point, p.Roughness)).ToArray(); } - private bool EqualDikeGeometry(RoughnessPoint[] otherPoints) + private bool EqualDikeGeometry(IEnumerable otherPoints) { - int nrOfPoints = DikeGeometry.Length; - if (otherPoints.Length != nrOfPoints) + int nrOfPoints = DikeGeometry.Count(); + if (otherPoints.Count() != nrOfPoints) { return false; } for (var i = 0; i < nrOfPoints; i++) { - if (!DikeGeometry[i].Equals(otherPoints[i])) + if (!DikeGeometry.ElementAt(i).Equals(otherPoints.ElementAt(i))) { return false; } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsChartDataPointsFactory.cs =================================================================== diff -u -r93036b575ee81b4517b29db51f1eadf81454fb93 -r3b51a30f833b58265a599b56920597d656f906c6 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsChartDataPointsFactory.cs (.../GrassCoverErosionInwardsChartDataPointsFactory.cs) (revision 93036b575ee81b4517b29db51f1eadf81454fb93) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsChartDataPointsFactory.cs (.../GrassCoverErosionInwardsChartDataPointsFactory.cs) (revision 3b51a30f833b58265a599b56920597d656f906c6) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; using System.Linq; using Core.Common.Base.Geometry; using Core.Components.Chart.Data; @@ -75,13 +76,13 @@ /// public static Point2D[] CreateDikeHeightPoints(GrassCoverErosionInwardsInput input) { - if (input?.DikeProfile == null || double.IsNaN(input.DikeHeight) || input.DikeProfile.DikeGeometry.Length < 2) + if (input?.DikeProfile == null || double.IsNaN(input.DikeHeight) || input.DikeProfile.DikeGeometry.Count() < 2) { return new Point2D[0]; } DikeProfile dikeProfile = input.DikeProfile; - RoughnessPoint[] roughnessPoints = dikeProfile.DikeGeometry; + IEnumerable roughnessPoints = dikeProfile.DikeGeometry; return new[] { Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs =================================================================== diff -u -r8900f570b33f0de1a512fc5b2509771e1201672c -r3b51a30f833b58265a599b56920597d656f906c6 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs (.../GrassCoverErosionInwardsInputTest.cs) (revision 8900f570b33f0de1a512fc5b2509771e1201672c) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs (.../GrassCoverErosionInwardsInputTest.cs) (revision 3b51a30f833b58265a599b56920597d656f906c6) @@ -45,7 +45,7 @@ { DikeProfile defaultDikeProfile = CreateTestDikeProfile(); Point2D defaultLocation = defaultDikeProfile.WorldReferencePoint; - RoughnessPoint[] defaultRoughnessPoints = defaultDikeProfile.DikeGeometry; + IEnumerable defaultRoughnessPoints = defaultDikeProfile.DikeGeometry; RoundedDouble defaultDikeHeight = defaultDikeProfile.DikeHeight; RoundedPoint2DCollection defaultForeshoreGeometry = defaultDikeProfile.ForeshoreGeometry; RoundedDouble defaultBreakWaterHeight = defaultDikeProfile.BreakWater.Height; Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsInputViewTest.cs =================================================================== diff -u -rd337718251f4330d447d555eb1c70df226dd9823 -r3b51a30f833b58265a599b56920597d656f906c6 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsInputViewTest.cs (.../GrassCoverErosionInwardsInputViewTest.cs) (revision d337718251f4330d447d555eb1c70df226dd9823) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsInputViewTest.cs (.../GrassCoverErosionInwardsInputViewTest.cs) (revision 3b51a30f833b58265a599b56920597d656f906c6) @@ -529,8 +529,8 @@ Assert.IsInstanceOf(chartData); var dikeProfileChartData = (ChartLineData) chartData; - RoughnessPoint[] dikeGeometry = dikeProfile.DikeGeometry; - Assert.AreEqual(dikeGeometry.Length, dikeProfileChartData.Points.Length); + IEnumerable dikeGeometry = dikeProfile.DikeGeometry; + Assert.AreEqual(dikeGeometry.Count(), dikeProfileChartData.Points.Length); CollectionAssert.AreEqual(dikeGeometry.Select(dg => dg.Point), dikeProfileChartData.Points); string expectedName = $"{dikeProfile.Name} - Dijkprofiel";