JBIG2 - basic reading of segments

This commit is contained in:
Jakub Melka
2019-10-26 18:02:37 +02:00
parent ee4e21320e
commit abbe7a920a
5 changed files with 385 additions and 6 deletions

View File

@ -78,7 +78,7 @@ PDFBitReader::Value PDFBitReader::look(Value bits) const
void PDFBitReader::seek(qint64 position)
{
if (position < m_stream->size())
if (position <= m_stream->size())
{
m_position = position;
m_buffer = 0;
@ -90,6 +90,22 @@ void PDFBitReader::seek(qint64 position)
}
}
void PDFBitReader::skipBytes(Value bytes)
{
// Jakub Melka: if we are lucky, then we just seek to the new position
if (m_bitsInBuffer == 0)
{
seek(m_position + bytes);
}
else
{
for (Value i = 0; i < bytes; ++i)
{
read(8);
}
}
}
void PDFBitReader::alignToBytes()
{
const Value remainder = m_bitsInBuffer % 8;