允许net5以上可选gdi

This commit is contained in:
dengzaiju 2024-06-07 09:58:49 +08:00
parent a942ee6c2e
commit 2cc2a6d931
10 changed files with 29 additions and 18 deletions

View File

@ -43,7 +43,7 @@ namespace CPF.Skia
var size = new PixelSize((int)Math.Round(cSize.Width * Root.RenderScaling), (int)Math.Round(cSize.Height * Root.RenderScaling)); var size = new PixelSize((int)Math.Round(cSize.Width * Root.RenderScaling), (int)Math.Round(cSize.Height * Root.RenderScaling));
var skia = dc as SkiaDrawingContext; var skia = dc as SkiaDrawingContext;
var _gl = skia.GlContext; var _gl = skia?.GlContext;
if (_gl == null) if (_gl == null)
{ {
return; return;

View File

@ -52,6 +52,16 @@
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Drawing.Common">
<Version>8.0.6</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5'">
<PackageReference Include="System.Drawing.Common">
<Version>8.0.6</Version>
</PackageReference>
</ItemGroup>
<PropertyGroup> <PropertyGroup>
<DefineConstants Condition="'$(TargetFramework)'=='net40'">Net4</DefineConstants> <DefineConstants Condition="'$(TargetFramework)'=='net40'">Net4</DefineConstants>

View File

@ -1,4 +1,4 @@
#if Net4 //#if Net4
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@ -83,4 +83,4 @@ namespace CPF.GDIPlus
} }
} }
} }
#endif //#endif

View File

@ -1,4 +1,4 @@
#if Net4 //#if Net4
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -91,4 +91,4 @@ namespace CPF.GDIPlus
} }
} }
} }
#endif //#endif

View File

@ -1,4 +1,4 @@
#if Net4 //#if Net4
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@ -166,4 +166,4 @@ namespace CPF.GDIPlus
} }
} }
} }
#endif //#endif

View File

@ -1,4 +1,4 @@
#if Net4 //#if Net4
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@ -802,4 +802,4 @@ namespace CPF.GDIPlus
} }
#endif //#endif

View File

@ -1,4 +1,4 @@
#if Net4 //#if Net4
using CPF.Platform; using CPF.Platform;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -20,7 +20,8 @@ namespace CPF.GDIPlus
/// <summary> /// <summary>
/// GDI+不支持GPU加速 /// GDI+不支持GPU加速
/// </summary> /// </summary>
public override bool UseGPU { get => false; set => throw new NotSupportedException("GDI+不支持GPU加速"); } private bool _useGPU = false;
public override bool UseGPU { get => _useGPU; set => _useGPU = false; }
public override IImageImpl ImageFromFile(string path) public override IImageImpl ImageFromFile(string path)
{ {
@ -333,4 +334,4 @@ namespace CPF.GDIPlus
} }
} }
} }
#endif //#endif

View File

@ -1,4 +1,4 @@
#if Net4 //#if Net4
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
@ -255,4 +255,4 @@ namespace CPF.GDIPlus
} }
} }
} }
#endif //#endif

View File

@ -1,4 +1,4 @@
#if Net4 //#if Net4
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
@ -304,4 +304,4 @@ namespace CPF.GDIPlus
} }
} }
} }
#endif //#endif

View File

@ -1,4 +1,4 @@
#if Net4 //#if Net4
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@ -70,4 +70,4 @@ namespace CPF.GDIPlus
} }
} }
#endif //#endif