This topic is 4356 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi! this is another of my readback woes again. I managed to solve the last one on G16R16 by using a WORD directly instead of a D3DXFLOAT16. This time I found that my current code for A2R10G10B10 readback is not correct. Unfortunately, I dun seem to understand how the bitshifting should work... perhaps someone or Jack can enlighten me again... thx! Edwin
//current code (not entirely correct)
if(format == D3DFMT_A2R10G10B10)
{
for(int y=0; y<desc.Height; y++)
{
DWORD* pPixel = (DWORD*)(((BYTE*)theRect.pBits) + (y*theRect.Pitch));
for(int x=0; x<desc.Width; x++)
{
BYTE alpha = (*pPixel&0xff000000)>>30;
unsigned short red = (*pPixel&0xff0000)>>20;
unsigned short green = (*pPixel&0xff00)>>10;
unsigned short blue = (*pPixel&0xff);
pPixel++;
}
}
}



##### Share on other sites

Try this:

BYTE alpha = ((*pPixel)>>30) & 0x3;unsigned short red = ((*pPixel)>>20) & 0x3FF;unsigned short green = ((*pPixel)>>10) & 0x3FF;unsigned short blue = (*pPixel) & 0x3FF;

hi demirug!

it works!

thx
Edwin