Files
stgsharp/源代码/StgSharp/Graphics/Image.cs
T

49 lines
1.2 KiB
C#

using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Graphics
{
public class Image
{
[StructLayout(LayoutKind.Sequential)]
internal struct ImageInfo
{
internal int width;
internal int height;
internal int channel;
internal IntPtr pixelPtr;
}
internal glHandle pixelArrayHandle;
internal ImageInfo info;
public int Width { get => info.width; }
public int Height { get => info.height; }
public int Channel { get => info.channel; }
//TODO fix the bug
internal Image(ImageInfo information)
{
info = information;
int length = info.width * info.height * info.channel;
pixelArrayHandle = glHandle.Alloc(information.pixelPtr);
}
public unsafe Image()
{
info = new ImageInfo();
}
~Image()
{
Marshal.FreeHGlobal(info.pixelPtr);
}
}
}