diff options
Diffstat (limited to 'fpdfsdk/fpdfeditpath.cpp')
-rw-r--r-- | fpdfsdk/fpdfeditpath.cpp | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/fpdfsdk/fpdfeditpath.cpp b/fpdfsdk/fpdfeditpath.cpp index 3a0a296cdf..6235210113 100644 --- a/fpdfsdk/fpdfeditpath.cpp +++ b/fpdfsdk/fpdfeditpath.cpp @@ -52,7 +52,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_SetStrokeColor(FPDF_PAGEOBJECT path, return false; float rgb[3] = {R / 255.f, G / 255.f, B / 255.f}; - auto* pPathObj = static_cast<CPDF_PathObject*>(path); + auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); pPathObj->m_GeneralState.SetStrokeAlpha(A / 255.f); pPathObj->m_ColorState.SetStrokeColor( CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3); @@ -60,11 +60,29 @@ DLLEXPORT FPDF_BOOL FPDFPath_SetStrokeColor(FPDF_PAGEOBJECT path, return true; } +DLLEXPORT FPDF_BOOL FPDFPath_GetStrokeColor(FPDF_PAGEOBJECT path, + unsigned int* R, + unsigned int* G, + unsigned int* B, + unsigned int* A) { + if (!path || !R || !G || !B || !A) + return false; + + auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); + uint32_t strokeRGB = pPathObj->m_ColorState.GetStrokeRGB(); + *R = FXSYS_GetRValue(strokeRGB); + *G = FXSYS_GetGValue(strokeRGB); + *B = FXSYS_GetBValue(strokeRGB); + *A = static_cast<unsigned int>(pPathObj->m_GeneralState.GetStrokeAlpha() * + 255.f); + return true; +} + DLLEXPORT FPDF_BOOL FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width) { if (!path || width < 0.0f) return false; - auto* pPathObj = static_cast<CPDF_PathObject*>(path); + auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); pPathObj->m_GraphState.SetLineWidth(width); pPathObj->SetDirty(true); return true; @@ -86,7 +104,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_GetFillColor(FPDF_PAGEOBJECT path, if (!path || !R || !G || !B || !A) return false; - auto* pPathObj = static_cast<CPDF_PathObject*>(path); + auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); uint32_t fillRGB = pPathObj->m_ColorState.GetFillRGB(); *R = FXSYS_GetRValue(fillRGB); *G = FXSYS_GetGValue(fillRGB); @@ -100,7 +118,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_MoveTo(FPDF_PAGEOBJECT path, float x, float y) { if (!path) return false; - auto* pPathObj = static_cast<CPDF_PathObject*>(path); + auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); pPathObj->m_Path.AppendPoint(CFX_PointF(x, y), FXPT_TYPE::MoveTo, false); pPathObj->SetDirty(true); return true; @@ -110,7 +128,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_LineTo(FPDF_PAGEOBJECT path, float x, float y) { if (!path) return false; - auto* pPathObj = static_cast<CPDF_PathObject*>(path); + auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); pPathObj->m_Path.AppendPoint(CFX_PointF(x, y), FXPT_TYPE::LineTo, false); pPathObj->SetDirty(true); return true; @@ -126,7 +144,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_BezierTo(FPDF_PAGEOBJECT path, if (!path) return false; - auto* pPathObj = static_cast<CPDF_PathObject*>(path); + auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); pPathObj->m_Path.AppendPoint(CFX_PointF(x1, y1), FXPT_TYPE::BezierTo, false); pPathObj->m_Path.AppendPoint(CFX_PointF(x2, y2), FXPT_TYPE::BezierTo, false); pPathObj->m_Path.AppendPoint(CFX_PointF(x3, y3), FXPT_TYPE::BezierTo, false); @@ -138,7 +156,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_Close(FPDF_PAGEOBJECT path) { if (!path) return false; - auto* pPathObj = static_cast<CPDF_PathObject*>(path); + auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); if (pPathObj->m_Path.GetPoints().empty()) return false; @@ -153,7 +171,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, if (!path) return false; - auto* pPathObj = static_cast<CPDF_PathObject*>(path); + auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); if (fillmode == FPDF_FILLMODE_ALTERNATE) pPathObj->m_FillType = FXFILL_ALTERNATE; |