diff options
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/fpdfeditpath.cpp | 34 | ||||
-rw-r--r-- | fpdfsdk/fpdfview.cpp | 5 | ||||
-rw-r--r-- | fpdfsdk/fpdfview_c_api_test.c | 1 | ||||
-rw-r--r-- | fpdfsdk/fsdk_define.h | 4 |
4 files changed, 36 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; diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 0dcb25aaca..6eafdee407 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -16,6 +16,7 @@ #include "core/fpdfapi/page/cpdf_imageobject.h" #include "core/fpdfapi/page/cpdf_page.h" #include "core/fpdfapi/page/cpdf_pageobject.h" +#include "core/fpdfapi/page/cpdf_pathobject.h" #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fpdfapi/parser/cpdf_document.h" @@ -312,6 +313,10 @@ CPDF_Dictionary* CPDFDictionaryFromFPDFAnnotation(FPDF_ANNOTATION annot) { return static_cast<CPDF_Dictionary*>(annot); } +CPDF_PathObject* CPDFPathObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object) { + return static_cast<CPDF_PathObject*>(page_object); +} + CFX_DIBitmap* CFXBitmapFromFPDFBitmap(FPDF_BITMAP bitmap) { return static_cast<CFX_DIBitmap*>(bitmap); } diff --git a/fpdfsdk/fpdfview_c_api_test.c b/fpdfsdk/fpdfview_c_api_test.c index b7752775a3..c8fdc47b51 100644 --- a/fpdfsdk/fpdfview_c_api_test.c +++ b/fpdfsdk/fpdfview_c_api_test.c @@ -109,6 +109,7 @@ int CheckPDFiumCApi() { CHK(FPDFPageObj_CreateNewPath); CHK(FPDFPageObj_CreateNewRect); CHK(FPDFPath_SetStrokeColor); + CHK(FPDFPath_GetStrokeColor); CHK(FPDFPath_SetStrokeWidth); CHK(FPDFPath_SetFillColor); CHK(FPDFPath_GetFillColor); diff --git a/fpdfsdk/fsdk_define.h b/fpdfsdk/fsdk_define.h index e49977976b..1aec6cb963 100644 --- a/fpdfsdk/fsdk_define.h +++ b/fpdfsdk/fsdk_define.h @@ -24,6 +24,7 @@ class CPDF_Annot; class CPDF_Page; class CPDF_PageRenderContext; +class CPDF_PathObject; class IFSDK_PAUSE_Adapter; // Layering prevents fxcrt from knowing about FPDF_FILEACCESS, so this can't @@ -63,6 +64,9 @@ CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page); FPDF_ANNOTATION FPDFAnnotationFromCPDFDictionary(CPDF_Dictionary* pDict); CPDF_Dictionary* CPDFDictionaryFromFPDFAnnotation(FPDF_ANNOTATION annot); + +CPDF_PathObject* CPDFPathObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object); + CFX_DIBitmap* CFXBitmapFromFPDFBitmap(FPDF_BITMAP bitmap); void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable); |