summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfeditpage.cpp16
-rw-r--r--fpdfsdk/fpdfeditpath.cpp11
-rw-r--r--fpdfsdk/fpdfedittext.cpp8
-rw-r--r--fpdfsdk/fsdk_define.h5
4 files changed, 31 insertions, 9 deletions
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
index 6ed375807f..2c58caf6db 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -304,3 +304,19 @@ DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) {
rotate %= 4;
pPage->m_pFormDict->SetNewFor<CPDF_Number>("Rotate", rotate * 90);
}
+
+FPDF_BOOL FPDFPageObj_SetFillColor(FPDF_PAGEOBJECT page_object,
+ unsigned int R,
+ unsigned int G,
+ unsigned int B,
+ unsigned int A) {
+ if (!page_object || R > 255 || G > 255 || B > 255 || A > 255)
+ return false;
+
+ float rgb[3] = {R / 255.f, G / 255.f, B / 255.f};
+ auto* pPageObj = static_cast<CPDF_PageObject*>(page_object);
+ pPageObj->m_GeneralState.SetFillAlpha(A / 255.f);
+ pPageObj->m_ColorState.SetFillColor(
+ CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
+ return true;
+}
diff --git a/fpdfsdk/fpdfeditpath.cpp b/fpdfsdk/fpdfeditpath.cpp
index 54937ef91a..ad5ca9433f 100644
--- a/fpdfsdk/fpdfeditpath.cpp
+++ b/fpdfsdk/fpdfeditpath.cpp
@@ -7,6 +7,7 @@
#include "core/fpdfapi/page/cpdf_path.h"
#include "core/fpdfapi/page/cpdf_pathobject.h"
#include "core/fxcrt/fx_system.h"
+#include "fpdfsdk/fsdk_define.h"
#include "third_party/base/ptr_util.h"
DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_CreateNewPath(float x, float y) {
@@ -56,15 +57,7 @@ DLLEXPORT FPDF_BOOL FPDFPath_SetFillColor(FPDF_PAGEOBJECT path,
unsigned int G,
unsigned int B,
unsigned int A) {
- if (!path || R > 255 || G > 255 || B > 255 || A > 255)
- return false;
-
- float rgb[3] = {R / 255.f, G / 255.f, B / 255.f};
- auto* pPathObj = static_cast<CPDF_PathObject*>(path);
- pPathObj->m_GeneralState.SetFillAlpha(A / 255.f);
- pPathObj->m_ColorState.SetFillColor(
- CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
- return true;
+ return FPDFPageObj_SetFillColor(path, R, G, B, A);
}
DLLEXPORT FPDF_BOOL FPDFPath_GetFillColor(FPDF_PAGEOBJECT path,
diff --git a/fpdfsdk/fpdfedittext.cpp b/fpdfsdk/fpdfedittext.cpp
index 2dde2e6624..3deae7ea20 100644
--- a/fpdfsdk/fpdfedittext.cpp
+++ b/fpdfsdk/fpdfedittext.cpp
@@ -447,6 +447,14 @@ DLLEXPORT FPDF_FONT STDCALL FPDFText_LoadFont(FPDF_DOCUMENT document,
: LoadSimpleFont(pDoc, std::move(pFont), data, size, font_type);
}
+DLLEXPORT FPDF_BOOL STDCALL FPDFText_SetFillColor(FPDF_PAGEOBJECT text_object,
+ unsigned int R,
+ unsigned int G,
+ unsigned int B,
+ unsigned int A) {
+ return FPDFPageObj_SetFillColor(text_object, R, G, B, A);
+}
+
DLLEXPORT void STDCALL FPDFFont_Close(FPDF_FONT font) {
CPDF_Font* pFont = static_cast<CPDF_Font*>(font);
if (!pFont)
diff --git a/fpdfsdk/fsdk_define.h b/fpdfsdk/fsdk_define.h
index b7691bbdd9..e14cc19ea1 100644
--- a/fpdfsdk/fsdk_define.h
+++ b/fpdfsdk/fsdk_define.h
@@ -79,5 +79,10 @@ void FPDF_RenderPage_Retail(CPDF_PageRenderContext* pContext,
void CheckUnSupportError(CPDF_Document* pDoc, uint32_t err_code);
void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot);
void ProcessParseError(CPDF_Parser::Error err);
+FPDF_BOOL FPDFPageObj_SetFillColor(FPDF_PAGEOBJECT page_object,
+ unsigned int R,
+ unsigned int G,
+ unsigned int B,
+ unsigned int A);
#endif // FPDFSDK_FSDK_DEFINE_H_