Jump to content
  • Advertisement
Sign in to follow this  
edwinnie

A2R10G10B10 readback woes

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Your shifting is OK but masks are wrong.

Try this:

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


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!