I have tried. I used the "Textures" example in dx sdk june10, but all my tryings of displaying look so pixelated.
Should I set the back buffer size to the image size? How to do this?
Or other methods should I take?
if( FAILED( g_pd3dDevice->CreateVertexBuffer( 6*2 * sizeof( CUSTOMVERTEX ),
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )
{
return E_FAIL;
}
// Fill the vertex buffer. We are setting the tu and tv texture
// coordinates, which range from 0.0 to 1.0
CUSTOMVERTEX* pVertices;
if( FAILED( g_pVB->Lock( 0, 0, ( void** )&pVertices, 0 ) ) )
return E_FAIL;
pVertices[0].position = D3DXVECTOR3( -1.0f, 1.0f, 0.0f);
pVertices[0].color = 0xffffffff;
pVertices[1].position = D3DXVECTOR3( -1.0f, -1.0f, 0.0f);
pVertices[1].color = 0xffffffff;
pVertices[2].position = D3DXVECTOR3( 1.0f, -1.0f, 0.0f);
pVertices[2].color = 0xffffffff;
pVertices[3].position = D3DXVECTOR3( -1.0f, 1.0f, 0.0f);
pVertices[3].color = 0xffffffff;
pVertices[4].position = D3DXVECTOR3( 1.0f, 1.0f, 0.0f);
pVertices[4].color = 0xffffffff;
pVertices[5].position = D3DXVECTOR3( 1.0f, -1.0f, 0.0f);
pVertices[5].color = 0xffffffff;
pVertices[0].tu = 0.0f;
pVertices[0].tv = 0.0f;
pVertices[1].tu = 0.0f;
pVertices[1].tv = 1.0f;
pVertices[2].tu = 1.0f;
pVertices[2].tv = 1.0f;
pVertices[3].tu = 0.0f;
pVertices[3].tv = 0.0f;
pVertices[4].tu = 1.0f;
pVertices[4].tv = 0.0f;
pVertices[5].tu = 1.0f;
pVertices[5].tv = 1.0f;
g_pVB->Unlock();
.........
cvNamedWindow("nihao");
cvResizeWindow(400, 300);
hWnd = (HWND)cvGetWindowHandle("nihao");
.........
in=cvLoadImage("24bpp_1920*1200_1.bmp", 1);
RECT rc;
rc.left = 0,
rc.top = 0;
rc.right = in->width;//1920
rc.bottom = in->height;//1200
g_pd3dDevice->Present( NULL, &rc, hWnd, NULL );
I create a small size window of 400x300px on purpose that I had tested it out that the more pixelated the displaying , the smaller the window is.