I would like to draw a texture in a rectangle that is smaller than the texture, normally the texture will be scaled to fill the rectangle, which results in a squished image. I want to draw it to fit.
For example, if the green stuff is the Texture, I would like to draw only the stuff in the red rectangle.
I already tried to get the color data from the base texture and create a new one, filled with the part from the base.
Color[] colorData = new Color[progressRectangle.Width * progressRectangle.Height];
Color[] sourceColorData = new Color[t2dBack.Width * t2dBack.Height];
t2dBack.GetData(sourceColorData);
for (int x = 0; x < progressRectangle.Width; x++)
{
for (int y = 0; y < progressRectangle.Height; y++)
{
colorData[x + progressRectangle.Width * y] = sourceColorData[x + t2dBack.Width * y];
}
}
t2dBackDraw.SetData(colorData);
but that just results in gibberish.
Is there an easy way to accomplish this?
kind regards