Differenze tra le versioni di "Convertire il valore di un colore in RGBA"
Da Gambas-it.org - Wikipedia.
(Creata pagina con "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: '''...") |
|||
Riga 2: | Riga 2: | ||
'''Public''' Sub Main() | '''Public''' Sub Main() | ||
− | Dim | + | Dim r, g, b, a As Integer |
<FONT Color=gray>' ''Il valore del colore va considerato così composto: <FONT Color=black>alfa</font>, <FONT Color=red>rosso</font>, <FONT Color=green>verde</font>, <FONT Color=blue>blu</font>.''</font> | <FONT Color=gray>' ''Il valore del colore va considerato così composto: <FONT Color=black>alfa</font>, <FONT Color=red>rosso</font>, <FONT Color=green>verde</font>, <FONT Color=blue>blu</font>.''</font> |
Versione delle 18:50, 16 nov 2015
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