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數據?