Anyone got a 24-bit or 16bit Graphics Card?

Miscellaneous Forums/General Discussion/Anyone got a 24-bit or 16bit Graphics Card?

Yah there's no reason why you couldn't do alpha blending on 16-bit and 24-bit screens unless the graphics hardware or driver does not support the blending portion of the API, which would be silly.

Alpha blending pseudocode:

SourceAlpha=Value of the alpha channel pixel in the image you are drawing
SourceRed=Value of the red component in the image you are drawing
SourceGreen=Value of the green component in the image you are drawing
SourceBlue=Value of the blue component in the image you are drawing

DestRed=Value of the red component already drawn on the backbuffer
DestGreen=Value of the green component already drawn on the backbuffer
DestBlue=Value of the blue component already drawn on the backbuffer

An example:

Source image pixel is $FF,$88,$33,$80 (alpha is about 128 on a range of 0..255)
Dest image pixel is $22,$66,$AA (who cares what the dest alpha is, not used)

AlphaScaleSource=(1.0/256)*SourceAlpha (convert it to a number between 0 and 1)

SourceRed=SourceRed*AlphaScaleSource
SourceGreen=SourceGreen*AlphaScaleSource
SourceBlue=SourceBlue*AlphaScaleSource

AlphaScaleDest=1.0-AlphaScaleSource (invert the alpha value to get what's left in the dest)

DestRed=DestRed*AlphaScaleDest
DestGreen=DestGreen*AlphaScaleGreen
DestBlue=DestBlue*AlphaScaleBlue

FinalRed=Max(255,SourceRed+DestRed) (combine source and destination contributions)
FinalGreen=Max(255,SourceGreen+DestGreen)
FinalBlue=Max(255,SourceBlue+DestBlue)

SetColor FinalRed,FinalGreen,FinalBlue
Plot X,Y

Nowhere in this process is the destination alpha value used or needed. The source alpha is used only to scale both the source pixel colors and the destination pixel colors, which are then added together. So if you have 256-color displays, 15-bit, 16-bit, 18-bit, 24-bit, it doesn't matter. So long as there is support for blending in the driver, which is usually in hardware, alpha blending will work. And in Blitz, your source image will likely have 8-bit alpha channels, regardless of how much bit depth the screen has.