bool DisplaySurface::Create(const boost::any& _rConfig) { CreateInfo* pInfo = boost::any_cast<CreateInfo*>(_rConfig); FilePtr pFile = NULL; bool bResult = (NULL != pInfo); { pFile = FS::GetRoot()->OpenFile(pInfo->m_strPath, FS::EOpenMode_READBINARY); bResult = (NULL != pFile); } if (false != bResult) { int sSize = pFile->Size(); unsigned char* pBuffer = new unsigned char[sSize]; sSize = pFile->Read(pBuffer, sSize); bResult = SUCCEEDED(D3DXGetImageInfoFromFileInMemory(pBuffer, sSize, &m_oInfo)); if (false != bResult) { #pragma message(__FUNCTION__" : for better support some image formats must be converted into supported surface format. For example luminance image should be translated into paletted surface.") bResult = SUCCEEDED(m_rDisplay.GetDevicePtr()->CreateOffscreenPlainSurface(m_oInfo.Width, m_oInfo.Height, m_oInfo.Format, D3DPOOL_DEFAULT, &m_pSurface, NULL)); } if (false != bResult) { bResult = SUCCEEDED(D3DXLoadSurfaceFromFileInMemory(m_pSurface, NULL, NULL, pBuffer, sSize, NULL, D3DX_FILTER_NONE, 0xff000000, NULL)); } if (false != bResult) { m_uBPP = m_rDisplay.GetFormatBitsPerPixel(m_oInfo.Format); bResult = (0 != m_uBPP); } delete[] pBuffer; FS::GetRoot()->CloseFile(pFile); } return bResult; }
bool Lua::Loadfile(const string& _strFileName, LuaStatePtr _pState) { FilePtr pFile = FS::GetRoot()->OpenFile(_strFileName, FS::EOpenMode_READTEXT); bool bResult = (NULL != pFile); if (false != bResult) { int sSize = pFile->Size(); char* pSourceCode = new char[sSize + 1]; sSize = pFile->Read(pSourceCode, sSize); FS::GetRoot()->CloseFile(pFile); pSourceCode[sSize] = '\0'; _pState = (NULL == _pState) ? s_pState : _pState; const int sResult = _pState->DoString(pSourceCode); bResult = (0 == sResult); delete[] pSourceCode; if (false == bResult) { OutputError(sResult, _pState); } } return bResult; }