Lload image from one file but alpha mask from other

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Magnet
Posts: 101
Joined: Wed Sep 27, 2006 7:32 pm

Lload image from one file but alpha mask from other

Post by Magnet »

How to load image data from one file but alpha mask from other.
For example:
ImageData:
Image
Alpha mask:
Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Why not just give the image data a transparent background?
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yeah, try makeColorKeyTexture. Otherwise lock the images and copy the alpha channel (note that you have to check for the color formats).
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

ok JP & hybrid gave you the answer, but i have a note.

your image size is 1200 x 40 ,some VGA card only supprots a max 1024 X1024 size ,so did you first try to load this image with irrlicht ?
Magnet
Posts: 101
Joined: Wed Sep 27, 2006 7:32 pm

Post by Magnet »

How to copy the alpha channel?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You have to mask the alpha bits (depending on the color type either 0x8000 or 0xFF000000) and iterate over all pixels, merging the new alpha with the old color. You cannot avoid byte operations here.
IPv6
Posts: 188
Joined: Tue Aug 08, 2006 11:58 am

Post by IPv6 »

nice diamonds :) where did you get them? :)
BTW, you can use alpha channel of another texture without byte work - just create your own material and set color texture as first and alpha as second and make a bunch of right pID3DDevice8->SetTextureStageState(0/ 1/ 2, ...); (assuming you are using DX)

video card will do the rest. it is useful when you want to use the same alpha with different color textures
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes alpha mask materials tend to be useful, but that's even more work - and requires decent knowledge of D3D and OpenGL (if you really want to make it portable).
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Shaders are even easier than materials. Just set the 2 textures, set the color from the first texture and then set the alpha of the pixel based on the color in the 2nd texture.

Easiest way though, would be to create the image as a TGA and make the black background transparent.
Image
Post Reply