|
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
OP
Expert
|
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.jpgThe 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 ._.
|
|
|
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
OP
Expert
|
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.
|
|
|
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
User
|
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: Espér]
#376518
07/03/11 20:31
07/03/11 20:31
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
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
OP
Expert
|
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:
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.
|
|
|
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
OP
Expert
|
OP
Expert
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
|
ok.. the function at the moment:
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)
|
|
|
|