|
|

楼主 |
发表于 2008-5-13 23:55:00
|
显示全部楼层
Re:surface with D3DFMT_A32B32G32R32F
???我解?Q了,感?tonykee的?兔
列出我最?的程式?,大家如果有遇到一?拥???可以?⒖家幌
<1>?於D3DFMT_A32B32G32R32F的?取pixel的程式?如下:
- IDirect3DTexture9 *g_pTexture2;
- D3DXCreateTextureFromFile(g_pD3DDevice, "eyefortest.png", &g_pTexture2);
- HRESULT hr;
- D3DLOCKED_RECT LockedRect;
- D3DSURFACE_DESC Desc;
- hr = g_pTexture2->GetLevelDesc(0,&Desc);//D3DFMT_A32B32G32R32F
- hr = g_pTexture2->LockRect(0,&LockedRect,NULL,0);
- D3DXVECTOR4 *pbits = (D3DXVECTOR4 *) LockedRect.pBits;
- D3DXVECTOR4 vec4;
- //int index=0;
- for (UINT y=0;y<Desc.Height;y++)
- {
- DWORD dwOffset = y*Desc.Width;
- for (UINT x=0;x<Desc.Width;x++)
- {
- vec4=pbits[dwOffset+x];
- }
- }
- hr = g_pTexture2->UnlockRect(0);
复制代码
<2>?於D3DFMT_X8R8G8B8的?取pixel的程式?如下:
- HRESULT hr;
- D3DLOCKED_RECT LockedRect;
- D3DSURFACE_DESC Desc;
- hr = g_pTexture->GetLevelDesc(0,&Desc);//D3DFMT_X8R8G8B8
- hr = g_pTexture->LockRect(0,&LockedRect,NULL,0);
- DWORD *pbits = (DWORD *) LockedRect.pBits;
- for (UINT y=0;y<Desc.Height;y++)
- {
- DWORD dwOffset = y*Desc.Width;
- for (UINT x=0;x<Desc.Width;x++)
- {
- DWORD rgb=pbits[dwOffset+x];
- DWORD b=LOBYTE(rgb);
- DWORD g=(LOBYTE(((WORD)(rgb)) >> 8));
- DWORD r=(LOBYTE((rgb)>>16));
- DWORD a=(LOBYTE((rgb)>>24));
- //GetRValue
- int c=12;
- }
- }
- hr = g_pTexture->UnlockRect(0);
复制代码 |
|