Switched WinUI sample to use new WIC texture loading APIs
このコミットが含まれているのは:
1 親
a2d137d26b
コミット
0ff75fe246
3ファイル変更
+1
-35
検索条件に一致するファイルはありません
-1
@@ -35,7 +35,6 @@
|
||||
<PackageReference Include="Microsoft.ProjectReunion" Version="0.5.6" />
|
||||
<PackageReference Include="Microsoft.ProjectReunion.Foundation" Version="0.5.6" />
|
||||
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="0.5.6" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.3" />
|
||||
<Manifest Include="$(ApplicationManifest)" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
using SixLabors.ImageSharp;
|
||||
using ImageSharpRgba32 = SixLabors.ImageSharp.PixelFormats.Rgba32;
|
||||
|
||||
namespace ComputeSharp.SwapChain.WinUI.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper class for loading images into resources.
|
||||
/// </summary>
|
||||
public static class ImagingExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Allocates a new <see cref="ReadOnlyTexture2D{T, TPixel}"/> instance with the specified texture data.
|
||||
/// </summary>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance to allocate the texture for.</param>
|
||||
/// <param name="path">The path of the texture to load.</param>
|
||||
/// <returns>A texture with the data from the image at the specified path.</returns>
|
||||
[Pure]
|
||||
public static ReadOnlyTexture2D<Rgba32, Float4> LoadTexture(this GraphicsDevice device, string path)
|
||||
{
|
||||
using Image<ImageSharpRgba32> image = Image.Load<ImageSharpRgba32>(path);
|
||||
|
||||
_ = image.TryGetSinglePixelSpan(out Span<ImageSharpRgba32> span);
|
||||
|
||||
Span<Rgba32> pixels = MemoryMarshal.Cast<ImageSharpRgba32, Rgba32>(span);
|
||||
|
||||
return device.AllocateReadOnlyTexture2D<Rgba32, Float4>(pixels, image.Width, image.Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using ComputeSharp.SwapChain.Shaders;
|
||||
using ComputeSharp.SwapChain.WinUI.Extensions;
|
||||
using ComputeSharp.WinUI;
|
||||
using Windows.ApplicationModel;
|
||||
|
||||
@@ -24,7 +23,7 @@ namespace ComputeSharp.SwapChain.WinUI.Shaders.Runners
|
||||
{
|
||||
string filename = Path.Combine(Package.Current.InstalledLocation.Path, "Images", "Textures", "RustyMetal.png");
|
||||
|
||||
this.texture = Gpu.Default.LoadTexture(filename);
|
||||
this.texture = Gpu.Default.LoadReadOnlyTexture2D<Rgba32, Float4>(filename);
|
||||
}
|
||||
|
||||
Gpu.Default.ForEach(texture, new ContouredLayers((float)timespan.TotalSeconds, this.texture));
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする