ARGBToRGB Function

Requires: Direct2D.lg32

Purpose

Returns a RGB formatted color value from an ARGB color value, ignores the alpha channel.

Syntax

rgb% = ARGBToRGB(argbcol)

rgb%: Long Integer containing RGB colour value
argbcol: Long Integer containing ARGB colour value

Description

Converts a ARGB color value (AARRGGBB) to a RGB color value (BBGGRR) ignoring the alpha channnel. This is useful in places where a Direct2D color is used as input for a GDI or OCX color argument, see example.

Example

'

' ARGBToRGB sample (dpi-unaware)

'

$Library "direct2d"

Global Object Win1RT

OpenW 1, 0, 0, 320, 260, ~15

Set Win1RT = D2GetRT()

Global Long BkCol = D2C_WhiteSmoke

' Match the window's background to the D2 background,

' this prevents a flicker when processing WM_PAINT.

Win_1.BackColor = ARGBToRGB(D2C_WhiteSmoke)

Do

Sleep

Until Me Is Nothing

 

Sub Win_1_Paint

D2BeginDraw Win1RT, D2C_WhiteSmoke

D2ForeColor = D2C_Brown

D2Box 20, 20, 120, 120

D2PBox 20, 20, 120, 120

' Create and select a 50% transparent fillpattern

D2DefFill ARGB(128, 0, 128, 0)

D2PBox 70, 20, 240, 120

D2EndDraw

EndSub

See Also

ARGB, D2Color, D2ForeColor, D2BkColor, D2RGBColor

{Created by Sjouke Hamstra; Last updated: 04/03/2021 by James Gaite}