# Getting Rendered Sprite Size

I need the rendered dimensions of a sprite, I'm calling Draw in the class below:

public class Ship
{
public Ship(Texture2D texture)
{
Width = texture.Width;
Height = texture.Height;

Texture = texture;
}

public int Width { get; set; }

public int Height { get; set; }

public float Scale { get; set; }

public Vector2 Position { get; set; }

public Texture2D Texture { get; }

public Rectangle Rectangle => new Rectangle((int)Position.X, (int) Position.Y, Width, Height);

public void Draw(SpriteBatch batch)
{
var origin = new Vector2(Texture.Width / 2, Texture.Height / 2);
var scale = new Vector2(Scale, Scale);

batch.Draw(Texture, Position, null, Color.White,
rotation,
origin,
scale,
SpriteEffects.None, 0f);
}
}


The problem is Width and Height are based off the source (see the constructor) Texture size, so after drawing they are not actual dimensions. Is there away to determine the scaled sprite size?

Side note: I'm using these dimension to detect if an sprite was clicked on by the mouse. Maybe there is a better way to detect clicks?

• It's actually not the most trivial thing to do to be honest. Quite some time ago I solved this problem in the MonoGame.Extended Sprite class which you're welcome to borrow the code from. – craftworkgames Jul 3 '20 at 22:27
• @craftworkgames I actually discovered that (your?) library last night, its saving me a ton of time, thanks! – mxmissile Jul 4 '20 at 4:36
• It's unclear to me how Texture.Width * Scale (and likewise for height) differs from what you need in this situation. Can you clarify what other effects are modifying the rendered size of your asset? It doesn't look like you have 3D perspective to contend with here... – DMGregory Jul 7 '20 at 21:47

public RectangleF GetBoundingRectangle()