Board index » delphi » Tcolor to RGB converting?

Tcolor to RGB converting?

To load an image to a canvas property, i used the RGB(r,g,b) function to set
the pixel's color.
Now i want to save the image, so i need the opposite like ColorRGB(var r, g,
b);
I saw a ColortoRGB function, but that is not what i need apparently
I need to convert Tcolor to 3 seperate bytes r,g,b ...

any ideas?

thanx,

Interface.

 

Re:Tcolor to RGB converting?


The opposite of the RGB function are the GetRValue, GetGValue and GetBValue
functions, or use:

type
  TColorRGB = packed record
    Red, Green, Blue, Alpha: Byte;
  end;

function RGBToColor(const R, G, B: Byte): TColor;
begin
  TColorRGB(Result).Red := R;
  TColorRGB(Result).Green := G;
  TColorRGB(Result).Blue := B;
  TColorRGB(Result).Alpha := 0;
end;

procedure ColorToRGB(const C: TColor; var R, G, B: Byte);
begin
  R := TColorRGB(C).Red;
  G := TColorRGB(C).Green;
  B := TColorRGB(C).Blue;
end;

ps. The alpha channel can be used for several purposes, like defining system
colors or transparency.

"Magic Interface" <Magic_Interf...@yahoo.com.should_be> schreef in bericht
news:xy145.4587$Ve.4869@afrodite.telenet-ops.be...

Quote
> To load an image to a canvas property, i used the RGB(r,g,b) function to
set
> the pixel's color.
> Now i want to save the image, so i need the opposite like ColorRGB(var r,
g,
> b);
> I saw a ColortoRGB function, but that is not what i need apparently
> I need to convert Tcolor to 3 seperate bytes r,g,b ...

> any ideas?

> thanx,

> Interface.

Re:Tcolor to RGB converting?


found it already...
thanx anyway :)

Magic Interface <Magic_Interf...@yahoo.com.should_be> schreef in
berichtnieuws xy145.4587$Ve.4...@afrodite.telenet-ops.be...

Quote
> To load an image to a canvas property, i used the RGB(r,g,b) function to
set
> the pixel's color.
> Now i want to save the image, so i need the opposite like ColorRGB(var r,
g,
> b);
> I saw a ColortoRGB function, but that is not what i need apparently
> I need to convert Tcolor to 3 seperate bytes r,g,b ...

> any ideas?

> thanx,

> Interface.

Other Threads