本文整理汇总了C++中CXBTFFrame::GetPackedSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CXBTFFrame::GetPackedSize方法的具体用法?C++ CXBTFFrame::GetPackedSize怎么用?C++ CXBTFFrame::GetPackedSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CXBTFFrame
的用法示例。
在下文中一共展示了CXBTFFrame::GetPackedSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertFrameToTexture
bool CTextureBundleXBT::ConvertFrameToTexture(const CStdString& name, CXBTFFrame& frame, CBaseTexture** ppTexture)
{
// found texture - allocate the necessary buffers
squish::u8 *buffer = new squish::u8[(size_t)frame.GetPackedSize()];
if (buffer == NULL)
{
CLog::Log(LOGERROR, "Out of memory loading texture: %s (need %"PRIu64" bytes)", name.c_str(), frame.GetPackedSize());
return false;
}
// load the compressed texture
if (!m_XBTFReader.Load(frame, buffer))
{
CLog::Log(LOGERROR, "Error loading texture: %s", name.c_str());
delete[] buffer;
return false;
}
// check if it's packed with lzo
if (frame.IsPacked())
{ // unpack
squish::u8 *unpacked = new squish::u8[(size_t)frame.GetUnpackedSize()];
if (unpacked == NULL)
{
CLog::Log(LOGERROR, "Out of memory unpacking texture: %s (need %"PRIu64" bytes)", name.c_str(), frame.GetUnpackedSize());
delete[] buffer;
return false;
}
lzo_uint s = (lzo_uint)frame.GetUnpackedSize();
if (lzo1x_decompress(buffer, (lzo_uint)frame.GetPackedSize(), unpacked, &s, NULL) != LZO_E_OK ||
s != frame.GetUnpackedSize())
{
CLog::Log(LOGERROR, "Error loading texture: %s: Decompression error", name.c_str());
delete[] buffer;
delete[] unpacked;
return false;
}
delete[] buffer;
buffer = unpacked;
}
// create an xbmc texture
*ppTexture = new CTexture();
(*ppTexture)->LoadFromMemory(frame.GetWidth(), frame.GetHeight(), 0, frame.GetFormat(), buffer);
delete[] buffer;
return true;
}
示例2: Load
bool CXBTFReader::Load(const CXBTFFrame& frame, unsigned char* buffer) const
{
if (m_file == nullptr)
return false;
#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
if (fseeko(m_file, static_cast<off_t>(frame.GetOffset()), SEEK_SET) == -1)
#else
if (fseeko64(m_file, static_cast<off_t>(frame.GetOffset()), SEEK_SET) == -1)
#endif
return false;
if (fread(buffer, 1, static_cast<size_t>(frame.GetPackedSize()), m_file) != frame.GetPackedSize())
return false;
return true;
}
示例3: Load
bool CXBTFReader::Load(const CXBTFFrame& frame, unsigned char* buffer)
{
if (!m_file)
{
return false;
}
#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
if (fseeko(m_file, (off_t)frame.GetOffset(), SEEK_SET) == -1)
#else
if (fseeko64(m_file, (off_t)frame.GetOffset(), SEEK_SET) == -1)
#endif
{
return false;
}
if (fread(buffer, 1, (size_t)frame.GetPackedSize(), m_file) != frame.GetPackedSize())
{
return false;
}
return true;
}