using System;
using System.Runtime.InteropServices;
using NvAPIWrapper.Native.Attributes;
using NvAPIWrapper.Native.General.Structures;
using NvAPIWrapper.Native.Helpers;
using NvAPIWrapper.Native.Interfaces;
namespace NvAPIWrapper.Native.Display.Structures
{
///
[StructLayout(LayoutKind.Sequential, Pack = 8)]
[StructureVersion(1)]
public struct ScanOutIntensityV1 : IDisposable, IInitializable, IScanOutIntensity
{
internal StructureVersion _Version;
internal uint _Width;
internal uint _Height;
internal IntPtr _BlendingTexture;
///
/// Creates a new instance of .
///
/// The width of the input texture.
/// The height of the input texture
/// The array of floating values building an intensity RGB texture.
public ScanOutIntensityV1(uint width, uint height, float[] blendingTexture)
{
if (blendingTexture?.Length != width * height * 3)
{
throw new ArgumentOutOfRangeException(nameof(blendingTexture));
}
this = typeof(ScanOutIntensityV1).Instantiate();
_Width = width;
_Height = height;
_BlendingTexture = Marshal.AllocHGlobal((int) (width * height * 3 * sizeof(float)));
Marshal.Copy(blendingTexture, 0, _BlendingTexture, blendingTexture.Length);
}
///
public uint Width
{
get => _Width;
}
///
public uint Height
{
get => _Height;
}
///
public float[] BlendingTexture
{
get
{
var floats = new float[_Width * _Height * 3];
Marshal.Copy(_BlendingTexture, floats, 0, floats.Length);
return floats;
}
}
///
public void Dispose()
{
Marshal.FreeHGlobal(_BlendingTexture);
}
}
}