本文整理汇总了C++中CBaseTexture::LoadFromFile方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseTexture::LoadFromFile方法的具体用法?C++ CBaseTexture::LoadFromFile怎么用?C++ CBaseTexture::LoadFromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseTexture
的用法示例。
在下文中一共展示了CBaseTexture::LoadFromFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Process
void CBackgroundPicLoader::Process()
{
unsigned int totalTime = 0;
unsigned int count = 0;
while (!m_bStop)
{ // loop around forever, waiting for the app to call LoadPic
if (AbortableWait(m_loadPic,10) == WAIT_SIGNALED)
{
if (m_pCallback)
{
unsigned int start = XbmcThreads::SystemClockMillis();
CBaseTexture* texture = new CTexture();
unsigned int originalWidth = 0;
unsigned int originalHeight = 0;
texture->LoadFromFile(m_strFileName, m_maxWidth, m_maxHeight, g_guiSettings.GetBool("pictures.useexifrotation"), &originalWidth, &originalHeight);
totalTime += XbmcThreads::SystemClockMillis() - start;
count++;
// tell our parent
bool bFullSize = ((int)texture->GetWidth() < m_maxWidth) && ((int)texture->GetHeight() < m_maxHeight);
if (!bFullSize)
{
int iSize = texture->GetWidth() * texture->GetHeight() - MAX_PICTURE_SIZE;
if ((iSize + (int)texture->GetWidth() > 0) || (iSize + (int)texture->GetHeight() > 0))
bFullSize = true;
if (!bFullSize && texture->GetWidth() == g_Windowing.GetMaxTextureSize())
bFullSize = true;
if (!bFullSize && texture->GetHeight() == g_Windowing.GetMaxTextureSize())
bFullSize = true;
}
m_pCallback->OnLoadPic(m_iPic, m_iSlideNumber, texture, originalWidth, originalHeight, bFullSize);
m_isLoading = false;
}
}
}
if (count > 0)
CLog::Log(LOGDEBUG, "Time for loading %u images: %u ms, average %u ms",
count, totalTime, totalTime / count);
}
示例2: Load
//.........这里部分代码省略.........
{
CLog::Log(LOGERROR, "Texture manager unable to load bundled file: %s", strTextureName.c_str());
return 0;
}
pMap = new CTextureMap(strTextureName, width, height, nLoops);
for (int iImage = 0; iImage < nImages; ++iImage)
{
pMap->Add(pTextures[iImage], Delay[iImage]);
}
delete [] pTextures;
delete [] Delay;
}
else
{
CAnimatedGifSet AnimatedGifSet;
int iImages = AnimatedGifSet.LoadGIF(strPath.c_str());
if (iImages == 0)
{
CStdString rootPath = strPath.Left(g_SkinInfo->Path().GetLength());
if (0 == rootPath.CompareNoCase(g_SkinInfo->Path()))
CLog::Log(LOGERROR, "Texture manager unable to load file: %s", strPath.c_str());
return 0;
}
int iWidth = AnimatedGifSet.FrameWidth;
int iHeight = AnimatedGifSet.FrameHeight;
// fixup our palette
COLOR *palette = AnimatedGifSet.m_vecimg[0]->Palette;
// set the alpha values to fully opaque
for (int i = 0; i < 256; i++)
palette[i].x = 0xff;
// and set the transparent colour
if (AnimatedGifSet.m_vecimg[0]->Transparency && AnimatedGifSet.m_vecimg[0]->Transparent >= 0)
palette[AnimatedGifSet.m_vecimg[0]->Transparent].x = 0;
pMap = new CTextureMap(strTextureName, iWidth, iHeight, AnimatedGifSet.nLoops);
for (int iImage = 0; iImage < iImages; iImage++)
{
CTexture *glTexture = new CTexture();
if (glTexture)
{
CAnimatedGif* pImage = AnimatedGifSet.m_vecimg[iImage];
glTexture->LoadPaletted(pImage->Width, pImage->Height, pImage->BytesPerRow, XB_FMT_A8R8G8B8, (unsigned char *)pImage->Raster, palette);
pMap->Add(glTexture, pImage->Delay);
}
} // of for (int iImage=0; iImage < iImages; iImage++)
}
#ifdef _DEBUG
int64_t end, freq;
end = CurrentHostCounter();
freq = CurrentHostFrequency();
char temp[200];
sprintf(temp, "Load %s: %.1fms%s\n", strPath.c_str(), 1000.f * (end - start) / freq, (bundle >= 0) ? " (bundled)" : "");
OutputDebugString(temp);
#endif
m_vecTextures.push_back(pMap);
return 1;
} // of if (strPath.Right(4).ToLower()==".gif")
CBaseTexture *pTexture = NULL;
int width = 0, height = 0;
if (bundle >= 0)
{
if (FAILED(m_TexBundle[bundle].LoadTexture(strTextureName, &pTexture, width, height)))
{
CLog::Log(LOGERROR, "Texture manager unable to load bundled file: %s", strTextureName.c_str());
return 0;
}
}
else
{
pTexture = new CTexture();
if(!pTexture->LoadFromFile(strPath))
return 0;
width = pTexture->GetWidth();
height = pTexture->GetHeight();
}
if (!pTexture) return 0;
CTextureMap* pMap = new CTextureMap(strTextureName, width, height, 0);
pMap->Add(pTexture, 100);
m_vecTextures.push_back(pMap);
#ifdef _DEBUG_TEXTURES
int64_t end, freq;
end = CurrentHostCounter();
freq = CurrentHostFrequency();
char temp[200];
sprintf(temp, "Load %s: %.1fms%s\n", strPath.c_str(), 1000.f * (end - start) / freq, (bundle >= 0) ? " (bundled)" : "");
OutputDebugString(temp);
#endif
return 1;
}