rgba() function suppose to create color with alpha channel, but with 16-bit maps it ignores 4-th parameter.
Is it correct behaviour?
Test case:
[code language="bennu"]import "mod_key"
import "mod_map"
import "mod_proc"
import "mod_grproc"
import "mod_video"
process obj()
begin
loop frame; end
end
function test_mode(int bpp)
local
int proc;
end
begin
set_mode( 320, 240, bpp );
proc = obj();
proc.x = 100;
proc.y = 100;
proc.graph = new_map( 100, 100, bpp);
map_clear( 0, 0, rgb(255,0,0) );
// Opaque square
map_clear( 0, proc.graph, rgba(0,255,0,255) );
while( !key(_ESC) ) frame; end
while( key(_ESC) ) frame; end
// Semi-transparent in 32-bit & opaque? in 16-bit
map_clear( 0, proc.graph, rgba(0,255,0,127) );
while( !key(_ESC) ) frame; end
while( key(_ESC) ) frame; end
// I expect it to be transparent in 32-bit and 16-bit
map_clear( 0, proc.graph, rgba( 100,100,100, 0) );
while( !key(_ESC) ) frame; end
while( key(_ESC) ) frame; end
end
begin
test_mode( 32 );
let_me_alone();
test_mode( 16 );
let_me_alone();
end[/code]
I do not expect to see grey square in 16 bit mode.
This issue makes it impossible to clear existing 16-bit map with transparent color.
In 16bpp, rgba(r, g, b, a) is the same as rgb(r, g, b). In 16 ( & 8 ) bpp, the transparency is controlled by the local variable alpha.
Quote from: josebita on July 30, 2010, 11:49:51 AM
In 16bpp, rgba(r, g, b, a) is the same as rgb(r, g, b). In 16 ( & 8 ) bpp, the transparency is controlled by the local variable alpha.
Yes, this goes for a
process. But I want to make transparent
map. To be specific, I need to make a transparent hole on existing map.
Use black color RGB(0, 0, 0) in 16bpp for this (in your map).
I see, in 16bpp you cannot use partial transparency but when applied to a complete map, you can only use complete/no transparency.
Quote from: FreeYourMind on July 30, 2010, 12:10:51 PM
Use black color RGB(0, 0, 0) in 16bpp for this (in your map).
Not quite right. I managed to solve a problem by using zero as color (All bits, including alpha channel are zero in this case).
So, example above worked as I want after I have changed
map_clear( 0, proc.graph, rgba( 100,100,100, 0) ); to
map_clear( 0, proc.graph, 0 );Let call this a... feature :)
rgb0,0,0 isn't transparent... this was said 1000 times...
instead of RGB(0,0,0) you need use de absolut value 0. fexample
map_clear( 0, proc.graph, 0) ;