Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
TheDarkIn1978
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook

Capabilities.screenDPI Returns Accurate Value on Simulator 0.9.4

i had been concerned that the PlayBook might not return an accurate value when calling Capabilities.screenDPI, which would be essential for portable applications targeting multiple screen sizes on multiple devices with the same code base, because the Samsung Galaxy Tab returns an inaccurate value (mostly because it's a table running a non-tablet version of Android OS).

 

i just received the following reply from RIM:

 

 

Hello,

Thank you for contacting BlackBerry Application Development Support.

I just tested this on a PlayBook 0.9.4 simulator and it returns 170 when running it as an installed AIR application. 

Regards,

Garett
Enterprise Solutions Consultant
Application Development Support
Research In Motion Limited
devsupport@rim.com

 

interestingly, as stated above, it appears that this call now returns an accurate value not only on a device but also on the 0.9.4 simulator.

 

 

you can test it yourself with the following code:

 

 

package
{
	import flash.display.Sprite;
	import flash.system.Capabilities;
	
	public class PlayBookTest extends Sprite
	{
		public function PlayBookTest()
		{
			trace("PlayBook Pixel Density: " + Capabilities.screenDPI);
		}
	}
}

 

 

 

 


PlayBook Applications:
Drop Swatch
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Capabilities.screenDPI Returns Accurate Value on Simulator 0.9.4

I wonder if you should report back to Garett (or maybe he'll see it here and respond to this) that 170 is not as accurate as it could be, unless they deliberately chose to use Math.ceil() on the value instead of rounding to the nearest integer.

 

The correct value is 169.333, so I would have thought 169 would be what screenDPI reports instead, assuming they can't do a more precise value.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
TheDarkIn1978
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook

Re: Capabilities.screenDPI Returns Accurate Value on Simulator 0.9.4

[ Edited ]

yeah, i was preparing to hardcode the value at 169 myself, but i guess the 0.67 difference within this pixel density is negligible.


PlayBook Applications:
Drop Swatch
Please use plain text.
Developer
thesmileman
Posts: 345
Registered: ‎03-13-2011
My Device: Playbook

Re: Capabilities.screenDPI Returns Accurate Value on Simulator 0.9.4

The UI guidelines say it is 169.3
Please use plain text.
Trusted Contributor
PBDev
Posts: 108
Registered: ‎12-28-2010
My Device: Free PlayBook

Re: Capabilities.screenDPI Returns Accurate Value on Simulator 0.9.4

The rounding error is about 0.17 of a dot per inch with a maximum error of 0.17 * 7 = 1.19 dots. the dot pitch is 0.15 mm so the maximum rounding error is 0.1785 mm or 0.007 inches. That's based on the UI guidelines.

 

But by the specs the PlayBook's screen is 7' diagonally. So

 

Math.sqrt((1024 * 1024) + (600 * 600)) = 1186.834 dots diagonally / 7 is 169.548 dpi. Rounded to the nearest integer is 170.

 

It's hard to say what's correct.

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Capabilities.screenDPI Returns Accurate Value on Simulator 0.9.4

The UI Guidelines, if we're going to use them for anything, happen to say the screen has 169.3 pixels per inch.

 

They also say 153.6mm by 90mm, which works out to 7.00886 or so inches.  If we take the 1186.834 dots and divide, we get 169.3334.  I expect that's where the 169.3 comes from in the UI Guidelines.

 

If there's one specification you don't want to be using as precise, it's the "7 inches" measurement.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Trusted Contributor
PBDev
Posts: 108
Registered: ‎12-28-2010
My Device: Free PlayBook

Re: Capabilities.screenDPI Returns Accurate Value on Simulator 0.9.4

The guidelines do change. Look at the guidelines for the size of the icons. It was 90x90 then 72x72 and now 86x86 and I have no idea why they recommend a 5 pixel transparent border when the icons are centered. Capabilities.screenDPI reports 170. What's correct the guidelines or Capabilities.screenDPI?

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Capabilities.screenDPI Returns Accurate Value on Simulator 0.9.4

Not to belabour the point, but the icon size is as you say a recommendation, whereas the true screen DPI is a physical characteristic of the device.  It will not change based on the whims of some UI designer, though it could be changed if it turns out to be inaccurate and someone thinks its important enough to fix.

 

It may or may not be the case that the 169.3 is correct.  Possibly 170 is correct.  Without a datasheet for the LCD we don't know for sure.

 

I'd put my money on the 1024x600 being exact, and on the (let's say average) 0.15mm dot pitch being exact.  The latter is very likely a hard value specified by the LCD manufacturer, with very tight tolerances.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Trusted Contributor
PBDev
Posts: 108
Registered: ‎12-28-2010
My Device: Free PlayBook

Re: Capabilities.screenDPI Returns Accurate Value on Simulator 0.9.4

[ Edited ]

You're probably right Peter. Like I said in my first post it's hard to say what's correct. When we get an actual device and can make precise measurements then we can complain about Capabilities.screenDPI reporting 170 if it should be 169.

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Capabilities.screenDPI Returns Accurate Value on Simulator 0.9.4

With an error around 0.5%, it will be very hard to measure! :smileyhappy:


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.