Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.149 Beiträge
 
Delphi 12 Athens
 
#9

Re: Bildbearbeitung: Linien verstärken, gibt's sowas?

  Alt 29. Sep 2009, 21:24
Delphi-Quellcode:
procedure LinienFettierer(Image: TBitmap; Background: TColor; Size: Integer);
var
  x, y, x2, y2, x3, y3, R, G, B, P: Integer;
  C: TColor;
  Temp: TBitmap;
  Mask: Array of Array of Boolean;
begin
  SetLength(Mask, Size, Size);
  for x := 0 to Size - 1 do
    for y := 0 to Size - 1 do
      Mask[x, y] := True;//(x - Size div 2)
  Temp := TBitmap.Create;
  try
    Temp.Width := Image.Width + Size - 1;
    Temp.Height := Image.Height + Size - 1;
    for x := 0 to Temp.Width - 1 do
      for y := 0 to Temp.Height - 1 do
      begin
        R := 0; G := 0; B := 0; P := 0;
        for x2 := 0 to Size - 1 do
        begin
          x3 := x - Size div 2 + x2;
          if (x3 >= 0) and (x3 < Image.Width) then
            for y2 := 0 to Size - 1 do
            begin
              y3 := y - Size div 2 + y2;
              if (y3 >= 0) and (y3 < Image.Height) and Mask[x2, y2] then
              begin
                C := Image.Canvas.Pixels[x3, y3];
                if C <> Background then
                begin
                  Inc(R, GetRValue(C));
                  Inc(G, GetGValue(C));
                  Inc(B, GetBValue(C));
                  Inc(P);
                end;
              end;
            end;
        end;
        if P <> 0 then
          Temp.Canvas.Pixels[x, y] := RGB(R div P, G div P, B div P)
        else
          Temp.Canvas.Pixels[x, y] := Background;
      end;
    Image.Width := Temp.Width;
    Image.Height := Temp.Height;
    Image.Canvas.Draw(0, 0, Temp);
  finally
    Temp.Free;
  end;
end;
Miniaturansicht angehängter Grafiken
unbenannt_130.png  
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat