daily update on 20240226 by nitload youmu

This commit is contained in:
YoumuLiu
2024-02-27 00:43:29 +08:00
parent a2241a5a58
commit 06e39f7a31
543 changed files with 230273 additions and 21423 deletions
+5 -30
View File
@@ -1,4 +1,5 @@
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -20,46 +21,23 @@ namespace StgSharp.Graphics
internal IntPtr pixelPtr;
}
internal byte[] pixelArray;
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;
pixelArray = new byte[length];
Marshal.Copy(
source: info.pixelPtr,
destination: pixelArray,
startIndex: 0,
length: length
);
}
internal byte[] PixelArray
{
get
{
if (pixelArray == null)
{
pixelArray = new byte[info.width * info.height * info.channel];
Marshal.Copy(source: info.pixelPtr, destination: pixelArray,
startIndex: 0, length: info.width * info.height * info.channel);
Marshal.FreeHGlobal(info.pixelPtr);
}
return pixelArray;
}
pixelArrayHandle = glHandle.Alloc(information.pixelPtr);
}
public unsafe Image()
{
#if NET5_0_OR_GREATER
Unsafe.SkipInit(out pixelArray);
#endif
info = new ImageInfo();
}
@@ -67,8 +45,5 @@ namespace StgSharp.Graphics
{
Marshal.FreeHGlobal(info.pixelPtr);
}
}
}
}