Revision as of 15:04, 10 March 2009 by Forum Nokia KB (Talk | contribs)

Conversions between twips, pixels, and millimeters using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search


Article Metadata
Tested with
Devices(s): S60 (All)
Keywords: TwipsToPixels, PixelsToTwips
Created: (10 Mar 2009)
Last edited: Forum Nokia KB (10 Mar 2009)


The screen device in Symbian OS provides helper functions to convert a number of pixels to how much physical screen area they occupy (in twips, 1/1440 inches), and vice versa.

Detailed description

Information about how many pixels are required to draw a shape of a certain size in each device is especially useful in touch-enabled UIs, where icons and controls need to have a proper size for use with fingers.


The following methods convert between pixels and millimeters.

  #define KTwipInMillimeters 0.0176389
// Returns the number of pixels corresponding
// to millimeters (x,y) passed as parameter
TPoint MillimetersToPixels( const TPoint& aMm ) const
TReal twipsX = (TReal)aMm.iX / KTwipInMillimeters;
TReal twipsY = (TReal)aMm.iY / KTwipInMillimeters;
return iEikonEnv->ScreenDevice()->TwipsToPixels( TPoint((TInt)twipsX,
(TInt)twipsY) );
// Returns the number of millimeters corresponding
// to pixels (x,y) passed as parameter
TPoint PixelsToMillimeters( const TPoint& aPixels ) const
TPoint twips = iEikonEnv->ScreenDevice()->PixelsToTwips(aPixels);
TReal mmX = (TReal)twips.iX * KTwipInMillimeters;
TReal mmY = (TReal)twips.iY * KTwipInMillimeters;
return TPoint((TInt)mmX, (TInt)mmY);

Note that all currently available devices have square pixel aspect ratio.

73 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.