Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

As you all know, when using a texture in Direct3D we must inform the texture's size when using it as a sprite in a form of a rectangle.

 

What I need to know is how can I retrieve the picture's size which is being assigned to the texture object so that I can create the apropriate rectangle to display the correct texture aspect ratio. Like, if I load a 32x32 picture into a texture object I also need to inform the Sprite.Draw command that the texture is a 32x32 image.

 

Pseucode:

 

//Check the apropriate texture size to use
if the original image's size which was loaded into the current texture is 32x32
    sprite.draw(texture with size 32x32)
else if image size is 128x128
    sprite.draw(texture with size 128x128)
(...)

 

tks for any possible help on this one

Posted

When I load textures, I use the TextureLoader.FromFile method. The last argument I pass is a reference to an ImageInfo class. The ImageInfo gets filled, and you can look at its .Width and .Height values.

 

Also, if you already have the texture loaded, you can do the following:

 

SurfaceDescription sd = texture.GetLevelDescription(0);

 

And look at ds.Width and ds.Height.

 

--Vic--

http://www.flatredball.com

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...