mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
CCITT fax decoder, finishing
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "pdfconstants.h"
|
||||
#include "pdfexception.h"
|
||||
#include "pdfutils.h"
|
||||
#include "pdfccittfaxdecoder.h"
|
||||
|
||||
#include <openjpeg.h>
|
||||
#include <jpeglib.h>
|
||||
@@ -166,6 +167,26 @@ PDFImage PDFImage::createImage(const PDFDocument* document, const PDFStream* str
|
||||
}
|
||||
}
|
||||
|
||||
const PDFDictionary* filterParamsDictionary = nullptr;
|
||||
if (filterParameters.isDictionary())
|
||||
{
|
||||
filterParamsDictionary = filterParameters.getDictionary();
|
||||
}
|
||||
else if (filterParameters.isArray())
|
||||
{
|
||||
const PDFArray* filterParametersArray = filterParameters.getArray();
|
||||
const size_t filterParamsCount = filterParametersArray->getCount();
|
||||
|
||||
if (filterParamsCount)
|
||||
{
|
||||
const PDFObject& object = document->getObject(filterParametersArray->getItem(filterParamsCount - 1));
|
||||
if (object.isDictionary())
|
||||
{
|
||||
filterParamsDictionary = object.getDictionary();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (imageFilterName == "DCTDecode" || imageFilterName == "DCT")
|
||||
{
|
||||
int colorTransform = loader.readIntegerFromDictionary(dictionary, "ColorTransform", -1);
|
||||
@@ -493,7 +514,26 @@ PDFImage PDFImage::createImage(const PDFDocument* document, const PDFStream* str
|
||||
}
|
||||
else if (imageFilterName == "CCITTFaxDecode" || imageFilterName == "CCF")
|
||||
{
|
||||
throw PDFRendererException(RenderErrorType::NotImplemented, PDFTranslationContext::tr("Not implemented image filter 'CCITTFaxDecode'."));
|
||||
if (!filterParamsDictionary)
|
||||
{
|
||||
throw PDFRendererException(RenderErrorType::Error, PDFTranslationContext::tr("Invalid parameters for filter CCITT fax decode."));
|
||||
}
|
||||
|
||||
PDFCCITTFaxDecoderParameters parameters;
|
||||
parameters.maskingType = maskingType;
|
||||
|
||||
parameters.K = loader.readIntegerFromDictionary(filterParamsDictionary, "K", 0);
|
||||
parameters.hasEndOfLine = loader.readBooleanFromDictionary(filterParamsDictionary, "EndOfLine", false);
|
||||
parameters.hasEncodedByteAlign = loader.readBooleanFromDictionary(filterParamsDictionary, "EncodedByteAlign", false);
|
||||
parameters.columns = loader.readIntegerFromDictionary(filterParamsDictionary, "Columns", 1728);
|
||||
parameters.rows = loader.readIntegerFromDictionary(filterParamsDictionary, "Rows", 0);
|
||||
parameters.hasEndOfBlock = loader.readBooleanFromDictionary(filterParamsDictionary, "EndOfBlock", true);
|
||||
parameters.hasBlackIsOne = loader.readBooleanFromDictionary(filterParamsDictionary, "BlackIs1", false);
|
||||
parameters.damagedRowsBeforeError = loader.readIntegerFromDictionary(filterParamsDictionary, "DamagedRowsBeforeError", 0);
|
||||
|
||||
QByteArray imageDataBuffer = document->getDecodedStream(stream);
|
||||
PDFCCITTFaxDecoder decoder(&imageDataBuffer, parameters);
|
||||
image.m_imageData = decoder.decode();
|
||||
}
|
||||
else if (imageFilterName == "JBIG2Decode")
|
||||
{
|
||||
|
Reference in New Issue
Block a user