Updated sample and tests to use new texture loading APIs

このコミットが含まれているのは:
Sergio Pedri committed 2021-05-12 11:33:05 +02:00
1 親 41d4ae683f
コミット d1a2c667dd
6ファイル変更
+7 -40

検索条件に一致するファイルはありません

-18
ファイルの表示
@@ -12,24 +12,6 @@ namespace ComputeSharp.Tests.Extensions
/// </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);
Assert.IsTrue(image.TryGetSinglePixelSpan(out Span<ImageSharpRgba32> span));
Span<Rgba32> pixels = MemoryMarshal.Cast<ImageSharpRgba32, Rgba32>(span);
return device.AllocateReadOnlyTexture2D<Rgba32, Float4>(pixels, image.Width, image.Height);
}
/// <summary>
/// Creates a new <see cref="Image{TPixel}"/> instance with the specified texture data.
/// </summary>