How to display a picture using D3DFMT_A2R10G10B10 format?

Started by
4 comments, last by Namethatnobodyelsetook 15 years, 11 months ago
My OS is vista,display card is GF8800GT .I want to show picture 10bpc? my code as follow: ..... m_pd3d = Direct3DCreate9(D3D_SDK_VERSION); if (m_pd3d == NULL) { AfxMessageBox(ID_ERROR_D3DCREATEFAILED, MB_OK, 0); return FALSE; } HRESULT hr; D3DPRESENT_PARAMETERS presentParams; D3DDEVTYPE devType; ZeroMemory(&presentParams, sizeof(presentParams)); presentParams.Windowed = TRUE; presentParams.SwapEffect = D3DSWAPEFFECT_COPY; presentParams.BackBufferWidth = 1280; presentParams.BackBufferHeight =1024; presentParams.BackBufferFormat =D3DFMT_A2R10G10B10/*D3DFMT_A2R10G10B10*//*D3DFMT_UNKNOWN*/; devType = D3DDEVTYPE_REF; hr = m_pd3d->CreateDevice(D3DADAPTER_DEFAULT, devType, m_pMainWnd->GetSafeHwnd(), D3DCREATE_SOFTWARE_VERTEXPROCESSING, &presentParams, &m_pd3ddev); .................. hr = pd3ddev->CreateTexture(sd.Width, sd.Height, 1, 0 /* Usage */, D3DFMT_A2R10G10B10/*D3DFMT_L16*/, D3DPOOL_MANAGED, &m_ptexCur, NULL); if (FAILED(hr)) return hr; ........................... but the effect is 8bpc(bit per channel)
Advertisement
thanks a lot
How do you know the effect is 8bpp? It's my understanding that graphics cards can't send a 10bpp image to the monitor, it has to be 8-bit at that point.

Where are you measureing it as 8-bit?
Steve is right, anything you want to actually be visible on a monitor needs to be re-mapped back to 8 bits per component, irregardless of what intermediate formats you've rendered to. So if you've rendered everything to an A2R10G10B10 texture and you want to visualize what's on it, you need to remap it either manually pixel by pixel or implicitly by either rendering the texture on a full-screen quad or by using something like StretchRect to copy it to the backbuffer.

Also note that if you use PIX, you can have a look at the texture and it will handle conversion for you (you can also right click on any pixel and view its actual value).
Oh Sorry,I do it like this:
hr = pd3ddev->CreateTexture(sd.Width, sd.Height, 1,
0 /* Usage */, D3DFMT_A2R10G10B10/*D3DFMT_L16*/, D3DPOOL_MANAGED, &m_ptexCur, NULL);
if (FAILED(hr))
return hr;

m_rcSrc.SetRect(0, 0, sd.Width, sd.Height);
m_rcDest.SetRect(0, 0, (INT)(sd.Width * m_fZoom), (INT)(sd.Height * m_fZoom));

LPDIRECT3DSURFACE9 psurfSrc = NULL;
LPDIRECT3DSURFACE9 psurfDest = NULL;

hr = m_ptexCur->GetSurfaceLevel(0, &psurfDest);
hr = ((LPDIRECT3DTEXTURE9)ptex)->GetSurfaceLevel(m_lwMipCur, &psurfSrc);
hr = D3DXLoadSurfaceFromSurface(psurfDest, NULL, NULL, psurfSrc, NULL, NULL, D3DX_FILTER_TRIANGLE, 0);
....................................
at fisrt , I read a texture(640*480),then I set the pixel like this:
...................................................................
D3DLOCKED_RECT lr;

hr = psurfDest->LockRect(&lr, NULL, 0);

DWORD xp;
DWORD yp;
DWORD* pdwRow = (DWORD*)lr.pBits;
DWORD* pdw;
DWORD dwAlpha;
LONG dataBytesPerRow = 4 * sd.Width;

for (yp = 0; yp < sd.Height; yp++)
{
pdw = pdwRow;
for (xp = 0; xp < sd.Width; xp++)
{
dwAlpha=493+((short)(xp/20));

short nVal=(short)dwAlpha;
m_pImageBuf[yp*sd.Width+xp]=nVal;

*pdw = 0xc0000000 | (dwAlpha << 20) | (dwAlpha << 10) | wAlpha);
pdw++;
}
pdwRow += lr.Pitch / 4;
}
psurfDest->UnlockRect();
}
.............................
this is a medical image 10bit grey pixel,The middle grey level value is 512,
I give 32 levels from left to right.but I only see 8 different grey levels.
I have read sth about vista support 10bit color depth,I want to know if I can achieve this function for dispay image 10bit per channel.
the problem is Vista OS not support this format,graphic cart do not suport or my codes have errors.actually GF8800GT support D3DFMT_A2R10G10B10 Back Buffer Formats,Render Target Formats,Texture Formats.
.........thanks for reply!

If it's possible at all you'll likely need fullscreen mode. Windowed mode will convert to the desktop mode (1555, 565, or 8888).

If you ask for a fullscreen 10 bit buffer, it's possible the card will have a 10-bit DAC for VGA. It's possible the card supports a higher bit depth format for HDMI.

HDMI 1.3 has support for 10, 12, and 16 bit per channel deep color modes. As this is fairly new, monitors supporting it are rare. A quick search shows that some 8800gt cards claim to have HDMI1.3 support, so you might be set there, assuming the cards use the deep color capabilities of HDMI1.3.

This topic is closed to new replies.

Advertisement