Fix typo in ToFloatBuffer

This commit is contained in:
YoshiRulz 2020-01-23 15:54:26 +10:00
parent abba7fbb78
commit 751ef54f4f
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 4 additions and 5 deletions

View File

@ -15,8 +15,7 @@
var buffer = new byte[size]; var buffer = new byte[size];
while (len > 0) while (len > 0)
{ {
var todo = Math.Min(len, size); var n = src.Read(buffer, 0, (int) Math.Min(len, size));
var n = src.Read(buffer, 0, (int) todo);
dest.Write(buffer, 0, n); dest.Write(buffer, 0, n);
len -= n; len -= n;
} }
@ -134,9 +133,9 @@
public static float[] ToFloatBuffer(this byte[] buf) public static float[] ToFloatBuffer(this byte[] buf)
{ {
var len = buf.Length / 4; var len = buf.Length;
var ret = new float[len]; var ret = new float[len / 4];
Buffer.BlockCopy(buf, 0, ret, 0, len); //TODO bug? the last arg should be in bytes Buffer.BlockCopy(buf, 0, ret, 0, len);
return ret; return ret;
} }