Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

[GR32] What's wrong with my Gamma()?

  Alt 25. Jan 2010, 16:22
This is my version of gamma:

Delphi-Quellcode:
procedure Gamma(ASource: TBitmap32; AFactor: Single);
var
  F: Single;
  I: Integer;
  LUT: TLUT8;
  B: TBitmap32;
begin
  AFactor := EnsureRange(AFactor, 0.1, 5);

  B := TBitmap32.Create;
  try
    B.Width := ASource.Width;
    B.Height := ASource.Height;

    for I := 0 to 255 do
    begin
      F := I / 255;
      F := Power(F, AFactor);

      LUT[I] := EnsureRange(Round(F * 255), 0, 255);
    end;

    ApplyLUT(B, ASource, LUT, True);

    ASource.Assign(B);
    ASource.Changed;
  finally
    B.free;
  end;
end;
Generally for values <0.1; 1.0) makes image lighter, for (1.0; 5.0> darker... What I did wrong?
  Mit Zitat antworten Zitat