Autor Beitrag
idefix123456
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Do 14.10.10 16:55 
Hallo,

ich bin jetzt hier langsam am verzweifeln, und im Internet find ich auch nix.

Ich habe ein Dynamisches Bitmap mit dem Namen "Block" aus diesem Soll ein rechteck herausgeschnitten werden. Dieses rechteck soll nun einem Neuen Dynamischen Bild mit dem Namen "test" zugewiesen werden... hab diesen Code hier programmiert, leider funktioniert das nicht!


Währe dankbar über eine Antwort...


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure schneide_bloecke_aus_level_block();
  var
    img: TBmp;
    Schnitt: Trect;
begin
  img := TBmp.Create(Form1);
  img.Parent := Form1;
  img.Name := 'test';
  img.Width := 75;
  img.Height := 75;
  img.Left := 500;
  img.Top:= 500;
  img.Visible := true;
  img.Picture.Bitmap.Canvas.CopyRect(Rect(007575), TBmp(Form1.FindComponent('Block')).Picture.Bitmap.Canvas, Schnitt);
  Form1.FindComponent('test').Assign(img);
end;
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Do 14.10.10 17:15 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
procedure schneide_bloecke_aus_level_block(AParent:TWinControl;Const Name:String;theBounds:Trect;Source:Timage;SourceRect:Trect);
  var
    Img:TImage;
    paintrect: Trect;
begin
  paintrect := rect(0,0,theBounds.Right - theBounds.Left,theBounds.Bottom - theBounds.top);
  img := Timage.Create(AParent);
  with img do
    begin
     Parent := AParent;
     Name := 'test';
     boundsrect := theBounds;
     Canvas.FillRect(paintrect);
    end;

  img.Picture.Bitmap.Canvas.CopyRect(Paintrect,Source.Picture.Bitmap.Canvas  , SourceRect);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
     schneide_bloecke_aus_level_block(Form1,'test',Rect(500,500,575,575),Image1,Rect(0,0,75,75));
end