rgba() and 16bit

Started by EugeneP, July 30, 2010, 07:45:38 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

EugeneP

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.

josebita

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.

EugeneP

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.

FreeYourMind

Use black color RGB(0, 0, 0) in 16bpp for this (in your map).

josebita

I see, in 16bpp you cannot use partial transparency but when applied to a complete map, you can only use complete/no transparency.

EugeneP

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 :)

SplinterGU

rgb0,0,0 isn't transparent... this was said 1000 times...
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

DCelso

instead of RGB(0,0,0) you need use de absolut value 0. fexample

map_clear( 0, proc.graph, 0) ;

Monstruos Diabólicos

"A PAck of classic GAMEs For BennuGD" en desarrollo
http://code.google.com/p/apagame4be/