Einzelnen Beitrag anzeigen

hamptoncourt

Registriert seit: 20. Nov 2010
34 Beiträge
 
#13

AW: Bildbearbeitung - Astronomie-Aufgabe

  Alt 19. Dez 2010, 18:29
hmm ... nun tut sich gar nix mehr ...

Delphi-Quellcode:
type

  { TForm1 }
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Image1: TImage;
    Image2: TImage;
    Image3: TImage;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure roter_Kreis(xm, ym, r, anzahl : integer);

  private
    { private declarations }
  public
    { public declarations }


  end;

var
  Form1: TForm1;
  P1, P2, P3, P4: Integer;


Delphi-Quellcode:
procedure TForm1.Button2Click(Sender: TObject);
var
   i, j, l, k, xm, ym : Integer;
begin
  for j:=0 to image3.Height-1 do begin
   for i:=1 to image3.width-1 do begin
    if(image3.Canvas.pixels[i,j]-image3.Canvas.pixels[i-1,j]>10) then break;
    P1:=i;
   end;
  end;

  for k:=image3.width-1 to 0 do begin
   for l:=image3.Height-2 to 0 do begin
    if(image3.Canvas.pixels[k,l]-image3.Canvas.pixels[k,l+1]>10) then break;
    P2 := l;
   end;
  end;

  for l:=image3.Height-1 to 0 do begin
   for k:=image3.width-2 to 0 do begin
    if(image3.Canvas.pixels[k,l]-image3.Canvas.pixels[k+1,l]>10) then break;
    P3 := k;
   end;
  end;


  for i:=0 to image3.width-1 do begin
   for j:=1 to image3.Height-1 do begin
   if(image3.Canvas.pixels[i,j]-image3.Canvas.pixels[i,j-1]>10) then break;
   P4 := j;
   end;
  end;

   xm := round((P3-P1)/2);
   ym := round((P4-P2)/2);


 Form1.roter_Kreis(xm, ym, 15, 40);

end;

procedure TForm1.roter_Kreis(xm, ym, r, anzahl : integer);
var
   gesamtwinkel , winkelschritt : real;
   i, x, y : Integer;

begin
   winkelschritt := 4*PI/80;
   gesamtwinkel := 0;


   Image1.Canvas.Pen.Color := clRed;
   Image1.Canvas.MoveTo((xm+15),ym);

   For i := 1 To anzahl do begin
     gesamtwinkel := gesamtwinkel+winkelschritt;
     x := (xm + round(cos(gesamtwinkel) * r));
     y := (ym + round(sin(gesamtwinkel) * r));
     Image1.Canvas.LineTo(x,y);
   end;

end;
  Mit Zitat antworten Zitat