Skip to content

Commit ceb6747

Browse files
committed
更新
1 parent 64c360b commit ceb6747

File tree

8 files changed

+19
-27
lines changed

8 files changed

+19
-27
lines changed

src/Pixeval.Extensions.Upscaler/ExtensionsHost.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Pixeval.Extensions.Upscaler;
1313

1414
[GeneratedComClass]
15-
[Guid("15946DBC-7928-4CF9-B63D-D5340756235E")]
1615
public partial class ExtensionsHost : ExtensionsHostBase
1716
{
1817
public static string TempDirectory { get; private set; } = "";

src/Pixeval.Extensions.Upscaler/Pixeval.Extensions.Upscaler.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<LangVersion>preview</LangVersion>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<PublishAot>true</PublishAot>
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Pixeval.Extensions.SDK" Version="4.3.3" />
12+
<PackageReference Include="Pixeval.Extensions.SDK" Version="4.3.3.2" />
1313

1414
<EmbeddedResource Include="Resources/logo.png" Link="logo.png" LogicalName="logo" />
1515
</ItemGroup>

src/Pixeval.Extensions.Upscaler/Properties/PublishProfiles/FolderProfile.pubxml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
66
<PropertyGroup>
77
<Configuration>Release</Configuration>
88
<Platform>Any CPU</Platform>
9-
<PublishDir>bin\Release\net8.0\publish\win-x64\</PublishDir>
9+
<PublishDir>bin\Release\net9.0\publish\win-x64\</PublishDir>
1010
<PublishProtocol>FileSystem</PublishProtocol>
1111
<_TargetId>Folder</_TargetId>
12-
<TargetFramework>net8.0</TargetFramework>
12+
<TargetFramework>net9.0</TargetFramework>
1313
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
14-
<SelfContained>false</SelfContained>
14+
<SelfContained>true</SelfContained>
1515
<PublishSingleFile>false</PublishSingleFile>
1616
<PublishReadyToRun>false</PublishReadyToRun>
1717
</PropertyGroup>

src/Pixeval.Extensions.Upscaler/Settings/UpscalerModelSettingExtension.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
// Licensed under the GPL v3 License.
33

44
using System;
5-
using System.Runtime.InteropServices;
65
using System.Runtime.InteropServices.Marshalling;
76
using FluentIcons.Common;
87
using Pixeval.Extensions.SDK.Settings;
98

109
namespace Pixeval.Extensions.Upscaler.Settings;
1110

1211
[GeneratedComClass]
13-
[Guid("AD1BCDA9-55C7-4FA0-92F6-114E465E2F5F")]
1412
public partial class UpscalerModelSettingExtension : EnumSettingsExtensionBase
1513
{
1614
public override Symbol Icon => Symbol.EyeTracking;

src/Pixeval.Extensions.Upscaler/Settings/UpscalerOutputTypeSettingExtension.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
// Licensed under the GPL v3 License.
33

44
using System;
5-
using System.Runtime.InteropServices;
65
using System.Runtime.InteropServices.Marshalling;
76
using FluentIcons.Common;
87
using Pixeval.Extensions.SDK.Settings;
98

109
namespace Pixeval.Extensions.Upscaler.Settings;
1110

1211
[GeneratedComClass]
13-
[Guid("1C03FD87-A5C8-4B45-95D7-6B11F0BBC000")]
1412
public partial class UpscalerOutputTypeSettingExtension : EnumSettingsExtensionBase
1513
{
1614
public override Symbol Icon => Symbol.ImageGlobe;

src/Pixeval.Extensions.Upscaler/Settings/UpscalerScaleRatioSettingExtension.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
// Copyright (c) Pixeval.Extensions.Upscaler.
22
// Licensed under the GPL v3 License.
33

4-
using System.Runtime.InteropServices;
54
using System.Runtime.InteropServices.Marshalling;
65
using FluentIcons.Common;
76
using Pixeval.Extensions.SDK.Settings;
87

98
namespace Pixeval.Extensions.Upscaler.Settings;
109

1110
[GeneratedComClass]
12-
[Guid("6D184CD5-3926-4294-95AC-5F643D5D9CF9")]
1311
public partial class UpscalerScaleRatioSettingExtension : IntSettingsExtensionBase
1412
{
1513
public override Symbol Icon => Symbol.RatioOneToOne;

src/Pixeval.Extensions.Upscaler/Transformers/UpscaleImageTransformerExtension.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
// Copyright (c) Pixeval.Extensions.Upscaler.
22
// Licensed under the GPL v3 License.
33

4-
using System.Runtime.InteropServices;
54
using System.Runtime.InteropServices.Marshalling;
65
using System.Threading.Tasks;
6+
using FluentIcons.Common;
77
using Pixeval.Extensions.Common;
88
using Pixeval.Extensions.SDK.Transformers;
99

1010
namespace Pixeval.Extensions.Upscaler.Transformers;
1111

1212
[GeneratedComClass]
13-
[Guid("0628396E-7A74-4EBA-AD7F-C76892FB8041")]
1413
public partial class UpscaleImageTransformerExtension : ImageTransformerExtensionBase
1514
{
1615
public override void OnExtensionLoaded()
@@ -25,4 +24,13 @@ public override void OnExtensionUnloaded()
2524
{
2625
return (await ExtensionsHost.Upscaler.UpscaleAsync(originalStream)).ToIStream();
2726
}
27+
28+
/// <inheritdoc />
29+
public override Symbol Icon => Symbol.ImageSparkle;
30+
31+
/// <inheritdoc />
32+
public override string Label => "提升画质";
33+
34+
/// <inheritdoc />
35+
public override string Description => Label;
2836
}

src/Pixeval.Extensions.Upscaler/Upscaler.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,14 @@ public async Task<Stream> UpscaleAsync(IStream stream)
4141
var id = Guid.NewGuid().ToString();
4242

4343
var tempFilePath = Path.Combine(ExtensionsHost.TempDirectory, id);
44-
stream.Seek(0, SeekOrigin.Begin, out _);
44+
stream.Seek(0, SeekOrigin.Begin);
4545

4646
// scoped-using is obligatory here, otherwise the file will be locked and the process will not be able to access it
4747

48-
await using (var tempStream = IoHelper.OpenAsyncWrite(tempFilePath))
49-
{
50-
var buffer = new byte[4096];
51-
while (true)
52-
{
53-
stream.Read(buffer, (uint)buffer.Length, out var bytesRead);
54-
if (bytesRead is 0)
55-
break;
56-
await tempStream.WriteAsync(buffer);
57-
}
58-
}
48+
await using (var tempStream = IoHelper.OpenAsyncWrite(tempFilePath))
49+
await stream.CopyToAsync(tempStream.ToIStream());
5950

60-
stream.Seek(0, SeekOrigin.Begin, out _);
51+
stream.Seek(0, SeekOrigin.Begin);
6152

6253
var modelParam = Model switch
6354
{

0 commit comments

Comments
 (0)