diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index b2fb6cabab2e18..b9bd51351bf5bb 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -90,9 +90,9 @@ https://github.com/dotnet/runtime-assets 4aa2a9b60112e056b61295826c2def4956b14bbc - + https://github.com/dotnet/runtime-assets - 4aa2a9b60112e056b61295826c2def4956b14bbc + 205a003b723482863e26e9d29eb7c8513ae3ded1 https://github.com/dotnet/runtime-assets diff --git a/eng/Versions.props b/eng/Versions.props index 515af6c685ea4f..2694f4fc389985 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -82,7 +82,7 @@ 5.0.0-alpha.1.19563.3 5.0.0-beta.20228.1 - 5.0.0-beta.20228.1 + 5.0.0-beta.20251.1 5.0.0-beta.20228.1 5.0.0-beta.20228.1 5.0.0-beta.20228.1 diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs index c11ed0eda0e7cf..98aadfa2be2e30 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs @@ -1374,8 +1374,12 @@ internal struct StartupInput public static StartupInput GetDefault() { + OperatingSystem os = Environment.OSVersion; StartupInput result = default; - result.GdiplusVersion = 1; + + // In Windows 7 GDI+1.1 story is different as there are different binaries per GDI+ version. + bool isWindows7 = os.Platform == PlatformID.Win32NT && os.Version.Major == 6 && os.Version.Minor == 1; + result.GdiplusVersion = isWindows7 ? 1 : 2; // result.DebugEventCallback = null; result.SuppressBackgroundThread = false; result.SuppressExternalCodecs = false; diff --git a/src/libraries/System.Drawing.Common/tests/BitmapTests.cs b/src/libraries/System.Drawing.Common/tests/BitmapTests.cs index f9123c253039c4..e45488a74f8f83 100644 --- a/src/libraries/System.Drawing.Common/tests/BitmapTests.cs +++ b/src/libraries/System.Drawing.Common/tests/BitmapTests.cs @@ -29,6 +29,7 @@ using System.IO; using System.Linq; using System.Runtime.InteropServices; +using Microsoft.DotNet.XUnitExtensions; using Xunit; namespace System.Drawing.Tests @@ -804,6 +805,34 @@ public void GetHicon_Disposed_ThrowsArgumentException() AssertExtensions.Throws(null, () => bitmap.GetHicon()); } + [ConditionalFact(Helpers.IsDrawingSupported)] + [PlatformSpecific(TestPlatforms.Windows)] + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "In .NET Framework we use GDI 1.0")] + public void SaveWmfAsPngDoesntChangeImageBoundaries() + { + if (PlatformDetection.IsWindows7) + { + throw new SkipTestException("GDI+ 1.1 is not supported"); + } + + string output = GetTestFilePath() + ".png"; + using Stream wmfStream = File.OpenRead(Helpers.GetTestBitmapPath("gdiwmfboundariesbug.wmf")); + using Image bitmapFromWmf = Bitmap.FromStream(wmfStream); + bitmapFromWmf.Save(output, ImageFormat.Png); + + using Stream expectedPngStream = File.OpenRead(Helpers.GetTestBitmapPath("gdiwmfboundariesbug-output.png")); + using Image expectedPngBitmap = Bitmap.FromStream(expectedPngStream); + using MemoryStream expectedMemoryStream = new MemoryStream(); + expectedPngBitmap.Save(expectedMemoryStream, ImageFormat.Png); + + using Stream outputPngStream = File.OpenRead(output); + using Image outputPngBitmap = Bitmap.FromStream(outputPngStream); + using MemoryStream outputMemoryStream = new MemoryStream(); + outputPngBitmap.Save(outputMemoryStream, ImageFormat.Png); + + Assert.Equal(expectedMemoryStream.ToArray(), outputMemoryStream.ToArray()); + } + // This test causes an AV on Linux [ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)] [ConditionalFact(Helpers.IsDrawingSupported)] @@ -1091,7 +1120,7 @@ public void SetResolution_Disposed_ThrowsArgumentException() public static IEnumerable LockBits_NotUnix_TestData() { Bitmap bitmap() => new Bitmap(2, 2, PixelFormat.Format32bppArgb); - yield return new object[] { bitmap(), new Rectangle(1, 1, 1,1), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb, 8, 1 }; + yield return new object[] { bitmap(), new Rectangle(1, 1, 1, 1), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb, 8, 1 }; yield return new object[] { bitmap(), new Rectangle(1, 1, 1, 1), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb, 8, 3 }; yield return new object[] { bitmap(), new Rectangle(1, 1, 1, 1), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb, 8, 2 }; diff --git a/src/libraries/System.Drawing.Common/tests/GdiplusTests.cs b/src/libraries/System.Drawing.Common/tests/GdiplusTests.cs index 69a9a84afb2b16..c2719dec150a86 100644 --- a/src/libraries/System.Drawing.Common/tests/GdiplusTests.cs +++ b/src/libraries/System.Drawing.Common/tests/GdiplusTests.cs @@ -2,9 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing.Text; using Xunit; namespace System.Drawing.Tests