0
此代碼創建一個非零的alpha通道的紋理。XNA。的Texture2D。 SetData的。錯誤的Alpha香奈爾
Texture2D result = new Texture2D(Program.MainThread.GraphicsDevice, (Int32)texture_size, (Int32)texture_size);
Color[ ] colorData = new Color[result.Width * result.Height];
for (UInt32 x = 0; x < result.Width; x++) {
for (UInt32 y = 0; y < result.Height; y++) {
UInt32 index = (UInt32)(x * result.Width + y);
colorData[index] = new Color(1f, 0f, 0f, 0f);
}
}
result.SetData(colorData);
顏色變得稍微透明。但是,大約爲0.5f的值。這是爲什麼發生?
P.S. Color.Transparent正常工作,但我必須通過編程計算的alpha通道,例如:
colorData[index] = new Color(1f, 0f, 0f, 1f - temp);