![]() |
AW: Screenshot und Skalierung
Hier ist es noch einmal erklärt:
![]() |
AW: Screenshot und Skalierung
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo
ich komme erst jetzt wieder dazu, mich damit zu beschäftigen, deshalb erst heute meine Rückmeldung Ich stehe total auf dem Schlauch, auch in Bezug auf diese Antwort. Wieso startet das bei 0,0 ? Ich habe nochmal ein Bild angehängt worum es mir geht. Es gibt eine beliebige Anwendung, Position der Anwendung ist variabel. Ich benötige einen Screenshot dieser Anwendung. Handle der Anwendung hab ich. Ich erstelle also einen Screenshot vom kompletten Desktop, wie im Anhang zu sehen. Über das Handle bekomme ich die Koordinaten des Fenster der anderen Anwendung, hier im Beispiel 45 x 160. Das ist ja nicht 0 x 0 Die anderen Koordinaten habe ich ja auch. Ich muss also aus dem kompletten Screenshot den rot markierten Bereich rauskopieren. Wenn ich die Skalierung auf 100% hab, funktioniert es, wenn die Skalierung windowsseitig bei 125% ist, ist alles verschoben und die Maße passen nicht Zitat:
|
AW: Screenshot und Skalierung
Was ich erst jetzt verstanden hab, ich kann auch einen SCreenshot vom aktiven Fenster machen und muss gar nicht "rauskopieren"
Habe diese Funktion nun im Einsatz Das Problem mit der Skalierung bleibt aber, habe dann bei dem rot markierten Code das ganze noch so berücksichtigt. Damit scheint es nun zu funktionieren iWidth := round((Rec.Right - Rec.Left)*1.25); iHeight := round((Rec.Bottom - Rec.Top)*1.25);
Delphi-Quellcode:
function FormularSaveScreenShot(FileName: String; h : hWnd): Boolean;
var Rec: TRect; iWidth, iHeight: Integer; begin with TBitmap.Create do try GetWindowRect(h, Rec); iWidth := round((Rec.Right - Rec.Left)*1.25); iHeight := round((Rec.Bottom - Rec.Top)*1.25); Width := iWidth; Height := iHeight; BitBlt(Canvas.Handle, 0, 0, iWidth, iHeight, GetWindowDC(h), 0, 0, SRCCOPY); Result := True; try SaveToFile(Filename) except Result := False end; finally ReleaseDC(h, GetWindowDC(h)); Free; end; end; |
AW: Screenshot und Skalierung
@tofse01 , do yourself a favor and drop using this half baked approach by copying DC, because this will always have problems unless it get way more complicated, a complexity which very needed here to do it right.
See, you are creating a DC then copying from the target application DC, did you queried the target DC scaling ? no you did not, to be done right this way you should align the DC in parameters (dimensions, color, device capability and of course scaling ), here comes the OS forced values and the target application if it is following the OS request or is doing it by its own custom drawing, example AlphaSkins does the scaling on its own (only if configured to do that or just leave it the OS). Anyway, drop that approach and ask the target application to to the drawing for you ! this is simpler and will work exactly as intended no matter what OS is doing. Please take a look at the answer here ![]() And use PrintWindow, or even the better approach with SendMessage of WM_PRINTCLIENT or WM_PRINT .. ![]() |
AW: Screenshot und Skalierung
One more thing, with these Print function/messages the target will be drawn even if it is behind other windows, so you are not screenshot the desktop (as your code now), no, you are drawing the application as it would be if it is focused and on top.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:27 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