When using this code:
public static Texture2D MakeTexRed(Texture2D tex)
{
Texture2D drawTex = new Texture2D(Game1.graphics.GraphicsDevice, tex.Width, tex.Height);
Color[] data = new Color[tex.Width * tex.Height];
tex.GetData<Color>(data);
for (int i = 0; i < data.Length; i++)
{
data[i].R = (byte)((data[i].R + 255) / 2);
data[i].G /= 2;
data[i].B /= 2;
}
drawTex.SetData(data);
return drawTex;
}
I'm getting this exception:
The type you are using for T in this method is an invalid size for this resource.
The size of the texture I'm using is 64x64 pixel.
When using this line:
Texture2D drawTex = new Texture2D(Game1.graphics.GraphicsDevice, tex.Width, tex.Height, false, SurfaceFormat.Color);
it still doesn't work.
Color
type from a different namespace? It's theMicrosoft.Xna.Framework
namespace? \$\endgroup\$ – MichaelHouse♦ Apr 18 '13 at 16:35GetData()
on the texture being passed in, not the one you're creating. How is the texture being passed in constructed? Where does it come from? \$\endgroup\$ – Cole Campbell Apr 18 '13 at 19:16