Archived

This topic is now archived and is closed to further replies.

wonyee

way to setup alpha values. please help

Recommended Posts

i''ve got two bitmap files. i want to use one file as the other''s alpha channel for example, i''ve got file "texture.bmp" and "alpha.bmp" alpha.bmp is a 256 color file. the method i use now is: 1) preload pixels from "alpha.bmp" , i''ll use them as alpha value later. 2) call D3DXCreateTextureFromFileEx to load "texture.bmp" and set the texture format to D3DFMT_A8R8G8B8 after this call, texture are created and the alpha channel are all valued 255 3) lock this texture and get the surface. then for every pixel, set the alpha value, use the preloaded alpha data. is there any more efficient to do this? my method seems toooo inefficient..

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think that with BMPs this is your best option.

I don''t know if this would work, but have you tried creating a surface with D3DFMT_A8 as the format and loading the BMP into that? I''m assuming the bitmap is an 8 bit image, but not sure if there''re any compatibility issues with D3DFMT_A8 not working on some devices (assuming this method works at all) ... seems a bit hackish either way, but your initial method of changing the pixels seems the most reliable, IMHO.

Share this post


Link to post
Share on other sites
Why not use .tga format or directx own format (.dds I think). If you haven''t got an editor to create them then there is a util that comes with the directX 8.x SDK where you load one .bmp then load another as the alpha channel and save as .dds (whatever).

Share this post


Link to post
Share on other sites
i don''t use .tga file because i want to reuse "alpha bmps" i mentioned.
i want to do tile transition, but i don''t wanna creat too many textures. so i decided to seperate textures and their alpha informations, store as "texture bmps" and "alpha bmps",
so i if i have 10 texture bmps, 8 alpha bmps,
i can gain 10 + 10*8 = 90 textures.
the first 10 are textures without transitions,
and the 10*8 are textures with various transitions.

pls help

Share this post


Link to post
Share on other sites
Why not just write your own texture loading routine rather than using d3dx?

You have the bitmap, you have the alpha''s, and just read the bitmap and correct alpha value into memory, then lock the surface, memcpy over, and unlock. One lock total per texture, rather than 2+ with the current way you''re doing it now.

Of course, I seriously doubt performance is going to improve that much.

Share this post


Link to post
Share on other sites