本文整理汇总了C++中CPDF_Document::LoadColorSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Document::LoadColorSpace方法的具体用法?C++ CPDF_Document::LoadColorSpace怎么用?C++ CPDF_Document::LoadColorSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Document
的用法示例。
在下文中一共展示了CPDF_Document::LoadColorSpace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessTransparency
FX_BOOL CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
const CFX_Matrix* pObj2Device) {
#if defined _SKIA_SUPPORT_
DebugVerifyDeviceIsPreMultiplied();
#endif
int blend_type = pPageObj->m_GeneralState.GetBlendType();
if (blend_type == FXDIB_BLEND_UNSUPPORTED)
return TRUE;
CPDF_Dictionary* pSMaskDict =
ToDictionary(pPageObj->m_GeneralState.GetSoftMask());
if (pSMaskDict) {
if (pPageObj->IsImage() &&
pPageObj->AsImage()->GetImage()->GetDict()->KeyExist("SMask")) {
pSMaskDict = nullptr;
}
}
CPDF_Dictionary* pFormResource = nullptr;
FX_FLOAT group_alpha = 1.0f;
int Transparency = m_Transparency;
FX_BOOL bGroupTransparent = FALSE;
if (pPageObj->IsForm()) {
const CPDF_FormObject* pFormObj = pPageObj->AsForm();
group_alpha = pFormObj->m_GeneralState.GetFillAlpha();
Transparency = pFormObj->m_pForm->m_Transparency;
bGroupTransparent = !!(Transparency & PDFTRANS_ISOLATED);
if (pFormObj->m_pForm->m_pFormDict) {
pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources");
}
}
bool bTextClip =
(pPageObj->m_ClipPath && pPageObj->m_ClipPath.GetTextCount() &&
m_pDevice->GetDeviceClass() == FXDC_DISPLAY &&
!(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP));
if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->IsImage() &&
pPageObj->m_GeneralState.GetFillOP() &&
pPageObj->m_GeneralState.GetStrokeOP()) {
CPDF_Document* pDocument = nullptr;
CPDF_Page* pPage = nullptr;
if (m_pContext->GetPageCache()) {
pPage = m_pContext->GetPageCache()->GetPage();
pDocument = pPage->m_pDocument;
} else {
pDocument = pPageObj->AsImage()->GetImage()->GetDocument();
}
CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr;
CPDF_Object* pCSObj = pPageObj->AsImage()
->GetImage()
->GetStream()
->GetDict()
->GetDirectObjectBy("ColorSpace");
CPDF_ColorSpace* pColorSpace =
pDocument->LoadColorSpace(pCSObj, pPageResources);
if (pColorSpace) {
int format = pColorSpace->GetFamily();
if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION ||
format == PDFCS_DEVICEN) {
blend_type = FXDIB_BLEND_DARKEN;
}
pDocument->GetPageData()->ReleaseColorSpace(pCSObj);
}
}
if (!pSMaskDict && group_alpha == 1.0f && blend_type == FXDIB_BLEND_NORMAL &&
!bTextClip && !bGroupTransparent) {
return FALSE;
}
bool isolated = !!(Transparency & PDFTRANS_ISOLATED);
if (m_bPrint) {
FX_BOOL bRet = FALSE;
int rendCaps = m_pDevice->GetRenderCaps();
if (!((Transparency & PDFTRANS_ISOLATED) || pSMaskDict || bTextClip) &&
(rendCaps & FXRC_BLEND_MODE)) {
int oldBlend = m_curBlend;
m_curBlend = blend_type;
bRet = DrawObjWithBlend(pPageObj, pObj2Device);
m_curBlend = oldBlend;
}
if (!bRet) {
DrawObjWithBackground(pPageObj, pObj2Device);
}
return TRUE;
}
FX_RECT rect = pPageObj->GetBBox(pObj2Device);
rect.Intersect(m_pDevice->GetClipBox());
if (rect.IsEmpty()) {
return TRUE;
}
CFX_Matrix deviceCTM = m_pDevice->GetCTM();
FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a);
FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d);
int width = FXSYS_round((FX_FLOAT)rect.Width() * scaleX);
int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY);
CFX_FxgeDevice bitmap_device;
std::unique_ptr<CFX_DIBitmap> oriDevice;
if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) {
oriDevice.reset(new CFX_DIBitmap);
if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height))
return TRUE;
m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top);
}
//.........这里部分代码省略.........
示例2: ProcessTransparency
FX_BOOL CPDF_RenderStatus::ProcessTransparency(
const CPDF_PageObject* pPageObj,
const CFX_AffineMatrix* pObj2Device) {
const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState;
int blend_type =
pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NORMAL;
if (blend_type == FXDIB_BLEND_UNSUPPORTED) {
return TRUE;
}
CPDF_Dictionary* pSMaskDict =
pGeneralState ? ToDictionary(pGeneralState->m_pSoftMask) : NULL;
if (pSMaskDict) {
if (pPageObj->m_Type == PDFPAGE_IMAGE &&
((CPDF_ImageObject*)pPageObj)
->m_pImage->GetDict()
->KeyExist(FX_BSTRC("SMask"))) {
pSMaskDict = NULL;
}
}
CPDF_Dictionary* pFormResource = NULL;
FX_FLOAT group_alpha = 1.0f;
int Transparency = m_Transparency;
FX_BOOL bGroupTransparent = FALSE;
if (pPageObj->m_Type == PDFPAGE_FORM) {
CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj;
const CPDF_GeneralStateData* pStateData =
pFormObj->m_GeneralState.GetObject();
if (pStateData) {
group_alpha = pStateData->m_FillAlpha;
}
Transparency = pFormObj->m_pForm->m_Transparency;
bGroupTransparent = !!(Transparency & PDFTRANS_ISOLATED);
if (pFormObj->m_pForm->m_pFormDict) {
pFormResource = pFormObj->m_pForm->m_pFormDict->GetDict("Resources");
}
}
FX_BOOL bTextClip = FALSE;
if (pPageObj->m_ClipPath.NotNull() && pPageObj->m_ClipPath.GetTextCount() &&
m_pDevice->GetDeviceClass() == FXDC_DISPLAY &&
!(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)) {
bTextClip = TRUE;
}
if ((m_Options.m_Flags & RENDER_OVERPRINT) &&
pPageObj->m_Type == PDFPAGE_IMAGE && pGeneralState &&
pGeneralState->m_FillOP && pGeneralState->m_StrokeOP) {
CPDF_Document* pDocument = NULL;
CPDF_Page* pPage = NULL;
if (m_pContext->m_pPageCache) {
pPage = m_pContext->m_pPageCache->GetPage();
pDocument = pPage->m_pDocument;
} else {
pDocument = ((CPDF_ImageObject*)pPageObj)->m_pImage->GetDocument();
}
CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL;
CPDF_Object* pCSObj = ((CPDF_ImageObject*)pPageObj)
->m_pImage->GetStream()
->GetDict()
->GetElementValue(FX_BSTRC("ColorSpace"));
CPDF_ColorSpace* pColorSpace =
pDocument->LoadColorSpace(pCSObj, pPageResources);
if (pColorSpace) {
int format = pColorSpace->GetFamily();
if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION ||
format == PDFCS_DEVICEN) {
blend_type = FXDIB_BLEND_DARKEN;
}
pDocument->GetPageData()->ReleaseColorSpace(pCSObj);
}
}
if (pSMaskDict == NULL && group_alpha == 1.0f &&
blend_type == FXDIB_BLEND_NORMAL && !bTextClip && !bGroupTransparent) {
return FALSE;
}
FX_BOOL isolated = Transparency & PDFTRANS_ISOLATED;
if (m_bPrint) {
FX_BOOL bRet = FALSE;
int rendCaps = m_pDevice->GetRenderCaps();
if (!((Transparency & PDFTRANS_ISOLATED) || pSMaskDict || bTextClip) &&
(rendCaps & FXRC_BLEND_MODE)) {
int oldBlend = m_curBlend;
m_curBlend = blend_type;
bRet = DrawObjWithBlend(pPageObj, pObj2Device);
m_curBlend = oldBlend;
}
if (!bRet) {
DrawObjWithBackground(pPageObj, pObj2Device);
}
return TRUE;
}
FX_RECT rect = pPageObj->GetBBox(pObj2Device);
rect.Intersect(m_pDevice->GetClipBox());
if (rect.IsEmpty()) {
return TRUE;
}
CFX_Matrix deviceCTM = m_pDevice->GetCTM();
FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a);
FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d);
int width = FXSYS_round((FX_FLOAT)rect.Width() * scaleX);
int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY);
CFX_FxgeDevice bitmap_device;
//.........这里部分代码省略.........
示例3: StartRenderDIBSource
//.........这里部分代码省略.........
if (m_pImageObject->m_GeneralState.GetTR()) {
if (!m_pImageObject->m_GeneralState.GetTransferFunc()) {
m_pImageObject->m_GeneralState.SetTransferFunc(
m_pRenderStatus->GetTransferFunc(
m_pImageObject->m_GeneralState.GetTR()));
}
if (m_pImageObject->m_GeneralState.GetTransferFunc() &&
!m_pImageObject->m_GeneralState.GetTransferFunc()->m_bIdentity) {
m_pDIBSource = m_Loader.m_pBitmap =
m_pImageObject->m_GeneralState.GetTransferFunc()->TranslateImage(
m_Loader.m_pBitmap, !m_Loader.m_bCached);
if (m_Loader.m_bCached && m_Loader.m_pMask)
m_Loader.m_pMask = m_Loader.m_pMask->Clone().release();
m_Loader.m_bCached = false;
}
}
m_FillArgb = 0;
m_bPatternColor = false;
m_pPattern = nullptr;
if (m_pDIBSource->IsAlphaMask()) {
const CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor();
if (pColor && pColor->IsPattern()) {
m_pPattern = pColor->GetPattern();
if (m_pPattern)
m_bPatternColor = true;
}
m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject);
} else if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_GRAY) {
m_pClone = m_pDIBSource->Clone();
m_pClone->ConvertColorScale(m_pRenderStatus->m_Options.m_BackColor,
m_pRenderStatus->m_Options.m_ForeColor);
m_pDIBSource = m_pClone.get();
}
m_Flags = 0;
if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE)
m_Flags |= RENDER_FORCE_DOWNSAMPLE;
else if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE)
m_Flags |= RENDER_FORCE_HALFTONE;
if (m_pRenderStatus->m_pDevice->GetDeviceClass() != FXDC_DISPLAY) {
CPDF_Object* pFilters =
m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectFor(
"Filter");
if (pFilters) {
if (pFilters->IsName()) {
CFX_ByteString bsDecodeType = pFilters->GetString();
if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode")
m_Flags |= FXRENDER_IMAGE_LOSSY;
} else if (CPDF_Array* pArray = pFilters->AsArray()) {
for (size_t i = 0; i < pArray->GetCount(); i++) {
CFX_ByteString bsDecodeType = pArray->GetStringAt(i);
if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") {
m_Flags |= FXRENDER_IMAGE_LOSSY;
break;
}
}
}
}
}
if (m_pRenderStatus->m_Options.m_Flags & RENDER_NOIMAGESMOOTH)
m_Flags |= FXDIB_NOSMOOTH;
else if (m_pImageObject->GetImage()->IsInterpol())
m_Flags |= FXDIB_INTERPOL;
if (m_Loader.m_pMask)
return DrawMaskedImage();
if (m_bPatternColor)
return DrawPatternImage(m_pObj2Device);
if (m_BitmapAlpha != 255 || !m_pImageObject->m_GeneralState ||
!m_pImageObject->m_GeneralState.GetFillOP() ||
m_pImageObject->m_GeneralState.GetOPMode() != 0 ||
m_pImageObject->m_GeneralState.GetBlendType() != FXDIB_BLEND_NORMAL ||
m_pImageObject->m_GeneralState.GetStrokeAlpha() != 1.0f ||
m_pImageObject->m_GeneralState.GetFillAlpha() != 1.0f) {
return StartDIBSource();
}
CPDF_Document* pDocument = nullptr;
CPDF_Page* pPage = nullptr;
if (m_pRenderStatus->m_pContext->GetPageCache()) {
pPage = m_pRenderStatus->m_pContext->GetPageCache()->GetPage();
pDocument = pPage->m_pDocument;
} else {
pDocument = m_pImageObject->GetImage()->GetDocument();
}
CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr;
CPDF_Object* pCSObj =
m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectFor(
"ColorSpace");
CPDF_ColorSpace* pColorSpace =
pDocument->LoadColorSpace(pCSObj, pPageResources);
if (!pColorSpace)
return StartDIBSource();
int format = pColorSpace->GetFamily();
if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION ||
format == PDFCS_DEVICEN) {
m_BlendType = FXDIB_BLEND_DARKEN;
}
pDocument->GetPageData()->ReleaseColorSpace(pCSObj);
return StartDIBSource();
}
示例4: StartRenderDIBSource
//.........这里部分代码省略.........
m_pRenderStatus->GetTransferFunc(pGeneralState->m_pTR);
}
if (pGeneralState->m_pTransferFunc &&
!pGeneralState->m_pTransferFunc->m_bIdentity) {
m_pDIBSource = m_Loader.m_pBitmap =
pGeneralState->m_pTransferFunc->TranslateImage(m_Loader.m_pBitmap,
!m_Loader.m_bCached);
if (m_Loader.m_bCached && m_Loader.m_pMask) {
m_Loader.m_pMask = m_Loader.m_pMask->Clone();
}
m_Loader.m_bCached = FALSE;
}
}
m_FillArgb = 0;
m_bPatternColor = FALSE;
m_pPattern = NULL;
if (m_pDIBSource->IsAlphaMask()) {
CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor();
if (pColor && pColor->IsPattern()) {
m_pPattern = pColor->GetPattern();
if (m_pPattern != NULL) {
m_bPatternColor = TRUE;
}
}
m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject);
} else if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_GRAY) {
m_pClone = m_pDIBSource->Clone();
m_pClone->ConvertColorScale(m_pRenderStatus->m_Options.m_BackColor,
m_pRenderStatus->m_Options.m_ForeColor);
m_pDIBSource = m_pClone;
}
m_Flags = 0;
if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) {
m_Flags |= RENDER_FORCE_DOWNSAMPLE;
} else if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE) {
m_Flags |= RENDER_FORCE_HALFTONE;
}
if (m_pRenderStatus->m_pDevice->GetDeviceClass() != FXDC_DISPLAY) {
CPDF_Object* pFilters =
m_pImageObject->m_pImage->GetStream()->GetDict()->GetElementValue(
FX_BSTRC("Filter"));
if (pFilters) {
if (pFilters->IsName()) {
CFX_ByteStringC bsDecodeType = pFilters->GetConstString();
if (bsDecodeType == FX_BSTRC("DCTDecode") ||
bsDecodeType == FX_BSTRC("JPXDecode")) {
m_Flags |= FXRENDER_IMAGE_LOSSY;
}
} else if (CPDF_Array* pArray = pFilters->AsArray()) {
for (FX_DWORD i = 0; i < pArray->GetCount(); i++) {
CFX_ByteStringC bsDecodeType = pArray->GetConstString(i);
if (bsDecodeType == FX_BSTRC("DCTDecode") ||
bsDecodeType == FX_BSTRC("JPXDecode")) {
m_Flags |= FXRENDER_IMAGE_LOSSY;
break;
}
}
}
}
}
if (m_pRenderStatus->m_Options.m_Flags & RENDER_NOIMAGESMOOTH) {
m_Flags |= FXDIB_NOSMOOTH;
} else if (m_pImageObject->m_pImage->IsInterpol()) {
m_Flags |= FXDIB_INTERPOL;
}
if (m_Loader.m_pMask) {
return DrawMaskedImage();
}
if (m_bPatternColor) {
return DrawPatternImage(m_pObj2Device);
}
if (m_BitmapAlpha == 255 && pGeneralState && pGeneralState->m_FillOP &&
pGeneralState->m_OPMode == 0 &&
pGeneralState->m_BlendType == FXDIB_BLEND_NORMAL &&
pGeneralState->m_StrokeAlpha == 1 && pGeneralState->m_FillAlpha == 1) {
CPDF_Document* pDocument = NULL;
CPDF_Page* pPage = NULL;
if (m_pRenderStatus->m_pContext->m_pPageCache) {
pPage = m_pRenderStatus->m_pContext->m_pPageCache->GetPage();
pDocument = pPage->m_pDocument;
} else {
pDocument = m_pImageObject->m_pImage->GetDocument();
}
CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL;
CPDF_Object* pCSObj =
m_pImageObject->m_pImage->GetStream()->GetDict()->GetElementValue(
FX_BSTRC("ColorSpace"));
CPDF_ColorSpace* pColorSpace =
pDocument->LoadColorSpace(pCSObj, pPageResources);
if (pColorSpace) {
int format = pColorSpace->GetFamily();
if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION ||
format == PDFCS_DEVICEN) {
m_BlendType = FXDIB_BLEND_DARKEN;
}
pDocument->GetPageData()->ReleaseColorSpace(pCSObj);
}
}
return StartDIBSource();
}