mirror of https://github.com/JakubMelka/PDF4QT.git
JBIG2 - bugfixing
This commit is contained in:
parent
ab10a6923e
commit
0b507c2610
|
@ -102,7 +102,7 @@ void MainWindow::on_actionAdd_JBIG2_image_triggered()
|
|||
QImage image(imageData.getWidth(), imageData.getHeight(), QImage::Format_Mono);
|
||||
const uchar* sourceData = reinterpret_cast<const uchar*>(imageData.getData().constData());
|
||||
Q_ASSERT(imageData.getData().size() == image.byteCount());
|
||||
std::transform(sourceData, sourceData + imageData.getData().size(), image.bits(), [](const uchar value) { return ~value; });
|
||||
std::transform(sourceData, sourceData + imageData.getData().size(), image.bits(), [](const uchar value) { return value; });
|
||||
addImage(file.fileName() + QString(", Decoded in %1 [msec]").arg(time), qMove(image));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -670,6 +670,7 @@ PDFImage PDFImage::createImage(const PDFDocument* document,
|
|||
|
||||
PDFJBIG2Decoder decoder(qMove(data), qMove(globalData), errorReporter);
|
||||
image.m_imageData = decoder.decode(maskingType);
|
||||
image.m_imageData.setDecode(!decode.empty() ? qMove(decode) : std::vector<PDFReal>({ 0.0, 1.0 }));
|
||||
}
|
||||
else if (colorSpace || isSoftMask)
|
||||
{
|
||||
|
|
|
@ -992,7 +992,7 @@ PDFImageData PDFJBIG2Decoder::decode(PDFImageData::MaskingType maskingType)
|
|||
{
|
||||
for (int column = 0; column < columns; ++column)
|
||||
{
|
||||
writer.write(m_pageBitmap.getPixel(column, row));
|
||||
writer.write(!m_pageBitmap.getPixel(column, row));
|
||||
}
|
||||
writer.finishLine();
|
||||
}
|
||||
|
@ -1205,8 +1205,8 @@ void PDFJBIG2Decoder::processSymbolDictionary(const PDFJBIG2SegmentHeader& heade
|
|||
parameters.isArithmeticCodingStateRetained = (symbolDictionaryFlags >> 9) & 0x0001;
|
||||
parameters.SDTEMPLATE = (symbolDictionaryFlags >> 10) & 0x0003;
|
||||
parameters.SDRTEMPLATE = (symbolDictionaryFlags >> 12) & 0x0001;
|
||||
parameters.SDAT = readATTemplatePixelPositions((parameters.SDHUFF == 0) ? ((parameters.SDTEMPLATE == 0) ? 4 : 1) : 0);
|
||||
parameters.SDRAT = readATTemplatePixelPositions((parameters.SDREFAGG == 1 && parameters.SDRTEMPLATE == 0) ? 2 : 0);
|
||||
parameters.SDAT = readATTemplatePixelPositions((!parameters.SDHUFF) ? ((parameters.SDTEMPLATE == 0) ? 4 : 1) : 0);
|
||||
parameters.SDRAT = readATTemplatePixelPositions((parameters.SDREFAGG && parameters.SDRTEMPLATE == 0) ? 2 : 0);
|
||||
parameters.SDNUMEXSYMS = m_reader.readUnsignedInt();
|
||||
parameters.SDNUMNEWSYMS = m_reader.readUnsignedInt();
|
||||
|
||||
|
|
|
@ -112,6 +112,11 @@ void PDFBitReader::alignToBytes()
|
|||
if (remainder > 0)
|
||||
{
|
||||
read(remainder);
|
||||
|
||||
if (m_bitsInBuffer == 0)
|
||||
{
|
||||
m_buffer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue