How to find out dpi of a certain device

4 posts / 0 new
Last post
DI (FH) Ludwig Ertl
ert@csp.at's picture
Offline
Mobile Conjurer
Joined: 22 Feb 2010
Posts:
How to find out dpi of a certain device

Hi,

I know that I can get the screen resoultion by calling maFrameBufferGetInfo before initializing my framebuffer.But I don't know how I can find out the dpi resolution of the targe device. I also haven't found anything in the header files of the device profiles.
Or is there a specific resolution I should always assume, like 72dpi?

Oh, and when talking about the framebuffer, what does the member
int supportsGfxSyscalls;
indicate? I guess there are some fast operations for drawing that I could use in this case which are directly supported by the target platform, but how do I use them to speed up my UI library in case it's supported by the target platform? Or should I just ignore this member?

I hope this is the right place to post this question to...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Hi, certainly is the right place. I don't know of any way of getting the dpi of a device. The logical size of the screen is available, but not the physical size.

supportsGfxSyscalls does indicate that the current platform has support for the fast drawing syscalls. I think that every platform supports them, as they are used frequently in MAUI.

DI (FH) Ludwig Ertl
ert@csp.at's picture
Offline
Mobile Conjurer
Joined: 22 Feb 2010
Posts:

Hi, could you implement such functionality in MoSync? this would be quite handy...
For Windows Mobile, for instance, you just would have to call
GetDeviceCaps(NULL, LOGPIXELSX) and GetDeviceCaps(NULL, LOGPIXELSY)
Android: http://developer.android.com/reference/android/util/DisplayMetrics.html
For Iphone etc.., this you could make a #define i nthe device profile, I think the IPhone has 163dpi.

Regarding the Gfx-Syscalls: Would they draw to the framebuffer memory so that buffer and screen are in sync, or are they
just drawing to the output screen so that the drawing would go away again on next maUpdateScreen call?
I remember using the maLine etc. Syscalls once and they were not compatible with the framebuffer iirc.

Mattias Bybro
mattiasb's picture
Offline
Mobile Wizard
Joined: 20 Jan 2010
Posts:

+1 on this one! Important for creating truly cross-platform apps -- only having pixel-based units of measurement is very limiting and makes it difficult to handle the multitude of screen sizes, dpis, etc.