Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.


From Wiki
Jump to: navigation, search
  • 开发伙伴平台:

Symbian C++

  • 详细描述

Symbian OS手机提供了一系列方法可以进行像素和它们对应屏幕物理大小(以twip为单位,1/1440英寸)的互相转换。

  • 解决方案


#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);


This page was last modified on 30 May 2013, at 04:40.
159 page views in the last 30 days.