The old Alpha channel

Community Forums/General Help/The old Alpha channel

Blitzplotter(Posted 2013) [#1]
I've two runners, a green and a purple one displayed within a small part of a display which are dynamically updated during GPS data replay:



Thing is they obliterate each other, is anyone aware of the, I think its called the alpha channel, for setting a colour that is transparent as the background colour for use within B3D? Any tutorials/code that anyone is aware of would be greatly appreciated.

Am sure I'll get there in the end, I don't mind sharing that seeing comparative 'runners' in 2D was quite sweet earlier today - its been a long path to get here though.

The sweet thing was I thought what'll I use as 'markers' in the GUI pictured above - I grabbed the images from my Blitz 3D app - which was initially rendered by myself in Blender and just used Gimp to give them the white background. Rudimentary to a lot of folk, I know - but there you go.


dawlane(Posted 2013) [#2]
Hi BP
Why use a any kind of background at all when you can remove it and save the image as a png?

I'm not at the computer at the moment to look at B3D's docs, but I'm sure there was a command to set the transparency with a colour/mask key command. If not, then I think there was something in the code archives.

EDIT: Ha found it.
It's MaskImage use to set the masking colour for an image. colour is in RGB format.
Syntax: MaskImage image_handle, red_value, green_value, blue_value


steve_ancell(Posted 2013) [#3]
MaskImage imageHandle, r, g, b

Didn't notice the bit where you said that you found it, I'm half asleep at the moment.


Blitzplotter(Posted 2013) [#4]
Steve, that makes it really clear (no pun intended) ;), thanks.


Blitzplotter(Posted 2013) [#5]
Alpha Channel 101 :--

Okay, had a revelation - tried to invoke the maskimage, however I am using fastlibs - so, I dipped into the fastlibs examples directory, opened up the image which had a 'maskimage' working very well in one of the examples - opened the image in GIMP and everything became clear - I needed to simply use GIMP's Color to To Alpha function within the Layer - Transparency - Color to Alpha option.

http://graphicdesign.stackexchange.com/questions/6449/add-transparency-to-an-existing-png

Happy Days:




_PJ_(Posted 2013) [#6]
Glad you got it sorted, Sorry if this is a bit late, but I just thought this might need some clarification in case it matters in the future:

The way Blitz3D handles Images (2D) doesn't actually take into account the "Alpha Channel", there is no means to Natively achieve "Alpha transparency" in Blitz3D aside from "Masking" which is what you achieved above.

Take a 32-Bit Depth pixel for example. These are com[prised of 4 channels, each of 8-bits (8 x 4 = 32 )
These are broken down as:
Red = 8Bits
Green = 8Bits
Blue = 8Bits
Alpha= 8bits

This alpha channel, in the 32-bit colour (where Alpha is denoted by 8 bits) can therefore be any of 256 different states. Typically 0-255
This infers 256 levels of transparency, with 255 being completely opaque and 0 being invisible.

You can have many other varieties of colour depths, and different arrangements such as 5 bits per R,G and B channel and just 1 bit for Alpha to make a 16-bit colour. In which case, the single Alpha bit is either On (Invisible) or Off (Opaque)

None of these alpha values, however, have the slightest effect on an Image rendered by Blitz3D*. Instead, blitz3D only considers the colour channels of the image (R,G and B)
Therefore, a separate value is needed, which represents the 32-Bit (though really only 24-Bits (Rx8,Gx8 and Bx8)) which should be considered "transparent". This is defined by the MaskColor command.

Unlike with 32-Bit depth Alpha, where there were 256 different values for transparancy, the MaskColor pixels will be totally transparent.
There is no means to natively obtain "partial transparency" in Blitz3D

By Default, MaskColor is set to black (0,0,0)







*3D Sprites and textures, however in B3D do make full use of Alpha levels from the images used to load them.


Blitzplotter(Posted 2013) [#7]
_PJ_ , thanks for the additional info.