1 registered members (AndrewAMD),
1,473
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: alpha channel for a bmap
[Re: GameScore]
#407418
09/12/12 16:11
09/12/12 16:11
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Yes, that is possible. You need to make sure that the first bitmap is in a format capable of holding alpha information. You could for example just set a completely translucent alpha channel for the first bitmap and overwrite that later with the data from the second bitmap. A more straightforward approach is to create a third bitmap with bmap_create and fill it with the rgb values from the first bitmap and the a values from the second one. In both approaches you could just iterate over the bitmap's pixels and use http://www.conitec.net/beta/apixel_for_bmap.htm and http://www.conitec.net/beta/apixel_to_bmap.htm.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: alpha channel for a bmap
[Re: Uhrwerk]
#407443
09/13/12 10:34
09/13/12 10:34
|
Joined: Apr 2008
Posts: 245
GameScore
OP
Member
|
OP
Member
Joined: Apr 2008
Posts: 245
|
Man i dont get it to work i have 2 bmaps the 1st one with the color patern and the 2nd one is a black image with only a alpha shape inside now i was try to read an write the 1st bmap into the 2nd one with pixel_for and pixel_to_bmap and save it with bmap_save to se the result but the alpha chanel is overwritten, complete white here is my code, please help
void create_bmap()
{
var alph, formatFrom, formatTo, pixel,format;
COLOR col;
int x,y, x_max = bmap_width(pattern_1), y_max = bmap_height(pattern_1);
bmap_to_format(alpha_1,4444);
bmap_to_format(pattern_1,4444);
formatTo = bmap_lock(alpha_1,format);
formatFrom = bmap_lock(pattern_1,format);
for(x = 0; x < x_max; x++)
{
for(y = 0; y < y_max; y++)
{
pixel = pixel_for_bmap(pattern_1, x, y);
pixel_to_vec(col, alph, formatFrom, pixel);
pixel = pixel_for_vec(col,alph, formatTo);
pixel_to_bmap(alpha_1, x, y, pixel);
}
}
bmap_unlock(pattern_1);
bmap_unlock(alpha_1);
wait(1);
bmap_save(flame_1,"test.tga");
}
|
|
|
Re: alpha channel for a bmap
[Re: sivan]
#407468
09/13/12 14:01
09/13/12 14:01
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
It actually can work. You forgot a step in your algorithm. You have only one pixel_for_bmap instruction in your code. You need two of them. In you inner loop you should:
1. Read RGB from bitmap A. 2. Read A from bitmap B. 3. Combine these values to RGBA. 4. Write this newly created value to A (or B).
Always learn from history, to be sure you make the same mistakes again...
|
|
|
|