DX GUI - Getting an image resolution

Started by
2 comments, last by sirob 16 years, 8 months ago
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...
http://sagito.wordpress.com
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.

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... (^^,)

http://sagito.wordpress.com
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.
Sirob Yes.» - status: Work-O-Rama.

This topic is closed to new replies.

Advertisement