Skip to main content
gamedev.net
🔒 Locked

32 bit texture

Started by Ksingh30 4 replies 1.1k views
Original Post
Ksingh30
Ksingh30
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?
Ksingh30
Ksingh30
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]
DXnut
DXnut
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.
--------------------------Most of what I know came from Frank D. Luna's DirectX books
Ksingh30
Ksingh30
well before i tried this for col
DWORD col=0xFF000000;
but that didnt do anything either.
BornToCode
BornToCode
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
Ksingh30
Ksingh30
sweet got it work thanks guys.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.