1
我想从位图制作Texture2D。我有C#Texture2D SetData ARGB?
Texture2D BitmapToTexture(Bitmap img)
{
var ret = new Texture2D(Game.GraphicsDevice, img.Width, img.Height);
var bd = img.LockBits(new Rectangle(0, 0, img.Width, img.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
int[] bytes = new int[img.Width * img.Height];
Marshal.Copy(bd.Scan0, bytes, 0, bytes.Length);
ret.SetData(bytes);
img.UnlockBits(bd);
return ret;
}
问题是SetData出于某种原因期待ABGR。有没有办法让SetData 获取ARGB数据?