Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 946 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
bmap_to_alpha does not work after pixel_to_bmap. #311332
02/19/10 15:18
02/19/10 15:18
Joined: Jul 2007
Posts: 53
Germany
Henning Offline OP
Junior Member
Henning  Offline OP
Junior Member

Joined: Jul 2007
Posts: 53
Germany
Hello,

I tried to make a multitexture terrain by reading a color coded feature map, convert each feature area to an alpha map and apply this with the proper texture on the terrain. I.e. where the feature map has blue color, water texture will show.

But after painting white color pixels onto a map, it cannot be converted to an alpha map with bmap_to_alpha. It works, when you do not paint on that map before. I tried several workarounds, store and reload the map, bmap_blit it to another name, etc.
The only working solution is to create a new one with bmap_create, but then - surprise - it is upside down.

So, I think I found two problems. No reports anywhere in the forum.

Version: Commercial 7.82
Here some code (inputPic should be black at 1,1, elsewhere some color):

#include <acknex.h>
#include <default.c>

BMAP* inPic = "inputPic.tga"; // 32x32 pixel, 24 bit tga, no alpha
//BMAP* wAlpha = "lila.tga";
BMAP* wAlpha;
var format;
var wPix;

function main () {
wait (1);

format = bmap_lock (inPic,0);
wPix = pixel_for_vec (vector (255,255,255),100,format);
pixel_to_bmap (inPic,1,1,wPix);
bmap_unlock (inPic);
bmap_save (inPic, "output1.tga");

wait (-1); // give some time for saving

wAlpha = bmap_create ("output1.tga");
// bmap_blit (wAlpha,inPic,NULL,NULL);

bmap_to_alpha (wAlpha, 100); // now 32 bit with alpha
bmap_save (wAlpha, "output2.tga");

sys_exit (NULL);
}

I would be pleased to get a simpler solution.

Re: bmap_to_alpha does not work after pixel_to_bmap. [Re: Henning] #312336
02/24/10 10:47
02/24/10 10:47
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yes, this is quite possible - I'm pretty sure bmap_to_alpha uses the original bitmap data, not the written pixels. I'll check and if this is the case, I'll mention this more clear in the manual.

- bmap_to_alpha was a legacy function from A4 times when alpha channel textures weren't supported yet. You won't need it in A7 - just use 32 bit TGA already, and write 32 bit pixels.

Re: bmap_to_alpha does not work after pixel_to_bmap. [Re: jcl] #312502
02/25/10 08:33
02/25/10 08:33
Joined: Jul 2007
Posts: 53
Germany
Henning Offline OP
Junior Member
Henning  Offline OP
Junior Member

Joined: Jul 2007
Posts: 53
Germany
Hello Jcl,

thank you for the quick response, but using prepared alpha maps does not solve my problem, because I want to generate the ground textures at run-time. I have a 24x24km area and a feature map showing yellow for main roads, grey for secondary roads, blue for water, two shades of green for wood and so on. From this I want to calculate 8 different alpha maps for the multi-texture terrain. But besides that I am a little afraid that it might have too much impact on FPS. So, as a workaround I prepared normal tex maps by hand, but that does not look so good.

Best regards
Henning

By the way, A7 is a great tool, exactly what I looked for since 25 years, when I started with VRML.

Re: bmap_to_alpha does not work after pixel_to_bmap. [Re: Henning] #312736
02/26/10 10:04
02/26/10 10:04
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You can either convert your image to 32 bit alpha first and write into it afterwards.

Or create a new 32-bit BMAP with bmap_create(...), and use it as write target. That would be the normal way to manipulate a source image and save it under a different name.

Re: bmap_to_alpha does not work after pixel_to_bmap. [Re: jcl] #316450
03/24/10 09:05
03/24/10 09:05
Joined: Jul 2007
Posts: 53
Germany
Henning Offline OP
Junior Member
Henning  Offline OP
Junior Member

Joined: Jul 2007
Posts: 53
Germany
Originally Posted By: jcl
Or create a new 32-bit BMAP with bmap_create(...), and use it as write target. That would be the normal way to manipulate a source image and save it under a different name.


Perfectly, that works. Thanks.


Moderated by  HeelX, Spirit 

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