0
Ce code crée une texture avec un canal alpha différent de zéro.XNA. Texture2D. SetData. Wrong Alpha Chanel
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);
La couleur devient légèrement transparente. Mais, environ, à la valeur de 0.5f. Pourquoi cela arrive-t-il?
P.S. Color.Transparent fonctionne correctement, mais je dois calculer un canal alpha par programmation, par exemple:
colorData[index] = new Color(1f, 0f, 0f, 1f - temp);