I am trying to Implement a Minimap for my game and for each Texture I want the avg color to paint the minimap.
so far I've this:
public Color GetAvgColor(Texture2D tex)
{
Color[] data = new Color[tex.Width*tex.Height];
Color sum = Color.Black;
int amount = 0;
tex.GetData<Color>(data);
foreach (Color c in data)
{
sum.R += c.R;
sum.G += c.G;
sum.B += c.B;
++amount;
}
return new Color(sum.R / amount, sum.G / amount, sum.B / amount); ;
}
I didn't tested with Colored Textures because my terrain textures are DXTCompressed and MipMapped.
The problem is with GetData:
{"The type you are using for T in this method is an invalid size for this resource."}
Is that possible to Get the Average Color of a DXTCompressed Texture?
Thanks ;-)