Open Shadowblitz16 opened 4 years ago
note this should probably be done with some sort of memory copying instead of looping so its faster
ok, your are right, this overrid is convenient. :+1: i think i will add them to next version.
but i have no idea how to use memory copy to speed up. beacuse i use 4 byte on Color(byte,byte,byte,byte) but use (4 * 4 = 16)byte on Vector4(float,float,float,float). and with more complex situation, it depending on how ImageDataPixelFormat it used,
So, In so many cases, only two are suitable for memory replication, and [x, y] and [y, x] are not considered. So I'm not interested in doing this optimization. :tired_face:
I was using span
public Color[] Flatten(Color[,] v)
{
Color[] value;
var length = v.GetLength(0) * v.GetLength(1);
unsafe
{
fixed (Color* p = v)
{
var span = new Span<Color>(p, length);
var slice = span.Slice(0);
value = slice.ToArray();
}
}
return value;
}
not sure if it works since I never tested it but it would require unsafe. I would suggest postponing this until we actually know that you can wrap unsafe code in a managed library without needing the unsafe option to be checked.
keep this open I will get back to you
please add these overloads