支持WebP图像,改用WebP.Net库

croire 3 years ago
parent 47e068e80c
commit 36b6b174e6

@ -55,9 +55,6 @@
<Reference Include="Google.Protobuf, Version=3.19.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.19.1\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="Imazen.WebP, Version=10.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Imazen.WebP.10.0.1\lib\net45\Imazen.WebP.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
@ -97,6 +94,9 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WebP.Net, Version=0.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WebP.Net.0.5.0\lib\net472\WebP.Net.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
@ -363,7 +363,9 @@
<Error Condition="!Exists('..\packages\Brotli.NET.2.1.1\build\Brotli.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Brotli.NET.2.1.1\build\Brotli.NET.targets'))" />
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.112.2\build\net40\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.112.2\build\net40\System.Data.SQLite.Core.targets'))" />
<Error Condition="!Exists('..\packages\Google.Protobuf.Tools.3.19.1\build\Google.Protobuf.Tools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Google.Protobuf.Tools.3.19.1\build\Google.Protobuf.Tools.targets'))" />
<Error Condition="!Exists('..\packages\WebP.Net.0.5.0\build\WebP.Net.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WebP.Net.0.5.0\build\WebP.Net.targets'))" />
</Target>
<Import Project="..\packages\System.Data.SQLite.Core.1.0.112.2\build\net40\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.112.2\build\net40\System.Data.SQLite.Core.targets')" />
<Import Project="..\packages\Google.Protobuf.Tools.3.19.1\build\Google.Protobuf.Tools.targets" Condition="Exists('..\packages\Google.Protobuf.Tools.3.19.1\build\Google.Protobuf.Tools.targets')" />
<Import Project="..\packages\WebP.Net.0.5.0\build\WebP.Net.targets" Condition="Exists('..\packages\WebP.Net.0.5.0\build\WebP.Net.targets')" />
</Project>

@ -1,11 +1,11 @@
using DownKyi.Core.Logging;
using DownKyi.Core.Storage.Database;
using DownKyi.Core.Utils.Encryptor;
using Imazen.WebP;
using System;
using System.Drawing;
using System.IO;
using System.Windows.Media.Imaging;
using WebP.Net;
namespace DownKyi.Core.Storage
{
@ -56,11 +56,8 @@ namespace DownKyi.Core.Storage
{
try
{
byte[] bytes = File.ReadAllBytes(cover);
Imazen.WebP.Extern.LoadLibrary.LoadWebPOrFail();
SimpleDecoder simpleDecoder = new SimpleDecoder();
Bitmap bitmap = simpleDecoder.DecodeFromBytes(bytes, bytes.LongLength);
SimpleDecoder simpleDecoder = new SimpleDecoder(cover);
Bitmap bitmap = simpleDecoder.WebPtoBitmap();
Image thumbnail = bitmap.GetThumbnailImage(width, height, null, IntPtr.Zero);
return StorageUtils.BitmapToBitmapImage(new Bitmap(thumbnail));

@ -1,11 +1,11 @@
using DownKyi.Core.Logging;
using DownKyi.Core.Storage.Database;
using DownKyi.Core.Utils.Encryptor;
using Imazen.WebP;
using System;
using System.Drawing;
using System.IO;
using System.Windows.Media.Imaging;
using WebP.Net;
namespace DownKyi.Core.Storage
{
@ -56,11 +56,8 @@ namespace DownKyi.Core.Storage
{
try
{
byte[] bytes = File.ReadAllBytes(header);
Imazen.WebP.Extern.LoadLibrary.LoadWebPOrFail();
SimpleDecoder simpleDecoder = new SimpleDecoder();
Bitmap bitmap = simpleDecoder.DecodeFromBytes(bytes, bytes.LongLength);
SimpleDecoder simpleDecoder = new SimpleDecoder(header);
Bitmap bitmap = simpleDecoder.WebPtoBitmap();
Image thumbnail = bitmap.GetThumbnailImage(width, height, null, IntPtr.Zero);
return StorageUtils.BitmapToBitmapImage(new Bitmap(thumbnail));

@ -3,7 +3,6 @@
<package id="Brotli.NET" version="2.1.1" targetFramework="net472" />
<package id="Google.Protobuf" version="3.19.1" targetFramework="net472" />
<package id="Google.Protobuf.Tools" version="3.19.1" targetFramework="net472" />
<package id="Imazen.WebP" version="10.0.1" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
<package id="QRCoder" version="1.4.3" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
@ -12,4 +11,5 @@
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net472" />
<package id="WebP.Net" version="0.5.0" targetFramework="net472" />
</packages>
Loading…
Cancel
Save