Last active
February 17, 2023 18:21
-
-
Save sulincix/64e91dd99888440f17981e0cb8d50ca2 to your computer and use it in GitHub Desktop.
dpi bulucu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// valac --pkg gtk+-3.0 main.vala -o main | |
int main(string[] args){ | |
double constant_screen = 50.95481424; | |
Gtk.init(ref args); | |
var display = Gdk.Display.get_default(); | |
for (var i = 0; i < display.get_n_monitors (); i++){ | |
var monitor = display.get_monitor(i); | |
var width_milimeter = monitor.get_width_mm(); | |
var height_milimeter = monitor.get_height_mm(); | |
var width_pixel = monitor.get_geometry().width; | |
var height_pixel = monitor.get_geometry().height; | |
var wdpi = (float)width_milimeter/(float)width_pixel; | |
var hdpi = (float)height_milimeter/(float)height_pixel; | |
var dpi_recommend = (constant_screen/(wdpi+hdpi)); | |
stdout.printf("%s %s => psize:%d:%d size:%d:%d dpi:%.2f:%s%.2f\n".printf( | |
monitor.get_manufacturer(), | |
monitor.get_model(), | |
width_milimeter, height_milimeter, | |
width_pixel,height_pixel, | |
dpi_recommend, "%", dpi_recommend*100/96 | |
)); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment