summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdfedit_embeddertest.cpp2
-rw-r--r--fpdfsdk/fpdfeditimg.cpp45
-rw-r--r--fpdfsdk/fpdfeditimg_unittest.cpp10
-rw-r--r--fpdfsdk/fpdfview_c_api_test.c1
-rw-r--r--public/fpdf_edit.h9
5 files changed, 42 insertions, 25 deletions
diff --git a/fpdfsdk/fpdfedit_embeddertest.cpp b/fpdfsdk/fpdfedit_embeddertest.cpp
index b21be2df1b..6d928597ff 100644
--- a/fpdfsdk/fpdfedit_embeddertest.cpp
+++ b/fpdfsdk/fpdfedit_embeddertest.cpp
@@ -220,7 +220,7 @@ TEST_F(FPDFEditEmbeddertest, RasterizePDF) {
// Add the bitmap to an image object and add the image object to the output
// page.
- FPDF_PAGEOBJECT temp_img = FPDFPageObj_NewImgeObj(temp_doc);
+ FPDF_PAGEOBJECT temp_img = FPDFPageObj_NewImageObj(temp_doc);
EXPECT_TRUE(FPDFImageObj_SetBitmap(&temp_page, 1, temp_img, orig_bitmap));
EXPECT_TRUE(FPDFImageObj_SetMatrix(temp_img, 612, 0, 0, 792, 0, 0));
FPDFPage_InsertObject(temp_page, temp_img);
diff --git a/fpdfsdk/fpdfeditimg.cpp b/fpdfsdk/fpdfeditimg.cpp
index ad5605011c..69151d1999 100644
--- a/fpdfsdk/fpdfeditimg.cpp
+++ b/fpdfsdk/fpdfeditimg.cpp
@@ -13,22 +13,13 @@
#include "fpdfsdk/fsdk_define.h"
#include "third_party/base/ptr_util.h"
-DLLEXPORT FPDF_PAGEOBJECT STDCALL
-FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document) {
- CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
- if (!pDoc)
- return nullptr;
+namespace {
- CPDF_ImageObject* pImageObj = new CPDF_ImageObject;
- pImageObj->SetOwnedImage(pdfium::MakeUnique<CPDF_Image>(pDoc));
- return pImageObj;
-}
-
-FPDF_BOOL FPDFImageObj_LoadJpegHelper(FPDF_PAGE* pages,
- int nCount,
- FPDF_PAGEOBJECT image_object,
- FPDF_FILEACCESS* fileAccess,
- bool inlineJpeg) {
+bool LoadJpegHelper(FPDF_PAGE* pages,
+ int nCount,
+ FPDF_PAGEOBJECT image_object,
+ FPDF_FILEACCESS* fileAccess,
+ bool inlineJpeg) {
if (!image_object || !fileAccess || !pages)
return false;
@@ -49,13 +40,30 @@ FPDF_BOOL FPDFImageObj_LoadJpegHelper(FPDF_PAGE* pages,
return true;
}
+} // namespace
+
+DLLEXPORT FPDF_PAGEOBJECT STDCALL
+FPDFPageObj_NewImageObj(FPDF_DOCUMENT document) {
+ CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
+ if (!pDoc)
+ return nullptr;
+
+ CPDF_ImageObject* pImageObj = new CPDF_ImageObject;
+ pImageObj->SetOwnedImage(pdfium::MakeUnique<CPDF_Image>(pDoc));
+ return pImageObj;
+}
+
+DLLEXPORT FPDF_PAGEOBJECT STDCALL
+FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document) {
+ return FPDFPageObj_NewImageObj(document);
+}
+
DLLEXPORT FPDF_BOOL STDCALL
FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages,
int nCount,
FPDF_PAGEOBJECT image_object,
FPDF_FILEACCESS* fileAccess) {
- return FPDFImageObj_LoadJpegHelper(pages, nCount, image_object, fileAccess,
- false);
+ return LoadJpegHelper(pages, nCount, image_object, fileAccess, false);
}
DLLEXPORT FPDF_BOOL STDCALL
@@ -63,8 +71,7 @@ FPDFImageObj_LoadJpegFileInline(FPDF_PAGE* pages,
int nCount,
FPDF_PAGEOBJECT image_object,
FPDF_FILEACCESS* fileAccess) {
- return FPDFImageObj_LoadJpegHelper(pages, nCount, image_object, fileAccess,
- true);
+ return LoadJpegHelper(pages, nCount, image_object, fileAccess, true);
}
DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object,
diff --git a/fpdfsdk/fpdfeditimg_unittest.cpp b/fpdfsdk/fpdfeditimg_unittest.cpp
index ae4af2591e..da6930caed 100644
--- a/fpdfsdk/fpdfeditimg_unittest.cpp
+++ b/fpdfsdk/fpdfeditimg_unittest.cpp
@@ -27,7 +27,7 @@ TEST_F(PDFEditTest, InsertObjectWithInvalidPage) {
FPDFPage_InsertObject(page, nullptr);
EXPECT_EQ(0, FPDFPage_CountObject(page));
- FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc);
+ FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImageObj(doc);
FPDFPage_InsertObject(nullptr, page_image);
EXPECT_EQ(0, FPDFPage_CountObject(page));
@@ -35,12 +35,12 @@ TEST_F(PDFEditTest, InsertObjectWithInvalidPage) {
FPDF_CloseDocument(doc);
}
-TEST_F(PDFEditTest, NewImgeObj) {
+TEST_F(PDFEditTest, NewImageObj) {
FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100);
EXPECT_EQ(0, FPDFPage_CountObject(page));
- FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc);
+ FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImageObj(doc);
FPDFPage_InsertObject(page, page_image);
EXPECT_EQ(1, FPDFPage_CountObject(page));
EXPECT_TRUE(FPDFPage_GenerateContent(page));
@@ -49,7 +49,7 @@ TEST_F(PDFEditTest, NewImgeObj) {
FPDF_CloseDocument(doc);
}
-TEST_F(PDFEditTest, NewImgeObjGenerateContent) {
+TEST_F(PDFEditTest, NewImageObjGenerateContent) {
FPDF_DOCUMENT doc = FPDF_CreateNewDocument();
FPDF_PAGE page = FPDFPage_New(doc, 0, 100, 100);
EXPECT_EQ(0, FPDFPage_CountObject(page));
@@ -60,7 +60,7 @@ TEST_F(PDFEditTest, NewImgeObjGenerateContent) {
EXPECT_EQ(kBitmapSize, FPDFBitmap_GetWidth(bitmap));
EXPECT_EQ(kBitmapSize, FPDFBitmap_GetHeight(bitmap));
- FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc);
+ FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImageObj(doc);
ASSERT_TRUE(FPDFImageObj_SetBitmap(&page, 0, page_image, bitmap));
ASSERT_TRUE(
FPDFImageObj_SetMatrix(page_image, kBitmapSize, 0, 0, kBitmapSize, 0, 0));
diff --git a/fpdfsdk/fpdfview_c_api_test.c b/fpdfsdk/fpdfview_c_api_test.c
index df3ef19d64..b090319d86 100644
--- a/fpdfsdk/fpdfview_c_api_test.c
+++ b/fpdfsdk/fpdfview_c_api_test.c
@@ -81,6 +81,7 @@ int CheckPDFiumCApi() {
CHK(FPDFPageObj_HasTransparency);
CHK(FPDFPageObj_Transform);
CHK(FPDFPage_TransformAnnots);
+ CHK(FPDFPageObj_NewImageObj);
CHK(FPDFPageObj_NewImgeObj);
CHK(FPDFImageObj_LoadJpegFile);
CHK(FPDFImageObj_LoadJpegFileInline);
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index 423229ab33..34a47a7c83 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -185,6 +185,15 @@ DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
//
// Returns a handle to a new image object.
DLLEXPORT FPDF_PAGEOBJECT STDCALL
+FPDFPageObj_NewImageObj(FPDF_DOCUMENT document);
+
+// Create a new image object.
+// DEPRECATED. Please use FPDFPageObj_NewImageObj() above.
+//
+// document - handle to a document.
+//
+// Returns a handle to a new image object.
+DLLEXPORT FPDF_PAGEOBJECT STDCALL
FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document);
// Load an image from a JPEG image file and then set it into |image_object|.