Difference between revisions of "RGBToColor"

From SCAR Divi Manual
Jump to: navigation, search
(Example 1)
(Example 2)
Line 42: Line 42:
  
 
begin
 
begin
   c := RGBToColor(1, 25, 127);
+
   c := RGBtoColor(1, 25, 127);
 
   WriteLn(c);
 
   WriteLn(c);
   ColorToRGB(c, r, g, b);
+
   ColortoRGB(c, r, g, b);
 
   WriteLn(IntToStr(r) + ',' + IntToStr(g) + ',' + IntToStr(b));
 
   WriteLn(IntToStr(r) + ',' + IntToStr(g) + ',' + IntToStr(b));
 
end.
 
end.

Revision as of 10:10, 28 June 2011

Definition

function RGBtoColor(R, G, B: Integer): Integer;

Source Code

function RGBtoColor(R, G, B: Integer): Integer;
begin
  Result := R or (G shl 8) or (B shl 16);
end;

Availability

SCAR Divi 3.00 > Current

Description

Converts RGB values specified by R, G and B to a regular color value. The result can be split back into RGB values using ColorToRGB.

Example 1

begin
  WriteLn(RGBtoColor(0, 0, 0));
  WriteLn(RGBtoColor(255, 0, 0));
  WriteLn(RGBtoColor(0, 255, 0));
  WriteLn(RGBtoColor(0, 0, 255));
  WriteLn(RGBtoColor(255, 255, 255));
end.

Output:

0
255
65280
16711680
16777215

Example 2

var
  c, r, g, b: Integer;

begin
  c := RGBtoColor(1, 25, 127);
  WriteLn(c);
  ColortoRGB(c, r, g, b);
  WriteLn(IntToStr(r) + ',' + IntToStr(g) + ',' + IntToStr(b));
end.

Output:

8329473
1,25,127

See Also