本文整理汇总了C++中IReader::lookahead方法的典型用法代码示例。如果您正苦于以下问题:C++ IReader::lookahead方法的具体用法?C++ IReader::lookahead怎么用?C++ IReader::lookahead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReader
的用法示例。
在下文中一共展示了IReader::lookahead方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSize
Size ImageFormat_JPEG::getSize(const IReader& reader) const
{
uint8 buf[24];
if (!reader.lookahead(buf))
{
return{ 0, 0 };
}
const auto len = reader.size();
//
// http://www.wischik.com/lu/programmer/get-image-size.html
//
if ((buf[0] == 0xFF && buf[1] == 0xD8 && buf[2] == 0xFF && buf[3] == 0xE0 && buf[6] == 'J' && buf[7] == 'F' && buf[8] == 'I' && buf[9] == 'F')
|| (buf[0] == 0xFF && buf[1] == 0xD8 && buf[2] == 0xFF && buf[3] == 0xE1 && buf[6] == 'E' && buf[7] == 'x' && buf[8] == 'i' && buf[9] == 'f'))
{
int64 pos = 2;
while (buf[2] == 0xFF)
{
if (buf[3] == 0xC0
|| buf[3] == 0xC1
|| buf[3] == 0xC2
|| buf[3] == 0xC3
|| buf[3] == 0xC5
|| buf[3] == 0xC6
|| buf[3] == 0xC7
|| buf[3] == 0xC9
|| buf[3] == 0xCA
|| buf[3] == 0xCB
|| buf[3] == 0xCD
|| buf[3] == 0xCE
|| buf[3] == 0xCF)
{
break;
}
pos += 2 + (buf[4] << 8) + buf[5];
if (pos + 12 > len)
{
break;
}
reader.lookahead(buf + 2, pos, 12);
}
}
// JPEG: (first two bytes of buf are first two bytes of the jpeg file; rest of buf is the DCT frame
if (buf[0] == 0xFF && buf[1] == 0xD8 && buf[2] == 0xFF)
{
const int32 width = (buf[9] << 8) + buf[10];
const int32 height = (buf[7] << 8) + buf[8];
return{ width, height };
}
return{ 0, 0 };
}
示例2: file
TemporaryFile(const IReader& reader)
: m_path(FileSystem::UniqueFilePath())
{
WritableMemoryMapping file(m_path);
const size_t size = static_cast<size_t>(reader.size());
file.map(0, size);
reader.lookahead(file.data(), size);
file.unmap();
}
示例3:
Array<std::unique_ptr<IAudioFormat>>::const_iterator CAudioFormat::findFormat(const IReader& reader, const FilePath& pathHint) const
{
if (!reader.isOpened())
{
return m_audioFormats.end();
}
if (!reader.supportsLookahead())
{
return m_audioFormats.end();
}
uint8 header[16] = {};
if (!reader.lookahead(header))
{
return m_audioFormats.end();
}
for (auto it = m_audioFormats.begin(); it != m_audioFormats.end(); ++it)
{
if ((*it)->isHeader(header))
{
return it;
}
}
if (!pathHint.isEmpty())
{
const String extension = FileSystem::Extension(pathHint);
for (auto it = m_audioFormats.begin(); it != m_audioFormats.end(); ++it)
{
if ((*it)->possibleExtexsions().includes(extension))
{
return it;
}
}
}
return m_audioFormats.end();
}