Jump to content
  • Advertisement
Sign in to follow this  

transparent images

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

How would i make a certain color in a pixel be tranparent (not be draw) in a IDirect3dTexture9 file? is there a certain function i set the colorkey or something for that pixel to not be drawn? i want it to be (254, 254, 254)

Share this post


Link to post
Share on other sites
Advertisement
As far as I know, that doesn't exist.

But you can do it this way:

First make sure the bitmap is 32 bit so it can contain alpha channel, run through a double for loop that will check each pixel on being RGB(254, 254, 254), if so make the alpha channal 0. Through RenderStates you can make the texture alpha transparent.

I hope this will help, I don't know exactly how to do this with code, you first need to look for the function where you check the pixels seperatly.

Share this post


Link to post
Share on other sites
Quote:
Original post by Xeile

First make sure the bitmap is 32 bit so it can contain alpha channel, run through a double for loop that will check each pixel on being RGB(254, 254, 254), if so make the alpha channal 0. Through RenderStates you can make the texture alpha transparent.


D3DX image loaders can do this automatically. Just supply the Colorkey parameter to specify which color the loader should alter to transparent black. Note that you need to set the alpha blending renderstates before rendering with the texture to actually make use of the alpha channel created by the loader.

When specifying the color key, it is usually needed to set the key's alpha value to 255 - a common error is to leave it as 0, causing only fully transparent pixels to pass the colorkey criteria, thus having no effect on the image data.

Share this post


Link to post
Share on other sites
Quote:
Original post by Nik02
Quote:
Original post by Xeile

First make sure the bitmap is 32 bit so it can contain alpha channel, run through a double for loop that will check each pixel on being RGB(254, 254, 254), if so make the alpha channal 0. Through RenderStates you can make the texture alpha transparent.


D3DX image loaders can do this automatically. Just supply the Colorkey parameter to specify which color the loader should alter to transparent black. Note that you need to set the alpha blending renderstates before rendering with the texture to actually make use of the alpha channel created by the loader.

When specifying the color key, it is usually needed to set the key's alpha value to 255 - a common error is to leave it as 0, causing only fully transparent pixels to pass the colorkey criteria, thus having no effect on the image data.


I looked it up and Nik02 is right, use this function to pull the job you want to:

HRESULT WINAPI D3DXCreateTextureFromFileEx( LPDIRECT3DDEVICE9 pDevice,
LPCTSTR pSrcFile,
UINT Width,
UINT Height,
UINT MipLevels,
DWORD Usage,
D3DFORMAT Format,
D3DPOOL Pool,
DWORD Filter,
DWORD MipFilter,
D3DCOLOR ColorKey,
D3DXIMAGE_INFO *pSrcInfo,
PALETTEENTRY *pPalette,
LPDIRECT3DTEXTURE9 *ppTexture
);




ColorKey
[in] D3DCOLOR value to replace with transparent black, or 0 to disable the color key. This is always a 32-bit ARGB color, independent of the source image format. Alpha is significant and should usually be set to FF for opaque color keys. Thus, for opaque black, the value would be equal to 0xFF000000.

Hope this helps.

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!