Chromium Code Reviews| Index: fpdfsdk/fpdfeditimg.cpp |
| diff --git a/fpdfsdk/fpdfeditimg.cpp b/fpdfsdk/fpdfeditimg.cpp |
| index 4429dcd2010201ff8b416f094f1374ab72d61058..b2c25779c6468a5779c1ceb9788e718c9ab25d20 100644 |
| --- a/fpdfsdk/fpdfeditimg.cpp |
| +++ b/fpdfsdk/fpdfeditimg.cpp |
| @@ -17,9 +17,9 @@ FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document) { |
| CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); |
| if (!pDoc) |
| return nullptr; |
| + |
| CPDF_ImageObject* pImageObj = new CPDF_ImageObject; |
| - CPDF_Image* pImg = new CPDF_Image(pDoc); |
| - pImageObj->m_pImage = pImg; |
| + pImageObj->m_pImage = new CPDF_Image(pDoc); |
|
dsinclair
2016/07/29 13:22:49
Should this be a unique_ptr?
Lei Zhang
2016/07/29 14:46:15
No. CPDF_Image is Released half the time. It's won
|
| return pImageObj; |
| } |
| @@ -32,13 +32,12 @@ FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, |
| return FALSE; |
| IFX_FileRead* pFile = new CPDF_CustomAccess(fileAccess); |
| - CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object; |
| + CPDF_ImageObject* pImgObj = reinterpret_cast<CPDF_ImageObject*>(image_object); |
| pImgObj->m_GeneralState.GetModify(); |
| for (int index = 0; index < nCount; index++) { |
| CPDF_Page* pPage = CPDFPageFromFPDFPage(pages[index]); |
| - if (!pPage) |
| - continue; |
| - pImgObj->m_pImage->ResetCache(pPage, nullptr); |
| + if (pPage) |
| + pImgObj->m_pImage->ResetCache(pPage, nullptr); |
| } |
| pImgObj->m_pImage->SetJpegImage(pFile); |
| @@ -54,13 +53,14 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, |
| double f) { |
| if (!image_object) |
| return FALSE; |
| - CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object; |
| - pImgObj->m_Matrix.a = (FX_FLOAT)a; |
| - pImgObj->m_Matrix.b = (FX_FLOAT)b; |
| - pImgObj->m_Matrix.c = (FX_FLOAT)c; |
| - pImgObj->m_Matrix.d = (FX_FLOAT)d; |
| - pImgObj->m_Matrix.e = (FX_FLOAT)e; |
| - pImgObj->m_Matrix.f = (FX_FLOAT)f; |
| + |
| + CPDF_ImageObject* pImgObj = reinterpret_cast<CPDF_ImageObject*>(image_object); |
| + pImgObj->m_Matrix.a = static_cast<FX_FLOAT>(a); |
| + pImgObj->m_Matrix.b = static_cast<FX_FLOAT>(b); |
| + pImgObj->m_Matrix.c = static_cast<FX_FLOAT>(c); |
| + pImgObj->m_Matrix.d = static_cast<FX_FLOAT>(d); |
| + pImgObj->m_Matrix.e = static_cast<FX_FLOAT>(e); |
| + pImgObj->m_Matrix.f = static_cast<FX_FLOAT>(f); |
| pImgObj->CalcBoundingBox(); |
| return TRUE; |
| } |
| @@ -71,17 +71,15 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages, |
| FPDF_BITMAP bitmap) { |
| if (!image_object || !bitmap || !pages) |
| return FALSE; |
| - CFX_DIBitmap* pBmp = nullptr; |
| - pBmp = (CFX_DIBitmap*)bitmap; |
| - CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object; |
| + |
| + CPDF_ImageObject* pImgObj = reinterpret_cast<CPDF_ImageObject*>(image_object); |
| pImgObj->m_GeneralState.GetModify(); |
| for (int index = 0; index < nCount; index++) { |
| CPDF_Page* pPage = CPDFPageFromFPDFPage(pages[index]); |
| - if (!pPage) |
| - continue; |
| - pImgObj->m_pImage->ResetCache(pPage, nullptr); |
| + if (pPage) |
| + pImgObj->m_pImage->ResetCache(pPage, nullptr); |
| } |
| - pImgObj->m_pImage->SetImage(pBmp, FALSE); |
| + pImgObj->m_pImage->SetImage(reinterpret_cast<CFX_DIBitmap*>(bitmap), FALSE); |
| pImgObj->CalcBoundingBox(); |
| return TRUE; |
| } |