You can get file information using this call:
D3DXIMAGE_INFO info; D3DXGetImageInfoFromFile(file_name, &info);
Although, knowing the initial size of the texture, you still get its size at boot time. This will obviously affect the quality of the texture. Resizing the texture doesn't really matter when you apply it on the grid (it will be resized anyway), but this can be a problem for drawing sprites. To get around this, I could suggest creating a surface by loading it through the D3DXLoadSurfaceFromFile , and then copying it into a βpow2β sized texture.
And offtopic: are you definitely sure about the capabilities of your card? Your do card may actually support arbitrary texture sizes, but you are using D3DXCreateTextureFromFile() , which uses pow2 values ββthrough deafult. To avoid this, try using the advanced version of this procedure:
D3DTexture* texture; D3DXCreateTextureFromFileEx( device, file_name, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &texture);
If your hardware suppors texture is non-pow2 you upload the file as is. If the hardware is not able to process it, and the method will not work.
source share