summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfeditpath.cpp
diff options
context:
space:
mode:
authorJane Liu <janeliulwq@google.com>2017-06-19 10:44:01 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-06-19 15:57:34 +0000
commit3b05743bd072d936f56250514d6b18bfbbde85bf (patch)
treeb5c046b9e65d2d36f5b837ceb711fceee6585b56 /fpdfsdk/fpdfeditpath.cpp
parent54d91ecc4cedd07da6ff599285ac12168c146129 (diff)
downloadpdfium-3b05743bd072d936f56250514d6b18bfbbde85bf.tar.xz
Added public API FPDFPath_GetStrokeColor
There is already public APIs for SetFillColor, GetFillColor, and SetStrokeColor; this is the only one missing. This function is helpful to have when extracting path information from annotations. Change-Id: I2bf80a1dc5433e65bbb1d005c0e609d01c9133be Reviewed-on: https://pdfium-review.googlesource.com/6710 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfeditpath.cpp')
-rw-r--r--fpdfsdk/fpdfeditpath.cpp34
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;