Entwickler-Ecke

Multimedia / Grafik - tBitMap einen Ausschnitt eines anderen TBitMap zuweisen


GSE - So 25.05.03 11:32
Titel: tBitMap einen Ausschnitt eines anderen TBitMap zuweisen
Hi Leutz,
mein Problem ist, dass ich einem per Create erstelltem TBitMap eines Ausschnitt eines anderen tBitMaps Objekt zuweisen möchte. Ich hab´das mit CopyRect versucht klappt aber nicht.
Sieht ungefähr so aus:

Quelltext
1:
2:
3:
vbmp := tBitMap.create;
//Hier möchte ich vbmp den Auschnitt rect(x1,y1,x2,y2) des image1.picture.bitmap zuweisen
vbmp.assign(image1.picture.bitmap);

Ich hab´s so versucht:

Quelltext
1:
2:
vbmp.width := x2; vbmp.height := y2;
vbmp.canvas.copyrect(rect(0,0,x2,y2), image1.canvas, rect(x1,y1,x2,y2));
funktioniert aber nicht.

Wer kann mir helfen?
Danke schon im Vorraus.

mfg
GSE


Moderiert von user profile icontommie-lie: Topic verschoben


GSE - Mo 26.05.03 15:50

Hab´s jetzt so gelöst:

Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
  if x2 >= x1 then dx := x2-x1 else dx := x1-x2;
  if y2 >= y1 then dy := y2-y1 else dy := y1-y2;
  vbmp := TBitMap.create;
  vbmp.assign(image1.picture.bitmap);
  vbmp.canvas.copyrect(Rect(0,0,dx,dy), vbmp.canvas, rect(x1,y1,x2,y2));
  vbmp.width := dx;
  vbmp.height := dy;


Erst wird dem erstellten TBitMap das ganze Bild zugewiesen, dann wird der ausgewählte Bereich in die linke obere Ecke kopiert und das BitMap wird entsprechend verkleinert.

mfg
GSE