本文整理汇总了C++中FX_RECT::Intersect方法的典型用法代码示例。如果您正苦于以下问题:C++ FX_RECT::Intersect方法的具体用法?C++ FX_RECT::Intersect怎么用?C++ FX_RECT::Intersect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FX_RECT
的用法示例。
在下文中一共展示了FX_RECT::Intersect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessShading
FX_BOOL CPDF_RenderStatus::ProcessShading(CPDF_ShadingObject* pShadingObj,
const CFX_Matrix* pObj2Device) {
FX_RECT rect = pShadingObj->GetBBox(pObj2Device);
FX_RECT clip_box = m_pDevice->GetClipBox();
rect.Intersect(clip_box);
if (rect.IsEmpty()) {
return TRUE;
}
CFX_Matrix matrix = pShadingObj->m_Matrix;
matrix.Concat(*pObj2Device);
DrawShading(pShadingObj->m_pShading, &matrix, rect,
pShadingObj->m_GeneralState.GetAlpha(FALSE),
m_Options.m_ColorMode == RENDER_COLOR_ALPHA);
return TRUE;
}
示例2: GetBackdrop
CFX_DIBitmap* CPDF_RenderStatus::GetBackdrop(const CPDF_PageObject* pObj,
const FX_RECT& rect,
int& left,
int& top,
FX_BOOL bBackAlphaRequired) {
FX_RECT bbox = rect;
bbox.Intersect(m_pDevice->GetClipBox());
left = bbox.left;
top = bbox.top;
CFX_Matrix deviceCTM = m_pDevice->GetCTM();
FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a);
FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d);
int width = FXSYS_round(bbox.Width() * scaleX);
int height = FXSYS_round(bbox.Height() * scaleY);
std::unique_ptr<CFX_DIBitmap> pBackdrop(new CFX_DIBitmap);
if (bBackAlphaRequired && !m_bDropObjects)
pBackdrop->Create(width, height, FXDIB_Argb);
else
m_pDevice->CreateCompatibleBitmap(pBackdrop.get(), width, height);
if (!pBackdrop->GetBuffer())
return nullptr;
FX_BOOL bNeedDraw;
if (pBackdrop->HasAlpha())
bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT);
else
bNeedDraw = !(m_pDevice->GetRenderCaps() & FXRC_GET_BITS);
if (!bNeedDraw) {
m_pDevice->GetDIBits(pBackdrop.get(), left, top);
return pBackdrop.release();
}
CFX_Matrix FinalMatrix = m_DeviceMatrix;
FinalMatrix.TranslateI(-left, -top);
FinalMatrix.Scale(scaleX, scaleY);
pBackdrop->Clear(pBackdrop->HasAlpha() ? 0 : 0xffffffff);
CFX_FxgeDevice device;
device.Attach(pBackdrop.get(), false, nullptr, false);
m_pContext->Render(&device, pObj, &m_Options, &FinalMatrix);
return pBackdrop.release();
}
示例3: GetObjectClippedRect
FX_BOOL CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj,
const CFX_Matrix* pObj2Device,
FX_BOOL bLogical,
FX_RECT& rect) const {
rect = pObj->GetBBox(pObj2Device);
FX_RECT rtClip = m_pDevice->GetClipBox();
if (!bLogical) {
CFX_Matrix dCTM = m_pDevice->GetCTM();
FX_FLOAT a = FXSYS_fabs(dCTM.a);
FX_FLOAT d = FXSYS_fabs(dCTM.d);
if (a != 1.0f || d != 1.0f) {
rect.right = rect.left + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Width() * a);
rect.bottom = rect.top + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Height() * d);
rtClip.right =
rtClip.left + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Width() * a);
rtClip.bottom =
rtClip.top + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Height() * d);
}
}
rect.Intersect(rtClip);
return rect.IsEmpty();
}
示例4: 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);
}
//.........这里部分代码省略.........
示例5: GetDrawRect
FX_RECT CPDF_ImageRenderer::GetDrawRect() const {
FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOuterRect();
rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox());
return rect;
}
示例6: DrawShading
void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern,
CFX_Matrix* pMatrix,
FX_RECT& clip_rect,
int alpha,
FX_BOOL bAlphaMode) {
CPDF_Function** pFuncs = pPattern->m_pFunctions;
int nFuncs = pPattern->m_nFuncs;
CPDF_Dictionary* pDict = pPattern->m_pShadingObj->GetDict();
CPDF_ColorSpace* pColorSpace = pPattern->m_pCS;
if (!pColorSpace) {
return;
}
FX_ARGB background = 0;
if (!pPattern->m_bShadingObj &&
pPattern->m_pShadingObj->GetDict()->KeyExist("Background")) {
CPDF_Array* pBackColor =
pPattern->m_pShadingObj->GetDict()->GetArray("Background");
if (pBackColor &&
pBackColor->GetCount() >= (FX_DWORD)pColorSpace->CountComponents()) {
CFX_FixedBufGrow<FX_FLOAT, 16> comps(pColorSpace->CountComponents());
for (int i = 0; i < pColorSpace->CountComponents(); i++) {
comps[i] = pBackColor->GetNumber(i);
}
FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f;
pColorSpace->GetRGB(comps, R, G, B);
background = ArgbEncode(255, (int32_t)(R * 255), (int32_t)(G * 255),
(int32_t)(B * 255));
}
}
if (pDict->KeyExist("BBox")) {
CFX_FloatRect rect = pDict->GetRect("BBox");
rect.Transform(pMatrix);
clip_rect.Intersect(rect.GetOutterRect());
}
CPDF_DeviceBuffer buffer;
buffer.Initialize(m_pContext, m_pDevice, &clip_rect, m_pCurObj, 150);
CFX_Matrix FinalMatrix = *pMatrix;
FinalMatrix.Concat(*buffer.GetMatrix());
CFX_DIBitmap* pBitmap = buffer.GetBitmap();
if (!pBitmap->GetBuffer()) {
return;
}
pBitmap->Clear(background);
int fill_mode = m_Options.m_Flags;
switch (pPattern->m_ShadingType) {
case kInvalidShading:
case kMaxShading:
return;
case kFunctionBasedShading:
DrawFuncShading(pBitmap, &FinalMatrix, pDict, pFuncs, nFuncs, pColorSpace,
alpha);
break;
case kAxialShading:
DrawAxialShading(pBitmap, &FinalMatrix, pDict, pFuncs, nFuncs,
pColorSpace, alpha);
break;
case kRadialShading:
DrawRadialShading(pBitmap, &FinalMatrix, pDict, pFuncs, nFuncs,
pColorSpace, alpha);
break;
case kFreeFormGouraudTriangleMeshShading: {
DrawFreeGouraudShading(pBitmap, &FinalMatrix,
ToStream(pPattern->m_pShadingObj), pFuncs, nFuncs,
pColorSpace, alpha);
} break;
case kLatticeFormGouraudTriangleMeshShading: {
DrawLatticeGouraudShading(pBitmap, &FinalMatrix,
ToStream(pPattern->m_pShadingObj), pFuncs,
nFuncs, pColorSpace, alpha);
} break;
case kCoonsPatchMeshShading:
case kTensorProductPatchMeshShading: {
DrawCoonPatchMeshes(
pPattern->m_ShadingType == kTensorProductPatchMeshShading, pBitmap,
&FinalMatrix, ToStream(pPattern->m_pShadingObj), pFuncs, nFuncs,
pColorSpace, fill_mode, alpha);
} break;
}
if (bAlphaMode) {
pBitmap->LoadChannel(FXDIB_Red, pBitmap, FXDIB_Alpha);
}
if (m_Options.m_ColorMode == RENDER_COLOR_GRAY) {
pBitmap->ConvertColorScale(m_Options.m_ForeColor, m_Options.m_BackColor);
}
buffer.OutputToDevice();
}
示例7: if
FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device)
{
if (m_pRenderStatus->m_bPrint && !(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) {
m_Result = FALSE;
return FALSE;
}
FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOutterRect();
rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox());
if (rect.IsEmpty()) {
return FALSE;
}
CFX_AffineMatrix new_matrix = m_ImageMatrix;
new_matrix.TranslateI(-rect.left, -rect.top);
int width = rect.Width();
int height = rect.Height();
CFX_FxgeDevice bitmap_device1;
if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32)) {
return TRUE;
}
bitmap_device1.GetBitmap()->Clear(0xffffff);
{
CPDF_RenderStatus bitmap_render;
bitmap_render.Initialize(m_pRenderStatus->m_Level + 1, m_pRenderStatus->m_pContext, &bitmap_device1, NULL, NULL,
NULL, NULL, &m_pRenderStatus->m_Options, 0, m_pRenderStatus->m_bDropObjects, NULL, TRUE);
CFX_Matrix patternDevice = *pObj2Device;
patternDevice.Translate((FX_FLOAT) - rect.left, (FX_FLOAT) - rect.top);
if(m_pPattern->m_PatternType == PATTERN_TILING) {
bitmap_render.DrawTilingPattern((CPDF_TilingPattern*)m_pPattern, m_pImageObject, &patternDevice, FALSE);
} else {
bitmap_render.DrawShadingPattern((CPDF_ShadingPattern*)m_pPattern, m_pImageObject, &patternDevice, FALSE);
}
}
{
CFX_FxgeDevice bitmap_device2;
if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb)) {
return TRUE;
}
bitmap_device2.GetBitmap()->Clear(0);
CPDF_RenderStatus bitmap_render;
bitmap_render.Initialize(m_pRenderStatus->m_Level + 1, m_pRenderStatus->m_pContext, &bitmap_device2, NULL, NULL,
NULL, NULL, NULL, 0, m_pRenderStatus->m_bDropObjects, NULL, TRUE);
CPDF_ImageRenderer image_render;
if (image_render.Start(&bitmap_render, m_pDIBSource, 0xffffffff, 255, &new_matrix, m_Flags, TRUE)) {
image_render.Continue(NULL);
}
if (m_Loader.m_MatteColor != 0xffffffff) {
int matte_r = FXARGB_R(m_Loader.m_MatteColor);
int matte_g = FXARGB_G(m_Loader.m_MatteColor);
int matte_b = FXARGB_B(m_Loader.m_MatteColor);
for (int row = 0; row < height; row ++) {
FX_LPBYTE dest_scan = (FX_LPBYTE)bitmap_device1.GetBitmap()->GetScanline(row);
FX_LPCBYTE mask_scan = bitmap_device2.GetBitmap()->GetScanline(row);
for (int col = 0; col < width; col ++) {
int alpha = *mask_scan ++;
if (alpha) {
int orig = (*dest_scan - matte_b) * 255 / alpha + matte_b;
if (orig < 0) {
orig = 0;
} else if (orig > 255) {
orig = 255;
}
*dest_scan++ = orig;
orig = (*dest_scan - matte_g) * 255 / alpha + matte_g;
if (orig < 0) {
orig = 0;
} else if (orig > 255) {
orig = 255;
}
*dest_scan++ = orig;
orig = (*dest_scan - matte_r) * 255 / alpha + matte_r;
if (orig < 0) {
orig = 0;
} else if (orig > 255) {
orig = 255;
}
*dest_scan++ = orig;
dest_scan ++;
} else {
dest_scan += 4;
}
}
}
}
bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask);
bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap());
bitmap_device1.GetBitmap()->MultiplyAlpha(255);
}
m_pRenderStatus->m_pDevice->SetDIBits(bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType);
return FALSE;
}
示例8: DrawPatternImage
bool CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) {
if (m_pRenderStatus->m_bPrint &&
!(m_pRenderStatus->m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) {
m_Result = false;
return false;
}
FX_RECT rect = m_ImageMatrix.GetUnitRect().GetOuterRect();
rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox());
if (rect.IsEmpty()) {
return false;
}
CFX_Matrix new_matrix = m_ImageMatrix;
new_matrix.TranslateI(-rect.left, -rect.top);
int width = rect.Width();
int height = rect.Height();
CFX_FxgeDevice bitmap_device1;
if (!bitmap_device1.Create(rect.Width(), rect.Height(), FXDIB_Rgb32, nullptr))
return true;
bitmap_device1.GetBitmap()->Clear(0xffffff);
{
CPDF_RenderStatus bitmap_render;
bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1,
nullptr, nullptr, nullptr, nullptr,
&m_pRenderStatus->m_Options, 0,
m_pRenderStatus->m_bDropObjects, nullptr, true);
CFX_Matrix patternDevice = *pObj2Device;
patternDevice.Translate((FX_FLOAT)-rect.left, (FX_FLOAT)-rect.top);
if (CPDF_TilingPattern* pTilingPattern = m_pPattern->AsTilingPattern()) {
bitmap_render.DrawTilingPattern(pTilingPattern, m_pImageObject,
&patternDevice, false);
} else if (CPDF_ShadingPattern* pShadingPattern =
m_pPattern->AsShadingPattern()) {
bitmap_render.DrawShadingPattern(pShadingPattern, m_pImageObject,
&patternDevice, false);
}
}
{
CFX_FxgeDevice bitmap_device2;
if (!bitmap_device2.Create(rect.Width(), rect.Height(), FXDIB_8bppRgb,
nullptr)) {
return true;
}
bitmap_device2.GetBitmap()->Clear(0);
CPDF_RenderStatus bitmap_render;
bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device2,
nullptr, nullptr, nullptr, nullptr, nullptr, 0,
m_pRenderStatus->m_bDropObjects, nullptr, true);
CPDF_ImageRenderer image_render;
if (image_render.Start(&bitmap_render, m_pDIBSource, 0xffffffff, 255,
&new_matrix, m_Flags, true)) {
image_render.Continue(nullptr);
}
if (m_Loader.m_MatteColor != 0xffffffff) {
int matte_r = FXARGB_R(m_Loader.m_MatteColor);
int matte_g = FXARGB_G(m_Loader.m_MatteColor);
int matte_b = FXARGB_B(m_Loader.m_MatteColor);
for (int row = 0; row < height; row++) {
uint8_t* dest_scan =
(uint8_t*)bitmap_device1.GetBitmap()->GetScanline(row);
const uint8_t* mask_scan = bitmap_device2.GetBitmap()->GetScanline(row);
for (int col = 0; col < width; col++) {
int alpha = *mask_scan++;
if (alpha) {
int orig = (*dest_scan - matte_b) * 255 / alpha + matte_b;
if (orig < 0) {
orig = 0;
} else if (orig > 255) {
orig = 255;
}
*dest_scan++ = orig;
orig = (*dest_scan - matte_g) * 255 / alpha + matte_g;
if (orig < 0) {
orig = 0;
} else if (orig > 255) {
orig = 255;
}
*dest_scan++ = orig;
orig = (*dest_scan - matte_r) * 255 / alpha + matte_r;
if (orig < 0) {
orig = 0;
} else if (orig > 255) {
orig = 255;
}
*dest_scan++ = orig;
dest_scan++;
} else {
dest_scan += 4;
}
}
}
}
bitmap_device2.GetBitmap()->ConvertFormat(FXDIB_8bppMask);
bitmap_device1.GetBitmap()->MultiplyAlpha(bitmap_device2.GetBitmap());
bitmap_device1.GetBitmap()->MultiplyAlpha(255);
}
m_pRenderStatus->m_pDevice->SetDIBitsWithBlend(
bitmap_device1.GetBitmap(), rect.left, rect.top, m_BlendType);
return false;
}