Original Post
Hi there.
This is my problem.
I got one big texture consisting of many small tiles.
When I click somewhere on this texture I want to highlight that area and I want to "extract" the selected part of the texture.
The highlighting work fine. The problem comes when I am to copy the selected part of the texture into a smaller one.
The code looks something like this
private void Extract_Texture(Rectangle rect)
{
int[] colorData = new int[rect.Width * rect.Height];
//Get data from the big texture
_texture.GetData(0, rect, colorData, 0, (rect.Width * rect.Height));
//Create the small texture
_choosenTexture = new Texture2D(GraphicsDevice, rect.Width, rect.Height);
//Place texturedata in the small texture
_choosenTexture.SetData(colorData);
}
It looks like it would work but when I try to place the texture somewhere on the game field it show's nothing.
All help would be appreciated.
*EDIT*
Solved by setting the correct SurfaceFormat.
[Edited by - ThereWillBeGame on August 15, 2010 8:26:21 AM]
This is my problem.
I got one big texture consisting of many small tiles.
When I click somewhere on this texture I want to highlight that area and I want to "extract" the selected part of the texture.
The highlighting work fine. The problem comes when I am to copy the selected part of the texture into a smaller one.
The code looks something like this
private void Extract_Texture(Rectangle rect)
{
int[] colorData = new int[rect.Width * rect.Height];
//Get data from the big texture
_texture.GetData(0, rect, colorData, 0, (rect.Width * rect.Height));
//Create the small texture
_choosenTexture = new Texture2D(GraphicsDevice, rect.Width, rect.Height);
//Place texturedata in the small texture
_choosenTexture.SetData(colorData);
}
It looks like it would work but when I try to place the texture somewhere on the game field it show's nothing.
All help would be appreciated.
*EDIT*
Solved by setting the correct SurfaceFormat.
[Edited by - ThereWillBeGame on August 15, 2010 8:26:21 AM]