public static byte[] ConvertTo32bit(byte[] buff, int w, int h)
{
if (buff.Length != (w * h * 3))
throw new ArgumentException("Buffer length is not equivalent to a 24-bit texture length");
byte[] val = new byte[w * h * 4];
for (int i = 0; i < w * h; i++)
{
Array.Copy(buff, i * 3, val, i * 4, 3);
val[(i * 4) + 3] = 0xFF;
}
return val;
}
}