Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [AGK V1 Feature Request] Command For Retrieving Screen DPI/PPI

Author
Message
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 7th Apr 2014 16:26 Edited at: 7th Apr 2014 16:49
I would really like to have a command to find out what the current DPI/PPI is on a mobile device for automatically resizing the game's graphics to account for high res on a small screen or low res on a big screen.

This should be a really easy command to implement, shouldn't it, Paul?

*crosses fingers and hopes Paul actually sees this post*

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 7th Apr 2014 17:02
@Clonkex,Paul

for android should be in
DisplayMetrics
.densityDpi



AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 7th Apr 2014 20:22
This command should be available for us on both Android and iOS. It is really difficult to design nice UI without knowing pixel density!

Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 7th Apr 2014 20:31
Doesn't GetDeviceWidth() and GetDeviceHeight() work?

Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 7th Apr 2014 20:38
No. It returns pixels. We need pixel density.
The biggest use of this is with text and UI.

I want my test to be, say, 0.5 inches high on all devices.
This is impossible to do without knowing PPI.
Which means that I have to pick a percent or pixel size.
If I pick a percent, say 2%, it would make the font 24 pixels high on a Nexus 7 which would be 0.11 inches high.
On a Nexus 5 it would result in 0.05 inches high text which is impossible to read and won't render well.

Pixel density is extremely common to use in mobile development.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 7th Apr 2014 21:03
without this feature it can be a input option 5"/7"/10"/22".
today i wonder me why windows is by default 96 dpi because its
often wrong.
i have a paint tool that shows a bar and ask how long it is on screen
for calculate the dpi ...

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 7th Apr 2014 22:40
Ah, I read the thread too fast

Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 8th Apr 2014 01:45
Quote: "for android should be in
DisplayMetrics
.densityDpi"


Why do you assume I'm using T2? I can't do that in T1.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 8th Apr 2014 08:25
@Clonkex
that was for paul because android is java.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Satchmo
18
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 9th Apr 2014 05:46 Edited at: 9th Apr 2014 05:49
Hey guys.

I've come across this problem in the past and have figured out a solution. I have a function I use in most of my apps for returning "Screen DPI/PPI"



Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 9th Apr 2014 05:49
@Satchmo
That's some magic function you've got there...

Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 9th Apr 2014 11:02 Edited at: 9th Apr 2014 11:03
@Satchmo

Wow, that's BRILLIANT!! That's gotta be the BEST function I've ever seen in my WHOOOOLE life!! My mind is totally BLOWN, dude! My face is just like !



Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 10th Apr 2014 03:35
added to the google code project
https://code.google.com/p/agk/issues/detail?id=641

Login to post a reply

Server time is: 2024-05-11 20:54:24
Your offset time is: 2024-05-11 20:54:24