How can I get the screen scale ?

I am trying to use screenshotRectMBS to grab a window content, but I have trouble with left, top, width and height, since in Xojo coordinates are at 96 dpi, whereas the screen itself is 3840 x 2160 instead of being 1920 x 1080.

How would I go about getting that scale ?

I just tried this:

dim scale as double = TrueWindow.ScaleFactor system.debuglog "scale: " + str(scale)

Problem is, I get 1.75, not 2.

OK. It works. Somehow, Christian’s plugin finds its way through this:

dim scale as double = TrueWindow.ScaleFactor system.debuglog "scale: " + str(scale) dim p as picture =screenshotRectMBS(self.left * scale,self.top * scale,self.width * scale,self.height * scale)

I will leave this thread visible, as others may need the same.

you tested DrawInto? (Self is a Window)

[code]Var p As New Picture(Self.Width,Self.Height)

Self.DrawInto(p.Graphics,0,0)

Canvas1.Backdrop = p[/code]

I thought about using GetWindowRect from Windows API per declare to get the coordinates in pixels instead of points.

I think values that are not 1.0, 2.0 or 3.0 will only show up on MS Windows. Is that what you were working on, Windows?

MacOS appears to only use 1.0, 2.0 and maybe 3.0 (but my monitors only go up 4K, so I can’t test that fact).

The scaling logic between Windows and macOS are of course different. I ran my own tests to verify this, out of curiosity.

I think I also read this either in the docs or in a post somewhere in the forums (by @Greg O’Lone ??), but I can’t find it now.

iOS does 3.0, MacOS only 2.0 as far as I know.

[quote=472888:@Markus Rauch]you tested DrawInto? (Self is a Window)

[code]Var p As New Picture(Self.Width,Self.Height)

Self.DrawInto(p.Graphics,0,0)

Canvas1.Backdrop = p[/code][/quote]

Drawinto’s quality is dismal. Absolutely not usable for what I need.

The issue I see is that if you don’t change the name of the class, it will break existing code.

That is the reason I posted in the Windows channel :wink:

D’oh!

That’s good to know. Thank you.

Please explain. What class needs renaming?

If the class would no longer use points, but rather pixels, it could break existing code, would it not ?

screenshotRectMBS on Windows was always pixels as Windows itself uses pixels for Window and screen.
No need to change.