BGR function 

Purpose

Create a BGR color value from 3 primary color values or from an RGB value

Syntax

result& = BGR(red&, green&, blue&)

result& = BGR(rgbexpr&)

Remarks

An RGB value is a long integer value in the range of 0 to &H00FFFFFF. It is used to specify a very precise color to various PowerBASIC functions and Windows API functions.  The lowest three bytes of the value each specify the intensity of a primary color which combine to form the resultant color.  Byte 1 (lowest) represents the red component, byte 2 the green, and byte 3 the blue.  They can each take on a value in the range of 0 to 255.  Byte 4 (highest) is always 0.

Some Windows API functions, such as those which reference Device Independent Bitmaps (DIB), require that the colors be specified in the reverse sequence (Blue-Green-Red instead of Red-Green-Blue).  In order to maximize performance and execution speed, PowerBASIC statements and functions which reference these structures also use the BGR format. These include GRAPHIC GET BITS and GRAPHIC SET BITS. When used with 3 parameters, the BGR() function creates a BGR value from the three component values.

When used with one parameter, this function translates an RGB value to its BGR equivalent by swapping the first byte with the third byte, and returning the result.

For example, the RGB value of blue is &HFF0000.  BGR() translates it to &H0000FF.  Calling RGB() with that value converts it back to &HFF0000.

See also

RGB