daily update on 20240226 by nitload youmu
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user