Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
482 Beiträge
 
Delphi XE6 Professional
 
#7

Re: Black and white - advanced

  Alt 4. Dez 2010, 15:46
In my version:

Delphi-Quellcode:
function IntToByte(Value: Integer): Byte;
begin
  if Value < 0 then
    Result := 0
  else if Value > 255 then
    Result := 255
  else
    Result := Value
  ;
end;

var
  Luminousity: Integer;
  C, M, Y: Byte;

for I := 0 to ASource.Height - 1 do
begin
  for J := 0 to ASource.Width - 1 do
  begin
    C := (Bits.G + Bits.B) div 2;
    M := (Bits.R + Bits.B) div 2;
    Y := (Bits.R + Bits.G) div 2;
    Luminousity := Round(Bits.R * Input(Reds)) + Round(Bits.G * Input(Greens)) + Round(Bits.B * Input(Blues)) + Round(C * Input(Cyans)) + Round(M * Input(Magentas)) + Round(Y * Input(Yellows));
    Luminousity := IntToByte(Luminousity);
    Bits.R := Luminousity;
    Bits.G := Luminousity;
    Bits.B := Luminousity;
  end;
end;
Input R, G, B, C, M and Y are in -200..300 range.

Your new version is faster, but work as my version, mean don't correct for values < 0 and near 0
  Mit Zitat antworten Zitat