Convertire il valore di un colore in RGBA
Da Gambas-it.org - Wikipedia.
Versione del 16 nov 2015 alle 18:50 di Vuott (Discussione | contributi)
Per convertire in RGBA il valore di un colore, contenente anche il canale alfa attinente alla trasparenza, possiamo adottare il calcolo contenuto nel seguente codice:
Public Sub Main() Dim r, g, b, a As Integer ' Il valore del colore va considerato così composto: alfa, rosso, verde, blu. gt_color_to_rgba(&FF00FF00&, VarPtr(r), VarPtr(g), VarPtr(b), VarPtr(a)) Print "Rosso: "; r Print "Verde: "; g Print "Blu: "; b Print "Alfa: "; a End Private Function gt_color_to_rgba(colore As Long, rosso As Pointer, verde As Pointer, blu As Pointer, alfa As Pointer) Dim st As Stream st = Memory blu For Write Write #st, colore And &FF As Integer st.Close st = Memory verde For Write Write #st, (colore \ CInt(2 ^ 8)) And &FF As Integer st.Close st = Memory rosso For Write Write #st, (colore \ CInt(2 ^ 16)) And &FF As Integer st.Close st = Memory alfa For Write Write #st, (colore \ CInt(2 ^ 24)) And &FF As Integer st.Close End