Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,473 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
alpha channel for a bmap #407415
09/12/12 15:21
09/12/12 15:21
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
is it possible to create a alpha channel for a bmap and safe it in the bmap by script?

i mean,
i have 2 bmap`s
1 colored with a pattern
and 1 black bmap with a white shape
can i copy the 2nd bmap as alpha channel into the 1st one?

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 Offline
Expert
Uhrwerk  Offline
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 Offline OP
Member
GameScore  Offline 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

Code:
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: GameScore] #407450
09/13/12 11:46
09/13/12 11:46
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
you should use bmap_to_format(pattern_1,8888); to convert it first to 32b ARGB to enable alpha writing. or use first bmap_to_alpha simply.

and use 2 different pixel variable when reading pixels , to not to overwrite previously read data.


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: alpha channel for a bmap [Re: sivan] #407451
09/13/12 12:07
09/13/12 12:07
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
the problem is that the alpha channel is overwritten
i dont want pattern writes into the shape alpha
only the rgb layers i wanna write

Re: alpha channel for a bmap [Re: GameScore] #407454
09/13/12 12:22
09/13/12 12:22
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
it won't work,
- make a totally new 32b bitmap
- read both pattern image and alpha image pixel data into separate pixel variables,
- write it into the new image: pattern colour to new colour, alpha colour to new alpha
- save new image


Free world editor for 3D Gamestudio: MapBuilder Editor
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 Offline
Expert
Uhrwerk  Offline
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...
Re: alpha channel for a bmap [Re: Uhrwerk] #407483
09/13/12 16:12
09/13/12 16:12
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
thanks for your help uhrwerk,
got it allready from sivian
and thanks for your help


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1