mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Further optimize the gallery
This commit is contained in:
parent
87c794dd57
commit
402f80e6a4
@ -10,11 +10,7 @@
|
||||
<Grid Width="540" Height="480" RowDefinitions="Auto, *, 40" ColumnDefinitions="*, Auto">
|
||||
<Border Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" BorderThickness="0, 0, 0, 1">
|
||||
<Grid ClipToBounds="True">
|
||||
<Viewbox Height="340" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Stretch="UniformToFill">
|
||||
<Image x:Name="ModListImage" />
|
||||
</Viewbox>
|
||||
|
||||
<Image x:Name="ModListImage" />
|
||||
<Label Margin="10, 242, 0, 0" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
x:Name="VersionText" />
|
||||
</Grid>
|
||||
|
@ -167,7 +167,7 @@ public class BrowseItemViewModel : ViewModelBase, IActivatableViewModel
|
||||
|
||||
public async Task LoadListImage()
|
||||
{
|
||||
Image = await _imageCache.From(ImageUri);
|
||||
Image = await _imageCache.From(ImageUri, 540, 300);
|
||||
}
|
||||
|
||||
public async Task<ModListState> GetState()
|
||||
|
@ -28,16 +28,18 @@ public class ImageCache
|
||||
_limiter = limiter;
|
||||
}
|
||||
|
||||
public async Task<IBitmap> From(Uri uri)
|
||||
public async Task<IBitmap> From(Uri uri, int width, int height)
|
||||
{
|
||||
var hash = (await Encoding.UTF8.GetBytes(uri.ToString()).Hash()).ToHex();
|
||||
var file = _configuration.ImageCacheLocation.Combine(hash);
|
||||
var file = _configuration.ImageCacheLocation.Combine(hash + $"_{width}_{height}");
|
||||
|
||||
if (!file.FileExists())
|
||||
{
|
||||
using var job = await _limiter.Begin("Loading Image", 0, CancellationToken.None);
|
||||
|
||||
var wdata = await _client.GetByteArrayAsync(uri);
|
||||
await file.WriteAllBytesAsync(wdata);
|
||||
return new Bitmap(new MemoryStream(wdata));
|
||||
var resized = SKBitmap.Decode(wdata).Resize(new SKSizeI(width, height), SKFilterQuality.High);
|
||||
await file.WriteAllBytesAsync(resized.Encode(SKEncodedImageFormat.Webp, 90).ToArray());
|
||||
}
|
||||
|
||||
var data = await file.ReadAllBytesAsync();
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework Condition=" '$(OS)' == 'Windows_NT'">net6.0-windows</TargetFramework>
|
||||
@ -50,7 +50,7 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="AferBuild" AfterTargets="Build" Condition="!Exists('$(ProjectDir)$(OutDir)libcef.dll')">
|
||||
<Target Name="AferBuild" AfterTargets="Build" Condition="!Exists('$(ProjectDir)$(OutDir)swiftshader')">
|
||||
<Message Text="Downloading Cef" />
|
||||
<Exec Command="dotnet run --project $(ProjectDir)../Wabbajack.CLI/Wabbajack.CLI.csproj -- download-cef -f $(ProjectDir)$(OutDir)" />
|
||||
</Target>
|
||||
|
Loading…
Reference in New Issue
Block a user