summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_editimg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdf_editimg.cpp')
-rw-r--r--fpdfsdk/fpdf_editimg.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/fpdfsdk/fpdf_editimg.cpp b/fpdfsdk/fpdf_editimg.cpp
index f1d90ece2d..9485a75002 100644
--- a/fpdfsdk/fpdf_editimg.cpp
+++ b/fpdfsdk/fpdf_editimg.cpp
@@ -57,8 +57,10 @@ bool LoadJpegHelper(FPDF_PAGE* pages,
if (!image_object || !fileAccess)
return false;
- RetainPtr<IFX_SeekableReadStream> pFile = MakeSeekableReadStream(fileAccess);
- CPDF_ImageObject* pImgObj = static_cast<CPDF_ImageObject*>(image_object);
+ CPDF_ImageObject* pImgObj =
+ CPDFPageObjectFromFPDFPageObject(image_object)->AsImage();
+ if (!pImgObj)
+ return false;
if (pages) {
for (int index = 0; index < nCount; index++) {
@@ -68,6 +70,7 @@ bool LoadJpegHelper(FPDF_PAGE* pages,
}
}
+ RetainPtr<IFX_SeekableReadStream> pFile = MakeSeekableReadStream(fileAccess);
if (inlineJpeg)
pImgObj->GetImage()->SetJpegImageInline(pFile);
else
@@ -86,7 +89,9 @@ FPDFPageObj_NewImageObj(FPDF_DOCUMENT document) {
auto pImageObj = pdfium::MakeUnique<CPDF_ImageObject>();
pImageObj->SetImage(pdfium::MakeRetain<CPDF_Image>(pDoc));
- return pImageObj.release();
+
+ // Caller takes ownership.
+ return FPDFPageObjectFromCPDFPageObject(pImageObj.release());
}
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
@@ -116,7 +121,11 @@ FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object,
if (!image_object)
return false;
- CPDF_ImageObject* pImgObj = static_cast<CPDF_ImageObject*>(image_object);
+ CPDF_ImageObject* pImgObj =
+ CPDFPageObjectFromFPDFPageObject(image_object)->AsImage();
+ if (!pImgObj)
+ return false;
+
pImgObj->set_matrix(CFX_Matrix(static_cast<float>(a), static_cast<float>(b),
static_cast<float>(c), static_cast<float>(d),
static_cast<float>(e), static_cast<float>(f)));
@@ -133,13 +142,17 @@ FPDFImageObj_SetBitmap(FPDF_PAGE* pages,
if (!image_object || !bitmap || !pages)
return false;
- CPDF_ImageObject* pImgObj = static_cast<CPDF_ImageObject*>(image_object);
+ CPDF_ImageObject* pImgObj =
+ CPDFPageObjectFromFPDFPageObject(image_object)->AsImage();
+ if (!pImgObj)
+ return false;
+
for (int index = 0; index < nCount; index++) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(pages[index]);
if (pPage)
pImgObj->GetImage()->ResetCache(pPage, nullptr);
}
- RetainPtr<CFX_DIBitmap> holder(CFXBitmapFromFPDFBitmap(bitmap));
+ RetainPtr<CFX_DIBitmap> holder(CFXDIBitmapFromFPDFBitmap(bitmap));
pImgObj->GetImage()->SetImage(holder);
pImgObj->CalcBoundingBox();
pImgObj->SetDirty(true);
@@ -170,7 +183,7 @@ FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object) {
else
pBitmap = pSource->Clone(nullptr);
- return pBitmap.Leak();
+ return FPDFBitmapFromCFXDIBitmap(pBitmap.Leak());
}
FPDF_EXPORT unsigned long FPDF_CALLCONV