mirror of https://github.com/adamdruppe/arsd.git
add dpi function
This commit is contained in:
parent
38c84d7fa2
commit
baeadebbc4
|
@ -1158,6 +1158,27 @@ string sdpyWindowClass () {
|
|||
return null;
|
||||
}
|
||||
|
||||
/++
|
||||
Returns the DPI of the default monitor. [0] is width, [1] is height (they are usually the same though). You may wish to round the numbers off.
|
||||
+/
|
||||
float[2] getDpi() {
|
||||
float[2] dpi;
|
||||
version(Windows) {
|
||||
HDC screen = GetDC(null);
|
||||
dpi[0] = GetDeviceCaps(screen, LOGPIXELSX);
|
||||
dpi[1] = GetDeviceCaps(screen, LOGPIXELSY);
|
||||
} else version(X11) {
|
||||
auto display = XDisplayConnection.get;
|
||||
auto screen = DefaultScreen(display);
|
||||
|
||||
// 25.4 millimeters in an inch...
|
||||
dpi[0] = cast(float) DisplayWidth(display, screen) / DisplayWidthMM(display, screen) * 25.4;
|
||||
dpi[1] = cast(float) DisplayHeight(display, screen) / DisplayHeightMM(display, screen) * 25.4;
|
||||
}
|
||||
|
||||
return dpi;
|
||||
}
|
||||
|
||||
TrueColorImage trueColorImageFromNativeHandle(NativeWindowHandle handle, int width, int height) {
|
||||
throw new Exception("not implemented");
|
||||
version(none) {
|
||||
|
@ -11897,6 +11918,8 @@ struct Visual
|
|||
int DefaultDepth(Display* dpy, int scr) { return ScreenOfDisplay(dpy, scr).root_depth; }
|
||||
int DisplayWidth(Display* dpy, int scr) { return ScreenOfDisplay(dpy, scr).width; }
|
||||
int DisplayHeight(Display* dpy, int scr) { return ScreenOfDisplay(dpy, scr).height; }
|
||||
int DisplayWidthMM(Display* dpy, int scr) { return ScreenOfDisplay(dpy, scr).mwidth; }
|
||||
int DisplayHeightMM(Display* dpy, int scr) { return ScreenOfDisplay(dpy, scr).mheight; }
|
||||
auto DefaultColormap(Display* dpy, int scr) { return ScreenOfDisplay(dpy, scr).cmap; }
|
||||
|
||||
int ConnectionNumber(Display* dpy) { return dpy.fd; }
|
||||
|
|
Loading…
Reference in New Issue