void CCatalog::AddPageLabel(unsigned int unPageNum, CDictObject* pPageLabel) { CDictObject* pLabels = (CDictObject*)Get("PageLabels"); if (!pLabels) { pLabels = new CDictObject(); if (!pLabels) return; Add("PageLabels", pLabels); } CArrayObject* pNums = (CArrayObject*)pLabels->Get("Nums"); if (!pNums) { pNums = new CArrayObject(); if (!pNums) return; pLabels->Add("Nums", pNums); } pNums->Add(unPageNum); pNums->Add(pPageLabel); }
void CImageDict::LoadMask(NSImages::CPixJbig2* 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); }
void CImageDict::LoadCCITT4(const wchar_t* wsTempFile, unsigned int unWidth, unsigned int unHeight) { CImageFileStream* pStream = new CImageFileStream(); if (!pStream) return; pStream->OpenFile(wsTempFile); SetStream(m_pXref, pStream); Add("Type", "XObject"); Add("Subtype", "Image"); Add("Height", unHeight); Add("Width", unWidth); Add("ColorSpace", "DeviceGray"); Add("BitsPerComponent", 1); CArrayObject* pDecodeParams = new CArrayObject(); CDictObject* pParams = new CDictObject(); pDecodeParams->Add(pParams); pParams->Add("K", 0); pParams->Add("Columns", unWidth); pParams->Add("EncodedByteAlign", true); Add("DecodeParams", pDecodeParams); SetFilter(STREAM_FILTER_CCITT_DECODE); }
void CImageDict::LoadBW(NSImages::CPixJbig2* pPix, unsigned int unWidth, unsigned int unHeight) { SetStream(m_pXref, new CMemoryStream()); CJbig2Global* pJbig2Global = m_pDocument->GetJbig2Global(); pJbig2Global->AddImage(pPix, GetStream()); Add("Type", "XObject"); Add("Subtype", "Image"); Add("Height", unHeight); Add("Width", unWidth); Add("ColorSpace", "DeviceGray"); Add("BitsPerComponent", 1); SetFilter(STREAM_FILTER_JBIG2_DECODE); CArrayObject* pDecodeParams = new CArrayObject(); CDictObject* pParams = new CDictObject(); pDecodeParams->Add(pParams); pParams->Add("JBIG2Globals", pJbig2Global); Add("DecodeParms", pDecodeParams); }
CDictObject* CDocument::CreatePageLabel(EPageNumStyle eStyle, unsigned int unFirstPage, const char* sPrefix) { CDictObject* pLabel = new CDictObject(); if (!pLabel) return NULL; eStyle = std::min(std::max(eStyle, pagenumstyle_Min), pagenumstyle_Max); switch (eStyle) { case pagenumstyle_UpperRoman: pLabel->Add("S", "R"); break; case pagenumstyle_LowerRoman: pLabel->Add("S", "r"); break; case pagenumstyle_UpperLetters: pLabel->Add("S", "A"); break; case pagenumstyle_LowerLetters: pLabel->Add("S", "a"); break; case pagenumstyle_Decimal: pLabel->Add("S", "D"); break; } if (sPrefix && 0 != sPrefix[0]) pLabel->Add("P", new CStringObject(sPrefix)); if (0 != unFirstPage) pLabel->Add("St", unFirstPage); return pLabel; }
CShading* CDocument::CreateShading(CPage* pPage, double *pPattern, bool bAxial, unsigned char* pColors, unsigned char* pAlphas, double* pPoints, int nCount, CExtGrState*& pExtGrState) { pExtGrState = NULL; bool bNeedAlpha = false; unsigned char* pA = new unsigned char[3 * nCount]; if (!pA) return NULL; for (int nIndex = 0; nIndex < nCount; nIndex++) { pA[3 * nIndex + 0] = pAlphas[nIndex]; pA[3 * nIndex + 1] = pAlphas[nIndex]; pA[3 * nIndex + 2] = pAlphas[nIndex]; if (255 != pAlphas[nIndex]) bNeedAlpha = true; } if (!bNeedAlpha) { delete[] pA; if (bAxial) return CreateAxialShading(pPattern[0], pPattern[1], pPattern[2], pPattern[3], pColors, pPoints, nCount); else return CreateRadialShading(pPattern[0], pPattern[1], pPattern[2], pPattern[3], pPattern[4], pPattern[5], pColors, pPoints, nCount); } // Создаем 2 shading-объекта, один цветной RGB, второй серый со значениями альфа-канала CShading* pColorShading = NULL; CShading* pAlphaShading = NULL; if (bAxial) { pColorShading = CreateAxialShading(pPattern[0], pPattern[1], pPattern[2], pPattern[3], pColors, pPoints, nCount); pAlphaShading = CreateAxialShading(pPattern[0], pPattern[1], pPattern[2], pPattern[3], pA, pPoints, nCount); } else { pColorShading = CreateRadialShading(pPattern[0], pPattern[1], pPattern[2], pPattern[3], pPattern[4], pPattern[5], pColors, pPoints, nCount); pAlphaShading = CreateRadialShading(pPattern[0], pPattern[1], pPattern[2], pPattern[3], pPattern[4], pPattern[5], pA, pPoints, nCount); } delete[] pA; if (!m_pTransparencyGroup) { m_pTransparencyGroup = new CDictObject(); m_pTransparencyGroup->Add("Type", "Group"); m_pTransparencyGroup->Add("S", "Transparency"); m_pTransparencyGroup->Add("CS", "DeviceRGB"); } pPage->Add("Group", m_pTransparencyGroup); double dWidth = pPage->GetWidth(); double dHeight = pPage->GetHeight(); // Создаем графический объект, который будет альфа-маской CDictObject* pXObject = new CDictObject(m_pXref); pXObject->Add("Type", "XObject"); pXObject->Add("Subtype", "Form"); pXObject->Add("BBox", CArrayObject::CreateBox(0, 0, dWidth, dHeight)); pXObject->Add("Group", m_pTransparencyGroup); CDictObject* pResources = new CDictObject(); pXObject->Add("Resources", pResources); CDictObject* pResShadings = new CDictObject(); pResources->Add("Shading", pResShadings); pResShadings->Add("S1", pAlphaShading); CStream* pStream = pXObject->GetStream(); pStream->WriteStr("0 0 "); pStream->WriteReal(dWidth); pStream->WriteChar(' '); pStream->WriteReal(dHeight); pStream->WriteStr(" re\012W\012\n\012/S1 sh\012"); // Создаем обект-маску для графического состояние CDictObject* pMask = new CDictObject(); m_pXref->Add(pMask); pMask->Add("Type", "Mask"); pMask->Add("S", "Luminosity"); pMask->Add("G", pXObject); if (!IsPDFA()) { // Создаем ExtGState объект, в который мы запишем альфа-маску pExtGrState = new CExtGrState(m_pXref); pExtGrState->Add("BM", "Normal"); pExtGrState->Add("ca", 1); pExtGrState->Add("SMask", pMask); } return pColorShading; }