本文整理汇总了C++中CFX_ByteTextBuf::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CFX_ByteTextBuf::GetSize方法的具体用法?C++ CFX_ByteTextBuf::GetSize怎么用?C++ CFX_ByteTextBuf::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFX_ByteTextBuf
的用法示例。
在下文中一共展示了CFX_ByteTextBuf::GetSize方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetGraphState
void CFX_PSRenderer::SetGraphState(const CFX_GraphStateData* pGraphState)
{
CFX_ByteTextBuf buf;
if (!m_bGraphStateSet || m_CurGraphState.m_LineCap != pGraphState->m_LineCap) {
buf << pGraphState->m_LineCap << FX_BSTRC(" J\n");
}
if (!m_bGraphStateSet || m_CurGraphState.m_DashCount != pGraphState->m_DashCount ||
FXSYS_memcmp32(m_CurGraphState.m_DashArray, pGraphState->m_DashArray, sizeof(FX_FLOAT)*m_CurGraphState.m_DashCount)) {
buf << FX_BSTRC("[");
for (int i = 0; i < pGraphState->m_DashCount; i ++) {
buf << pGraphState->m_DashArray[i] << FX_BSTRC(" ");
}
buf << FX_BSTRC("]") << pGraphState->m_DashPhase << FX_BSTRC(" d\n");
}
if (!m_bGraphStateSet || m_CurGraphState.m_LineJoin != pGraphState->m_LineJoin) {
buf << pGraphState->m_LineJoin << FX_BSTRC(" j\n");
}
if (!m_bGraphStateSet || m_CurGraphState.m_LineWidth != pGraphState->m_LineWidth) {
buf << pGraphState->m_LineWidth << FX_BSTRC(" w\n");
}
if (!m_bGraphStateSet || m_CurGraphState.m_MiterLimit != pGraphState->m_MiterLimit) {
buf << pGraphState->m_MiterLimit << FX_BSTRC(" M\n");
}
m_CurGraphState.Copy(*pGraphState);
m_bGraphStateSet = TRUE;
if (buf.GetSize()) {
m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
}
}
示例2: SetColor
void CFX_PSRenderer::SetColor(FX_DWORD color, int alpha_flag, void* pIccTransform)
{
if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
pIccTransform = NULL;
}
FX_BOOL bCMYK = FALSE;
if (pIccTransform) {
ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
color = FXGETFLAG_COLORTYPE(alpha_flag) ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
FX_LPBYTE pColor = (FX_LPBYTE)&color;
pIccModule->TranslateScanline(pIccTransform, pColor, pColor, 1);
color = m_bCmykOutput ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
bCMYK = m_bCmykOutput;
} else {
bCMYK = FXGETFLAG_COLORTYPE(alpha_flag);
}
if (bCMYK != m_bCmykOutput || !m_bColorSet || m_LastColor != color) {
CFX_ByteTextBuf buf;
if (bCMYK) {
buf << FXSYS_GetCValue(color) / 255.0 << FX_BSTRC(" ") << FXSYS_GetMValue(color) / 255.0 << FX_BSTRC(" ")
<< FXSYS_GetYValue(color) / 255.0 << FX_BSTRC(" ") << FXSYS_GetKValue(color) / 255.0 << FX_BSTRC(" k\n");
} else {
buf << FXARGB_R(color) / 255.0 << FX_BSTRC(" ") << FXARGB_G(color) / 255.0 << FX_BSTRC(" ")
<< FXARGB_B(color) / 255.0 << FX_BSTRC(" rg\n");
}
if (bCMYK == m_bCmykOutput) {
m_bColorSet = TRUE;
m_LastColor = color;
}
m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
}
}
示例3: DrawPath
FX_BOOL CFX_PSRenderer::DrawPath(const CFX_PathData* pPathData,
const CFX_AffineMatrix* pObject2Device,
const CFX_GraphStateData* pGraphState,
FX_DWORD fill_color,
FX_DWORD stroke_color,
int fill_mode,
int alpha_flag,
void* pIccTransform
)
{
StartRendering();
int fill_alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(fill_color);
int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_STROKE(alpha_flag) : FXARGB_A(stroke_color);
if (fill_alpha && fill_alpha < 255) {
return FALSE;
}
if (stroke_alpha && stroke_alpha < 255) {
return FALSE;
}
if (fill_alpha == 0 && stroke_alpha == 0) {
return FALSE;
}
if (stroke_alpha) {
SetGraphState(pGraphState);
if (pObject2Device) {
CFX_ByteTextBuf buf;
buf << FX_BSTRC("mx Cm [") << pObject2Device->a << FX_BSTRC(" ") << pObject2Device->b << FX_BSTRC(" ") <<
pObject2Device->c << FX_BSTRC(" ") << pObject2Device->d << FX_BSTRC(" ") << pObject2Device->e <<
FX_BSTRC(" ") << pObject2Device->f << FX_BSTRC("]cm ");
m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
}
}
OutputPath(pPathData, stroke_alpha ? NULL : pObject2Device);
if (fill_mode && fill_alpha) {
SetColor(fill_color, alpha_flag, pIccTransform);
if ((fill_mode & 3) == FXFILL_WINDING) {
if (stroke_alpha) {
OUTPUT_PS("q f Q ");
} else {
OUTPUT_PS("f");
}
} else if ((fill_mode & 3) == FXFILL_ALTERNATE) {
if (stroke_alpha) {
OUTPUT_PS("q F Q ");
} else {
OUTPUT_PS("F");
}
}
}
if (stroke_alpha) {
SetColor(stroke_color, alpha_flag, pIccTransform);
if (pObject2Device) {
OUTPUT_PS("s sm");
} else {
OUTPUT_PS("s");
}
}
OUTPUT_PS("\n");
return TRUE;
}
示例4: WriteFile
FX_BOOL CFDF_Document::WriteFile(IFX_FileWrite *pFile) const
{
CFX_ByteTextBuf buf;
WriteBuf(buf);
FX_BOOL bRet = pFile->WriteBlock(buf.GetBuffer(), buf.GetSize());
if (bRet) {
pFile->Flush();
}
return bRet;
}
示例5: OutputPath
void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device)
{
int nPoints = pPathData->GetPointCount();
CFX_ByteTextBuf buf;
buf.EstimateSize(nPoints * 10);
for (int i = 0; i < nPoints; i ++) {
FX_BYTE flag = pPathData->GetFlag(i);
FX_FLOAT x = pPathData->GetPointX(i);
FX_FLOAT y = pPathData->GetPointY(i);
if (pObject2Device) {
pObject2Device->Transform(x, y);
}
buf << x << FX_BSTRC(" ") << y;
switch (flag & FXPT_TYPE) {
case FXPT_MOVETO:
buf << FX_BSTRC(" m ");
break;
case FXPT_LINETO:
if (flag & FXPT_CLOSEFIGURE) {
buf << FX_BSTRC(" l h ");
} else {
buf << FX_BSTRC(" l ");
}
break;
case FXPT_BEZIERTO: {
FX_FLOAT x1 = pPathData->GetPointX(i + 1);
FX_FLOAT x2 = pPathData->GetPointX(i + 2);
FX_FLOAT y1 = pPathData->GetPointY(i + 1);
FX_FLOAT y2 = pPathData->GetPointY(i + 2);
if (pObject2Device) {
pObject2Device->Transform(x1, y1);
pObject2Device->Transform(x2, y2);
}
buf << FX_BSTRC(" ") << x1 << FX_BSTRC(" ") << y1 << FX_BSTRC(" ") << x2 << FX_BSTRC(" ") << y2;
if (flag & FXPT_CLOSEFIGURE) {
buf << FX_BSTRC(" c h\n");
} else {
buf << FX_BSTRC(" c\n");
}
i += 2;
break;
}
}
}
m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
}
示例6: DrawText
FX_BOOL CFX_PSRenderer::DrawText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont,
CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device,
FX_FLOAT font_size, FX_DWORD color,
int alpha_flag, void* pIccTransform)
{
StartRendering();
int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
if (alpha < 255) {
return FALSE;
}
if ((pObject2Device->a == 0 && pObject2Device->b == 0) || (pObject2Device->c == 0 && pObject2Device->d == 0)) {
return TRUE;
}
SetColor(color, alpha_flag, pIccTransform);
CFX_ByteTextBuf buf;
buf << FX_BSTRC("q[") << pObject2Device->a << FX_BSTRC(" ") << pObject2Device->b << FX_BSTRC(" ")
<< pObject2Device->c << FX_BSTRC(" ") << pObject2Device->d;
buf << FX_BSTRC(" ") << pObject2Device->e << FX_BSTRC(" ") << pObject2Device->f << "]cm\n";
if (pCache == NULL) {
pCache = CFX_GEModule::Get()->GetFontCache();
}
CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
FX_FONTCACHE_DEFINE(pCache, pFont);
int last_fontnum = -1;
for (int i = 0; i < nChars; i ++) {
int ps_fontnum, ps_glyphindex;
FindPSFontGlyph(pFaceCache, pFont, pCharPos[i], ps_fontnum, ps_glyphindex);
if (last_fontnum != ps_fontnum) {
buf << FX_BSTRC("/X") << ps_fontnum << FX_BSTRC(" Ff ") << font_size
<< FX_BSTRC(" Fs Sf ");
last_fontnum = ps_fontnum;
}
buf << pCharPos[i].m_OriginX << FX_BSTRC(" ")
<< pCharPos[i].m_OriginY << FX_BSTRC(" m");
CFX_ByteString hex;
hex.Format("<%02X>", ps_glyphindex);
buf << hex << FX_BSTRC("Tj\n");
}
buf << FX_BSTRC("Q\n");
m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
return TRUE;
}
示例7: SetClip_PathStroke
void CFX_PSRenderer::SetClip_PathStroke(const CFX_PathData* pPathData,
const CFX_AffineMatrix* pObject2Device,
const CFX_GraphStateData* pGraphState
)
{
StartRendering();
SetGraphState(pGraphState);
if (pObject2Device) {
CFX_ByteTextBuf buf;
buf << FX_BSTRC("mx Cm [") << pObject2Device->a << FX_BSTRC(" ") << pObject2Device->b << FX_BSTRC(" ") <<
pObject2Device->c << FX_BSTRC(" ") << pObject2Device->d << FX_BSTRC(" ") << pObject2Device->e <<
FX_BSTRC(" ") << pObject2Device->f << FX_BSTRC("]cm ");
m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
}
OutputPath(pPathData, NULL);
CFX_FloatRect rect = pPathData->GetBoundingBox(pGraphState->m_LineWidth, pGraphState->m_MiterLimit);
rect.Transform(pObject2Device);
m_ClipBox.Intersect(rect.GetOutterRect());
if (pObject2Device) {
OUTPUT_PS("strokepath W n sm\n");
} else {
OUTPUT_PS("strokepath W n\n");
}
}
示例8: rect
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
FS_MATRIX* matrix,
FS_RECTF* clipRect) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return FALSE;
CFX_ByteTextBuf textBuf;
textBuf << "q ";
CFX_FloatRect rect(clipRect->left, clipRect->bottom, clipRect->right,
clipRect->top);
rect.Normalize();
CFX_ByteString bsClipping;
bsClipping.Format("%f %f %f %f re W* n ", rect.left, rect.bottom,
rect.Width(), rect.Height());
textBuf << bsClipping;
CFX_ByteString bsMatix;
bsMatix.Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b, matrix->c,
matrix->d, matrix->e, matrix->f);
textBuf << bsMatix;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
CPDF_Object* pContentObj =
pPageDic ? pPageDic->GetElement("Contents") : nullptr;
if (!pContentObj)
pContentObj = pPageDic ? pPageDic->GetArrayBy("Contents") : nullptr;
if (!pContentObj)
return FALSE;
CPDF_Dictionary* pDic = new CPDF_Dictionary;
CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic);
pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize(), FALSE, FALSE);
CPDF_Document* pDoc = pPage->m_pDocument;
if (!pDoc)
return FALSE;
pDoc->AddIndirectObject(pStream);
pDic = new CPDF_Dictionary;
CPDF_Stream* pEndStream = new CPDF_Stream(nullptr, 0, pDic);
pEndStream->SetData((const uint8_t*)" Q", 2, FALSE, FALSE);
pDoc->AddIndirectObject(pEndStream);
CPDF_Array* pContentArray = nullptr;
if (CPDF_Array* pArray = ToArray(pContentObj)) {
pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc, pEndStream);
} else if (CPDF_Reference* pReference = ToReference(pContentObj)) {
CPDF_Object* pDirectObj = pReference->GetDirect();
if (pDirectObj) {
if (CPDF_Array* pArray = pDirectObj->AsArray()) {
pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc, pEndStream);
} else if (pDirectObj->IsStream()) {
pContentArray = new CPDF_Array();
pContentArray->AddReference(pDoc, pStream->GetObjNum());
pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
pContentArray->AddReference(pDoc, pEndStream);
pPageDic->SetAtReference("Contents", pDoc,
pDoc->AddIndirectObject(pContentArray));
}
}
}
// Need to transform the patterns as well.
CPDF_Dictionary* pRes = pPageDic->GetDictBy("Resources");
if (pRes) {
CPDF_Dictionary* pPattenDict = pRes->GetDictBy("Pattern");
if (pPattenDict) {
for (const auto& it : *pPattenDict) {
CPDF_Object* pObj = it.second;
if (pObj->IsReference())
pObj = pObj->GetDirect();
CPDF_Dictionary* pDict = nullptr;
if (pObj->IsDictionary())
pDict = pObj->AsDictionary();
else if (CPDF_Stream* pStream = pObj->AsStream())
pDict = pStream->GetDict();
else
continue;
CFX_Matrix m = pDict->GetMatrixBy("Matrix");
CFX_Matrix t = *(CFX_Matrix*)matrix;
m.Concat(t);
pDict->SetAtMatrix("Matrix", m);
}
}
}
return TRUE;
}
示例9: CPDFPageFromFPDFPage
DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,
FPDF_CLIPPATH clipPath) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
CPDF_Object* pContentObj =
pPageDic ? pPageDic->GetElement("Contents") : nullptr;
if (!pContentObj)
pContentObj = pPageDic ? pPageDic->GetArrayBy("Contents") : nullptr;
if (!pContentObj)
return;
CFX_ByteTextBuf strClip;
CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath;
FX_DWORD i;
for (i = 0; i < pClipPath->GetPathCount(); i++) {
CPDF_Path path = pClipPath->GetPath(i);
int iClipType = pClipPath->GetClipType(i);
if (path.GetPointCount() == 0) {
// Empty clipping (totally clipped out)
strClip << "0 0 m W n ";
} else {
OutputPath(strClip, path);
if (iClipType == FXFILL_WINDING)
strClip << "W n\n";
else
strClip << "W* n\n";
}
}
CPDF_Dictionary* pDic = new CPDF_Dictionary;
CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic);
pStream->SetData(strClip.GetBuffer(), strClip.GetSize(), FALSE, FALSE);
CPDF_Document* pDoc = pPage->m_pDocument;
if (!pDoc)
return;
pDoc->AddIndirectObject(pStream);
CPDF_Array* pContentArray = nullptr;
if (CPDF_Array* pArray = ToArray(pContentObj)) {
pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
} else if (CPDF_Reference* pReference = ToReference(pContentObj)) {
CPDF_Object* pDirectObj = pReference->GetDirect();
if (pDirectObj) {
if (CPDF_Array* pArray = pDirectObj->AsArray()) {
pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
} else if (pDirectObj->IsStream()) {
pContentArray = new CPDF_Array();
pContentArray->AddReference(pDoc, pStream->GetObjNum());
pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
pPageDic->SetAtReference("Contents", pDoc,
pDoc->AddIndirectObject(pContentArray));
}
}
}
}
示例10: rect
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, FS_MATRIX* matrix, FS_RECTF* clipRect)
{
if(!page)
return FALSE;
CFX_ByteTextBuf textBuf;
textBuf<<"q ";
CFX_FloatRect rect(clipRect->left, clipRect->bottom, clipRect->right, clipRect->top);
rect.Normalize();
CFX_ByteString bsClipping;
bsClipping.Format("%f %f %f %f re W* n ", rect.left, rect.bottom, rect.Width(), rect.Height());
textBuf<<bsClipping;
CFX_ByteString bsMatix;
bsMatix.Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b,matrix->c,matrix->d,matrix->e,matrix->f);
textBuf<<bsMatix;
CPDF_Page* pPage = (CPDF_Page*)page;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
CPDF_Object* pContentObj = pPageDic->GetElement("Contents");
if(!pContentObj)
pContentObj = pPageDic->GetArray("Contents");
if(!pContentObj)
return FALSE;
CPDF_Dictionary* pDic = FX_NEW CPDF_Dictionary;
CPDF_Stream* pStream = FX_NEW CPDF_Stream(NULL,0, pDic);
pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize(), FALSE, FALSE);
CPDF_Document* pDoc = pPage->m_pDocument;
if(!pDoc)
return FALSE;
pDoc->AddIndirectObject(pStream);
pDic = FX_NEW CPDF_Dictionary;
CPDF_Stream* pEndStream = FX_NEW CPDF_Stream(NULL,0, pDic);
pEndStream->SetData((FX_LPCBYTE)" Q", 2, FALSE, FALSE);
pDoc->AddIndirectObject(pEndStream);
CPDF_Array* pContentArray = NULL;
if (pContentObj && pContentObj->GetType() == PDFOBJ_ARRAY)
{
pContentArray = (CPDF_Array*)pContentObj;
CPDF_Reference* pRef = FX_NEW CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc,pEndStream);
}
else if(pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE)
{
CPDF_Reference* pReference = (CPDF_Reference*)pContentObj;
CPDF_Object* pDirectObj = pReference->GetDirect();
if(pDirectObj != NULL)
{
if(pDirectObj->GetType() == PDFOBJ_ARRAY)
{
pContentArray = (CPDF_Array*)pDirectObj;
CPDF_Reference* pRef = FX_NEW CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc,pEndStream);
}
else if(pDirectObj->GetType() == PDFOBJ_STREAM)
{
pContentArray = FX_NEW CPDF_Array();
pContentArray->AddReference(pDoc,pStream->GetObjNum());
pContentArray->AddReference(pDoc,pDirectObj->GetObjNum());
pContentArray->AddReference(pDoc, pEndStream);
pPageDic->SetAtReference("Contents", pDoc, pDoc->AddIndirectObject(pContentArray));
}
}
}
//Need to transform the patterns as well.
CPDF_Dictionary* pRes = pPageDic->GetDict(FX_BSTRC("Resources"));
if(pRes)
{
CPDF_Dictionary* pPattenDict = pRes->GetDict(FX_BSTRC("Pattern"));
if(pPattenDict)
{
FX_POSITION pos = pPattenDict->GetStartPos();
while(pos)
{
CPDF_Dictionary* pDict = NULL;
CFX_ByteString key;
CPDF_Object* pObj = pPattenDict->GetNextElement(pos, key);
if(pObj->GetType() == PDFOBJ_REFERENCE)
pObj = pObj->GetDirect();
if(pObj->GetType() == PDFOBJ_DICTIONARY)
{
pDict = (CPDF_Dictionary*)pObj;
}
else if(pObj->GetType() == PDFOBJ_STREAM)
{
pDict = ((CPDF_Stream*)pObj)->GetDict();
}
else
continue;
CFX_AffineMatrix m = pDict->GetMatrix(FX_BSTRC("Matrix"));
//.........这里部分代码省略.........
示例11: if
DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,FPDF_CLIPPATH clipPath)
{
if(!page)
return;
CPDF_Page* pPage = (CPDF_Page*)page;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
CPDF_Object* pContentObj = pPageDic->GetElement("Contents");
if(!pContentObj)
pContentObj = pPageDic->GetArray("Contents");
if(!pContentObj)
return;
CFX_ByteTextBuf strClip;
CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath;
FX_DWORD i;
for (i = 0; i < pClipPath->GetPathCount(); i ++) {
CPDF_Path path = pClipPath->GetPath(i);
int iClipType = pClipPath->GetClipType(i);
if (path.GetPointCount() == 0) {
// Empty clipping (totally clipped out)
strClip << "0 0 m W n ";
} else {
OutputPath(strClip, path);
if (iClipType == FXFILL_WINDING)
strClip << "W n\n";
else
strClip << "W* n\n";
}
}
CPDF_Dictionary* pDic = FX_NEW CPDF_Dictionary;
CPDF_Stream* pStream = FX_NEW CPDF_Stream(NULL,0, pDic);
pStream->SetData(strClip.GetBuffer(), strClip.GetSize(), FALSE, FALSE);
CPDF_Document* pDoc = pPage->m_pDocument;
if(!pDoc)
return;
pDoc->AddIndirectObject(pStream);
CPDF_Array* pContentArray = NULL;
if (pContentObj && pContentObj->GetType() == PDFOBJ_ARRAY)
{
pContentArray = (CPDF_Array*)pContentObj;
CPDF_Reference* pRef = FX_NEW CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
}
else if(pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE)
{
CPDF_Reference* pReference = (CPDF_Reference*)pContentObj;
CPDF_Object* pDirectObj = pReference->GetDirect();
if(pDirectObj != NULL)
{
if(pDirectObj->GetType() == PDFOBJ_ARRAY)
{
pContentArray = (CPDF_Array*)pDirectObj;
CPDF_Reference* pRef = FX_NEW CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
}
else if(pDirectObj->GetType() == PDFOBJ_STREAM)
{
pContentArray = FX_NEW CPDF_Array();
pContentArray->AddReference(pDoc,pStream->GetObjNum());
pContentArray->AddReference(pDoc,pDirectObj->GetObjNum());
pPageDic->SetAtReference("Contents", pDoc, pDoc->AddIndirectObject(pContentArray));
}
}
}
}
示例12: FindPSFontGlyph
void CFX_PSRenderer::FindPSFontGlyph(CFX_FaceCache* pFaceCache, CFX_Font* pFont, const FXTEXT_CHARPOS& charpos,
int& ps_fontnum, int &ps_glyphindex)
{
for (int i = 0; i < (int)m_PSFontList.GetSize(); i ++) {
CPSFont* pPSFont = m_PSFontList[i];
for (int j = 0; j < pPSFont->m_nGlyphs; j ++)
if (pPSFont->m_Glyphs[j].m_pFont == pFont && pPSFont->m_Glyphs[j].m_GlyphIndex == charpos.m_GlyphIndex) {
if ((!pPSFont->m_Glyphs[j].m_bGlyphAdjust && !charpos.m_bGlyphAdjust) ||
(pPSFont->m_Glyphs[j].m_bGlyphAdjust && charpos.m_bGlyphAdjust &&
(FXSYS_fabs(pPSFont->m_Glyphs[j].m_AdjustMatrix[0] - charpos.m_AdjustMatrix[0]) < 0.01 &&
FXSYS_fabs(pPSFont->m_Glyphs[j].m_AdjustMatrix[1] - charpos.m_AdjustMatrix[1]) < 0.01 &&
FXSYS_fabs(pPSFont->m_Glyphs[j].m_AdjustMatrix[2] - charpos.m_AdjustMatrix[2]) < 0.01 &&
FXSYS_fabs(pPSFont->m_Glyphs[j].m_AdjustMatrix[3] - charpos.m_AdjustMatrix[3]) < 0.01))) {
ps_fontnum = i;
ps_glyphindex = j;
return;
}
}
}
if (m_PSFontList.GetSize() == 0 || m_PSFontList[m_PSFontList.GetSize() - 1]->m_nGlyphs == 256) {
CPSFont* pPSFont = new CPSFont;
pPSFont->m_nGlyphs = 0;
m_PSFontList.Add(pPSFont);
CFX_ByteTextBuf buf;
buf << FX_BSTRC("8 dict begin/FontType 3 def/FontMatrix[1 0 0 1 0 0]def\n"
"/FontBBox[0 0 0 0]def/Encoding 256 array def 0 1 255{Encoding exch/.notdef put}for\n"
"/CharProcs 1 dict def CharProcs begin/.notdef {} def end\n"
"/BuildGlyph{1 0 -10 -10 10 10 setcachedevice exch/CharProcs get exch 2 copy known not{pop/.notdef}if get exec}bind def\n"
"/BuildChar{1 index/Encoding get exch get 1 index/BuildGlyph get exec}bind def\n"
"currentdict end\n");
buf << FX_BSTRC("/X") << m_PSFontList.GetSize() - 1 << FX_BSTRC(" exch definefont pop\n");
m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
buf.Clear();
}
ps_fontnum = m_PSFontList.GetSize() - 1;
CPSFont* pPSFont = m_PSFontList[ps_fontnum];
ps_glyphindex = pPSFont->m_nGlyphs;
pPSFont->m_Glyphs[ps_glyphindex].m_GlyphIndex = charpos.m_GlyphIndex;
pPSFont->m_Glyphs[ps_glyphindex].m_pFont = pFont;
pPSFont->m_Glyphs[ps_glyphindex].m_bGlyphAdjust = charpos.m_bGlyphAdjust;
if (charpos.m_bGlyphAdjust) {
pPSFont->m_Glyphs[ps_glyphindex].m_AdjustMatrix[0] = charpos.m_AdjustMatrix[0];
pPSFont->m_Glyphs[ps_glyphindex].m_AdjustMatrix[1] = charpos.m_AdjustMatrix[1];
pPSFont->m_Glyphs[ps_glyphindex].m_AdjustMatrix[2] = charpos.m_AdjustMatrix[2];
pPSFont->m_Glyphs[ps_glyphindex].m_AdjustMatrix[3] = charpos.m_AdjustMatrix[3];
}
pPSFont->m_nGlyphs ++;
CFX_AffineMatrix matrix;
if (charpos.m_bGlyphAdjust)
matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1],
charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0);
matrix.Concat(1.0f, 0, 0, 1.0f, 0, 0);
const CFX_PathData* pPathData = pFaceCache->LoadGlyphPath(pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth);
if (pPathData == NULL) {
return;
}
CFX_PathData TransformedPath(*pPathData);
if (charpos.m_bGlyphAdjust) {
TransformedPath.Transform(&matrix);
}
CFX_ByteTextBuf buf;
buf << FX_BSTRC("/X") << ps_fontnum << FX_BSTRC(" Ff/CharProcs get begin/")
<< ps_glyphindex << FX_BSTRC("{");
buf << FX_BSTRC("n ");
for (int p = 0; p < TransformedPath.GetPointCount(); p ++) {
FX_FLOAT x = TransformedPath.GetPointX(p), y = TransformedPath.GetPointY(p);
switch (TransformedPath.GetFlag(p) & FXPT_TYPE) {
case FXPT_MOVETO: {
buf << x << FX_BSTRC(" ") << y << FX_BSTRC(" m\n");
break;
}
case FXPT_LINETO: {
buf << x << FX_BSTRC(" ") << y << FX_BSTRC(" l\n");
break;
}
case FXPT_BEZIERTO: {
buf << x << FX_BSTRC(" ") << y << FX_BSTRC(" ")
<< TransformedPath.GetPointX(p + 1) << FX_BSTRC(" ")
<< TransformedPath.GetPointY(p + 1) << FX_BSTRC(" ")
<< TransformedPath.GetPointX(p + 2) << FX_BSTRC(" ")
<< TransformedPath.GetPointY(p + 2) << FX_BSTRC(" c\n");
p += 2;
break;
}
}
}
buf << FX_BSTRC("f");
buf << FX_BSTRC("}bind def end\n");
buf << FX_BSTRC("/X") << ps_fontnum << FX_BSTRC(" Ff/Encoding get ") << ps_glyphindex
<< FX_BSTRC("/") << ps_glyphindex << FX_BSTRC(" put\n");
m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
}
示例13: DrawDIBits
FX_BOOL CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource, FX_DWORD color,
const CFX_AffineMatrix* pMatrix, FX_DWORD flags,
int alpha_flag, void* pIccTransform)
{
StartRendering();
if ((pMatrix->a == 0 && pMatrix->b == 0) || (pMatrix->c == 0 && pMatrix->d == 0)) {
return TRUE;
}
if (pSource->HasAlpha()) {
return FALSE;
}
int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(color) : FXARGB_A(color);
if (pSource->IsAlphaMask() && (alpha < 255 || pSource->GetBPP() != 1)) {
return FALSE;
}
OUTPUT_PS("q\n");
CFX_ByteTextBuf buf;
buf << FX_BSTRC("[") << pMatrix->a << FX_BSTRC(" ") << pMatrix->b << FX_BSTRC(" ") <<
pMatrix->c << FX_BSTRC(" ") << pMatrix->d << FX_BSTRC(" ") << pMatrix->e <<
FX_BSTRC(" ") << pMatrix->f << FX_BSTRC("]cm ");
int width = pSource->GetWidth();
int height = pSource->GetHeight();
buf << width << FX_BSTRC(" ") << height;
if (pSource->GetBPP() == 1 && pSource->GetPalette() == NULL) {
int pitch = (width + 7) / 8;
FX_DWORD src_size = height * pitch;
FX_LPBYTE src_buf = FX_Alloc(FX_BYTE, src_size);
if (!src_buf) {
return FALSE;
}
for (int row = 0; row < height; row ++) {
FX_LPCBYTE src_scan = pSource->GetScanline(row);
FXSYS_memcpy32(src_buf + row * pitch, src_scan, pitch);
}
FX_LPBYTE output_buf;
FX_DWORD output_size;
FaxCompressData(src_buf, width, height, output_buf, output_size);
if (pSource->IsAlphaMask()) {
SetColor(color, alpha_flag, pIccTransform);
m_bColorSet = FALSE;
buf << FX_BSTRC(" true[");
} else {
buf << FX_BSTRC(" 1[");
}
buf << width << FX_BSTRC(" 0 0 -") << height << FX_BSTRC(" 0 ") << height <<
FX_BSTRC("]currentfile/ASCII85Decode filter ");
if (output_buf != src_buf)
buf << FX_BSTRC("<</K -1/EndOfBlock false/Columns ") << width << FX_BSTRC("/Rows ") << height <<
FX_BSTRC(">>/CCITTFaxDecode filter ");
if (pSource->IsAlphaMask()) {
buf << FX_BSTRC("iM\n");
} else {
buf << FX_BSTRC("false 1 colorimage\n");
}
m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize());
WritePSBinary(output_buf, output_size);
FX_Free(output_buf);
} else {
CFX_DIBSource* pConverted = (CFX_DIBSource*)pSource;
if (pIccTransform) {
FXDIB_Format format = m_bCmykOutput ? FXDIB_Cmyk : FXDIB_Rgb;
pConverted = pSource->CloneConvert(format, NULL, pIccTransform);
} else {
switch (pSource->GetFormat()) {
case FXDIB_1bppRgb:
case FXDIB_Rgb32:
pConverted = pSource->CloneConvert(FXDIB_Rgb);
break;
case FXDIB_8bppRgb:
if (pSource->GetPalette() != NULL) {
pConverted = pSource->CloneConvert(FXDIB_Rgb);
}
break;
case FXDIB_1bppCmyk:
pConverted = pSource->CloneConvert(FXDIB_Cmyk);
break;
case FXDIB_8bppCmyk:
if (pSource->GetPalette() != NULL) {
pConverted = pSource->CloneConvert(FXDIB_Cmyk);
}
break;
default:
break;
}
}
if (pConverted == NULL) {
OUTPUT_PS("\nQ\n");
return FALSE;
}
int Bpp = pConverted->GetBPP() / 8;
FX_LPBYTE output_buf = NULL;
FX_STRSIZE output_size = 0;
FX_LPCSTR filter = NULL;
if (flags & FXRENDER_IMAGE_LOSSY) {
CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule();
if (pEncoders && pEncoders->GetJpegModule()->Encode(pConverted, output_buf, output_size)) {
filter = "/DCTDecode filter ";
}
}
if (filter == NULL) {
//.........这里部分代码省略.........
示例14: CPDFPageFromFPDFPage
DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,
FPDF_CLIPPATH clipPath) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
CPDF_Object* pContentObj =
pPageDic ? pPageDic->GetObjectFor("Contents") : nullptr;
if (!pContentObj)
pContentObj = pPageDic ? pPageDic->GetArrayFor("Contents") : nullptr;
if (!pContentObj)
return;
CFX_ByteTextBuf strClip;
CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath;
uint32_t i;
for (i = 0; i < pClipPath->GetPathCount(); i++) {
CPDF_Path path = pClipPath->GetPath(i);
int iClipType = pClipPath->GetClipType(i);
if (path.GetPoints().empty()) {
// Empty clipping (totally clipped out)
strClip << "0 0 m W n ";
} else {
OutputPath(strClip, path);
if (iClipType == FXFILL_WINDING)
strClip << "W n\n";
else
strClip << "W* n\n";
}
}
CPDF_Document* pDoc = pPage->m_pDocument;
if (!pDoc)
return;
CPDF_Stream* pStream = pDoc->NewIndirect<CPDF_Stream>(
nullptr, 0,
pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()));
pStream->SetData(strClip.GetBuffer(), strClip.GetSize());
CPDF_Array* pArray = ToArray(pContentObj);
if (pArray) {
pArray->InsertNewAt<CPDF_Reference>(0, pDoc, pStream->GetObjNum());
return;
}
CPDF_Reference* pReference = ToReference(pContentObj);
if (!pReference)
return;
CPDF_Object* pDirectObj = pReference->GetDirect();
if (!pDirectObj)
return;
CPDF_Array* pObjArray = pDirectObj->AsArray();
if (pObjArray) {
pObjArray->InsertNewAt<CPDF_Reference>(0, pDoc, pStream->GetObjNum());
return;
}
if (pDirectObj->IsStream()) {
CPDF_Array* pContentArray = pDoc->NewIndirect<CPDF_Array>();
pContentArray->AddNew<CPDF_Reference>(pDoc, pStream->GetObjNum());
pContentArray->AddNew<CPDF_Reference>(pDoc, pDirectObj->GetObjNum());
pPageDic->SetNewFor<CPDF_Reference>("Contents", pDoc,
pContentArray->GetObjNum());
}
}