Why the texture blurred ? I need it keeps the same resolution of the source image

Started by
15 comments, last by sainimu78 9 years, 8 months ago

Ok, I think I got it:

There are 2 windows and the same image is drawn in both of them :

- In the first window the image seems to be correct (it is stretched over the whole window, mipmapping / filtering seems to work as intended).

- In the second window the back buffer is streched over a 500x500 region. Probably the back buffer isn't 500x500 pixels, so the image to be presented is stretched without any filtering. I'm not sure if there is a way to stretch with some filtering operation - anyhow, if the back buffer isn't the same size as the destination rectangle the image quality won't be the same.

Cheers!

[edit] to fix the problem, you'll need another swap chain for the other window, with the correct back buffer size

[edit 2] or fix your RECT rc to match the back buffer size

Advertisement

You are Present()’ing the image to 2 different windows, so texture filters and mipmaps are unrelated.

Present() is what is resizing your image. It only resizes 1 way: with a point filter.

Therefor the only possible result you can get with your current method is the one you see (which is pixelated, not blurred).

You have to render to the 2nd window separately (and using a linear filter), ensuring that its back buffer stays the correct width and height for Present() not to resize.

This means maintaining 2 back buffers, performing 2 renders, and performing 2 Present()’s.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Ok, I think I got it:

There are 2 windows and the same image is drawn in both of them :

- In the first window the image seems to be correct (it is stretched over the whole window, mipmapping / filtering seems to work as intended).

- In the second window the back buffer is streched over a 500x500 region. Probably the back buffer isn't 500x500 pixels, so the image to be presented is stretched without any filtering. I'm not sure if there is a way to stretch with some filtering operation - anyhow, if the back buffer isn't the same size as the destination rectangle the image quality won't be the same.

Cheers!

[edit] to fix the problem, you'll need another swap chain for the other window, with the correct back buffer size

[edit 2] or fix your RECT rc to match the back buffer size

I test it out

The buffer size is equal to the window size.

But a window size is limited, commonly, in 1400x800

I tried pDevice->SetScissorRect(), It doesn't work.

How to set the buffer size?

You are Present()’ing the image to 2 different windows, so texture filters and mipmaps are unrelated.

Present() is what is resizing your image. It only resizes 1 way: with a point filter.

Therefor the only possible result you can get with your current method is the one you see (which is pixelated, not blurred).

You have to render to the 2nd window separately (and using a linear filter), ensuring that its back buffer stays the correct width and height for Present() not to resize.

This means maintaining 2 back buffers, performing 2 renders, and performing 2 Present()’s.

L. Spiro

How to ensure that?

I have tried :


    in = cvLoadImage("24bpp_1920x1200_1.bmp", 1);
    rc.left = 0; rc.top =0; rc.bottom = in->height; rc.right = in->width;
    cvReleaseImage(&in);
    g_pd3dDevice->SetScissorRect(&rc);
    g_pd3dDevice->GetScissorRect(&rc);
    IDirect3DSurface9* pSurf = NULL;
    IDirect3DSurface9* pBB = NULL;
    IDirect3DSwapChain9* pSwapChain = NULL;
    g_pd3dDevice->GetSwapChain(0, &pSwapChain);
    pSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pSurf);
    g_pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBB);
 
    hr = g_pd3dDevice->StretchRect(pSurf, NULL, pBB, &rc, D3DTEXF_LINEAR);

Both methods totally make no effects.

There are still pixelated

somewhat conclusion

When you draw to your 400x300 window, is your back buffer size 400x300?

- if you use Present to scale (RECT of a different size than the backbuffer) the backbuffer when flipping it will get pixelated (regardless of the resolution of the image)

Cheers!

When you draw to your 400x300 window, is your back buffer size 400x300?

- if you use Present to scale (RECT of a different size than the backbuffer) the backbuffer when flipping it will get pixelated (regardless of the resolution of the image)

Cheers!

That it is.

How to allocate a back buffer in specified size matters now.

This topic is closed to new replies.

Advertisement