Here is the test program I used to generate the images testing ALPHA. A latest build of fbc 1.20 is required.
Code: Select all
#include once "fbgfx.bi"
const MAXSIZE = 64
dim shared gradient( 0 to MAXSIZE-1 ) as ulong = _
{ _
000, 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, _
020, 025, 030, 030, 035, 040, 050, 060, 070, 080, 090, 110, 120, 123, 126, 127, _
128, 129, 132, 140, 150, 160, 170, 180, 190, 200, 210, 215, 220, 225, 230, 235, _
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 _
}
sub plot _
( _
byval xc as single, _
byval yc as integer, _
byval img as fb.image ptr, _
byref title as const string _
)
const HGUTTER = 32
const VGUTTER = 64
const LEFTMARGIN = 32
const TOPMARGIN = 32
dim xx as integer = LEFTMARGIN + xc*(MAXSIZE+HGUTTER)
dim yy as integer = TOPMARGIN + yc*(MAXSIZE+VGUTTER)
put (xx,yy), img, pset
dim yt as integer = yy - 16
draw string (xx, yt), title
dim x1 as integer = xx - 2
dim x2 as integer = xx + MAXSIZE + 1
dim y1 as integer = yy - 2
dim y2 as integer = yy + MAXSIZE + 1
line (x1,y1)-(x2,y2),rgba(255,255,255,255),b
end sub
function getAlphaPrimitives( ) as ulong
dim value as ulong
ScreenControl fb.GET_ALPHA_PRIMITIVES, value
return value
end function
sub setAlphaPrimitives( byval value as ulong )
ScreenControl fb.SET_ALPHA_PRIMITIVES, value
end sub
sub InitRGBA _
( _
byval dst as fb.image ptr, _
byval r as ulong, _
byval g as ulong, _
byval b as ulong, _
byval a as ulong _
)
var ap = getAlphaPrimitives()
setAlphaPrimitives( 0 )
for y as integer = 0 to MAXSIZE-1
for x as integer = 0 to MAXSIZE-1
pset dst, ( x, y ), rgba( r, g, b, a )
next
next
setAlphaPrimitives( ap )
end sub
sub InitChnl _
( _
byval dst as fb.image ptr, _
byval src as fb.image ptr, _
byval channel as integer _
)
var ap = getAlphaPrimitives()
setAlphaPrimitives( 0 )
dim psrc as ulong ptr = cast( ulong ptr, fb.__pixels( src ) )
dim pdst as ulong ptr = cast( ulong ptr, fb.__pixels( dst ) )
for y as integer = 0 to MAXSIZE-1
for x as integer = 0 to MAXSIZE-1
dim c as ulong = psrc[y*src->pitch\4 + x]
c = (c shr (8 * channel)) and &hff
c = rgba( c, c, c, 255 )
pset dst, ( x, y ), c
'' pdst[y*dst->pitch\4 + x] = c
next
next
setAlphaPrimitives( ap )
end sub
sub InitGrad _
( _
byval dst as fb.image ptr, _
byval r0 as ulong, byval g0 as ulong, byval b0 as ulong, byval a0 as ulong, _
byval rdx as single, byval gdx as single, byval bdx as single, byval adx as single, _
byval rdy as single, byval gdy as single, byval bdy as single, byval ady as single _
)
dim as ulong r, g, b, a
var ap = getAlphaPrimitives()
setAlphaPrimitives( 0 )
for y as integer = 0 to MAXSIZE-1
for x as integer = 0 to MAXSIZE-1
r = r0 + gradient(x) * rdx + gradient(y) * rdy
g = g0 + gradient(x) * gdx + gradient(y) * gdy
b = b0 + gradient(x) * bdx + gradient(y) * bdy
a = a0 + gradient(x) * adx + gradient(y) * ady
pset dst, ( x, y ), rgba( r, g, b, a )
next
next
setAlphaPrimitives( ap )
end sub
const flags = fb.GFX_ALPHA_PRIMITIVES
screenres 512, 768, 32, 1, flags
ScreenControl fb.SET_X86_MMX_ENABLED, 0
dim src as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim sc0 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim sc1 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim sc2 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim sc3 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim dst as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim dc0 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim dc1 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim dc2 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim dc3 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim rst as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim rc0 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim rc1 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim rc2 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim rc3 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim qst as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim qc0 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim qc1 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim qc2 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim qc3 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim wst as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim wc0 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim wc1 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim wc2 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim wc3 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim yst as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim yc0 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim yc1 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim yc2 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
dim yc3 as fb.image ptr = imagecreate( MAXSIZE, MAXSIZE )
do
cls
InitRGBA( src, 0, 0, 0, 0 )
InitRGBA( dst, 0, 0, 0, 0 )
InitRGBA( rst, 0, 0, 0, 0 )
InitRGBA( wst, 255, 255, 255, 1 )
InitRGBA( yst, 255, 255, 255, 1 )
InitGrad( src, 0, 0, 0, 0, 1.0, 1.0, 0.0, 0.5, 0.0, 0.0, 1.0, 0.5 )
InitGrad( dst, 0, 0, 0, 0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0 )
put rst, (0, 0), dst, pset
put rst, (0, 0), src, pset
put qst, (0, 0), dst, pset
put qst, (0, 0), src, pset
for i as integer = 15 to 0 step -1
put qst, (0, i), qst, alpha, 255
next
put yst, (0, 0), wst, pset
put yst, (0, 0), qst, alpha, 255
InitChnl( sc0, src, 0 )
InitChnl( sc1, src, 1 )
InitChnl( sc2, src, 2 )
InitChnl( sc3, src, 3 )
InitChnl( dc0, dst, 0 )
InitChnl( dc1, dst, 1 )
InitChnl( dc2, dst, 2 )
InitChnl( dc3, dst, 3 )
InitChnl( rc0, rst, 0 )
InitChnl( rc1, rst, 1 )
InitChnl( rc2, rst, 2 )
InitChnl( rc3, rst, 3 )
InitChnl( qc0, qst, 0 )
InitChnl( qc1, qst, 1 )
InitChnl( qc2, qst, 2 )
InitChnl( qc3, qst, 3 )
InitChnl( wc0, wst, 0 )
InitChnl( wc1, wst, 1 )
InitChnl( wc2, wst, 2 )
InitChnl( wc3, wst, 3 )
InitChnl( yc0, yst, 0 )
InitChnl( yc1, yst, 1 )
InitChnl( yc2, yst, 2 )
InitChnl( yc3, yst, 3 )
plot 0, 0, src, "src"
plot 1, 0, sc0, "srcB"
plot 2, 0, sc1, "srcG"
plot 3, 0, sc2, "srcR"
plot 4, 0, sc3, "srcA"
plot 0, 1, dst, "dst"
plot 1, 1, dc0, "dstB"
plot 2, 1, dc1, "dstG"
plot 3, 1, dc2, "dstR"
plot 4, 1, dc3, "dstA"
plot 0, 2, rst, "rst"
plot 1, 2, rc0, "rstB"
plot 2, 2, rc1, "rstG"
plot 3, 2, rc2, "rstR"
plot 4, 2, rc3, "rstA"
plot 0, 3, qst, "qst"
plot 1, 3, qc0, "qstB"
plot 2, 3, qc1, "qstG"
plot 3, 3, qc2, "qstR"
plot 4, 3, qc3, "qstA"
plot 0, 4, wst, "wst"
plot 1, 4, wc0, "wstB"
plot 2, 4, wc1, "wstG"
plot 3, 4, wc2, "wstR"
plot 4, 4, wc3, "wstA"
plot 0, 5, yst, "yst"
plot 1, 5, yc0, "ystB"
plot 2, 5, yc1, "ystG"
plot 3, 5, yc2, "ystR"
plot 4, 5, yc3, "ystA"
dim value as long
ScreenControl fb.GET_X86_MMX_ENABLED, value
if( value ) then print "X86_MMX_ENABLED ";
ScreenControl fb.GET_ALPHA_PRIMITIVES, value
if( value ) then print "ALPHA_PRIMITIVES ";
dim as string k
do
k = inkey
sleep 50, 1
loop until k > ""
select case k
case chr(27)
exit do
case "x", "X"
dim value as long
ScreenControl fb.GET_X86_MMX_ENABLED, value
ScreenControl fb.SET_X86_MMX_ENABLED, iif(value,0,1)
case "a", "A"
dim value as long
ScreenControl fb.GET_ALPHA_PRIMITIVES, value
ScreenControl fb.SET_ALPHA_PRIMITIVES, iif(value,0,1)
end select
loop