Skip to content

Commit 76b4cf9

Browse files
committed
Merge branch 'Development'
2 parents b104c75 + a45c8ad commit 76b4cf9

File tree

91 files changed

+3569
-670
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3569
-670
lines changed
Loading
Loading
Loading

Help/Images/Information4A16_WPF.png

3.94 KB
Loading
Loading
35.1 KB
Loading

Help/Images/ShieldBgr555_WPF.png

22.6 KB
Loading

Help/Images/ShieldRgb24_WPF.png

43.4 KB
Loading

Help/KGySoft.Drawing.chm

259 KB
Binary file not shown.

KGySoft.Drawing.Core.UnitTest/GlobalInitialization.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
#region Usings
1818

19+
#if !WINDOWS && (NET5_0 || NET6_0)
20+
using System;
21+
#endif
22+
1923
using NUnit.Framework;
2024

2125
#endregion
@@ -30,12 +34,13 @@ public class GlobalInitialization
3034
[OneTimeSetUp]
3135
public void Initialize()
3236
{
37+
#if !WINDOWS && (NET5_0 || NET6_0)
38+
AppContext.SetSwitch("System.Drawing.EnableUnixSupport", true);
39+
#endif
40+
3341
#if NET7_0_OR_GREATER && !WINDOWS
3442
Assert.Inconclusive("When targeting .NET 7 or later, executing the tests require Windows. For Unix systems target .NET 6 or earlier.");
3543
#endif
36-
37-
// To make sure that System.Drawing types can be used also on Unix systems
38-
DrawingModule.Initialize();
3944
}
4045

4146
#endregion

KGySoft.Drawing.Core.UnitTest/GlobalSuppressions.cs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System.Diagnostics.CodeAnalysis;
77

8+
[assembly: SuppressMessage("Style", "IDE0017:Simplify object initialization", Justification = "Decided individually")]
89
[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Validated by global initialization")]
910
[assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "Decided individually")]
1011
[assembly: SuppressMessage("Style", "IDE0090:Use 'new(...)'", Justification = "Decided individually")]

KGySoft.Drawing.Core.UnitTest/KGySoft.Drawing.Core.UnitTest.csproj

+30-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<!--<TargetFrameworks>net35;net40;net45;net46;netcoreapp2.0;netcoreapp3.0</TargetFrameworks>-->
5-
<TargetFrameworks>net45;net6.0</TargetFrameworks>
4+
<TargetFrameworks>net35;net40;net45;net46;netcoreapp2.0;netcoreapp3.0</TargetFrameworks>
5+
<!--<TargetFrameworks>net6.0</TargetFrameworks>-->
66

77
<!--For UnitTesting the .NET Standard versions-->
88
<!--<TargetFrameworks>netcoreapp2.0;netcoreapp3.0</TargetFrameworks>-->
@@ -41,7 +41,34 @@
4141
<!-- Project references -->
4242
<ItemGroup>
4343
<ProjectReference Include="..\KGySoft.Drawing.Core\KGySoft.Drawing.Core.csproj" />
44-
<ProjectReference Include="..\Specific\GdiPlus\KGySoft.Drawing\KGySoft.Drawing.csproj" />
44+
</ItemGroup>
45+
46+
<!-- .NET 7.0 or newer references: Unix is no nonger supported -->
47+
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
48+
<PackageReference Include="System.Drawing.Common" Version="7.0.0-preview.4.22229.4" />
49+
</ItemGroup>
50+
51+
<!-- .NET 5.0 or newer references: Unix is supported only by an app context switch (initialized by DrawingModule) -->
52+
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'net6.0'">
53+
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
54+
</ItemGroup>
55+
56+
<!-- Legacy .NET Standard / .NET Core references (they cannot be upgraded, see https://github.com/dotnet/runtime/issues/59032) -->
57+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0' OR '$(TargetFramework)' == 'netcoreapp3.0'">
58+
<PackageReference Include="System.Drawing.Common" Version="5.0.3" />
59+
</ItemGroup>
60+
<ItemGroup>
61+
<Compile Update="Properties\Resources.Designer.cs">
62+
<DesignTime>True</DesignTime>
63+
<AutoGen>True</AutoGen>
64+
<DependentUpon>Resources.resx</DependentUpon>
65+
</Compile>
66+
</ItemGroup>
67+
<ItemGroup>
68+
<EmbeddedResource Update="Properties\Resources.resx">
69+
<Generator>ResXFileCodeGenerator</Generator>
70+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
71+
</EmbeddedResource>
4572
</ItemGroup>
4673

4774
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=_005Fextensions/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

KGySoft.Drawing.Core.UnitTest/UnitTests/Imaging/BitmapDataExtensionsTest.cs

+71-101
Large diffs are not rendered by default.

KGySoft.Drawing.Core.UnitTest/UnitTests/Imaging/BitmapDataFactoryTest.cs

+9-10
Original file line numberDiff line numberDiff line change
@@ -303,30 +303,30 @@ private static void DoCommonCustomBitmapDataTests(string caseName, Size size, IR
303303
AssertAreEqual(bitmapDataDitheredContentDependent, referenceBitmapData, true);
304304

305305
// DrawInto
306-
using IReadableBitmapData icon32 = Icons.Information.ExtractBitmap(new Size(48, 48)).GetReadableBitmapData();
306+
using IReadableBitmapData icon48 = GetInfoIcon48();
307307
Point iconLocation = new Point(10, 10);
308308
Rectangle gradientRectangle = new Rectangle(60, 10, 50, 42);
309309

310310
bitmapDataNonDithered.CopyTo(referenceBitmapData, default, referenceQuantizer);
311-
icon32.DrawInto(referenceBitmapData, iconLocation, referenceQuantizer);
311+
icon48.DrawInto(referenceBitmapData, iconLocation, referenceQuantizer);
312312
alphaGradient.DrawInto(referenceBitmapData, gradientRectangle, referenceQuantizer);
313-
icon32.DrawInto(bitmapDataNonDithered, iconLocation);
313+
icon48.DrawInto(bitmapDataNonDithered, iconLocation);
314314
alphaGradient.DrawInto(bitmapDataNonDithered, gradientRectangle);
315315
SaveBitmapData($"{caseName} DrawInto", bitmapDataNonDithered, testName);
316316
AssertAreEqual(referenceBitmapData, bitmapDataNonDithered, true);
317317

318318
bitmapDataDitheredContentIndependent.CopyTo(referenceBitmapData, default, referenceQuantizer);
319-
icon32.DrawInto(referenceBitmapData, iconLocation, referenceQuantizer, contentIndependentDitherer);
319+
icon48.DrawInto(referenceBitmapData, iconLocation, referenceQuantizer, contentIndependentDitherer);
320320
alphaGradient.DrawInto(referenceBitmapData, gradientRectangle, referenceQuantizer, contentIndependentDitherer);
321-
icon32.DrawInto(bitmapDataDitheredContentIndependent, iconLocation, contentIndependentDitherer);
321+
icon48.DrawInto(bitmapDataDitheredContentIndependent, iconLocation, contentIndependentDitherer);
322322
alphaGradient.DrawInto(bitmapDataDitheredContentIndependent, gradientRectangle, contentIndependentDitherer);
323323
SaveBitmapData($"{caseName} DrawInto independent ditherer", bitmapDataDitheredContentIndependent, testName);
324324
AssertAreEqual(referenceBitmapData, bitmapDataDitheredContentIndependent, true);
325325

326326
bitmapDataDitheredContentDependent.CopyTo(referenceBitmapData, default, referenceQuantizer);
327-
icon32.DrawInto(referenceBitmapData, iconLocation, referenceQuantizer, contentDependentDitherer);
327+
icon48.DrawInto(referenceBitmapData, iconLocation, referenceQuantizer, contentDependentDitherer);
328328
alphaGradient.DrawInto(referenceBitmapData, gradientRectangle, referenceQuantizer, contentDependentDitherer);
329-
icon32.DrawInto(bitmapDataDitheredContentDependent, iconLocation, contentDependentDitherer);
329+
icon48.DrawInto(bitmapDataDitheredContentDependent, iconLocation, contentDependentDitherer);
330330
alphaGradient.DrawInto(bitmapDataDitheredContentDependent, gradientRectangle, contentDependentDitherer);
331331
SaveBitmapData($"{caseName} DrawInto dependent ditherer", bitmapDataDitheredContentDependent, testName);
332332
//AssertAreEqual(referenceBitmapData, bitmapDataDitheredContentDependent, true); //- Due to serpentine processing the resizing draw can be different on 32bpp reference and actual bitmap data
@@ -476,9 +476,8 @@ public void SupportedFormatsConsistencyTest(KnownPixelFormat pixelFormat)
476476
{
477477
// 0.) Reference: native to self-allocating managed bitmap data
478478
IReadWriteBitmapData reference;
479-
using (Bitmap bmp = Icons.Information.ExtractBitmap(new Size(256, 256)))
479+
using (var bmpData = GetInfoIcon256())
480480
{
481-
using var bmpData = bmp.GetReadWriteBitmapData();
482481
int bpp = pixelFormat.ToBitsPerPixel();
483482
reference = bmpData.Clone(pixelFormat, bpp <= 8 ? OptimizedPaletteQuantizer.Wu(1 << bpp, Color.Silver, (byte)(bpp == 1 ? 0 : 128)) : null, OrderedDitherer.Bayer8x8);
484483
}
@@ -578,7 +577,7 @@ public void CustomIndexedBitmapDataTest(string testName, PixelFormatInfo pixelFo
578577
int maxColors = 1 << bpp;
579578
foreach (var getQuantizer in new Func<int, Color, byte, OptimizedPaletteQuantizer>[] { OptimizedPaletteQuantizer.Octree, OptimizedPaletteQuantizer.MedianCut, OptimizedPaletteQuantizer.Wu })
580579
{
581-
using IReadableBitmapData optimizedReferenceBitmapData = Icons.Information.ExtractBitmap(new Size(256, 256))!.GetReadableBitmapData()
580+
using IReadableBitmapData optimizedReferenceBitmapData = GetInfoIcon256()
582581
.Clone(bpp <= 8 ? KnownPixelFormat.Format8bppIndexed : KnownPixelFormat.Format32bppArgb, getQuantizer.Invoke(maxColors, Color.Silver, (byte)(bpp == 1 ? 0 : 128)), OrderedDitherer.Bayer8x8);
583582
size = optimizedReferenceBitmapData.GetSize();
584583
stride = pixelFormat.GetByteWidth(size.Width);

0 commit comments

Comments
 (0)