Revert "Revert "Add type cast definitions for CPDF_Dictionary.""
[pdfium.git] / fpdfsdk / src / fpdfeditimg.cpp
index bb71078..73fc251 100644 (file)
@@ -9,10 +9,11 @@
 
 DLLEXPORT FPDF_PAGEOBJECT STDCALL
 FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document) {
-  if (!document)
-    return NULL;
+  CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
+  if (!pDoc)
+    return nullptr;
   CPDF_ImageObject* pImageObj = new CPDF_ImageObject;
-  CPDF_Image* pImg = new CPDF_Image((CPDF_Document*)document);
+  CPDF_Image* pImg = new CPDF_Image(pDoc);
   pImageObj->m_pImage = pImg;
   return pImageObj;
 }
@@ -29,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);
@@ -68,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);