Created
February 22, 2017 20:11
-
-
Save 44100hertz/a9b7e0c776ab7f5210e99d01745a2b11 to your computer and use it in GitHub Desktop.
DPI calculator
This file contains hidden or 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
#include <cstdio> | |
#include <cmath> | |
#include <vector> | |
int main() | |
{ | |
const auto sizes = {12.1, 13.3, 14.0}; | |
const auto res_x = {1440.0, 1680.0, 1920.0, 2048.0, 2560.0, 2880.0, 3840.0}; | |
const double aspect = 10.0/16.0; | |
const double x_multiple = 1.0/(1.0 + aspect*aspect); | |
std::printf("inches\tresolution\tppi\n"); | |
for (double size : sizes) { | |
double x_size = std::sqrt(size*size*x_multiple); | |
for (double res : res_x) { | |
double ppi = res / x_size; | |
std::printf("%0.1f\t%0.0fx%0.0f\t%0.1f\n", | |
size, res, res*aspect, ppi); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment