Reference pixels
Calculations
A practical way to put it
is to say that 1 inch equals
96 pixels, 72 points and 6 picas.
1 ″ = 96 px = 72 pt = 6 picas.
A logical
pixel or
reference pixel is independent of the physical pixels
present in a screen, but is tied to physical sizes.
More precisely, this binding to the inch is valid for a sight distance of 28 inch or about 70 cm. At a wider viewing distance larger letters are necessary, to the reference pixel is in fact an angle, not a distance:
(1 inch / 96) / (28 inch * 2π) * 360 degrees = 0.0213°
In other words, a right angle (90°) contains about 4222.3 logical pixels.
A program
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void Usage (void)
{
fprintf(stderr, "Usage: logpix screen res1 res2\n");
fprintf(stderr, "screen is the screen diagonal, in decimal inches\n");
fprintf(stderr,
"res1 and res2 are the number of physical pixels, in any order\n");
}
int main (int argc, char **argv)
{
double diagon, bigres, smlres;
double diagpix;
double ratio;
if (argc != 4)
{
Usage();
exit(1);
}
diagon = atof(argv[1]);
bigres = atof(argv[2]); smlres = atof(argv[3]);
if (smlres > bigres)
{
double swap = bigres;
bigres = smlres;
smlres = swap;
}
/* Pythagoras */
diagpix = sqrt(bigres*bigres + smlres*smlres);
/* 72 points (pt) in an inch.
12 pt = 16 logical pixels.
96 logical pixels in an inch. */
printf(
"Screen is %4.1f inch, %4.0f x %4.0f = %4.0f physical pixels\n",
diagon, bigres, smlres, diagpix);
/* printf("Diagonal is %5.0f physical pixels\n", diagpix); */
ratio = diagpix / (diagon * 96);
printf("Screen is %4.0f px, %4.0f x %4.0f logical pixels\n",
diagon * 96, bigres / ratio, smlres / ratio);
printf("One logical pixel is %5.3f physical pixel\n", ratio);
printf("Pixel density is %5.1f logical pixels per inch\n",
diagpix / diagon);
return 0;
}
Compiling it
cc logpix.c -lm -o yourbinpath/logpix
Sample output
user@machine:curdir$ logpix 6.3 2424 1080
Screen is 6.3 inch, 2424 x 1080 = 2654 physical pixels Screen is 605 px, 552 x 246 logical pixels One logical pixel is 4.388 physical pixel Pixel density is 421.2 logical pixels per inch
Copyright © 2025 by R. Harmsen, all rights reserved.