DirectX8 Image Quality

Started by
9 comments, last by Cambo_frog 18 years, 9 months ago
I am trying to upload images into my game so that they are of good quality when they are displayed on the screen. Whenever I upload them using D3DXLoadSurfaceFromFile or D3DXCreateTextureFromFileEx, I am losing quality and the images do not look nearly as good when they are in the game. How do I put high quality images into my game?
Advertisement
Are your textures powers of two? What kind of quality are they losing? What are you doing with the textures (using them as backgrounds, maybe?)?
_______________________________________________________________________Hoo-rah.
I forced this problem a few months ago. I used the textures as a fullscreen backround, so the whole texture was mmapped on a screen-size quad. The problem here is in the way how texels are mapped to pixels on screen.

This article describes the problem and solution http://nexe.gamedev.net/directKnowledge/default.asp?p=Mapping%20Texels%20To%20Pixels .
Can you ignore this when using Draw2D?

[Edited by - Daniel Miller on July 19, 2005 5:11:16 PM]
I am using them as tiles in the game. I am having the same problem with Surfaces. You showed me how to fix this problem with textures, but how do I fix it for surfaces? Am I supposed to be using a certain file format (jpeg, bmp, png, etc...) ? Does the D3DFormat matter? here is a typical call to create a texture

hResult = D3DXCreateTextureFromFileEx(m_pD3DDevice, "Graphics\\Player.bmp",
D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0xFF000000,
NULL, NULL, &m_pCharTex);

and to create a surface:


hResult = m_pD3DDevice->CreateImageSurface(64, 64, D3DFMT_X8R8G8B8, &m_pWoodsTiles);
if(FAILED(hResult))
{
strcpy(m_szErrorMsg, "Could not create grass surface.");
PostQuitMessage(WM_QUIT);
}
hResult = D3DXLoadSurfaceFromFile(m_pWoodsTiles, NULL, NULL, "Graphics\\tile.bmp", NULL, D3DX_DEFAULT, 0, NULL);
if(FAILED(hResult))
{
strcpy(m_szErrorMsg, "Could not load grass surface from file.");
PostQuitMessage(WM_QUIT);
}

All of these graphics are for a 2D rpg. I am using C++.
anyone?
The dimensions in the program match the actual dimensions of the images.

As for what type of image quality im losing, the pictures just look so much more crisp and clear when I view them on my desktop as opposed to viewing them in my directx game. So I guess you could say they are a bit blurry; its like they were compressed to a worse looking picture once they are loaded into my game and displayed.
I posted that last message, forgot to login

I use surfaces for background tiles (since they dont need to be transparent) and textures for images that require transparency, such as the character and other foreground images.
Hi Zander,
First of all if your texture has non power of 2 dimensions and your graphics card supports this (check D3DPTEXTURECAPS_NONPOW2CONDITIONAL) then don't specify D3DX_DEFAULT for the Width and Height parameters to D3DXCreateTextureFromFileEx or this will round the texture dimensions to a power of 2 when loading.
Either use explicit dimensions for width and height or in later versions of the SDK you can use D3DX_DEFAULT_NONPOW2 for the width and Height parameters to D3DXCreateTextureFromFileEx.

Also, as MePHyst0 mentioned, you need to check out mapping texels to pixels.
Search for "Directly Mapping Texels to Pixels" in the SDK help file.

HTH,
Cambo_frog
For the love of god, please tell me that you've just omitted your error checking code for brevity, and you don't really assume that all those functions succeed.
Quote:I use surfaces for background tiles (since they dont need to be transparent)


You can create nontransparent textures too.

Are you scaling the images when you draw them? Are you using ID3DXSprite, or your own method of drawing the tiles? Please try to answer these questions so that we can better help you instead of shooting in the dark!

[Edited by - Drakex on July 20, 2005 8:34:33 PM]
_______________________________________________________________________Hoo-rah.

This topic is closed to new replies.

Advertisement