//1.to byte[]
public static byte[] RawSerializeEx(object anything)
{
int rawsize = Marshal.SizeOf(anything);
byte[] rawdatas = new byte[rawsize];
GCHandle handle = GCHandle.Alloc(rawdatas, GCHandleType.Pinned);
IntPtr buffer = handle.AddrOfPinnedObject();
Marshal.StructureToPtr(anything, buffer, false);
handle.Free();
return rawdatas;
}
//2.save png
public void Createtexture()
{
var filePath = _outPutPath + Time.time + ".png";
File.WriteAllBytes(filePath, _finalTexture.EncodeToPNG());
}
//3.to byte[]
Array.ConvertAll(Frame.audioData, new Converter<float, byte>(PointFToPoint));
private static byte PointFToPoint(float resultPixelsValue)
{
return (byte)resultPixelsValue;
}