| John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. | 
|  | 2 | // Use of this source code is governed by a BSD-style license that can be | 
|  | 3 | // found in the LICENSE file. | 
| Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame^] | 4 |  | 
| John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 
|  | 6 |  | 
| Tom Sepez | 1ed8a21 | 2015-05-11 15:25:39 -0700 | [diff] [blame] | 7 | #include "../../public/fpdf_edit.h" | 
| John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 8 | #include "../include/fsdk_define.h" | 
| Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 9 | #include "../include/fpdfxfa/fpdfxfa_doc.h" | 
|  | 10 | #include "../include/fpdfxfa/fpdfxfa_page.h" | 
| John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 11 |  | 
| John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 12 | DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document) | 
|  | 13 | { | 
|  | 14 | if (!document) | 
|  | 15 | return NULL; | 
|  | 16 | CPDF_ImageObject* pImageObj = FX_NEW CPDF_ImageObject; | 
| Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 17 | CPDF_Image* pImg = FX_NEW CPDF_Image(((CPDFXFA_Document *)document)->GetPDFDoc()); | 
| John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 18 | pImageObj->m_pImage = pImg; | 
|  | 19 | return pImageObj; | 
|  | 20 | } | 
|  | 21 |  | 
|  | 22 | DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, int nCount,FPDF_PAGEOBJECT image_object, FPDF_FILEACCESS* fileAccess) | 
|  | 23 | { | 
| Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 24 | if (!image_object || !fileAccess || !pages) | 
| John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 25 | return FALSE; | 
|  | 26 |  | 
|  | 27 | IFX_FileRead* pFile = FX_NEW CPDF_CustomAccess(fileAccess); | 
|  | 28 |  | 
|  | 29 | CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object; | 
|  | 30 | pImgObj->m_GeneralState.GetModify(); | 
|  | 31 | for (int index=0;index<nCount;index++) | 
|  | 32 | { | 
| Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame^] | 33 | CPDF_Page* pPage = ((CPDFXFA_Page*)pages[index])->GetPDFPage(); | 
| Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 34 | if (!pPage) | 
|  | 35 | continue; | 
| John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 36 | pImgObj->m_pImage->ResetCache(pPage,NULL); | 
|  | 37 | } | 
|  | 38 | pImgObj->m_pImage->SetJpegImage(pFile); | 
|  | 39 |  | 
|  | 40 | return TRUE; | 
|  | 41 | } | 
|  | 42 |  | 
|  | 43 |  | 
|  | 44 | DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix	(FPDF_PAGEOBJECT image_object, | 
|  | 45 | double a, double b, double c, double d, double e, double f) | 
|  | 46 | { | 
|  | 47 | if (!image_object) | 
|  | 48 | return FALSE; | 
|  | 49 | CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object; | 
|  | 50 | pImgObj->m_Matrix.a = (FX_FLOAT)a; | 
|  | 51 | pImgObj->m_Matrix.b = (FX_FLOAT)b; | 
|  | 52 | pImgObj->m_Matrix.c = (FX_FLOAT)c; | 
|  | 53 | pImgObj->m_Matrix.d = (FX_FLOAT)d; | 
|  | 54 | pImgObj->m_Matrix.e = (FX_FLOAT)e; | 
|  | 55 | pImgObj->m_Matrix.f = (FX_FLOAT)f; | 
|  | 56 | pImgObj->CalcBoundingBox(); | 
|  | 57 | return  TRUE; | 
|  | 58 | } | 
|  | 59 |  | 
|  | 60 | DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,int nCount,FPDF_PAGEOBJECT image_object,FPDF_BITMAP bitmap) | 
|  | 61 | { | 
| Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 62 | if (!image_object || !bitmap || !pages) | 
| John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 63 | return FALSE; | 
|  | 64 | CFX_DIBitmap* pBmp = NULL; | 
|  | 65 | pBmp = (CFX_DIBitmap*)bitmap; | 
|  | 66 | CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object; | 
|  | 67 | pImgObj->m_GeneralState.GetModify(); | 
|  | 68 | for (int index=0;index<nCount;index++) | 
|  | 69 | { | 
| Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 70 | CPDF_Page* pPage = ((CPDFXFA_Page*)pages[index])->GetPDFPage(); | 
|  | 71 | if (!pPage) continue; | 
| John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 72 | pImgObj->m_pImage->ResetCache(pPage,NULL); | 
|  | 73 | } | 
|  | 74 | pImgObj->m_pImage->SetImage(pBmp,FALSE); | 
|  | 75 | pImgObj->CalcBoundingBox(); | 
|  | 76 | return TRUE; | 
|  | 77 | } | 
|  | 78 |  |