alpha in 8 bits

BlitzMax Forums/BlitzMax Programming/alpha in 8 bits

Bertrand(Posted 2005) [#1]
I'm surprise to see that the alpha channel use only 1 bit by default. Should be really good to solve that. For example, the TGA Loader module crash when i open picture with alpha.


taxlerendiosk(Posted 2005) [#2]
Er... sorry? Alpha works fine here. Where did you get the 1 bit thing from?


Bertrand(Posted 2005) [#3]
Could you give me an example of creating and visualising alpha in 8 bits please!


ziggy(Posted 2005) [#4]
I think you have the blendmode without alpha. setblend alphabled will use a BYTE to represent the alpha channel instead of a bit.


Bertrand(Posted 2005) [#5]
Well, i have that function:
Function Reorder:TPixmap(pixmap:TPixmap, Order:String = "rgba")
Local Alp:Byte = 0
Local Red:Byte = 0
Local Gre:Byte = 0
Local Blu:Byte = 0

Local rouge:String
Local vert:String
Local bleue:String
Local mask:String

Local re:Int
Local ge:Int
Local be:Int
Local ae:Int

Order = Lower(Order)

rouge$ = Right(Left(Order,1), 1)
If rouge$ = "r" Then re = 16
If rouge$ = "g" Then re = 8
If rouge$ = "b" Then re = 0
If rouge$ = "a" Then re = 24

vert$ = Right(Left(Order ,2), 1)
If vert$ = "r" Then ge = 16
If vert$ = "g" Then ge = 8
If vert$ = "b" Then ge = 0
If vert$ = "a" Then ge = 24

bleue$ = Right(Left(Order ,3), 1)
If bleue$ = "r" Then be = 16
If bleue$ = "g" Then be = 8
If bleue$ = "b" Then be = 0
If bleue$ = "a" Then be = 24

mask$ = Right(Left(Order ,4), 1)
If mask$ = "r" Then ae = 16
If mask$ = "g" Then ae = 8
If mask$ = "b" Then ae = 0
If mask$ = "a" Then ae = 24

Local x:Int
Local y:Int
Local argb:Int
Local out:TPixmap=CreatePixmap( pixmap.width, pixmap.height, pixmap.format )

For x = 0 To PixmapWidth(pixmap)-1
For y = 0 To PixmapHeight(pixmap)-1
argb = ReadPixel(pixmap, x, y)

Alp = (argb Shr ae ) & $FF
Red = (argb Shr re ) & $FF
Gre = (argb Shr ge ) & $FF
Blu = (argb Shr be ) & $FF

argb = (Alp Shl 24) + (Red Shl 16) + (Gre Shl 8) + (Blu)
WritePixel(out, x, y, argb)
Next
Next
Return out
End Function

When i reorganize the RGB channels, it work perfectly.
But when i copy one of RGB channel in the Alpha, i get a binary channel, Please, tell me my mistake?