How to get DPI in C# .NET?

Use an instance of the Graphics class. You get this using the following within your form (could be in form’s Load event handler): float dx, dy; Graphics g = this.CreateGraphics(); try { dx = g.DpiX; dy = g.DpiY; } finally { g.Dispose(); }

C# WinForms disable DPI scaling

You’ll have bigger problems when you change the AutoScaleMode property. Increasing the DPI also changes the system font size. Necessarily so, font sizes are expressed in points, 1/72 inch. The fonts need to be bigger to get the same point size when the DPI increases and keep the text just as readable when viewed from … Read more

Android – how to get or set (print) DPI ( dots per inch ) of JPEG file while loading or saving it programmatically?

Just for convenience here is ready to copy and paste method: public static void saveBitmapToJpg(Bitmap bitmap, File file, int dpi) throws IOException { ByteArrayOutputStream imageByteArray = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, imageByteArray); byte[] imageData = imageByteArray.toByteArray(); setDpi(imageData, dpi); FileOutputStream fileOutputStream = new FileOutputStream(file); fileOutputStream.write(imageData); fileOutputStream.close(); } private static void setDpi(byte[] imageData, int dpi) { imageData[13] = … Read more

Changing DPI scaling size of display make Qt application’s font size get rendered bigger

High DPI support is enabled from Qt 5.6 onward. Setting QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling) in your application source code allows automatic high-DPI scaling. NOTICE: To use the attribute method, you must set the attribute before you create your QApplication object: #include <QApplication> int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); return app.exec(); }