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;
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
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.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;
Last edited by User137; 16-07-2014 at 05:25 PM.
Bookmarks