Sign in to follow this  
zander

DirectX8 Image Quality

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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?)?

Share this post


Link to post
Share on other sites
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 .

Share this post


Link to post
Share on other sites
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++.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Quote:
Original post by Drakex
Could you please answer my questions instead of ignoring my reply this time? I really am trying to help, but unless I know these things, we're just going to keep blindly probing a bunch of different areas until we hit the right one!


Hi Drakex,
See my PM to you.

Stay cool,
Cambo_frog

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this