Originally Posted by
Carver413
Code:
Function Gray(vColor:TByte4):TByte4;
Var
vAverage:TFlt;
begin
vAverage:=vColor.R*0.3+vColor.G*0.59+vColor.B*0.11;
result.R:=Round(vAverage);
result.G:=Round(vAverage);
result.B:=Round(vAverage);
result.A:=vColor.A;
end;
Round() would be bottlenecking that
Code:
Function Gray(vColor:TByte4):TByte4;
Var
vAverage: byte;
begin
vAverage:=round(vColor.R*0.3+vColor.G*0.59+vColor.B*0.11);
result.R:=vAverage;
result.G:=vAverage;
result.B:=vAverage;
result.A:=vColor.A;
end;
The function should work, if you are getting black you are not using it with right parameters and result value. It's not directly compatible with TColor if that is the type.
Bookmarks