lyra-wasm-scripting-test/guests/csharp/dotnet-guest-test/LyraApi/Asset/ImageHandle.cs

28 lines
779 B
C#
Raw Permalink Normal View History

using ExampleWorld.wit.imports.lyra.api;
namespace LyraApi.Asset;
public class ImageHandle(IAsset.ImageHandle handle) : IAssetHandle
{
internal IAsset.ImageHandle inner = handle;
public uint? Height => inner.Height();
public uint? Width => inner.Width();
public static object? FromRawHandle(UntypedHandle untypedHandle)
{
var handle = IAsset.ImageHandle.FromRawHandle(untypedHandle.inner);
return handle != null ? new ImageHandle(handle) : null;
}
/// <summary>
/// Get the image's pixels as native endian bytes.
/// </summary>
///
/// Keep in mind that this does copy the image's pixels from the host.
/// This is pretty slow.
public byte[]? GetImageBytes()
{
return inner.GetBytes();
}
}