Results 1 to 9 of 9

Thread: How to desaturate image?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Quote Originally Posted by Carver413 View Post
    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.
    Last edited by User137; 16-07-2014 at 05:25 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •