axmol/cocos2dx/platform/win32/CCDevice.cpp

20 lines
406 B
C++
Raw Normal View History

2013-02-17 11:34:55 +08:00
#include "platform/CCDevice.h"
#include "CCStdC.h"
NS_CC_BEGIN
int CCDevice::getDPI()
2013-02-17 11:34:55 +08:00
{
static int dpi = -1;
if (dpi == -1)
{
HDC hScreenDC = GetDC( NULL );
int PixelsX = GetDeviceCaps( hScreenDC, HORZRES );
int MMX = GetDeviceCaps( hScreenDC, HORZSIZE );
ReleaseDC( NULL, hScreenDC );
dpi = 254.0f*PixelsX/MMX/10;
}
return dpi;
2013-02-17 11:34:55 +08:00
}
NS_CC_END