HGGitLab

Commit 646b33d7 authored by luoliangyi's avatar luoliangyi

集成mupdf的功能

parent d098a22e
#include "HGPdf.h"
#include "mupdf/pdf.h"
#include "mupdf/fitz.h"
struct HGPdfReaderImpl
{
HGPdfReaderImpl()
{
m_pContext = NULL;
m_pDoc = NULL;
}
~HGPdfReaderImpl()
{
if (NULL != m_pDoc)
{
fz_drop_document(m_pContext, m_pDoc);
m_pDoc = NULL;
}
if (NULL != m_pContext)
{
fz_drop_context(m_pContext);
m_pContext = NULL;
}
}
fz_context* m_pContext;
fz_document *m_pDoc;
};
HGResult HGAPI HGImgFmt_CheckPdfFile(const HGChar* fileName, HGBool* isPdf)
{
return HGBASE_ERR_NOTIMPL;
if (NULL == fileName || '\0' == *fileName || NULL == isPdf)
{
return HGBASE_ERR_INVALIDARG;
}
*isPdf = HGFALSE;
HGPdfReader reader = NULL;
HGImgFmt_OpenPdfReader(fileName, &reader);
if (NULL != reader)
{
*isPdf = HGTRUE;
HGImgFmt_ClosePdfReader(reader);
}
return HGBASE_ERR_OK;
}
HGResult HGAPI HGImgFmt_OpenPdfReader(const HGChar* fileName, HGPdfReader* reader)
{
return HGBASE_ERR_NOTIMPL;
if (NULL == fileName || '\0' == *fileName || NULL == reader)
{
return HGBASE_ERR_INVALIDARG;
}
fz_context* pContext = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT);
if (NULL == pContext)
{
return HGBASE_ERR_FAIL;
}
HGResult ret = HGBASE_ERR_FAIL;
fz_try(pContext)
{
fz_register_document_handlers(pContext);
fz_document* pDoc = fz_open_document(pContext, fileName);
HGPdfReaderImpl* pdfReaderImpl = new HGPdfReaderImpl;
pdfReaderImpl->m_pContext = pContext;
pdfReaderImpl->m_pDoc = pDoc;
ret = HGBASE_ERR_OK;
}
fz_catch(pContext)
{
fz_drop_context(pContext);
pContext = NULL;
}
return ret;
}
HGResult HGAPI HGImgFmt_ClosePdfReader(HGPdfReader reader)
{
return HGBASE_ERR_NOTIMPL;
if (NULL == reader)
{
return HGBASE_ERR_INVALIDARG;
}
HGPdfReaderImpl* pdfReaderImpl = (HGPdfReaderImpl*)reader;
delete pdfReaderImpl;
return HGBASE_ERR_OK;
}
HGResult HGAPI HGImgFmt_GetPdfPageCount(HGPdfReader reader, HGUInt* count)
{
return HGBASE_ERR_NOTIMPL;
if (NULL == reader || NULL == count)
{
return HGBASE_ERR_INVALIDARG;
}
HGPdfReaderImpl* pdfReaderImpl = (HGPdfReaderImpl*)reader;
HGResult ret = HGBASE_ERR_FAIL;
fz_try(pdfReaderImpl->m_pContext)
{
*count = (uint32_t)fz_count_pages(pdfReaderImpl->m_pContext, pdfReaderImpl->m_pDoc);
ret = HGBASE_ERR_OK;
}
fz_catch(pdfReaderImpl->m_pContext)
{
}
return ret;
}
HGResult HGAPI HGImgFmt_GetPdfPageInfo(HGPdfReader reader, HGUInt page, HGPdfPageInfo* info)
{
return HGBASE_ERR_NOTIMPL;
if (NULL == reader || NULL == info)
{
return HGBASE_ERR_INVALIDARG;
}
HGPdfReaderImpl* pdfReaderImpl = (HGPdfReaderImpl*)reader;
HGResult ret = HGBASE_ERR_FAIL;
fz_page* fzpage = NULL;
fz_try(pdfReaderImpl->m_pContext)
{
fzpage = fz_load_page(pdfReaderImpl->m_pContext, pdfReaderImpl->m_pDoc, (int)page);
pdf_page* page = pdf_page_from_fz_page(pdfReaderImpl->m_pContext, fzpage);
fz_rect pdfRect = pdf_bound_page(pdfReaderImpl->m_pContext, page);
info->width = pdfRect.x1;
info->height = pdfRect.y1;
ret = HGBASE_ERR_OK;
}
fz_catch(pdfReaderImpl->m_pContext)
{
}
if (NULL != fzpage)
fz_drop_page(pdfReaderImpl->m_pContext, fzpage);
return ret;
}
HGResult HGAPI HGImgFmt_LoadImageFromPdfReader(HGPdfReader reader, HGUInt page, HGFloat xScale, HGFloat yScale,
HGUInt imgType, HGUInt imgOrigin, HGImage* image)
{
return HGBASE_ERR_NOTIMPL;
if (NULL == reader || NULL == image || HGBASE_IMGTYPE_RGB != imgType)
{
return HGBASE_ERR_INVALIDARG;
}
HGPdfReaderImpl* pdfReaderImpl = (HGPdfReaderImpl*)reader;
HGResult ret = HGBASE_ERR_FAIL;
fz_pixmap* pix = NULL;
fz_try(pdfReaderImpl->m_pContext)
{
fz_matrix ctm = fz_scale(xScale, yScale);
pix = fz_new_pixmap_from_page_number(pdfReaderImpl->m_pContext, pdfReaderImpl->m_pDoc, (int)page,
ctm, fz_device_rgb(pdfReaderImpl->m_pContext), 0);
int width = fz_pixmap_width(pdfReaderImpl->m_pContext, pix);
int height = fz_pixmap_height(pdfReaderImpl->m_pContext, pix);
*image = NULL;
HGImageInfo imgInfo = { (uint32_t)width, (uint32_t)height, HGBASE_IMGTYPE_RGB, (uint32_t)pix->stride, HGBASE_IMGORIGIN_TOP };
HGBase_CreateImageFromData(pix->samples, &imgInfo, imgOrigin, image);
if (NULL != *image)
{
ret = HGBASE_ERR_OK;
}
}
fz_catch(pdfReaderImpl->m_pContext)
{
}
if (NULL != pix)
fz_drop_pixmap(pdfReaderImpl->m_pContext, pix);
return ret;
}
HGResult HGAPI HGImgFmt_OpenPdfImageWriter(const HGChar* fileName, HGPdfImageWriter* writer)
......
#include "HGTiff.h"
#include "HGTiff.h"
#include "tiffio.h"
HGResult HGAPI HGImgFmt_CheckTiffFile(const HGChar* fileName, HGBool* isTiff)
{
return HGBASE_ERR_NOTIMPL;
if (NULL == fileName || '\0' == *fileName || NULL == isTiff)
{
return HGBASE_ERR_INVALIDARG;
}
*isTiff = HGFALSE;
HGTiffReader reader = NULL;
HGImgFmt_OpenTiffReader(fileName, &reader);
if (NULL != reader)
{
*isTiff = HGTRUE;
HGImgFmt_CloseTiffReader(reader);
}
return HGBASE_ERR_OK;
}
HGResult HGAPI HGImgFmt_OpenTiffReader(const HGChar* fileName, HGTiffReader* reader)
{
return HGBASE_ERR_NOTIMPL;
if (NULL == fileName || '\0' == *fileName || NULL == reader)
{
return HGBASE_ERR_INVALIDARG;
}
TIFF* tif = TIFFOpen(fileName, "r");
if (NULL == tif)
{
return HGBASE_ERR_ACCESSDENIED;
}
*reader = (HGTiffReader)tif;
return HGBASE_ERR_OK;
}
HGResult HGAPI HGImgFmt_CloseTiffReader(HGTiffReader reader)
{
return HGBASE_ERR_NOTIMPL;
if (NULL == reader)
{
return HGBASE_ERR_INVALIDARG;
}
TIFF* tif = (TIFF*)reader;
TIFFClose(tif);
return HGBASE_ERR_OK;
}
HGResult HGAPI HGImgFmt_GetTiffPageCount(HGTiffReader reader, HGUInt* count)
{
return HGBASE_ERR_NOTIMPL;
if (NULL == reader || NULL == count)
{
return HGBASE_ERR_INVALIDARG;
}
TIFF* tif = (TIFF*)reader;
*count = TIFFNumberOfDirectories(tif);
return HGBASE_ERR_OK;
}
HGResult HGAPI HGImgFmt_LoadImageFromTiffReader(HGTiffReader reader, HGUInt index, UPTiffLoadInfo* info,
HGUInt imgType, HGUInt imgOrigin, HGImage* image)
{
return HGBASE_ERR_NOTIMPL;
if (NULL == reader)
{
return HGBASE_ERR_INVALIDARG;
}
if (NULL == image)
{
if (0 != imgType || 0 != imgOrigin)
{
return HGBASE_ERR_INVALIDARG;
}
}
else
{
if (0 != imgType && HGBASE_IMGTYPE_GRAY != imgType && HGBASE_IMGTYPE_RGB != imgType
&& HGBASE_IMGTYPE_RGBA != imgType)
{
return HGBASE_ERR_INVALIDARG;
}
if (HGBASE_IMGORIGIN_TOP != imgOrigin)
{
return HGBASE_ERR_INVALIDARG;
}
}
TIFF* tif = (TIFF*)reader;
if (0 == TIFFSetDirectory(tif, index))
{
return HGBASE_ERR_FAIL;
}
uint32 width;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
uint32 height;
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
uint16 bitsPerSample;
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitsPerSample);
uint16 samplesPerPixel;
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesPerPixel);
uint16 compression;
TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression);
uint16 resolutionUnit;
TIFFGetField(tif, TIFFTAG_RESOLUTIONUNIT, &resolutionUnit);
float xResolution;
TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xResolution);
float yResolution;
TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yResolution);
if (NULL != info)
{
info->width = width;
info->height = height;
info->bitsPerSample = bitsPerSample;
info->samplesPerPixel = samplesPerPixel;
info->compression = compression;
info->resolutionUnit = resolutionUnit;
info->xResolution = xResolution;
info->yResolution = yResolution;
}
if (NULL != image)
{
uint32* buffer = (uint32*)malloc(width * height * sizeof(uint32));
if (NULL == buffer)
{
return HGBASE_ERR_FAIL;
}
if (0 == TIFFReadRGBAImageOriented(tif, width, height, buffer, ORIENTATION_TOPLEFT))
{
free(buffer);
buffer = NULL;
return HGBASE_ERR_FAIL;
}
if (0 == imgType)
{
if (4 == samplesPerPixel)
{
imgType = HGBASE_IMGTYPE_RGBA;
}
else
{
imgType = HGBASE_IMGTYPE_RGB;
}
}
HGImage image2 = NULL;
HGImageInfo imgInfo = { width, height, imgType, 0, imgOrigin };
HGResult result = HGBase_CreateImage(&imgInfo, &image2);
if (HGBASE_ERR_OK != result)
{
free(buffer);
buffer = NULL;
return HGBASE_ERR_FAIL;
}
uint8_t* data;
HGBase_GetImageData(image2, &data);
HGBase_GetImageInfo(image2, &imgInfo);
uint32_t widthStep = imgInfo.widthStep;
if (HGBASE_IMGTYPE_GRAY == imgType)
{
//#pragma omp parallel for
for (int32 i = 0; i < (int32)height; i++)
{
uint8_t* pEx = (uint8_t*)buffer + (uintptr_t)i * (uintptr_t)width * (uintptr_t)4;
uint8_t* pExEnd = pEx + width * 4;
uint8_t* pDestEx = data + (uintptr_t)i * (uintptr_t)widthStep;
while (pEx < pExEnd)
{
uint8_t value = (pEx[0] * 76 + pEx[1] * 150 + pEx[2] * 30) >> 8;
*pDestEx = value;
pEx += 4;
++pDestEx;
}
}
}
else if (HGBASE_IMGTYPE_RGB == imgType)
{
//#pragma omp parallel for
for (int32 i = 0; i < (int32)height; i++)
{
uint8_t* pEx = (uint8_t*)buffer + (uintptr_t)i * (uintptr_t)width * (uintptr_t)4;
uint8_t* pExEnd = pEx + width * 4;
uint8_t* pDestEx = data + (uintptr_t)i * (uintptr_t)widthStep;
while (pEx < pExEnd)
{
pDestEx[0] = pEx[0];
pDestEx[1] = pEx[1];
pDestEx[2] = pEx[2];
pEx += 4;
pDestEx += 3;
}
}
}
else
{
assert(HGBASE_IMGTYPE_RGBA == imgType);
//#pragma omp parallel for
for (int32 i = 0; i < (int32)height; i++)
{
uint8_t* pEx = (uint8_t*)buffer + (uintptr_t)i * (uintptr_t)width * (uintptr_t)4;
uint8_t* pDestEx = data + (uintptr_t)i * (uintptr_t)widthStep;
memcpy(pDestEx, pEx, width * 4);
}
}
free(buffer);
buffer = NULL;
*image = image2;
}
return HGBASE_ERR_OK;
}
HGResult HGAPI HGImgFmt_OpenTiffWriter(const HGChar* fileName, HGTiffWriter* writer)
{
return HGBASE_ERR_NOTIMPL;
if (NULL == fileName || '\0' == *fileName || NULL == writer)
{
return HGBASE_ERR_INVALIDARG;
}
TIFF* tif = TIFFOpen(fileName, "w");
if (NULL == tif)
{
return HGBASE_ERR_ACCESSDENIED;
}
*writer = (HGTiffWriter)tif;
return HGBASE_ERR_OK;
}
HGResult HGAPI HGImgFmt_CloseTiffWriter(HGTiffWriter writer)
{
return HGBASE_ERR_NOTIMPL;
if (NULL == writer)
{
return HGBASE_ERR_INVALIDARG;
}
TIFF* tif = (TIFF*)writer;
TIFFClose(tif);
return HGBASE_ERR_OK;
}
HGResult HGAPI HGImgFmt_SaveImageToTiffWriter(HGTiffWriter writer, HGImage image, const UPTiffSaveInfo* info)
{
return HGBASE_ERR_NOTIMPL;
if (NULL == writer || NULL == image)
{
return HGBASE_ERR_INVALIDARG;
}
if (NULL != info)
{
// 判断合法性
}
HGImageInfo imgInfo;
HGBase_GetImageInfo(image, &imgInfo);
uint32_t width = imgInfo.width;
uint32_t height = imgInfo.height;
uint32_t widthStep = imgInfo.widthStep;
uint32_t type = imgInfo.type;
uint32_t origin = imgInfo.origin;
if (HGBASE_IMGTYPE_GRAY != type && HGBASE_IMGTYPE_RGB != type
&& HGBASE_IMGTYPE_RGBA != type)
{
return HGBASE_ERR_INVALIDARG;
}
if (HGBASE_IMGORIGIN_TOP != origin)
{
return HGBASE_ERR_INVALIDARG;
}
uint8_t* data;
HGBase_GetImageData(image, &data);
uint8 samplesPerPixel = 0;
if (HGBASE_IMGTYPE_GRAY == type)
samplesPerPixel = 1;
else if (HGBASE_IMGTYPE_RGB == type)
samplesPerPixel = 3;
else if (HGBASE_IMGTYPE_RGBA == type)
samplesPerPixel = 4;
assert(0 != samplesPerPixel);
TIFF* tif = (TIFF*)writer;
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, samplesPerPixel);
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, (1 == samplesPerPixel) ? PHOTOMETRIC_PALETTE : PHOTOMETRIC_RGB);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, height);
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
uint16 rTable[256], gTable[256], bTable[256];
//#pragma omp parallel for
for (int32_t i = 0; i < 256; ++i)
{
rTable[i] = i;
gTable[i] = i;
bTable[i] = i;
}
TIFFSetField(tif, TIFFTAG_COLORMAP, rTable, gTable, bTable);
if (NULL != info)
{
TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, info->resolutionUnit);
TIFFSetField(tif, TIFFTAG_XRESOLUTION, info->xResolution);
TIFFSetField(tif, TIFFTAG_YRESOLUTION, info->yResolution);
}
for (uint32_t i = 0; i < height; ++i)
{
uint8_t* p = data + i * widthStep;
TIFFWriteScanline(tif, p, i, 0);
}
TIFFWriteDirectory(tif);
return HGBASE_ERR_OK;
}
\ No newline at end of file
......@@ -113,7 +113,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>../../third_party/libjpeg/windows/include;../../third_party/libnsbmp/windows/include;../../third_party/libpng/windows/include;../../third_party/zlib/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../../third_party/libjpeg/windows/include;../../third_party/libnsbmp/windows/include;../../third_party/libpng/windows/include;../../third_party/zlib/windows/include;../../third_party/libtiff/windows/include;../../third_party/mupdf/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>5045;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
......@@ -121,7 +121,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>HGImgFmt.def</ModuleDefinitionFile>
<AdditionalDependencies>../../release/lib/windows/x86/HGBase.lib;../../third_party/libjpeg/windows/lib/x86/jpeg.lib;../../third_party/libnsbmp/windows/lib/x86/libnsbmp.lib;../../third_party/libpng/windows/lib/x86/libpng16.lib;../../third_party/zlib/windows/lib/x86/zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>../../release/lib/windows/x86/HGBase.lib;../../third_party/libjpeg/windows/lib/x86/jpeg.lib;../../third_party/libnsbmp/windows/lib/x86/libnsbmp.lib;../../third_party/libpng/windows/lib/x86/libpng16.lib;../../third_party/zlib/windows/lib/x86/zlib.lib;../../third_party/libtiff/windows/lib/x86/tiff.lib;../../third_party/mupdf/windows/lib/x86/libmupdf.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
......@@ -135,7 +135,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>../../third_party/libjpeg/windows/include;../../third_party/libnsbmp/windows/include;../../third_party/libpng/windows/include;../../third_party/zlib/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../../third_party/libjpeg/windows/include;../../third_party/libnsbmp/windows/include;../../third_party/libpng/windows/include;../../third_party/zlib/windows/include;../../third_party/libtiff/windows/include;../../third_party/mupdf/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
......@@ -144,7 +144,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>HGImgFmt.def</ModuleDefinitionFile>
<AdditionalDependencies>../../release/lib/windows/x86/HGBase.lib;../../third_party/libjpeg/windows/lib/x86/jpeg.lib;../../third_party/libnsbmp/windows/lib/x86/libnsbmp.lib;../../third_party/libpng/windows/lib/x86/libpng16.lib;../../third_party/zlib/windows/lib/x86/zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>../../release/lib/windows/x86/HGBase.lib;../../third_party/libjpeg/windows/lib/x86/jpeg.lib;../../third_party/libnsbmp/windows/lib/x86/libnsbmp.lib;../../third_party/libpng/windows/lib/x86/libpng16.lib;../../third_party/zlib/windows/lib/x86/zlib.lib;../../third_party/libtiff/windows/lib/x86/tiff.lib;../../third_party/mupdf/windows/lib/x86/libmupdf.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy $(OutDir)HGImgFmt.lib $(ProjectDir)..\..\release\lib\windows\x86\
......@@ -162,14 +162,14 @@ copy $(ProjectDir)..\*.h $(ProjectDir)..\..\release\include\imgfmt\</Command>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>../../third_party/libjpeg/windows/include;../../third_party/libnsbmp/windows/include;../../third_party/libpng/windows/include;../../third_party/zlib/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../../third_party/libjpeg/windows/include;../../third_party/libnsbmp/windows/include;../../third_party/libpng/windows/include;../../third_party/zlib/windows/include;../../third_party/libtiff/windows/include;../../third_party/mupdf/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>HGImgFmt.def</ModuleDefinitionFile>
<AdditionalDependencies>../../release/lib/windows/x64/HGBase.lib;../../third_party/libjpeg/windows/lib/x64/jpeg.lib;../../third_party/libnsbmp/windows/lib/x64/libnsbmp.lib;../../third_party/libpng/windows/lib/x64/libpng16.lib;../../third_party/zlib/windows/lib/x64/zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>../../release/lib/windows/x64/HGBase.lib;../../third_party/libjpeg/windows/lib/x64/jpeg.lib;../../third_party/libnsbmp/windows/lib/x64/libnsbmp.lib;../../third_party/libpng/windows/lib/x64/libpng16.lib;../../third_party/zlib/windows/lib/x64/zlib.lib;../../third_party/libtiff/windows/lib/x64/tiff.lib;../../third_party/mupdf/windows/lib/x64/libmupdf.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
......@@ -183,7 +183,7 @@ copy $(ProjectDir)..\*.h $(ProjectDir)..\..\release\include\imgfmt\</Command>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>../../third_party/libjpeg/windows/include;../../third_party/libnsbmp/windows/include;../../third_party/libpng/windows/include;../../third_party/zlib/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../../third_party/libjpeg/windows/include;../../third_party/libnsbmp/windows/include;../../third_party/libpng/windows/include;../../third_party/zlib/windows/include;../../third_party/libtiff/windows/include;../../third_party/mupdf/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
......@@ -192,7 +192,7 @@ copy $(ProjectDir)..\*.h $(ProjectDir)..\..\release\include\imgfmt\</Command>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>HGImgFmt.def</ModuleDefinitionFile>
<AdditionalDependencies>../../release/lib/windows/x64/HGBase.lib;../../third_party/libjpeg/windows/lib/x64/jpeg.lib;../../third_party/libnsbmp/windows/lib/x64/libnsbmp.lib;../../third_party/libpng/windows/lib/x64/libpng16.lib;../../third_party/zlib/windows/lib/x64/zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>../../release/lib/windows/x64/HGBase.lib;../../third_party/libjpeg/windows/lib/x64/jpeg.lib;../../third_party/libnsbmp/windows/lib/x64/libnsbmp.lib;../../third_party/libpng/windows/lib/x64/libpng16.lib;../../third_party/zlib/windows/lib/x64/zlib.lib;../../third_party/libtiff/windows/lib/x64/tiff.lib;../../third_party/mupdf/windows/lib/x64/libmupdf.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy $(OutDir)HGImgFmt.lib $(ProjectDir)..\..\release\lib\windows\x64\
......
This diff is collapsed.
/*
Configuration defines for installed libtiff.
This file maintained for backward compatibility. Do not use definitions
from this file in your programs.
*/
#ifndef _TIFFCONF_
#define _TIFFCONF_
/* Signed 16-bit type */
#define TIFF_INT16_T signed short
/* Signed 32-bit type */
#define TIFF_INT32_T signed int
/* Signed 64-bit type */
#define TIFF_INT64_T signed long long
/* Signed 8-bit type */
#define TIFF_INT8_T signed char
/* Unsigned 16-bit type */
#define TIFF_UINT16_T unsigned short
/* Unsigned 32-bit type */
#define TIFF_UINT32_T unsigned int
/* Unsigned 64-bit type */
#define TIFF_UINT64_T unsigned long long
/* Unsigned 8-bit type */
#define TIFF_UINT8_T unsigned char
/* Unsigned size type */
#define TIFF_SIZE_T unsigned long long
/* Signed size type */
#define TIFF_SSIZE_T signed long long
/* Pointer difference type */
#define TIFF_PTRDIFF_T ptrdiff_t
/* Compatibility stuff. */
/* Define as 0 or 1 according to the floating point format suported by the
machine */
#define HAVE_IEEEFP 1
/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
#define HOST_FILLORDER FILLORDER_LSB2MSB
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
(Intel) */
#define HOST_BIGENDIAN 0
/* Support CCITT Group 3 & 4 algorithms */
#define CCITT_SUPPORT 1
/* Support JPEG compression (requires IJG JPEG library) */
/* #undef JPEG_SUPPORT */
/* Support JBIG compression (requires JBIG-KIT library) */
/* #undef JBIG_SUPPORT */
/* Support LogLuv high dynamic range encoding */
#define LOGLUV_SUPPORT 1
/* Support LZW algorithm */
#define LZW_SUPPORT 1
/* Support NeXT 2-bit RLE algorithm */
#define NEXT_SUPPORT 1
/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation
fails with unpatched IJG JPEG library) */
/* #undef OJPEG_SUPPORT */
/* Support Macintosh PackBits algorithm */
#define PACKBITS_SUPPORT 1
/* Support Pixar log-format algorithm (requires Zlib) */
/* #undef PIXARLOG_SUPPORT */
/* Support ThunderScan 4-bit RLE algorithm */
#define THUNDER_SUPPORT 1
/* Support Deflate compression */
/* #undef ZIP_SUPPORT */
/* Support strip chopping (whether or not to convert single-strip uncompressed
images to mutiple strips of ~8Kb to reduce memory usage) */
#define STRIPCHOP_DEFAULT 1
/* Enable SubIFD tag (330) support */
#define SUBIFD_SUPPORT 1
/* Treat extra sample as alpha (default enabled). The RGBA interface will
treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many
packages produce RGBA files but don't mark the alpha properly. */
#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1
/* Pick up YCbCr subsampling info from the JPEG data stream to support files
lacking the tag (default enabled). */
#define CHECK_JPEG_YCBCR_SUBSAMPLING 1
/* Support MS MDI magic number files as TIFF */
#define MDI_SUPPORT 1
/*
* Feature support definitions.
* XXX: These macros are obsoleted. Don't use them in your apps!
* Macros stays here for backward compatibility and should be always defined.
*/
#define COLORIMETRY_SUPPORT
#define YCBCR_SUPPORT
#define CMYK_SUPPORT
#define ICC_SUPPORT
#define PHOTOSHOP_SUPPORT
#define IPTC_SUPPORT
#endif /* _TIFFCONF_ */
This diff is collapsed.
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.1.0\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
/*
* This define can be used in code that requires
* compilation-related definitions specific to a
* version or versions of the library. Runtime
* version checking should be done based on the
* string returned by TIFFGetVersion.
*/
#define TIFFLIB_VERSION 20191103
#ifndef MUDPF_FITZ_H
#define MUDPF_FITZ_H
#ifdef __cplusplus
extern "C" {
#endif
#include "mupdf/fitz/version.h"
#include "mupdf/fitz/config.h"
#include "mupdf/fitz/system.h"
#include "mupdf/fitz/context.h"
#include "mupdf/fitz/output.h"
#include "mupdf/fitz/log.h"
#include "mupdf/fitz/crypt.h"
#include "mupdf/fitz/getopt.h"
#include "mupdf/fitz/geometry.h"
#include "mupdf/fitz/hash.h"
#include "mupdf/fitz/pool.h"
#include "mupdf/fitz/string-util.h"
#include "mupdf/fitz/tree.h"
#include "mupdf/fitz/bidi.h"
#include "mupdf/fitz/xml.h"
/* I/O */
#include "mupdf/fitz/buffer.h"
#include "mupdf/fitz/stream.h"
#include "mupdf/fitz/compress.h"
#include "mupdf/fitz/compressed-buffer.h"
#include "mupdf/fitz/filter.h"
#include "mupdf/fitz/archive.h"
/* Resources */
#include "mupdf/fitz/store.h"
#include "mupdf/fitz/color.h"
#include "mupdf/fitz/pixmap.h"
#include "mupdf/fitz/bitmap.h"
#include "mupdf/fitz/image.h"
#include "mupdf/fitz/shade.h"
#include "mupdf/fitz/font.h"
#include "mupdf/fitz/path.h"
#include "mupdf/fitz/text.h"
#include "mupdf/fitz/separation.h"
#include "mupdf/fitz/glyph.h"
#include "mupdf/fitz/device.h"
#include "mupdf/fitz/display-list.h"
#include "mupdf/fitz/structured-text.h"
#include "mupdf/fitz/transition.h"
#include "mupdf/fitz/glyph-cache.h"
/* Document */
#include "mupdf/fitz/link.h"
#include "mupdf/fitz/outline.h"
#include "mupdf/fitz/document.h"
#include "mupdf/fitz/util.h"
/* Output formats */
#include "mupdf/fitz/writer.h"
#include "mupdf/fitz/band-writer.h"
#include "mupdf/fitz/write-pixmap.h"
#include "mupdf/fitz/output-svg.h"
#ifdef __cplusplus
}
#endif
#endif
#ifndef MUPDF_FITZ_ARCHIVE_H
#define MUPDF_FITZ_ARCHIVE_H
#include "mupdf/fitz/system.h"
#include "mupdf/fitz/context.h"
#include "mupdf/fitz/buffer.h"
#include "mupdf/fitz/stream.h"
/* PUBLIC API */
/**
fz_archive:
fz_archive provides methods for accessing "archive" files.
An archive file is a conceptual entity that contains multiple
files, which can be counted, enumerated, and read.
Implementations of fz_archive based upon directories, zip
and tar files are included.
*/
typedef struct fz_archive fz_archive;
/**
Open a zip or tar archive
Open a file and identify its archive type based on the archive
signature contained inside.
filename: a path to a file as it would be given to open(2).
*/
fz_archive *fz_open_archive(fz_context *ctx, const char *filename);
/**
Open zip or tar archive stream.
Open an archive using a seekable stream object rather than
opening a file or directory on disk.
*/
fz_archive *fz_open_archive_with_stream(fz_context *ctx, fz_stream *file);
/**
Open a directory as if it was an archive.
A special case where a directory is opened as if it was an
archive.
Note that for directories it is not possible to retrieve the
number of entries or list the entries. It is however possible
to check if the archive has a particular entry.
path: a path to a directory as it would be given to opendir(3).
*/
fz_archive *fz_open_directory(fz_context *ctx, const char *path);
/**
Determine if a given path is a directory.
*/
int fz_is_directory(fz_context *ctx, const char *path);
/**
Drop the reference to an archive.
Closes and releases any memory or filehandles associated
with the archive.
*/
void fz_drop_archive(fz_context *ctx, fz_archive *arch);
/**
Return a pointer to a string describing the format of the
archive.
The lifetime of the string is unspecified (in current
implementations the string will persist until the archive
is closed, but this is not guaranteed).
*/
const char *fz_archive_format(fz_context *ctx, fz_archive *arch);
/**
Number of entries in archive.
Will always return a value >= 0.
May throw an exception if this type of archive cannot count the
entries (such as a directory).
*/
int fz_count_archive_entries(fz_context *ctx, fz_archive *arch);
/**
Get listed name of entry position idx.
idx: Must be a value >= 0 < return value from
fz_count_archive_entries. If not in range NULL will be
returned.
May throw an exception if this type of archive cannot list the
entries (such as a directory).
*/
const char *fz_list_archive_entry(fz_context *ctx, fz_archive *arch, int idx);
/**
Check if entry by given name exists.
If named entry does not exist 0 will be returned, if it does
exist 1 is returned.
name: Entry name to look for, this must be an exact match to
the entry name in the archive.
*/
int fz_has_archive_entry(fz_context *ctx, fz_archive *arch, const char *name);
/**
Opens an archive entry as a stream.
name: Entry name to look for, this must be an exact match to
the entry name in the archive.
*/
fz_stream *fz_open_archive_entry(fz_context *ctx, fz_archive *arch, const char *name);
/**
Reads all bytes in an archive entry
into a buffer.
name: Entry name to look for, this must be an exact match to
the entry name in the archive.
*/
fz_buffer *fz_read_archive_entry(fz_context *ctx, fz_archive *arch, const char *name);
/**
fz_archive: tar implementation
*/
/**
Detect if stream object is a tar achieve.
Assumes that the stream object is seekable.
*/
int fz_is_tar_archive(fz_context *ctx, fz_stream *file);
/**
Open a tar archive file.
An exception is throw if the file is not a tar archive as
indicated by the presence of a tar signature.
filename: a path to a tar archive file as it would be given to
open(2).
*/
fz_archive *fz_open_tar_archive(fz_context *ctx, const char *filename);
/**
Open a tar archive stream.
Open an archive using a seekable stream object rather than
opening a file or directory on disk.
An exception is throw if the stream is not a tar archive as
indicated by the presence of a tar signature.
*/
fz_archive *fz_open_tar_archive_with_stream(fz_context *ctx, fz_stream *file);
/**
fz_archive: zip implementation
*/
/**
Detect if stream object is a zip archive.
Assumes that the stream object is seekable.
*/
int fz_is_zip_archive(fz_context *ctx, fz_stream *file);
/**
Open a zip archive file.
An exception is throw if the file is not a zip archive as
indicated by the presence of a zip signature.
filename: a path to a zip archive file as it would be given to
open(2).
*/
fz_archive *fz_open_zip_archive(fz_context *ctx, const char *path);
/**
Open a zip archive stream.
Open an archive using a seekable stream object rather than
opening a file or directory on disk.
An exception is throw if the stream is not a zip archive as
indicated by the presence of a zip signature.
*/
fz_archive *fz_open_zip_archive_with_stream(fz_context *ctx, fz_stream *file);
/**
fz_zip_writer offers methods for creating and writing zip files.
It can be seen as the reverse of the fz_archive zip
implementation.
*/
typedef struct fz_zip_writer fz_zip_writer;
/**
Create a new zip writer that writes to a given file.
Open an archive using a seekable stream object rather than
opening a file or directory on disk.
*/
fz_zip_writer *fz_new_zip_writer(fz_context *ctx, const char *filename);
/**
Create a new zip writer that writes to a given output stream.
*/
fz_zip_writer *fz_new_zip_writer_with_output(fz_context *ctx, fz_output *out);
/**
Given a buffer of data, (optionally) compress it, and add it to
the zip file with the given name.
*/
void fz_write_zip_entry(fz_context *ctx, fz_zip_writer *zip, const char *name, fz_buffer *buf, int compress);
/**
Close the zip file for writing.
This flushes any pending data to the file. This can throw
exceptions.
*/
void fz_close_zip_writer(fz_context *ctx, fz_zip_writer *zip);
/**
Drop the reference to the zipfile.
In common with other 'drop' methods, this will never throw an
exception.
*/
void fz_drop_zip_writer(fz_context *ctx, fz_zip_writer *zip);
/**
Implementation details: Subject to change.
*/
struct fz_archive
{
fz_stream *file;
const char *format;
void (*drop_archive)(fz_context *ctx, fz_archive *arch);
int (*count_entries)(fz_context *ctx, fz_archive *arch);
const char *(*list_entry)(fz_context *ctx, fz_archive *arch, int idx);
int (*has_entry)(fz_context *ctx, fz_archive *arch, const char *name);
fz_buffer *(*read_entry)(fz_context *ctx, fz_archive *arch, const char *name);
fz_stream *(*open_entry)(fz_context *ctx, fz_archive *arch, const char *name);
};
fz_archive *fz_new_archive_of_size(fz_context *ctx, fz_stream *file, int size);
#define fz_new_derived_archive(C,F,M) \
((M*)Memento_label(fz_new_archive_of_size(C, F, sizeof(M)), #M))
#endif
#ifndef MUPDF_FITZ_BAND_WRITER_H
#define MUPDF_FITZ_BAND_WRITER_H
#include "mupdf/fitz/system.h"
#include "mupdf/fitz/context.h"
#include "mupdf/fitz/output.h"
/**
fz_band_writer
*/
typedef struct fz_band_writer fz_band_writer;
/**
Cause a band writer to write the header for
a banded image with the given properties/dimensions etc. This
also configures the bandwriter for the format of the data to be
passed in future calls.
w, h: Width and Height of the entire page.
n: Number of components (including spots and alphas).
alpha: Number of alpha components.
xres, yres: X and Y resolutions in dpi.
cs: Colorspace (NULL for bitmaps)
seps: Separation details (or NULL).
*/
void fz_write_header(fz_context *ctx, fz_band_writer *writer, int w, int h, int n, int alpha, int xres, int yres, int pagenum, fz_colorspace *cs, fz_separations *seps);
/**
Cause a band writer to write the next band
of data for an image.
stride: The byte offset from the first byte of the data
for a pixel to the first byte of the data for the same pixel
on the row below.
band_height: The number of lines in this band.
samples: Pointer to first byte of the data.
*/
void fz_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_height, const unsigned char *samples);
/**
Drop the reference to the band writer, causing it to be
destroyed.
Never throws an exception.
*/
void fz_drop_band_writer(fz_context *ctx, fz_band_writer *writer);
/* Implementation details: subject to change. */
typedef void (fz_write_header_fn)(fz_context *ctx, fz_band_writer *writer, fz_colorspace *cs);
typedef void (fz_write_band_fn)(fz_context *ctx, fz_band_writer *writer, int stride, int band_start, int band_height, const unsigned char *samples);
typedef void (fz_write_trailer_fn)(fz_context *ctx, fz_band_writer *writer);
typedef void (fz_drop_band_writer_fn)(fz_context *ctx, fz_band_writer *writer);
struct fz_band_writer
{
fz_drop_band_writer_fn *drop;
fz_write_header_fn *header;
fz_write_band_fn *band;
fz_write_trailer_fn *trailer;
fz_output *out;
int w;
int h;
int n;
int s;
int alpha;
int xres;
int yres;
int pagenum;
int line;
fz_separations *seps;
};
fz_band_writer *fz_new_band_writer_of_size(fz_context *ctx, size_t size, fz_output *out);
#define fz_new_band_writer(C,M,O) ((M *)Memento_label(fz_new_band_writer_of_size(ctx, sizeof(M), O), #M))
#endif
/**
Bidirectional text processing.
Derived from the SmartOffice code, which is itself derived
from the example unicode standard code. Original copyright
messages follow:
Copyright (C) Picsel, 2004-2008. All Rights Reserved.
Processes Unicode text by arranging the characters into an order
suitable for display. E.g. Hebrew text will be arranged from
right-to-left and any English within the text will remain in the
left-to-right order.
This is an implementation of the Unicode Bidirectional Algorithm
which can be found here: http://www.unicode.org/reports/tr9/ and
is based on the reference implementation found on Unicode.org.
*/
#ifndef FITZ_BIDI_H
#define FITZ_BIDI_H
#include "mupdf/fitz/system.h"
/* Implementation details: subject to change. */
typedef enum
{
FZ_BIDI_LTR = 0,
FZ_BIDI_RTL = 1,
FZ_BIDI_NEUTRAL = 2
}
fz_bidi_direction;
typedef enum
{
FZ_BIDI_CLASSIFY_WHITE_SPACE = 1,
FZ_BIDI_REPLACE_TAB = 2
}
fz_bidi_flags;
/**
Prototype for callback function supplied to fz_bidi_fragment_text.
@param fragment first character in fragment
@param fragmentLen number of characters in fragment
@param bidiLevel The bidirectional level for this text.
The bottom bit will be set iff block
should concatenate with other blocks as
right-to-left
@param script the script in use for this fragment (other
than common or inherited)
@param arg data from caller of Bidi_fragmentText
*/
typedef void (fz_bidi_fragment_fn)(const uint32_t *fragment,
size_t fragmentLen,
int bidiLevel,
int script,
void *arg);
/**
Partitions the given Unicode sequence into one or more
unidirectional fragments and invokes the given callback
function for each fragment.
For example, if directionality of text is:
0123456789
rrlllrrrrr,
we'll invoke callback with:
&text[0], length == 2
&text[2], length == 3
&text[5], length == 5
@param[in] text start of Unicode sequence
@param[in] textlen number of Unicodes to analyse
@param[in] baseDir direction of paragraph (specify FZ_BIDI_NEUTRAL to force auto-detection)
@param[in] callback function to be called for each fragment
@param[in] arg data to be passed to the callback function
@param[in] flags flags to control operation (see fz_bidi_flags above)
*/
void fz_bidi_fragment_text(fz_context *ctx,
const uint32_t *text,
size_t textlen,
fz_bidi_direction *baseDir,
fz_bidi_fragment_fn *callback,
void *arg,
int flags);
#endif
#ifndef MUPDF_FITZ_BITMAP_H
#define MUPDF_FITZ_BITMAP_H
#include "mupdf/fitz/system.h"
#include "mupdf/fitz/context.h"
#include "mupdf/fitz/pixmap.h"
/**
Bitmaps have 1 bit per component. Only used for creating
halftoned versions of contone buffers, and saving out. Samples
are stored msb first, akin to pbms.
The internals of this struct are considered implementation
details and subject to change. Where possible, accessor
functions should be used in preference.
*/
typedef struct
{
int refs;
int w, h, stride, n;
int xres, yres;
unsigned char *samples;
} fz_bitmap;
/**
Take an additional reference to the bitmap. The same pointer
is returned.
Never throws exceptions.
*/
fz_bitmap *fz_keep_bitmap(fz_context *ctx, fz_bitmap *bit);
/**
Drop a reference to the bitmap. When the reference count reaches
zero, the bitmap will be destroyed.
Never throws exceptions.
*/
void fz_drop_bitmap(fz_context *ctx, fz_bitmap *bit);
/**
A halftone is a set of threshold tiles, one per component. Each
threshold tile is a pixmap, possibly of varying sizes and
phases. Currently, we only provide one 'default' halftone tile
for operating on 1 component plus alpha pixmaps (where the alpha
is ignored). This is signified by a fz_halftone pointer to NULL.
*/
typedef struct fz_halftone fz_halftone;
/**
Make a bitmap from a pixmap and a halftone.
pix: The pixmap to generate from. Currently must be a single
color component with no alpha.
ht: The halftone to use. NULL implies the default halftone.
Returns the resultant bitmap. Throws exceptions in the case of
failure to allocate.
*/
fz_bitmap *fz_new_bitmap_from_pixmap(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht);
/**
Make a bitmap from a pixmap and a
halftone, allowing for the position of the pixmap within an
overall banded rendering.
pix: The pixmap to generate from. Currently must be a single
color component with no alpha.
ht: The halftone to use. NULL implies the default halftone.
band_start: Vertical offset within the overall banded rendering
(in pixels)
Returns the resultant bitmap. Throws exceptions in the case of
failure to allocate.
*/
fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht, int band_start);
/**
Create a new bitmap.
w, h: Width and Height for the bitmap
n: Number of color components (assumed to be a divisor of 8)
xres, yres: X and Y resolutions (in pixels per inch).
Returns pointer to created bitmap structure. The bitmap
data is uninitialised.
*/
fz_bitmap *fz_new_bitmap(fz_context *ctx, int w, int h, int n, int xres, int yres);
/**
Retrieve details of a given bitmap.
bitmap: The bitmap to query.
w: Pointer to storage to retrieve width (or NULL).
h: Pointer to storage to retrieve height (or NULL).
n: Pointer to storage to retrieve number of color components (or
NULL).
stride: Pointer to storage to retrieve bitmap stride (or NULL).
*/
void fz_bitmap_details(fz_bitmap *bitmap, int *w, int *h, int *n, int *stride);
/**
Set the entire bitmap to 0.
Never throws exceptions.
*/
void fz_clear_bitmap(fz_context *ctx, fz_bitmap *bit);
/**
Create a 'default' halftone structure
for the given number of components.
num_comps: The number of components to use.
Returns a simple default halftone. The default halftone uses
the same halftone tile for each plane, which may not be ideal
for all purposes.
*/
fz_halftone *fz_default_halftone(fz_context *ctx, int num_comps);
/**
Take an additional reference to the halftone. The same pointer
is returned.
Never throws exceptions.
*/
fz_halftone *fz_keep_halftone(fz_context *ctx, fz_halftone *half);
/**
Drop a reference to the halftone. When the reference count
reaches zero, the halftone is destroyed.
Never throws exceptions.
*/
void fz_drop_halftone(fz_context *ctx, fz_halftone *ht);
#endif
#ifndef MUPDF_FITZ_BUFFER_H
#define MUPDF_FITZ_BUFFER_H
#include "mupdf/fitz/system.h"
#include "mupdf/fitz/context.h"
/**
fz_buffer is a wrapper around a dynamically allocated array of
bytes.
Buffers have a capacity (the number of bytes storage immediately
available) and a current size.
The contents of the structure are considered implementation
details and are subject to change. Users should use the accessor
functions in preference.
*/
typedef struct
{
int refs;
unsigned char *data;
size_t cap, len;
int unused_bits;
int shared;
} fz_buffer;
/**
Take an additional reference to the buffer. The same pointer
is returned.
Never throws exceptions.
*/
fz_buffer *fz_keep_buffer(fz_context *ctx, fz_buffer *buf);
/**
Drop a reference to the buffer. When the reference count reaches
zero, the buffer is destroyed.
Never throws exceptions.
*/
void fz_drop_buffer(fz_context *ctx, fz_buffer *buf);
/**
Retrieve internal memory of buffer.
datap: Output parameter that will be pointed to the data.
Returns the current size of the data in bytes.
*/
size_t fz_buffer_storage(fz_context *ctx, fz_buffer *buf, unsigned char **datap);
/**
Ensure that a buffer's data ends in a
0 byte, and return a pointer to it.
*/
const char *fz_string_from_buffer(fz_context *ctx, fz_buffer *buf);
fz_buffer *fz_new_buffer(fz_context *ctx, size_t capacity);
/**
Create a new buffer with existing data.
data: Pointer to existing data.
size: Size of existing data.
Takes ownership of data. Does not make a copy. Calls fz_free on
the data when the buffer is deallocated. Do not use 'data' after
passing to this function.
Returns pointer to new buffer. Throws exception on allocation
failure.
*/
fz_buffer *fz_new_buffer_from_data(fz_context *ctx, unsigned char *data, size_t size);
/**
Like fz_new_buffer, but does not take ownership.
*/
fz_buffer *fz_new_buffer_from_shared_data(fz_context *ctx, const unsigned char *data, size_t size);
/**
Create a new buffer containing a copy of the passed data.
*/
fz_buffer *fz_new_buffer_from_copied_data(fz_context *ctx, const unsigned char *data, size_t size);
/**
Create a new buffer with data decoded from a base64 input string.
*/
fz_buffer *fz_new_buffer_from_base64(fz_context *ctx, const char *data, size_t size);
/**
Ensure that a buffer has a given capacity,
truncating data if required.
capacity: The desired capacity for the buffer. If the current
size of the buffer contents is smaller than capacity, it is
truncated.
*/
void fz_resize_buffer(fz_context *ctx, fz_buffer *buf, size_t capacity);
/**
Make some space within a buffer (i.e. ensure that
capacity > size).
*/
void fz_grow_buffer(fz_context *ctx, fz_buffer *buf);
/**
Trim wasted capacity from a buffer by resizing internal memory.
*/
void fz_trim_buffer(fz_context *ctx, fz_buffer *buf);
/**
Empties the buffer. Storage is not freed, but is held ready
to be reused as the buffer is refilled.
Never throws exceptions.
*/
void fz_clear_buffer(fz_context *ctx, fz_buffer *buf);
/**
Append the contents of the source buffer onto the end of the
destination buffer, extending automatically as required.
Ownership of buffers does not change.
*/
void fz_append_buffer(fz_context *ctx, fz_buffer *destination, fz_buffer *source);
/**
fz_append_*: Append data to a buffer.
The buffer will automatically grow as required.
*/
void fz_append_data(fz_context *ctx, fz_buffer *buf, const void *data, size_t len);
void fz_append_string(fz_context *ctx, fz_buffer *buf, const char *data);
void fz_append_byte(fz_context *ctx, fz_buffer *buf, int c);
void fz_append_rune(fz_context *ctx, fz_buffer *buf, int c);
void fz_append_int32_le(fz_context *ctx, fz_buffer *buf, int x);
void fz_append_int16_le(fz_context *ctx, fz_buffer *buf, int x);
void fz_append_int32_be(fz_context *ctx, fz_buffer *buf, int x);
void fz_append_int16_be(fz_context *ctx, fz_buffer *buf, int x);
void fz_append_bits(fz_context *ctx, fz_buffer *buf, int value, int count);
void fz_append_bits_pad(fz_context *ctx, fz_buffer *buf);
/**
fz_append_pdf_string: Append a string with PDF syntax quotes and
escapes.
The buffer will automatically grow as required.
*/
void fz_append_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text);
/**
fz_append_printf: Format and append data to buffer using
printf-like formatting (see fz_vsnprintf).
The buffer will automatically grow as required.
*/
void fz_append_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt, ...);
/**
fz_append_vprintf: Format and append data to buffer using
printf-like formatting with varargs (see fz_vsnprintf).
*/
void fz_append_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list args);
/**
Zero-terminate buffer in order to use as a C string.
This byte is invisible and does not affect the length of the
buffer as returned by fz_buffer_storage. The zero byte is
written *after* the data, and subsequent writes will overwrite
the terminating byte.
Subsequent changes to the size of the buffer (such as by
fz_buffer_trim, fz_buffer_grow, fz_resize_buffer, etc) may
invalidate this.
*/
void fz_terminate_buffer(fz_context *ctx, fz_buffer *buf);
/**
Create an MD5 digest from buffer contents.
Never throws exceptions.
*/
void fz_md5_buffer(fz_context *ctx, fz_buffer *buffer, unsigned char digest[16]);
/**
Take ownership of buffer contents.
Performs the same task as fz_buffer_storage, but ownership of
the data buffer returns with this call. The buffer is left
empty.
Note: Bad things may happen if this is called on a buffer with
multiple references that is being used from multiple threads.
data: Pointer to place to retrieve data pointer.
Returns length of stream.
*/
size_t fz_buffer_extract(fz_context *ctx, fz_buffer *buf, unsigned char **data);
#endif
This diff is collapsed.
#ifndef MUPDF_FITZ_COMPRESS_H
#define MUPDF_FITZ_COMPRESS_H
#include "mupdf/fitz/system.h"
typedef enum
{
FZ_DEFLATE_NONE = 0,
FZ_DEFLATE_BEST_SPEED = 1,
FZ_DEFLATE_BEST = 9,
FZ_DEFLATE_DEFAULT = -1
} fz_deflate_level;
/**
Returns the upper bound on the
size of flated data of length size.
*/
size_t fz_deflate_bound(fz_context *ctx, size_t size);
/**
Compress source_length bytes of data starting
at source, into a buffer of length *destLen, starting at dest.
*compressed_length will be updated on exit to contain the size
actually used.
*/
void fz_deflate(fz_context *ctx, unsigned char *dest, size_t *compressed_length, const unsigned char *source, size_t source_length, fz_deflate_level level);
/**
Compress source_length bytes of data starting
at source, into a new memory block malloced for that purpose.
*compressed_length is updated on exit to contain the size used.
Ownership of the block is returned from this function, and the
caller is therefore responsible for freeing it. The block may be
considerably larger than is actually required. The caller is
free to fz_realloc it down if it wants to.
*/
unsigned char *fz_new_deflated_data(fz_context *ctx, size_t *compressed_length, const unsigned char *source, size_t source_length, fz_deflate_level level);
/**
Compress the contents of a fz_buffer into a
new block malloced for that purpose. *compressed_length is
updated on exit to contain the size used. Ownership of the block
is returned from this function, and the caller is therefore
responsible for freeing it. The block may be considerably larger
than is actually required. The caller is free to fz_realloc it
down if it wants to.
*/
unsigned char *fz_new_deflated_data_from_buffer(fz_context *ctx, size_t *compressed_length, fz_buffer *buffer, fz_deflate_level level);
/**
Compress bitmap data as CCITT Group 3 1D fax image.
Creates a stream assuming the default PDF parameters,
except the number of columns.
*/
fz_buffer *fz_compress_ccitt_fax_g3(fz_context *ctx, const unsigned char *data, int columns, int rows);
/**
Compress bitmap data as CCITT Group 4 2D fax image.
Creates a stream assuming the default PDF parameters, except
K=-1 and the number of columns.
*/
fz_buffer *fz_compress_ccitt_fax_g4(fz_context *ctx, const unsigned char *data, int columns, int rows);
#endif
#ifndef MUPDF_FITZ_COMPRESSED_BUFFER_H
#define MUPDF_FITZ_COMPRESSED_BUFFER_H
#include "mupdf/fitz/system.h"
#include "mupdf/fitz/context.h"
#include "mupdf/fitz/buffer.h"
#include "mupdf/fitz/stream.h"
#include "mupdf/fitz/filter.h"
/**
Compression parameters used for buffers of compressed data;
typically for the source data for images.
*/
typedef struct
{
int type;
union {
struct {
int color_transform; /* Use -1 for unset */
} jpeg;
struct {
int smask_in_data;
} jpx;
struct {
fz_jbig2_globals *globals;
} jbig2;
struct {
int columns;
int rows;
int k;
int end_of_line;
int encoded_byte_align;
int end_of_block;
int black_is_1;
int damaged_rows_before_error;
} fax;
struct
{
int columns;
int colors;
int predictor;
int bpc;
}
flate;
struct
{
int columns;
int colors;
int predictor;
int bpc;
int early_change;
} lzw;
} u;
} fz_compression_params;
/**
Buffers of compressed data; typically for the source data
for images.
*/
typedef struct
{
fz_compression_params params;
fz_buffer *buffer;
} fz_compressed_buffer;
/**
Return the storage size used for a buffer and its data.
Used in implementing store handling.
Never throws exceptions.
*/
size_t fz_compressed_buffer_size(fz_compressed_buffer *buffer);
/**
Open a stream to read the decompressed version of a buffer.
*/
fz_stream *fz_open_compressed_buffer(fz_context *ctx, fz_compressed_buffer *);
/**
Open a stream to read the decompressed version of a buffer,
with optional log2 subsampling.
l2factor = NULL for no subsampling, or a pointer to an integer
containing the maximum log2 subsample factor acceptable (0 =
none, 1 = halve dimensions, 2 = quarter dimensions etc). If
non-NULL, then *l2factor will be updated on exit with the actual
log2 subsample factor achieved.
*/
fz_stream *fz_open_image_decomp_stream_from_buffer(fz_context *ctx, fz_compressed_buffer *, int *l2factor);
/**
Open a stream to read the decompressed version of another stream
with optional log2 subsampling.
*/
fz_stream *fz_open_image_decomp_stream(fz_context *ctx, fz_stream *, fz_compression_params *, int *l2factor);
/**
Recognise image format strings in the first 8 bytes from image
data.
*/
int fz_recognize_image_format(fz_context *ctx, unsigned char p[8]);
enum
{
FZ_IMAGE_UNKNOWN = 0,
/* Uncompressed samples */
FZ_IMAGE_RAW,
/* Compressed samples */
FZ_IMAGE_FAX,
FZ_IMAGE_FLATE,
FZ_IMAGE_LZW,
FZ_IMAGE_RLD,
/* Full image formats */
FZ_IMAGE_BMP,
FZ_IMAGE_GIF,
FZ_IMAGE_JBIG2,
FZ_IMAGE_JPEG,
FZ_IMAGE_JPX,
FZ_IMAGE_JXR,
FZ_IMAGE_PNG,
FZ_IMAGE_PNM,
FZ_IMAGE_TIFF,
};
/**
Drop a reference to a compressed buffer. Destroys the buffer
and frees any storage/other references held by it.
Never throws exceptions.
*/
void fz_drop_compressed_buffer(fz_context *ctx, fz_compressed_buffer *buf);
#endif
#ifndef FZ_CONFIG_H
#define FZ_CONFIG_H
/**
Enable the following for spot (and hence overprint/overprint
simulation) capable rendering. This forces FZ_PLOTTERS_N on.
*/
/* #define FZ_ENABLE_SPOT_RENDERING 1 */
/**
Choose which plotters we need.
By default we build all the plotters in. To avoid building
plotters in that aren't needed, define the unwanted
FZ_PLOTTERS_... define to 0.
*/
/* #define FZ_PLOTTERS_G 1 */
/* #define FZ_PLOTTERS_RGB 1 */
/* #define FZ_PLOTTERS_CMYK 1 */
/* #define FZ_PLOTTERS_N 1 */
/**
Choose which document agents to include.
By default all are enabled. To avoid building unwanted
ones, define FZ_ENABLE_... to 0.
*/
/* #define FZ_ENABLE_PDF 1 */
/* #define FZ_ENABLE_XPS 1 */
/* #define FZ_ENABLE_SVG 1 */
/* #define FZ_ENABLE_CBZ 1 */
/* #define FZ_ENABLE_IMG 1 */
/* #define FZ_ENABLE_HTML 1 */
/* #define FZ_ENABLE_EPUB 1 */
/**
Choose whether to enable ICC color profiles.
*/
/* #define FZ_ENABLE_ICC 1 */
/**
Choose whether to enable JPEG2000 decoding.
By default, it is enabled, but due to frequent security
issues with the third party libraries we support disabling
it with this flag.
*/
/* #define FZ_ENABLE_JPX 1 */
/**
Choose whether to enable JavaScript.
By default JavaScript is enabled both for mutool and PDF
interactivity.
*/
/* #define FZ_ENABLE_JS 1 */
/**
Choose which fonts to include.
By default we include the base 14 PDF fonts,
DroidSansFallback from Android for CJK, and
Charis SIL from SIL for epub/html.
Enable the following defines to AVOID including
unwanted fonts.
*/
/* To avoid all noto fonts except CJK, enable: */
/* #define TOFU */
/* To skip the CJK font, enable: (this implicitly enables TOFU_CJK_EXT
* and TOFU_CJK_LANG) */
/* #define TOFU_CJK */
/* To skip CJK Extension A, enable: (this implicitly enables
* TOFU_CJK_LANG) */
/* #define TOFU_CJK_EXT */
/* To skip CJK language specific fonts, enable: */
/* #define TOFU_CJK_LANG */
/* To skip the Emoji font, enable: */
/* #define TOFU_EMOJI */
/* To skip the ancient/historic scripts, enable: */
/* #define TOFU_HISTORIC */
/* To skip the symbol font, enable: */
/* #define TOFU_SYMBOL */
/* To skip the SIL fonts, enable: */
/* #define TOFU_SIL */
/* To skip the Base14 fonts, enable: */
/* #define TOFU_BASE14 */
/* (You probably really don't want to do that except for measurement
* purposes!) */
/* ---------- DO NOT EDIT ANYTHING UNDER THIS LINE ---------- */
#ifndef FZ_ENABLE_SPOT_RENDERING
#define FZ_ENABLE_SPOT_RENDERING 1
#endif
#if FZ_ENABLE_SPOT_RENDERING
#undef FZ_PLOTTERS_N
#define FZ_PLOTTERS_N 1
#endif /* FZ_ENABLE_SPOT_RENDERING */
#ifndef FZ_PLOTTERS_G
#define FZ_PLOTTERS_G 1
#endif /* FZ_PLOTTERS_G */
#ifndef FZ_PLOTTERS_RGB
#define FZ_PLOTTERS_RGB 1
#endif /* FZ_PLOTTERS_RGB */
#ifndef FZ_PLOTTERS_CMYK
#define FZ_PLOTTERS_CMYK 1
#endif /* FZ_PLOTTERS_CMYK */
#ifndef FZ_PLOTTERS_N
#define FZ_PLOTTERS_N 1
#endif /* FZ_PLOTTERS_N */
/* We need at least 1 plotter defined */
#if FZ_PLOTTERS_G == 0 && FZ_PLOTTERS_RGB == 0 && FZ_PLOTTERS_CMYK == 0
#undef FZ_PLOTTERS_N
#define FZ_PLOTTERS_N 1
#endif
#ifndef FZ_ENABLE_PDF
#define FZ_ENABLE_PDF 1
#endif /* FZ_ENABLE_PDF */
#ifndef FZ_ENABLE_XPS
#define FZ_ENABLE_XPS 1
#endif /* FZ_ENABLE_XPS */
#ifndef FZ_ENABLE_SVG
#define FZ_ENABLE_SVG 1
#endif /* FZ_ENABLE_SVG */
#ifndef FZ_ENABLE_CBZ
#define FZ_ENABLE_CBZ 1
#endif /* FZ_ENABLE_CBZ */
#ifndef FZ_ENABLE_IMG
#define FZ_ENABLE_IMG 1
#endif /* FZ_ENABLE_IMG */
#ifndef FZ_ENABLE_HTML
#define FZ_ENABLE_HTML 1
#endif /* FZ_ENABLE_HTML */
#ifndef FZ_ENABLE_EPUB
#define FZ_ENABLE_EPUB 1
#endif /* FZ_ENABLE_EPUB */
#ifndef FZ_ENABLE_JPX
#define FZ_ENABLE_JPX 1
#endif /* FZ_ENABLE_JPX */
#ifndef FZ_ENABLE_JS
#define FZ_ENABLE_JS 1
#endif /* FZ_ENABLE_JS */
#ifndef FZ_ENABLE_ICC
#define FZ_ENABLE_ICC 1
#endif /* FZ_ENABLE_ICC */
/* If Epub and HTML are both disabled, disable SIL fonts */
#if FZ_ENABLE_HTML == 0 && FZ_ENABLE_EPUB == 0
#undef TOFU_SIL
#define TOFU_SIL
#endif
#endif /* FZ_CONFIG_H */
This diff is collapsed.
#ifndef MUPDF_FITZ_CRYPT_H
#define MUPDF_FITZ_CRYPT_H
#include "mupdf/fitz/system.h"
/* md5 digests */
/**
Structure definition is public to enable stack
based allocation. Do not access the members directly.
*/
typedef struct
{
unsigned int state[4];
unsigned int count[2];
unsigned char buffer[64];
} fz_md5;
/**
MD5 initialization. Begins an MD5 operation, writing a new
context.
Never throws an exception.
*/
void fz_md5_init(fz_md5 *state);
/**
MD5 block update operation. Continues an MD5 message-digest
operation, processing another message block, and updating the
context.
Never throws an exception.
*/
void fz_md5_update(fz_md5 *state, const unsigned char *input, size_t inlen);
/**
MD5 finalization. Ends an MD5 message-digest operation, writing
the message digest and zeroizing the context.
Never throws an exception.
*/
void fz_md5_final(fz_md5 *state, unsigned char digest[16]);
/* sha-256 digests */
/**
Structure definition is public to enable stack
based allocation. Do not access the members directly.
*/
typedef struct
{
unsigned int state[8];
unsigned int count[2];
union {
unsigned char u8[64];
unsigned int u32[16];
} buffer;
} fz_sha256;
/**
SHA256 initialization. Begins an SHA256 operation, initialising
the supplied context.
Never throws an exception.
*/
void fz_sha256_init(fz_sha256 *state);
/**
SHA256 block update operation. Continues an SHA256 message-
digest operation, processing another message block, and updating
the context.
Never throws an exception.
*/
void fz_sha256_update(fz_sha256 *state, const unsigned char *input, size_t inlen);
/**
MD5 finalization. Ends an MD5 message-digest operation, writing
the message digest and zeroizing the context.
Never throws an exception.
*/
void fz_sha256_final(fz_sha256 *state, unsigned char digest[32]);
/* sha-512 digests */
/**
Structure definition is public to enable stack
based allocation. Do not access the members directly.
*/
typedef struct
{
uint64_t state[8];
unsigned int count[2];
union {
unsigned char u8[128];
uint64_t u64[16];
} buffer;
} fz_sha512;
/**
SHA512 initialization. Begins an SHA512 operation, initialising
the supplied context.
Never throws an exception.
*/
void fz_sha512_init(fz_sha512 *state);
/**
SHA512 block update operation. Continues an SHA512 message-
digest operation, processing another message block, and updating
the context.
Never throws an exception.
*/
void fz_sha512_update(fz_sha512 *state, const unsigned char *input, size_t inlen);
/**
SHA512 finalization. Ends an SHA512 message-digest operation,
writing the message digest and zeroizing the context.
Never throws an exception.
*/
void fz_sha512_final(fz_sha512 *state, unsigned char digest[64]);
/* sha-384 digests */
typedef fz_sha512 fz_sha384;
/**
SHA384 initialization. Begins an SHA384 operation, initialising
the supplied context.
Never throws an exception.
*/
void fz_sha384_init(fz_sha384 *state);
/**
SHA384 block update operation. Continues an SHA384 message-
digest operation, processing another message block, and updating
the context.
Never throws an exception.
*/
void fz_sha384_update(fz_sha384 *state, const unsigned char *input, size_t inlen);
/**
SHA384 finalization. Ends an SHA384 message-digest operation,
writing the message digest and zeroizing the context.
Never throws an exception.
*/
void fz_sha384_final(fz_sha384 *state, unsigned char digest[64]);
/* arc4 crypto */
/**
Structure definition is public to enable stack
based allocation. Do not access the members directly.
*/
typedef struct
{
unsigned x;
unsigned y;
unsigned char state[256];
} fz_arc4;
/**
RC4 initialization. Begins an RC4 operation, writing a new
context.
Never throws an exception.
*/
void fz_arc4_init(fz_arc4 *state, const unsigned char *key, size_t len);
/**
RC4 block encrypt operation; encrypt src into dst (both of
length len) updating the RC4 state as we go.
Never throws an exception.
*/
void fz_arc4_encrypt(fz_arc4 *state, unsigned char *dest, const unsigned char *src, size_t len);
/**
RC4 finalization. Zero the context.
Never throws an exception.
*/
void fz_arc4_final(fz_arc4 *state);
/* AES block cipher implementation from XYSSL */
/**
Structure definitions are public to enable stack
based allocation. Do not access the members directly.
*/
typedef struct
{
int nr; /* number of rounds */
unsigned long *rk; /* AES round keys */
unsigned long buf[68]; /* unaligned data */
} fz_aes;
#define FZ_AES_DECRYPT 0
#define FZ_AES_ENCRYPT 1
/**
AES encryption intialisation. Fills in the supplied context
and prepares for encryption using the given key.
Returns non-zero for error (key size other than 128/192/256).
Never throws an exception.
*/
int fz_aes_setkey_enc(fz_aes *ctx, const unsigned char *key, int keysize);
/**
AES decryption intialisation. Fills in the supplied context
and prepares for decryption using the given key.
Returns non-zero for error (key size other than 128/192/256).
Never throws an exception.
*/
int fz_aes_setkey_dec(fz_aes *ctx, const unsigned char *key, int keysize);
/**
AES block processing. Encrypts or Decrypts (according to mode,
which must match what was initially set up) length bytes (which
must be a multiple of 16), using (and modifying) the insertion
vector iv, reading from input, and writing to output.
Never throws an exception.
*/
void fz_aes_crypt_cbc(fz_aes *ctx, int mode, size_t length,
unsigned char iv[16],
const unsigned char *input,
unsigned char *output );
#endif
This diff is collapsed.
#ifndef MUPDF_FITZ_DISPLAY_LIST_H
#define MUPDF_FITZ_DISPLAY_LIST_H
#include "mupdf/fitz/system.h"
#include "mupdf/fitz/context.h"
#include "mupdf/fitz/geometry.h"
#include "mupdf/fitz/device.h"
/**
Display list device -- record and play back device commands.
*/
/**
fz_display_list is a list containing drawing commands (text,
images, etc.). The intent is two-fold: as a caching-mechanism
to reduce parsing of a page, and to be used as a data
structure in multi-threading where one thread parses the page
and another renders pages.
Create a display list with fz_new_display_list, hand it over to
fz_new_list_device to have it populated, and later replay the
list (once or many times) by calling fz_run_display_list. When
the list is no longer needed drop it with fz_drop_display_list.
*/
typedef struct fz_display_list fz_display_list;
/**
Create an empty display list.
A display list contains drawing commands (text, images, etc.).
Use fz_new_list_device for populating the list.
mediabox: Bounds of the page (in points) represented by the
display list.
*/
fz_display_list *fz_new_display_list(fz_context *ctx, fz_rect mediabox);
/**
Create a rendering device for a display list.
When the device is rendering a page it will populate the
display list with drawing commands (text, images, etc.). The
display list can later be reused to render a page many times
without having to re-interpret the page from the document file
for each rendering. Once the device is no longer needed, free
it with fz_drop_device.
list: A display list that the list device takes a reference to.
*/
fz_device *fz_new_list_device(fz_context *ctx, fz_display_list *list);
/**
(Re)-run a display list through a device.
list: A display list, created by fz_new_display_list and
populated with objects from a page by running fz_run_page on a
device obtained from fz_new_list_device.
ctm: Transform to apply to display list contents. May include
for example scaling and rotation, see fz_scale, fz_rotate and
fz_concat. Set to fz_identity if no transformation is desired.
scissor: Only the part of the contents of the display list
visible within this area will be considered when the list is
run through the device. This does not imply for tile objects
contained in the display list.
cookie: Communication mechanism between caller and library
running the page. Intended for multi-threaded applications,
while single-threaded applications set cookie to NULL. The
caller may abort an ongoing page run. Cookie also communicates
progress information back to the caller. The fields inside
cookie are continually updated while the page is being run.
*/
void fz_run_display_list(fz_context *ctx, fz_display_list *list, fz_device *dev, fz_matrix ctm, fz_rect scissor, fz_cookie *cookie);
/**
Increment the reference count for a display list. Returns the
same pointer.
Never throws exceptions.
*/
fz_display_list *fz_keep_display_list(fz_context *ctx, fz_display_list *list);
/**
Decrement the reference count for a display list. When the
reference count reaches zero, all the references in the display
list itself are dropped, and the display list is freed.
Never throws exceptions.
*/
void fz_drop_display_list(fz_context *ctx, fz_display_list *list);
/**
Return the bounding box of the page recorded in a display list.
*/
fz_rect fz_bound_display_list(fz_context *ctx, fz_display_list *list);
/**
Create a new image from a display list.
w, h: The conceptual width/height of the image.
transform: The matrix that needs to be applied to the given
list to make it render to the unit square.
list: The display list.
*/
fz_image *fz_new_image_from_display_list(fz_context *ctx, float w, float h, fz_display_list *list);
/**
Check for a display list being empty
list: The list to check.
Returns true if empty, false otherwise.
*/
int fz_display_list_is_empty(fz_context *ctx, const fz_display_list *list);
#endif
This diff is collapsed.
#ifndef MUPDF_FITZ_FILTER_H
#define MUPDF_FITZ_FILTER_H
#include "mupdf/fitz/system.h"
#include "mupdf/fitz/context.h"
#include "mupdf/fitz/buffer.h"
#include "mupdf/fitz/store.h"
#include "mupdf/fitz/stream.h"
typedef struct fz_jbig2_globals fz_jbig2_globals;
typedef struct
{
int64_t offset;
size_t length;
} fz_range;
/**
The null filter reads a specified amount of data from the
substream.
*/
fz_stream *fz_open_null_filter(fz_context *ctx, fz_stream *chain, int len, int64_t offset);
/**
The range filter copies data from specified ranges of the
chained stream.
*/
fz_stream *fz_open_range_filter(fz_context *ctx, fz_stream *chain, fz_range *ranges, int nranges);
/**
The endstream filter reads a PDF substream, and starts to look
for an 'endstream' token after the specified length.
*/
fz_stream *fz_open_endstream_filter(fz_context *ctx, fz_stream *chain, int len, int64_t offset);
/**
Concat filter concatenates several streams into one.
*/
fz_stream *fz_open_concat(fz_context *ctx, int max, int pad);
/**
Add a chained stream to the end of the concatenate filter.
Ownership of chain is passed in.
*/
void fz_concat_push_drop(fz_context *ctx, fz_stream *concat, fz_stream *chain);
/**
arc4 filter performs RC4 decoding of data read from the chained
filter using the supplied key.
*/
fz_stream *fz_open_arc4(fz_context *ctx, fz_stream *chain, unsigned char *key, unsigned keylen);
/**
aesd filter performs AES decoding of data read from the chained
filter using the supplied key.
*/
fz_stream *fz_open_aesd(fz_context *ctx, fz_stream *chain, unsigned char *key, unsigned keylen);
/**
a85d filter performs ASCII 85 Decoding of data read
from the chained filter.
*/
fz_stream *fz_open_a85d(fz_context *ctx, fz_stream *chain);
/**
ahxd filter performs ASCII Hex decoding of data read
from the chained filter.
*/
fz_stream *fz_open_ahxd(fz_context *ctx, fz_stream *chain);
/**
rld filter performs Run Length Decoding of data read
from the chained filter.
*/
fz_stream *fz_open_rld(fz_context *ctx, fz_stream *chain);
/**
dctd filter performs DCT (JPEG) decoding of data read
from the chained filter.
color_transform implements the PDF color_transform option;
use -1 (unset) as a default.
For subsampling on decode, set l2factor to the log2 of the
reduction required (therefore 0 = full size decode).
jpegtables is an optional stream from which the JPEG tables
can be read. Use NULL if not required.
*/
fz_stream *fz_open_dctd(fz_context *ctx, fz_stream *chain, int color_transform, int l2factor, fz_stream *jpegtables);
/**
faxd filter performs FAX decoding of data read from
the chained filter.
k: see fax specification (fax default is 0).
end_of_line: whether we expect end of line markers (fax default
is 0).
encoded_byte_align: whether we align to bytes after each line
(fax default is 0).
columns: how many columns in the image (fax default is 1728).
rows: 0 for unspecified or the number of rows of data to expect.
end_of_block: whether we expect end of block markers (fax
default is 1).
black_is_1: determines the polarity of the image (fax default is
0).
*/
fz_stream *fz_open_faxd(fz_context *ctx, fz_stream *chain,
int k, int end_of_line, int encoded_byte_align,
int columns, int rows, int end_of_block, int black_is_1);
/**
flated filter performs LZ77 decoding (inflating) of data read
from the chained filter.
window_bits: How large a decompression window to use. Typically
15. A negative number, -n, means to use n bits, but to expect
raw data with no header.
*/
fz_stream *fz_open_flated(fz_context *ctx, fz_stream *chain, int window_bits);
/**
lzwd filter performs LZW decoding of data read from the chained
filter.
early_change: (Default 1) specifies whether to change codes 1
bit early.
min_bits: (Default 9) specifies the minimum number of bits to
use.
reverse_bits: (Default 0) allows for compatibility with gif and
old style tiffs (1).
old_tiff: (Default 0) allows for different handling of the clear
code, as found in old style tiffs.
*/
fz_stream *fz_open_lzwd(fz_context *ctx, fz_stream *chain, int early_change, int min_bits, int reverse_bits, int old_tiff);
/**
predict filter performs pixel prediction on data read from
the chained filter.
predictor: 1 = copy, 2 = tiff, other = inline PNG predictor
columns: width of image in pixels
colors: number of components.
bpc: bits per component (typically 8)
*/
fz_stream *fz_open_predict(fz_context *ctx, fz_stream *chain, int predictor, int columns, int colors, int bpc);
/**
Open a filter that performs jbig2 decompression on the chained
stream, using the optional globals record.
*/
fz_stream *fz_open_jbig2d(fz_context *ctx, fz_stream *chain, fz_jbig2_globals *globals);
/**
Create a jbig2 globals record from a buffer.
Immutable once created.
*/
fz_jbig2_globals *fz_load_jbig2_globals(fz_context *ctx, fz_buffer *buf);
/**
Increment the reference count for a jbig2 globals record.
Never throws an exception.
*/
fz_jbig2_globals *fz_keep_jbig2_globals(fz_context *ctx, fz_jbig2_globals *globals);
/**
Decrement the reference count for a jbig2 globals record.
When the reference count hits zero, the record is freed.
Never throws an exception.
*/
void fz_drop_jbig2_globals(fz_context *ctx, fz_jbig2_globals *globals);
/**
Special jbig2 globals drop function for use in implementing
store support.
*/
void fz_drop_jbig2_globals_imp(fz_context *ctx, fz_storable *globals);
/* Extra filters for tiff */
/**
SGI Log 16bit (greyscale) decode from the chained filter.
Decodes lines of w pixels to 8bpp greyscale.
*/
fz_stream *fz_open_sgilog16(fz_context *ctx, fz_stream *chain, int w);
/**
SGI Log 24bit (LUV) decode from the chained filter.
Decodes lines of w pixels to 8bpc rgb.
*/
fz_stream *fz_open_sgilog24(fz_context *ctx, fz_stream *chain, int w);
/**
SGI Log 32bit (LUV) decode from the chained filter.
Decodes lines of w pixels to 8bpc rgb.
*/
fz_stream *fz_open_sgilog32(fz_context *ctx, fz_stream *chain, int w);
/**
4bit greyscale Thunderscan decoding from the chained filter.
Decodes lines of w pixels to 8bpp greyscale.
*/
fz_stream *fz_open_thunder(fz_context *ctx, fz_stream *chain, int w);
#endif
This diff is collapsed.
This diff is collapsed.
#ifndef MUPDF_FITZ_GETOPT_H
#define MUPDF_FITZ_GETOPT_H
/**
Simple functions/variables for use in tools.
*/
extern int fz_getopt(int nargc, char * const *nargv, const char *ostr);
extern int fz_optind;
extern char *fz_optarg;
/**
Windows unicode versions.
*/
#ifdef _WIN32
extern int fz_getoptw(int nargc, wchar_t * const *nargv, const wchar_t *ostr);
extern int fz_optindw;
extern wchar_t *fz_optargw;
#endif
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef MUPDF_FITZ_LOG_H
#define MUPDF_FITZ_LOG_H
#include "mupdf/fitz/context.h"
#include "mupdf/fitz/output.h"
/**
The functions in this file offer simple logging abilities.
The default logfile is "fitz_log.txt". This can overridden by
defining an environment variable "FZ_LOG_FILE", or module
specific environment variables "FZ_LOG_FILE_<module>" (e.g.
"FZ_LOG_FILE_STORE").
Enable the following define(s) to enable built in debug logging
from within the appropriate module(s).
*/
/* #define ENABLE_STORE_LOGGING */
/**
Output a line to the log.
*/
void fz_log(fz_context *ctx, const char *fmt, ...);
/**
Output a line to the log for a given module.
*/
void fz_log_module(fz_context *ctx, const char *module, const char *fmt, ...);
/**
Internal function to actually do the opening of the logfile.
Caller should close/drop the output when finished with it.
*/
fz_output *fz_new_log_for_module(fz_context *ctx, const char *module);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef MUPDF_FITZ_VERSION_H
#define MUPDF_FITZ_VERSION_H
#ifndef FZ_VERSION
#define FZ_VERSION "1.18.0"
#define FZ_VERSION_MAJOR 1
#define FZ_VERSION_MINOR 18
#define FZ_VERSION_PATCH 0
#endif
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment