Reputation: 83
For some reason my textures look strange when I try to render them. XNA grabs the bottom row of pixels and stretches them upwards.
Real image:
What is rendered:
I use this function to render my image
// NOTE: c is a instance of my control class that contains textures etc.
Rectangle rect = c.Texture.Bounds;
rect.Offset(Convert.ToInt16(c.position.X), Convert.ToInt16(c.position.Y));
spriteBatch.Draw(c.Texture, c.position, rect, Color.White, 0F, new Vector2(), 1F, SpriteEffects.None, 1F);
Can someone please tell me what I'm doing wrong?
Thanks in advance.
Upvotes: 0
Views: 209
Reputation: 36537
Looks like you're somehow screwing up texture coordinates (i.e. the whole sprite using the lower border of the texture while also screwing up the horizontal scaling. What's your intention for the call to rect.Offset()
? The rectangle describes what part of the texture to draw as a sprite, not where to draw that sprite. If that isn't the reason or solution, we need more information, e.g. what v.X
or v.Y
are.
Upvotes: 1