Jump to content
  • Advertisement
Sign in to follow this  
Sagito

DX GUI - Getting an image resolution

This topic is 4000 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi... I'm trying to create a GUI/menu system in my DirectX 9.0c application, and I would like to load image files to the interface. That is relatively easy to do using sprites, but I wanted the image file object to throw mouse-over events and to do so, I need to know it's upper-left corner and the image dimensions. Is there any way in DirectX or in Windows API that retrieve these informations about an image, or will I have to create a parser for each and every image file type I want to read? Thanks in advance...

Share this post


Link to post
Share on other sites
Advertisement
You can get the resolution of the back buffer from the IDirect3DDevice*, get the back buffer surface and then the surface details. You can get the size of a texture the same way.

As a word of advice, don't specify the position of controls in pixels, do it in percent accross the screen, then convert the mouse position. This is for the internal representation of pixels BTW, in script files you can specify how you want, so long as you convert. You can deal with differentresolutions more easily this way.

Share this post


Link to post
Share on other sites

Thanks for the quick reply... =)

It worked perfectly. This is what I've done, based on what you said:

 
IDirect3DTexture9* test;
D3DXCreateTextureFromFile(device, L"test.bmp", &test);
D3DSURFACE_DESC descriptor;
test->GetLevelDesc(0, &descriptor);
cout << descriptor.Width << ", " << descriptor.Width << endl;



With which image file types does this work with, btw?

Once again, thanks for your answer, it really helped a lot... (^^,)

Share this post


Link to post
Share on other sites
Quote:
DX SDK Article about D3DXCreateTextureFromFile
This function supports the following file formats: .bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, and .tga. See D3DXIMAGE_FILEFORMAT.


The SDK Docmentation is your friend. Use it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!