Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, TipmyPip, VoroneTZ, Quad, 1 invisible), 688 guests, and 11 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Blitting multiple Bitmaps with transparent parts? #376501
07/03/11 15:01
07/03/11 15:01
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
hi there..

i´m trying to create a heightmap generator.. for this, i create a black bitmap, and tried to blit (for testing) white circles on it..
But all i get is:

http://www.imagesload.net/img/shot_099.jpg

The Code:
Click to reveal..
Code:
#include <acknex.h>
#include <default.c>


BMAP* map;
BMAP* plain_tile_a = "plain.tga";

var plaincount = 0;

PANEL* viewer =
{
	layer = 1;
	alpha = 100;
	flags = SHOW | TRANSLUCENT;
}

PANEL* infos =
{
	pos_x = 1024;
	pos_y = 50;
	layer = 99999;
	digits(0, 0, "Bitmapcount = %.0f", *, 1, plaincount);
	flags = SHOW | TRANSLUCENT;
}



void main()
{
	video_mode = 9;
	level_load(NULL);
	wait(3);
	
	map = bmap_createblack(2048, 2048, 32);
	bmap_fill(map, vector(1,1,1), 100);
	viewer.bmap = map;
	viewer.scale_x = 0.35;
	viewer.scale_y = 0.35;
	
	plaincount = 0;
	
	while(plaincount < 500)
	{
		bmap_blit(map, plain_tile_a, vector(random(2048), random(2048), 0), vector(random(512), random(512), 0));
		plaincount += 1;
		wait(1);
	}
}



The problem: The Bitmaps are not blit one above the other.. they just overwrite each other..

I´ve no clue how to change that ._.


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Blitting multiple Bitmaps with transparent parts? [Re: Espér] #376507
07/03/11 18:01
07/03/11 18:01
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Stupid question: does your bitmap contain an alpha channel?

Re: Blitting multiple Bitmaps with transparent parts? [Re: HeelX] #376508
07/03/11 18:03
07/03/11 18:03
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
yes...

When i use a TGA without Alpha.. or as 24Bit.. it just blits white plains...
when i use a png instead of TGA.. same problem as before.. no overlaying..

Last edited by Espér; 07/03/11 18:06.

Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Blitting multiple Bitmaps with transparent parts? [Re: Espér] #376512
07/03/11 19:51
07/03/11 19:51
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
hopfel Offline
User
hopfel  Offline
User

Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
I don't know if it could work with bmap_blit, but you could write a function which writes pixel for pixel,
then you could check for every pixel also, if there's a pixel under it which shouldn't be replaced.

Well, would be a much bigger code, but it works! ^-^


Hilf mir, dir zu helfen!
Re: Blitting multiple Bitmaps with transparent parts? [Re: hopfel] #376513
07/03/11 19:56
07/03/11 19:56
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Maybe, this helps. Its about pixel_to_bmap:
http://www.opserver.de/ubb7/ubbthreads.p...true#Post348321

Re: Blitting multiple Bitmaps with transparent parts? [Re: hopfel] #376514
07/03/11 20:03
07/03/11 20:03
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
it´s not that it shouldn´t be replaced.. it should blend over it.


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Blitting multiple Bitmaps with transparent parts? [Re: Espér] #376518
07/03/11 20:31
07/03/11 20:31
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
You have to do the blending yourself by multiplying the alpha with the rgb values and then adding the result to the previous pixel.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Blitting multiple Bitmaps with transparent parts? [Re: WretchedSid] #376520
07/03/11 20:42
07/03/11 20:42
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
means something like:

1. reading pixel X/Y
2. reading minibitmap pixel A/B
3. calculating:
Code:
pixel_X/Y.red + pixel_A/B.red
pixel_X/Y.green + pixel_A/B.green
pixel_X/Y.blue + pixel_A/B.blue


4. next pixel

?

if yes... WHY?!
I´ve 123 Heightmap parts (mountains, cliffs..etc).. so i need to lock 124 bitmaps (the parts + the ground), just to read a random part out..?

._.

Last edited by Espér; 07/03/11 21:15.

Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Blitting multiple Bitmaps with transparent parts? [Re: Espér] #376521
07/03/11 21:39
07/03/11 21:39
Joined: Oct 2006
Posts: 873
S
Shadow969 Offline
User
Shadow969  Offline
User
S

Joined: Oct 2006
Posts: 873
before adding pixel_A/B color you have to multiply it with A/B alpha value as Sid has already said. besides you don't have to lock all of your heightmap parts at once - just lock em one by one.

Re: Blitting multiple Bitmaps with transparent parts? [Re: Shadow969] #376522
07/03/11 21:43
07/03/11 21:43
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
ok.. the function at the moment:

Code:
var littleformat;
		var bigformat;
		var pixel;
		var pixel2;
		COLOR* temp;
		COLOR* temp2;
		var position[2];
		position[0] = random(2048);
		position[1] = random(2048);
		
		bigformat = bmap_lock(map, 0);
		while(plainmax != 0 && plaincount < plainmax)
		{
			
			var breite = bmap_width(plain_tile);
			var hoehe = bmap_height(plain_tile);
			
			littleformat = bmap_lock(plain_tile, 0);
			var a = 0;
			var b = 0;
			for(a = 0; a<breite; a++)
			{
				for(b = 0; b<breite; b++)
				{
					if(position[0]+a < breite && position[0]+a > 0 && position[1]+b < hoehe && position[1]+b > 0)
					{
						pixel = pixel_for_bmap(plain_tile, a, b);
						pixel_to_vec(temp,100,8888,pixel);
						
						pixel2 = pixel_for_bmap(map, position[0]+a, position[1]+b);
						pixel_to_vec(temp2,100,8888,pixel2);
						
						vec_add(temp2, temp);
						
						pixel = pixel_for_vec(temp2,100,8888);
						
						
						pixel_to_bmap(map,position[0]+a,position[1]+b,pixel);
					}
				}
				wait(1);
			}
			
			
			
			bmap_unlock(plain_tile);
			plaincount += 1;
			wait(1);
		}
		bmap_unlock(map);
	}


It makes.. nothing.. means: i can´t see anything ._.


Multiplying what alpha???
(plan = the heightmap part, map = the ground)


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Page 1 of 3 1 2 3

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