Original Post
🔒 Locked
32 bit texture
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]
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]
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.
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.
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
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement