m_pDirect3D9 = Direct3DCreate9(D3D_SDK_VERSION);
if(m_pDirect3D9){
IDirect3DDevice9* pDirect3DDevice;
D3DPRESENT_PARAMETERS params = { 0 };
params.BackBufferWidth = 0;
params.BackBufferHeight = 0;
params.BackBufferFormat = D3DFMT_UNKNOWN;
params.BackBufferCount = 1;
params.MultiSampleType = D3DMULTISAMPLE_NONE;
params.MultiSampleQuality = 0;
params.SwapEffect = D3DSWAPEFFECT_DISCARD;
params.Windowed = TRUE;
params.hDeviceWindow = hWnd;
params.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
params.EnableAutoDepthStencil = FALSE;
params.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
hr = m_pDirect3D9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
NULL, D3DCREATE_MIXED_VERTEXPROCESSING, ¶ms, &pDirect3DDevice);
if(SUCCEEDED(hr)){
IDirect3DSurface9* psurface1;
hr = pDirect3DDevice->CreateOffscreenPlainSurface(720, 576,
D3DFMT_UYVY, D3DPOOL_DEFAULT, &psurface1, NULL);
if(SUCCEEDED(hr)){
IDirect3DSurface9* psurface2;
D3DLOCKED_RECT lockedRect;
hr = psurface1->LockRect(&lockedRect, NULL,
D3DLOCK_DISCARD);
if(SUCCEEDED(hr)){
BYTE* pBuff = (BYTE*)lockedRect.pBits;
for(int y = 0; y < 576; ++y){
ZeroMemory(pBuff + y * lockedRect.Pitch, 720 * 2);
}
hr = psurface1->UnlockRect();
}
hr = pDirect3DDevice->CreateOffscreenPlainSurface(540, 432,
D3DFMT_UYVY, D3DPOOL_DEFAULT, &psurface2, NULL);
if(SUCCEEDED(hr)){
hr = pDirect3DDevice->StretchRect(psurface1, NULL, psurface2,
NULL, D3DTEXF_LINEAR);
DXTRACE_ERR(TEXT("DX ERROR: "),hr);
}
}
}
DXTRACE_ERR(TEXT("DX ERROR: "),hr);
Debug runtime chosen? Native debugging enabled?
My output window says:
"Direct3D9: (ERROR) :Unable to stretch from an offscreen plain to another
offscreen plain. StretchRect failed"
> if(SUCCEEDED(hr)){
> hr = pDirect3DDevice->StretchRect(psurface1, NULL, psurface2,
> NULL, D3DTEXF_LINEAR);
> DXTRACE_ERR(TEXT("DX ERROR: "),hr);
> }
See the bottom most table, bottom right cell in the documentation on
StretchRect:
http://msdn.microsoft.com/en-us/library/bb174471(VS.85).aspx
It says streching from and to an off-screen plain surface is not supported.
I currently have no other solution handy.
Armin
I have release runtime.
I was looking only my MSDN (March 2008) which says:
Stretching is not supported if the destination surface is an off-screen
plain surface but the source is not.
> See the bottom most table, bottom right cell in the documentation on
> StretchRect:
> http://msdn.microsoft.com/en-us/library/bb174471(VS.85).aspx
>
> It says streching from and to an off-screen plain surface is not
> supported.
Yes, this version of MSDN says it's not possible what I wanted to do.
>
> I currently have no other solution handy.
>
Any other idea on scaling UYVY image undex DirectX?
"no_name" <send_...@microsoft.com> spake the secret code
<#aXacddO...@TK2MSFTNGP05.phx.gbl> thusly:
>I have release runtime.
Install the SDK, switch to the debug runtime through the supplied
utility and then pay attention to the debug stream output when your
program is run. Developing Direct3D applications without the debug
runtime is like running through a mine field.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>
Legalize Adulthood! <http://blogs.xmission.com/legalize/>
I'll do that. But at the moment I have no idea how to solve the scaling.
Perhaps to forget the whole Direct3D story and use my own implementation of
bilinear scaling.
Hi, you can not use stretchrect() with ( src:offscreen, dst:offscreen
plain )
there is some restrictions in using this function also a difference
between dx8 driver and dx9 driver, but I will show you dx9 version:
it can be used like the follows:
if there is no stretching:
texture render target ----> texture render target.
texture render target ----> render target surface
off-screen plain ---> texture surface
off-screen plain ---> texture render target
off-screen plain ---> render target surface
off-screen plain ---> off-screen plain
other combination that are not specified are not allowed.
if there is a stretching:
texture surface ---> texture render target surface.
texture surface ---> render target surface ( like frame buffer )
texture render target ----> texture render target.
texture render target ----> render target surface
render target surface ----> texture render target
render target surface ----> render target surface
off-screen plain surface -----> texture render target
off-screen plain surface -----> render target surface
other combinations that are not specified are not allowed.
Best regards,
smart,
http://gptutors.com
Yes. That is the only path that is going to lead to success. You are
simply never going to find a system service to do scaling of in-memory YUV
surfaces.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.