Commit 512ba072 authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander Trofimov

Реализована специальная функция для записи картинок с маской (сделано...

Реализована специальная функция для записи картинок с маской (сделано специально для Djvu). Реализована запись скрытого текста из Djvu (тоже с объединялкой, как и в обычной ситуации).

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63315 954022d7-b5bf-4e40-9824-e11837661b57
parent 608c5df9
...@@ -40,6 +40,64 @@ using namespace PdfWriter; ...@@ -40,6 +40,64 @@ using namespace PdfWriter;
#define LO_SURROGATE_START 0xDC00 #define LO_SURROGATE_START 0xDC00
#define LO_SURROGATE_END 0xDFFF #define LO_SURROGATE_END 0xDFFF
static unsigned int* WStringToUtf32(const std::wstring& wsUnicodeText, unsigned int& unLen)
{
if (wsUnicodeText.size() <= 0)
return NULL;
unsigned int* pUnicodes = new unsigned int[wsUnicodeText.size()];
if (!pUnicodes)
return NULL;
unsigned int* pOutput = pUnicodes;
unLen = 0;
if (2 == sizeof(wchar_t))
{
const wchar_t* wsEnd = wsUnicodeText.c_str() + wsUnicodeText.size();
wchar_t* wsInput = (wchar_t*)wsUnicodeText.c_str();
wchar_t wLeading, wTrailing;
unsigned int unCode;
while (wsInput < wsEnd)
{
wLeading = *wsInput++;
if (wLeading < 0xD800 || wLeading > 0xDFFF)
{
pUnicodes[unLen++] = (unsigned int)wLeading;
}
else if (wLeading >= 0xDC00)
{
//
continue;
}
else
{
unCode = (wLeading & 0x3FF) << 10;
wTrailing = *wsInput++;
if (wTrailing < 0xDC00 || wTrailing > 0xDFFF)
{
//
continue;
}
else
{
pUnicodes[unLen++] = (unCode | (wTrailing & 0x3FF) + 0x10000);
}
}
}
}
else
{
unLen = wsUnicodeText.size();
for (unsigned int unIndex = 0; unIndex < unLen; unIndex++)
{
pUnicodes[unIndex] = (unsigned int)wsUnicodeText.at(unIndex);
}
}
return pUnicodes;
}
// , , // , ,
static const long c_BrushTypeLinearGradient = 8001; static const long c_BrushTypeLinearGradient = 8001;
static const long c_BrushTypeRadialGradient = 8002; static const long c_BrushTypeRadialGradient = 8002;
...@@ -67,11 +125,6 @@ public: ...@@ -67,11 +125,6 @@ public:
// CRendererTextCommand // CRendererTextCommand
// //
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
#define RENDERERTEXTCOMMAND_FLAGS_FONT 0x0001
#define RENDERERTEXTCOMMAND_FLAGS_SIZE 0x0002
#define RENDERERTEXTCOMMAND_FLAGS_COLOR 0x0004
#define RENDERERTEXTCOMMAND_FLAGS_ALPHA 0x0008
#define RENDERERTEXTCOMMAND_FLAGS_SPACE 0x0010
class CRendererTextCommand : public CRendererCommandBase class CRendererTextCommand : public CRendererCommandBase
{ {
public: public:
...@@ -81,7 +134,13 @@ public: ...@@ -81,7 +134,13 @@ public:
m_nLen = nLen; m_nLen = nLen;
m_dX = dX; m_dX = dX;
m_dY = dY; m_dY = dY;
m_nUpdateFlags = 0; m_pFont = NULL;
m_dSize = -1;
m_lColor = 0;
m_nAlpha = 255;
m_dCharSpace = 0;
m_dHorScaling = 100;
m_nMode = (int)textrenderingmode_Fill;
} }
~CRendererTextCommand() ~CRendererTextCommand()
{ {
...@@ -109,54 +168,33 @@ public: ...@@ -109,54 +168,33 @@ public:
{ {
return m_nLen; return m_nLen;
} }
void SetFont(CFontDict* pFont) inline void SetFont(CFontDict* pFont)
{ {
m_pFont = pFont; m_pFont = pFont;
m_nUpdateFlags |= RENDERERTEXTCOMMAND_FLAGS_FONT;
} }
void SetSize(const double& dSize) inline void SetSize(const double& dSize)
{ {
m_dSize = dSize; m_dSize = dSize;
m_nUpdateFlags |= RENDERERTEXTCOMMAND_FLAGS_SIZE;
} }
void SetColor(const LONG& lColor) inline void SetColor(const LONG& lColor)
{ {
m_lColor = lColor; m_lColor = lColor;
m_nUpdateFlags |= RENDERERTEXTCOMMAND_FLAGS_COLOR;
} }
void SetAlpha(const BYTE& nAlpha) inline void SetAlpha(const BYTE& nAlpha)
{ {
m_nAlpha = nAlpha; m_nAlpha = nAlpha;
m_nUpdateFlags |= RENDERERTEXTCOMMAND_FLAGS_ALPHA;
} }
void SetCharSpace(const double& dCharSpace) inline void SetCharSpace(const double& dCharSpace)
{ {
m_dCharSpace = dCharSpace; m_dCharSpace = dCharSpace;
m_nUpdateFlags |= RENDERERTEXTCOMMAND_FLAGS_SPACE;
}
inline bool IsPropertiesChanged() const
{
return (0 == m_nUpdateFlags ? false : true);
}
inline bool IsFontChanged() const
{
return LONG_2_BOOL(m_nUpdateFlags & RENDERERTEXTCOMMAND_FLAGS_FONT);
}
inline bool IsSizeChanged() const
{
return LONG_2_BOOL(m_nUpdateFlags & RENDERERTEXTCOMMAND_FLAGS_SIZE);
}
inline bool IsColorChanged() const
{
return LONG_2_BOOL(m_nUpdateFlags & RENDERERTEXTCOMMAND_FLAGS_COLOR);
} }
inline bool IsAlphaChanged() const inline void SetHorScaling(const double& dKoef)
{ {
return LONG_2_BOOL(m_nUpdateFlags & RENDERERTEXTCOMMAND_FLAGS_ALPHA); m_dHorScaling = dKoef;
} }
inline bool IsSpaceChanged() const inline void SetMode(const int& nMode)
{ {
return LONG_2_BOOL(m_nUpdateFlags & RENDERERTEXTCOMMAND_FLAGS_SPACE); m_nMode = nMode;
} }
inline CFontDict* GetFont() const inline CFontDict* GetFont() const
{ {
...@@ -178,6 +216,14 @@ public: ...@@ -178,6 +216,14 @@ public:
{ {
return m_dCharSpace; return m_dCharSpace;
} }
inline double GetHorScaling() const
{
return m_dHorScaling;
}
inline int GetMode() const
{
return m_nMode;
}
private: private:
...@@ -193,6 +239,8 @@ private: ...@@ -193,6 +239,8 @@ private:
LONG m_lColor; LONG m_lColor;
BYTE m_nAlpha; BYTE m_nAlpha;
double m_dCharSpace; double m_dCharSpace;
int m_nMode;
double m_dHorScaling;
}; };
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
// //
...@@ -244,6 +292,8 @@ void CPdfRenderer::CCommandManager::Flush() ...@@ -244,6 +292,8 @@ void CPdfRenderer::CCommandManager::Flush()
LONG lTextColor = 0; LONG lTextColor = 0;
BYTE nTextAlpha = 255; BYTE nTextAlpha = 255;
double dTextSpace = 0; double dTextSpace = 0;
double dHorScaling = 100;
ETextRenderingMode eMode = textrenderingmode_Fill;
double dPrevX = -1000; double dPrevX = -1000;
double dPrevY = -1000; double dPrevY = -1000;
...@@ -256,24 +306,6 @@ void CPdfRenderer::CCommandManager::Flush() ...@@ -256,24 +306,6 @@ void CPdfRenderer::CCommandManager::Flush()
if (!pText) if (!pText)
continue; continue;
//if (pText->IsPropertiesChanged())
//{
// if (pText->IsFontChanged() || pText->IsSizeChanged())
// pPage->SetFontAndSize(pText->GetFont(), pText->GetSize());
// if (pText->IsColorChanged())
// {
// TColor oColor = pText->GetColor();
// pPage->SetFillColor(oColor.r, oColor.g, oColor.b);
// }
// if (pText->IsAlphaChanged())
// pPage->SetFillAlpha(pText->GetAlpha());
// if (pText->IsSpaceChanged())
// pPage->SetCharSpace(pText->GetSpace());
//}
if (pTextFont != pText->GetFont() || abs(dTextSize - pText->GetSize()) > 0.001) if (pTextFont != pText->GetFont() || abs(dTextSize - pText->GetSize()) > 0.001)
{ {
oTextLine.Flush(pPage); oTextLine.Flush(pPage);
...@@ -304,8 +336,19 @@ void CPdfRenderer::CCommandManager::Flush() ...@@ -304,8 +336,19 @@ void CPdfRenderer::CCommandManager::Flush()
pPage->SetCharSpace(dTextSpace); pPage->SetCharSpace(dTextSpace);
} }
if ((int)eMode != pText->GetMode())
{
oTextLine.Flush(pPage);
eMode = (ETextRenderingMode)pText->GetMode();
pPage->SetTextRenderingMode(eMode);
}
//------------------------------------ if (abs(dHorScaling - pText->GetHorScaling()) > 0.001)
{
oTextLine.Flush(pPage);
dHorScaling = pText->GetHorScaling();
pPage->SetHorizontalScalling(dHorScaling);
}
unsigned char* pCodes = pText->GetCodes(); unsigned char* pCodes = pText->GetCodes();
unsigned short ushCode = (pCodes[0] << 8) + pCodes[1]; unsigned short ushCode = (pCodes[0] << 8) + pCodes[1];
...@@ -323,9 +366,6 @@ void CPdfRenderer::CCommandManager::Flush() ...@@ -323,9 +366,6 @@ void CPdfRenderer::CCommandManager::Flush()
pPage->DrawText(dX, dY, pCodes, unLen); pPage->DrawText(dX, dY, pCodes, unLen);
} }
} }
//-----------------------------------
//pPage->DrawText(pText->GetX(), pText->GetY(), pText->GetCodes(), pText->GetCodesLen());
} }
oTextLine.Flush(pPage); oTextLine.Flush(pPage);
...@@ -847,94 +887,89 @@ HRESULT CPdfRenderer::put_FontFaceIndex(const int& nFaceIndex) ...@@ -847,94 +887,89 @@ HRESULT CPdfRenderer::put_FontFaceIndex(const int& nFaceIndex)
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
HRESULT CPdfRenderer::CommandDrawTextCHAR(const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset) HRESULT CPdfRenderer::CommandDrawTextCHAR(const LONG& lUnicode, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset)
{ {
// TODO: if (!IsPageValid())
return S_OK; return S_FALSE;
unsigned int unUnicode = lUnicode;
bool bRes = DrawText(&unUnicode, 1, dX, dY);
return bRes ? S_OK : S_FALSE;
} }
HRESULT CPdfRenderer::CommandDrawText(const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset) HRESULT CPdfRenderer::CommandDrawText(const std::wstring& wsUnicodeText, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset)
{ {
if (!IsPageValid() || !wsUnicodeText.size()) if (!IsPageValid() || !wsUnicodeText.size())
return S_FALSE; return S_FALSE;
unsigned int* pUnicodes = new unsigned int[wsUnicodeText.size()]; unsigned int unLen;
unsigned int* pUnicodes = WStringToUtf32(wsUnicodeText, unLen);
if (!pUnicodes) if (!pUnicodes)
return S_FALSE; return S_FALSE;
unsigned int* pOutput = pUnicodes; // Djvu, ,
unsigned int unLen = 0; if (L"" == m_oFont.GetPath() && L"DjvuEmptyFont" == m_oFont.GetName())
if (2 == sizeof(wchar_t))
{
const wchar_t* wsEnd = wsUnicodeText.c_str() + wsUnicodeText.size();
wchar_t* wsInput = (wchar_t*)wsUnicodeText.c_str();
wchar_t wLeading, wTrailing;
unsigned int unCode;
while (wsInput < wsEnd)
{ {
wLeading = *wsInput++;
if (wLeading < 0xD800 || wLeading > 0xDFFF)
{
pUnicodes[unLen++] = (unsigned int)wLeading;
}
else if (wLeading >= 0xDC00)
{
//
continue;
}
else
{
unCode = (wLeading & 0x3FF) << 10;
wTrailing = *wsInput++;
if (wTrailing < 0xDC00 || wTrailing > 0xDFFF)
{
//
continue;
}
else
{
pUnicodes[unLen++] = (unCode | (wTrailing & 0x3FF) + 0x10000);
}
}
}
}
else
{
unLen = wsUnicodeText.size();
for (unsigned int unIndex = 0; unIndex < unLen; unIndex++)
{
pUnicodes[unIndex] = (unsigned int)wsUnicodeText.at(unIndex);
}
}
if (m_bNeedUpdateTextFont) if (m_bNeedUpdateTextFont)
{
m_oFont.SetName(L"Arial");
UpdateFont(); UpdateFont();
m_oFont.SetName(L"DjvuEmptyFont");
if (!m_pFont) if (!m_pFont)
return S_FALSE; return S_FALSE;
}
double dFontSize = MM_2_PT(dH);
unsigned char* pCodes = m_pFont->EncodeString(pUnicodes, unLen); unsigned char* pCodes = m_pFont->EncodeString(pUnicodes, unLen);
delete[] pUnicodes; delete[] pUnicodes;
double dStringWidth = 0;
for (unsigned int unIndex = 0; unIndex < unLen; unIndex++)
{
unsigned short ushCode = (pCodes[2 * unIndex] << 8) + pCodes[2 * unIndex + 1];
dStringWidth += m_pFont->GetWidth(ushCode) * dFontSize / 1000.0;
}
double dResultWidth = MM_2_PT(dW);
CTransform& t = m_oTransform; CTransform& t = m_oTransform;
m_oCommandManager.SetTransform(t.m11, -t.m12, -t.m21, t.m22, MM_2_PT(t.dx + t.m21 * m_dPageHeight), MM_2_PT(m_dPageHeight - m_dPageHeight * t.m22 - t.dy)); m_oCommandManager.SetTransform(t.m11, -t.m12, -t.m21, t.m22, MM_2_PT(t.dx + t.m21 * m_dPageHeight), MM_2_PT(m_dPageHeight - m_dPageHeight * t.m22 - t.dy));
CRendererTextCommand* pText = m_oCommandManager.AddText(pCodes, unLen * 2, MM_2_PT(dX), MM_2_PT(m_dPageHeight - dY)); CRendererTextCommand* pText = m_oCommandManager.AddText(pCodes, unLen * 2, MM_2_PT(dX), MM_2_PT(m_dPageHeight - dY - dH));
pText->SetFont(m_pFont); pText->SetFont(m_pFont);
pText->SetSize(m_oFont.GetSize()); pText->SetSize(dFontSize);
pText->SetColor(m_oBrush.GetColor1()); pText->SetMode(textrenderingmode_Invisible);
pText->SetAlpha((BYTE)m_oBrush.GetAlpha1()); if (abs(dStringWidth) > 0.001)
pText->SetCharSpace(MM_2_PT(m_oFont.GetCharSpace())); pText->SetHorScaling(dResultWidth / dStringWidth * 100);
return S_OK; return S_OK;
}
bool bRes = DrawText(pUnicodes, unLen, dX, dY);
delete[] pUnicodes;
return bRes ? S_OK : S_FALSE;
} }
HRESULT CPdfRenderer::CommandDrawTextExCHAR(const LONG& lUnicode, const LONG& lGid, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset, const DWORD& dwFlags) HRESULT CPdfRenderer::CommandDrawTextExCHAR(const LONG& lUnicode, const LONG& lGid, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset, const DWORD& dwFlags)
{ {
// TODO: if (!IsPageValid())
return S_OK; return S_FALSE;
unsigned int unUnicode = lUnicode;
bool bRes = DrawText(&unUnicode, 1, dX, dY);
return bRes ? S_OK : S_FALSE;
} }
HRESULT CPdfRenderer::CommandDrawTextEx(const std::wstring& wsUnicodeText, const std::wstring& wsGidText, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset, const DWORD& dwFlags) HRESULT CPdfRenderer::CommandDrawTextEx(const std::wstring& wsUnicodeText, const std::wstring& wsGidText, const double& dX, const double& dY, const double& dW, const double& dH, const double& dBaselineOffset, const DWORD& dwFlags)
{ {
// TODO: if (!IsPageValid() || !wsUnicodeText.size())
return S_OK; return S_FALSE;
unsigned int unLen;
unsigned int* pUnicodes = WStringToUtf32(wsUnicodeText, unLen);
if (!pUnicodes)
return S_FALSE;
bool bRes = DrawText(pUnicodes, unLen, dX, dY);
delete[] pUnicodes;
return bRes ? S_OK : S_FALSE;
} }
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
// //
...@@ -1244,6 +1279,22 @@ HRESULT CPdfRenderer::SetRadialGradient(const double& dX0, const double& dY0, co ...@@ -1244,6 +1279,22 @@ HRESULT CPdfRenderer::SetRadialGradient(const double& dX0, const double& dY0, co
m_oBrush.SetRadialGradientPattern(dX0, dY0, dR0, dX1, dY1, dR1); m_oBrush.SetRadialGradientPattern(dX0, dY0, dR0, dX1, dY1, dR1);
return S_OK; return S_OK;
} }
HRESULT CPdfRenderer::DrawImageWith1bppMask(IGrObject* pImage, Pix* pMaskBuffer, const unsigned int& unMaskWidth, const unsigned int& unMaskHeight, const double& dX, const double& dY, const double& dW, const double& dH)
{
m_oCommandManager.Flush();
if (!IsPageValid() || !pMaskBuffer || !pImage)
return S_OK;
m_pPage->GrSave();
UpdateTransform();
CImageDict* pPdfImage = LoadImage((Aggplus::CImage*)pImage, 255);
pPdfImage->LoadMask(pMaskBuffer, unMaskWidth, unMaskHeight);
m_pPage->DrawImage(pPdfImage, MM_2_PT(dX), MM_2_PT(m_dPageHeight - dY - dH), MM_2_PT(dW), MM_2_PT(dH));
m_pPage->GrRestore();
return S_OK;
}
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
// //
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
...@@ -1314,6 +1365,29 @@ bool CPdfRenderer::DrawImage(Aggplus::CImage* pImage, const double& dX, const do ...@@ -1314,6 +1365,29 @@ bool CPdfRenderer::DrawImage(Aggplus::CImage* pImage, const double& dX, const do
return true; return true;
} }
bool CPdfRenderer::DrawText(unsigned int* pUnicodes, unsigned int unLen, const double& dX, const double& dY)
{
if (m_bNeedUpdateTextFont)
UpdateFont();
if (!m_pFont)
return false;
unsigned char* pCodes = m_pFont->EncodeString(pUnicodes, unLen);
delete[] pUnicodes;
CTransform& t = m_oTransform;
m_oCommandManager.SetTransform(t.m11, -t.m12, -t.m21, t.m22, MM_2_PT(t.dx + t.m21 * m_dPageHeight), MM_2_PT(m_dPageHeight - m_dPageHeight * t.m22 - t.dy));
CRendererTextCommand* pText = m_oCommandManager.AddText(pCodes, unLen * 2, MM_2_PT(dX), MM_2_PT(m_dPageHeight - dY));
pText->SetFont(m_pFont);
pText->SetSize(m_oFont.GetSize());
pText->SetColor(m_oBrush.GetColor1());
pText->SetAlpha((BYTE)m_oBrush.GetAlpha1());
pText->SetCharSpace(MM_2_PT(m_oFont.GetCharSpace()));
return true;
}
void CPdfRenderer::UpdateFont() void CPdfRenderer::UpdateFont()
{ {
m_bNeedUpdateTextFont = false; m_bNeedUpdateTextFont = false;
...@@ -1364,8 +1438,17 @@ void CPdfRenderer::UpdateFont() ...@@ -1364,8 +1438,17 @@ void CPdfRenderer::UpdateFont()
} }
void CPdfRenderer::UpdateTransform() void CPdfRenderer::UpdateTransform()
{ {
CTransform& t = m_oTransform; CTransform t;
m_pPage->Concat(t.m11, -t.m12, -t.m21, t.m22, MM_2_PT(t.dx + t.m21 * m_dPageHeight), MM_2_PT(m_dPageHeight - m_dPageHeight * t.m22 - t.dy));
t.m11 = m_oTransform.m11;
t.m12 = -m_oTransform.m12;
t.m21 = -m_oTransform.m21;
t.m22 = m_oTransform.m22;
t.dx = MM_2_PT(t.dx + t.m21 * m_dPageHeight);
t.dy = MM_2_PT(m_dPageHeight - m_dPageHeight * t.m22 - t.dy);
if (!t.IsIdentity())
m_pPage->Concat(t.m11, t.m12, t.m21, t.m22, t.dx, t.dy);
} }
void CPdfRenderer::UpdatePen() void CPdfRenderer::UpdatePen()
{ {
......
...@@ -181,12 +181,14 @@ public: ...@@ -181,12 +181,14 @@ public:
HRESULT SetRadialGradient(const double& dX1, const double& dY1, const double& dR1, const double& dX2, const double& dY2, const double& dR2); HRESULT SetRadialGradient(const double& dX1, const double& dY1, const double& dR1, const double& dX2, const double& dY2, const double& dR2);
HRESULT OnlineWordToPdf (const std::wstring& wsSrcFile, const std::wstring& wsDstFile); HRESULT OnlineWordToPdf (const std::wstring& wsSrcFile, const std::wstring& wsDstFile);
HRESULT OnlineWordToPdfFromBinary(const std::wstring& wsSrcFile, const std::wstring& wsDstFile); HRESULT OnlineWordToPdfFromBinary(const std::wstring& wsSrcFile, const std::wstring& wsDstFile);
HRESULT DrawImageWith1bppMask(IGrObject* pImage, Pix* pMaskBuffer, const unsigned int& unMaskWidth, const unsigned int& unMaskHeight, const double& dX, const double& dY, const double& dW, const double& dH);
private: private:
void OnlineWordToPdfInternal(BYTE* dstArray, LONG lLen, const std::wstring& wsHtmlPlace, std::wstring& wsHypers, int& nCountPages, const std::wstring& wsTempLogo, LONG lReg); void OnlineWordToPdfInternal(BYTE* dstArray, LONG lLen, const std::wstring& wsHtmlPlace, std::wstring& wsHypers, int& nCountPages, const std::wstring& wsTempLogo, LONG lReg);
PdfWriter::CImageDict* LoadImage(Aggplus::CImage* pImage, const BYTE& nAlpha); PdfWriter::CImageDict* LoadImage(Aggplus::CImage* pImage, const BYTE& nAlpha);
bool DrawImage(Aggplus::CImage* pImage, const double& dX, const double& dY, const double& dW, const double& dH, const BYTE& nAlpha); bool DrawImage(Aggplus::CImage* pImage, const double& dX, const double& dY, const double& dW, const double& dH, const BYTE& nAlpha);
bool DrawText(unsigned int* pUnicodes, unsigned int unLen, const double& dX, const double& dY);
void UpdateFont(); void UpdateFont();
void UpdateTransform(); void UpdateTransform();
void UpdatePen(); void UpdatePen();
......
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
#include <vector> #include <vector>
#include <ctime> #include <ctime>
#ifdef DrawText #ifdef DrawText
#undef DrawText #undef DrawText
#endif #endif
...@@ -920,7 +918,8 @@ void TestMetafile() ...@@ -920,7 +918,8 @@ void TestMetafile()
} }
void TestOnlineBin() void TestOnlineBin()
{ {
std::wstring wsFolderPath = L"D://Test Files//Txt//IvanovaVeronica//"; std::wstring wsFolderPath = L"D://Test Files//Txt//";
//std::wstring wsFolderPath = L"D://Test Files//Txt//IvanovaVeronica//";
std::wstring wsTempFolder = L"D://Test Files//Temp//"; std::wstring wsTempFolder = L"D://Test Files//Temp//";
CApplicationFonts oFonts; CApplicationFonts oFonts;
......
...@@ -260,6 +260,32 @@ namespace PdfWriter ...@@ -260,6 +260,32 @@ namespace PdfWriter
pParams->Add("JBIG2Globals", pJbig2Global); pParams->Add("JBIG2Globals", pJbig2Global);
Add("DecodeParms", pDecodeParams); Add("DecodeParms", pDecodeParams);
} }
void CImageDict::LoadMask(Pix* pPix, unsigned int unWidth, unsigned int unHeight)
{
CImageDict* pMask = new CImageDict(m_pXref, m_pDocument);
if (!pMask)
return;
pMask->SetStream(m_pXref, new CMemoryStream());
CJbig2Global* pJbig2Global = m_pDocument->GetJbig2Global();
pJbig2Global->AddImage(pPix, pMask->GetStream());
pMask->Add("Type", "XObject");
pMask->Add("Subtype", "Image");
pMask->Add("Width", unWidth);
pMask->Add("Height", unHeight);
pMask->Add("BitsPerComponent", 1);
pMask->Add("ImageMask", true);
pMask->SetFilter(STREAM_FILTER_JBIG2_DECODE);
CArrayObject* pDecodeParams = new CArrayObject();
CDictObject* pParams = new CDictObject();
pDecodeParams->Add(pParams);
pParams->Add("JBIG2Globals", pJbig2Global);
pMask->Add("DecodeParms", pDecodeParams);
Add("Mask", pMask);
}
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
// CJbig2Global // CJbig2Global
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
......
...@@ -38,6 +38,7 @@ namespace PdfWriter ...@@ -38,6 +38,7 @@ namespace PdfWriter
void LoadSMask(const BYTE* pBuffer, unsigned int unSize, unsigned int unWidth, unsigned int unHeight); void LoadSMask(const BYTE* pBuffer, unsigned int unSize, unsigned int unWidth, unsigned int unHeight);
void LoadBW(const BYTE* pImage, unsigned int unWidth, unsigned int unHeight, unsigned int unStride); void LoadBW(const BYTE* pImage, unsigned int unWidth, unsigned int unHeight, unsigned int unStride);
void LoadBW(Pix* pPix, unsigned int unWidth, unsigned int unHeight); void LoadBW(Pix* pPix, unsigned int unWidth, unsigned int unHeight);
void LoadMask(Pix* pPix, unsigned int unWidth, unsigned int unHeight);
private: private:
......
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