![]() |
Einen Ausschnitt einer Metafile in eine Metafile kopieren.
Einen Ausschnitt einer Metafile in eine Metafile kopieren.
Ich dachte eigentlich daß man das so eventuell machen könnte, geht aber nicht. Er kopiert so immer die ganze Metafile? :gruebel:
Delphi-Quellcode:
procedure TDrawPad.CopySelectedRectToClipboard(const SelectRect: TFloatRectEx);
var ppMM: double; Rect: TRect; MF: TMetaFile; MC: TMetaFileCanvas; begin if SelectRect.Angle = 0 then begin ppMM := PlotDevice[csDefault].ppMM; Rect.Left := Round(ppMM * SelectRect.P1.X); Rect.Top := Round(ppMM * SelectRect.P1.Y); Rect.Right := Round(ppMM * SelectRect.P2.X); Rect.Bottom := Round(ppMM * SelectRect.P2.Y); MF := TMetaFile.Create; try MF.Width := Round(ppMM * SelectRect.Width); MF.Height := Round(ppMM * SelectRect.Height); MC := TMetaFileCanvas.Create(MF, 0); try MC.Draw(-Rect.Left, -Rect.Top, FMetaFile); finally MC.Free; end; Clipboard.Assign(MF); MF.SaveToFile('Test.emf'); finally MF.Free; end; end; end; |
AW: Einen Ausschnitt einer Metafile in eine Metafile kopieren.
Meintest Du evtl. MC.CopyRect statt MC.Draw?
[edit] Nach kurzer Recherche würde das so auch nicht funktionieren, vielleicht hilft Dir das hier weiter: ![]() |
AW: Einen Ausschnitt einer Metafile in eine Metafile kopieren.
CopyRect und Bitblt sind ja Pixelzeugs.
EnumEnhMetaFile ist nur was für "Männer ohne Nerven" und PlayEnhMetaFile braucht ein hdc. So stimmt schonmal die Bildgröße, aber Bild ist leer bzw. verschoben:
Delphi-Quellcode:
Dito:
IntersectClipRect(MC.Handle, Rect.Left, Rect.Top, Rect.Right, Rect.Bottom);
MC.Draw(0, 0, FMetaFile);
Delphi-Quellcode:
???
IntersectClipRect(MC.Handle, Rect.Left, Rect.Top, Rect.Right, Rect.Bottom);
MC.Draw(-Rect.Left, -Rect.Top, FMetaFile); |
AW: Einen Ausschnitt einer Metafile in eine Metafile kopieren.
Der hDC für PlayEnhMetaFile müsste doch TMetafileCanvas.Handle sein.
|
AW: Einen Ausschnitt einer Metafile in eine Metafile kopieren.
Delphi-Quellcode:
Weiß nicht, hdc ist zum Beispiel Bildschirm oder Printer.Handle. Kann ich denn als Dest das 2. Metafile.Handle oder MC.Canvas.Handle angben?
procedure DrawAntiAliased(Source: TMetafile; Dest: HDC; R: TRect);
begin Dec(R.Right); Dec(R.Bottom); PlayEnhMetaFile(Dest, Source.Handle, R); end; Edit: Jo. Geht. Thanx. Ist aber dasselbe wie Draw. |
AW: Einen Ausschnitt einer Metafile in eine Metafile kopieren.
Liste der Anhänge anzeigen (Anzahl: 1)
Falls jemand probieren möchte - herzlich willkommen. :)
-> Anlage. Krieg's nich hin.. :oops: |
AW: Einen Ausschnitt einer Metafile in eine Metafile kopieren.
Hab's hetzt doch raus. "Er" will die Metafile immer von 0/0 bis Rect.BottomRight; :wall:
Delphi-Quellcode:
procedure TMetafileExampleForm.Draw;
var MC: TMetafileCanvas; begin FMF2.Width := FRect.Right; FMF2.Height := FRect.Bottom; PaintBox2.Width := FMF2.Width; PaintBox2.Height := FMF2.Height; MC := TMetaFileCanvas.Create(FMF2, 0); try IntersectClipRect(MC.Handle, FRect.Left, FRect.Top, FRect.Right, FRect.Bottom); MC.Draw(0, 0, FMF1); finally MC.Free; end; Caption := Format('FMF2.Width %d FMF2.Height %d FRect.Width %d FRect.Height %d)', [FMF2.Width, FMF2.Height, FRect.Right - FRect.Left, FRect.Bottom - FRect.Top]); PaintBox2.Invalidate; end; |
AW: Einen Ausschnitt einer Metafile in eine Metafile kopieren.
Letzte Version.
Schönes WE. :)
Delphi-Quellcode:
procedure TMetafileExampleForm.Draw;
var MC: TMetafileCanvas; Temp: TMetaFile; begin Temp := TMetaFile.Create; try Temp.Width := FRect.Right; Temp.Height := FRect.Bottom; MC := TMetaFileCanvas.Create(Temp, 0); try IntersectClipRect(MC.Handle, FRect.Left, FRect.Top, FRect.Right, FRect.Bottom); MC.Draw(0, 0, FMF1); finally MC.Free; end; FMF2.Width := FRect.Right - FRect.Left; FMF2.Height := FRect.Bottom - FRect.Top; PaintBox2.Width := FMF2.Width; PaintBox2.Height := FMF2.Height; MC := TMetaFileCanvas.Create(FMF2, 0); try MC.Draw(-FRect.Left, -FRect.Top, Temp); finally MC.Free; end; finally Temp.Free; end; Caption := Format('FMF2.Width %d FMF2.Height %d FRect.Width %d FRect.Height %d)', [FMF2.Width, FMF2.Height, FRect.Right - FRect.Left, FRect.Bottom - FRect.Top]); PaintBox2.Invalidate; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:39 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz