I need to write a function for DPI screen scaling with parameters

  • Context: Undergrad 
  • Thread starter Thread starter chubbychub
  • Start date Start date
  • Tags Tags
    Function Parameters
Click For Summary
SUMMARY

The discussion centers on creating a function for DPI (dots per inch) screen scaling, specifically for Windows 11. The function should accept parameters ranging from 100% to 350% in 25% increments, adjusting the DPI accordingly. The relationship between percentage and DPI is defined by the formula Y = (25/24)X, where Y is the percentage and X is the DPI. The function must also account for rounding and ensure that the output remains within the bounds of 96 DPI to 336 DPI.

PREREQUISITES
  • Understanding of DPI (dots per inch) and its significance in screen resolution.
  • Familiarity with mathematical functions and formulas.
  • Basic programming skills to implement the function in a scripting language.
  • Knowledge of Windows 11 display settings and scaling options.
NEXT STEPS
  • Research how to implement mathematical functions in your preferred programming language.
  • Learn about rounding techniques in programming to handle decimal values.
  • Explore the impact of DPI settings on user interface design and usability.
  • Investigate the Windows 11 API for accessing display settings programmatically.
USEFUL FOR

Developers working on screen scaling solutions, UI/UX designers optimizing applications for different resolutions, and anyone interested in scripting for Windows 11 display settings.

chubbychub
Messages
5
Reaction score
0
i need to write a function for DPI screen scaling,

so the parameters is from 100 (percentage) to 350 (percentage) and increases at 25 (percentage) increase, it will subtract additional 1 DPI
so for example:

100% = 96 DPI which is -4
125% =120 DPI which is -5
150% =144 DPI which is -6
175% = 168 DPI which is -7
200% =192 DPI which is -8
225% = 216 DPI which is -9
250% = 240 DPI which is -10
275% = 264 DPI which is -11
300% = 288 DPI which is -12
325% = 312 DPI which is -13
350% = 336 DPi which is -14

if someone can help me solve this math problem please
 
Mathematics news on Phys.org
I do not know the abbreviation DPI but it seems
1 per cent = 0.96 DPI
 
but how can i write that into a function? that at every 25% increase, it should add 1 to subtract from?
 
Isn't it a homework?
 
anuttarasammyak said:
I do not know the abbreviation DPI but it seems.
1 per cent = 0.96 DPI
Pretty standard acronym for dots per inch, as used for printers.

The relationship is close to being linear, but a little bit messy. Each 25% increase corresponds to an increase of 24 DPI. A function's formula might have to do some rounding so as to map the percentage and DPI values onto the integers from 4 to 14.

Hill said:
Isn't it a homework?
Maybe, or maybe not.
 
no its not homework, i am trying to simplify a small script for macros, to detect screen size at different resolutions, using a function instead so that the script will work all the different monitor size and at different DPI scale for windows 11, if someone can help me write it please
 
chubbychub said:
no its not homework, i am trying to simplify a small script for macros, to detect screen size at different resolutions, using a function instead so that the script will work all the different monitor size and at different DPI scale for windows 11, if someone can help me write it please
The straightforward one is ##Y=\frac {25} {24} X##, where ##Y## is % and ##X## is DPI.
 
what about the limitations of 100 lowest bound and 350 highest bound?
 
Hill said:
The straightforward one is ##Y=\frac {25} {24} X##, where ##Y## is % and ##X## is DPI.
This provides only the relationship between dots per inch and percentages. The function also needs to map the DPI to the integers 4 through 14. This is similar to how Fahrenheit temps in the range 32 to 212 map to Celsius temps in the range 0 to 100.
 
  • #10
chubbychub said:
what about the limitations of 100 lowest bound and 350 highest bound?
##Y=max(100,min(350,int(\frac {25} {24} X +.5)))##
or
##X=max(96,min(336,int(\frac {24} {25} Y + .5)))##
 
  • #11
why is the .5 added on either equation? what does this means? its increments of 25% at a time, starting at 100% all the way to 350%
 
  • #12
chubbychub said:
why is the .5 added on either equation? what does this means? its increments of 25% at a time, starting at 100% all the way to 350%
It is there for rounding if the input is an arbitrary number.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 52 ·
2
Replies
52
Views
7K
Replies
5
Views
3K
  • · Replies 41 ·
2
Replies
41
Views
6K
  • · Replies 19 ·
Replies
19
Views
18K
  • · Replies 1 ·
Replies
1
Views
15K