• Advertisement
Sign in to follow this  

32 bit texture

This topic is 4323 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

ok I got a question. lets say I have a 32 bit texture mapped to a quad. Is there a way i can go and change the alpha value of the texture in the code?

Share this post


Link to post
Share on other sites
Advertisement
for example lets say i have a textre, and its 100% opaque, and i want to make 1 pixel transparent.

this is what im trying but it doesnt work

D3DLOCKED_RECT v;
DWORD col=(256,256,256,256);

_tex->LockRect(0,&v,0,0);
//v.pBits=100;
DWORD *R = (DWORD *)v.pBits;
int i;
for (i=0;i<=100;i++)
{
R = (DWORD)col;
};
_tex->UnlockRect(0);

[Edited by - Ksingh30 on April 20, 2006 12:38:48 AM]

Share this post


Link to post
Share on other sites
So, you know that your texture is in 8-bit per channel ARGB or RGBA format (like a D3DCOLOR, which is also a DWORD)? I am making this assumption based on this statement on your code:

DWORD col=(256,256,256,256);

I don't see how that instruction could work to create such a value. DirectX has macros that can create a D3DCOLOR (which is a typedef'ed DWORD). They are D3DCOLOR_XRGB (which sets the alpha channel to 255) and D3DCOLOR_ARGB. Note also that 255 = hex FF, which is the max that can fit in one byte. 256 = hex 100.

Share this post


Link to post
Share on other sites
well before i tried this for col
DWORD col=0xFF000000;
but that didnt do anything either.

Share this post


Link to post
Share on other sites
One way i could think of doing this is by locking the texture and go through each pixel and modify the alpha channel. The format is in ARGB so the first element per component will represent the alpha channel. By the way there is some stuff you need to be carefull as i believe that DirectX only allows you to lock the top surface, since a texture may have have mipmap surfaces as well. Hope that helps

Share this post


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

  • Advertisement