Revert "Revert "Add type cast definitions for CPDF_Dictionary.""
[pdfium.git] / fpdfsdk / src / fpdfeditimg.cpp
index ef0576b..73fc251 100644 (file)
@@ -9,7 +9,7 @@
 
 DLLEXPORT FPDF_PAGEOBJECT STDCALL
 FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document) {
-  CPDF_Document* pDoc = CPDF_Document::FromFPDFDocument(document);
+  CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
   if (!pDoc)
     return nullptr;
   CPDF_ImageObject* pImageObj = new CPDF_ImageObject;
@@ -30,7 +30,9 @@ FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages,
   CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object;
   pImgObj->m_GeneralState.GetModify();
   for (int index = 0; index < nCount; index++) {
-    CPDF_Page* pPage = (CPDF_Page*)pages[index];
+    CPDF_Page* pPage = CPDFPageFromFPDFPage(pages[index]);
+    if (!pPage)
+      continue;
     pImgObj->m_pImage->ResetCache(pPage, NULL);
   }
   pImgObj->m_pImage->SetJpegImage(pFile);
@@ -69,7 +71,9 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,
   CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object;
   pImgObj->m_GeneralState.GetModify();
   for (int index = 0; index < nCount; index++) {
-    CPDF_Page* pPage = (CPDF_Page*)pages[index];
+    CPDF_Page* pPage = CPDFPageFromFPDFPage(pages[index]);
+    if (!pPage)
+      continue;
     pImgObj->m_pImage->ResetCache(pPage, NULL);
   }
   pImgObj->m_pImage->SetImage(pBmp, FALSE);