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.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "../../public/fpdf_edit.h"
8 #include "../include/fsdk_define.h"
9 
10 
FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document)11 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document)
12 {
13 	if (!document)
14 		return NULL;
15 	CPDF_ImageObject* pImageObj = new CPDF_ImageObject;
16 	CPDF_Image* pImg = new CPDF_Image((CPDF_Document *)document);
17 	pImageObj->m_pImage = pImg;
18 	return pImageObj;
19 }
20 
FPDFImageObj_LoadJpegFile(FPDF_PAGE * pages,int nCount,FPDF_PAGEOBJECT image_object,FPDF_FILEACCESS * fileAccess)21 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, int nCount,FPDF_PAGEOBJECT image_object, FPDF_FILEACCESS* fileAccess)
22 {
23 	if (!image_object || !fileAccess)
24 		return FALSE;
25 
26 	IFX_FileRead* pFile = new CPDF_CustomAccess(fileAccess);
27 	CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object;
28 	pImgObj->m_GeneralState.GetModify();
29 	for (int index=0;index<nCount;index++)
30 	{
31 		CPDF_Page* pPage = (CPDF_Page*)pages[index];
32 		pImgObj->m_pImage->ResetCache(pPage,NULL);
33 	}
34 	pImgObj->m_pImage->SetJpegImage(pFile);
35 
36 	return TRUE;
37 }
38 
39 
FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object,double a,double b,double c,double d,double e,double f)40 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix	(FPDF_PAGEOBJECT image_object,
41 												 double a, double b, double c, double d, double e, double f)
42 {
43 	if (!image_object)
44 		return FALSE;
45 	CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object;
46 	pImgObj->m_Matrix.a = (FX_FLOAT)a;
47 	pImgObj->m_Matrix.b = (FX_FLOAT)b;
48 	pImgObj->m_Matrix.c = (FX_FLOAT)c;
49 	pImgObj->m_Matrix.d = (FX_FLOAT)d;
50 	pImgObj->m_Matrix.e = (FX_FLOAT)e;
51 	pImgObj->m_Matrix.f = (FX_FLOAT)f;
52 	pImgObj->CalcBoundingBox();
53 	return  TRUE;
54 }
55 
FPDFImageObj_SetBitmap(FPDF_PAGE * pages,int nCount,FPDF_PAGEOBJECT image_object,FPDF_BITMAP bitmap)56 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,int nCount,FPDF_PAGEOBJECT image_object,FPDF_BITMAP bitmap)
57 {
58 	if (!image_object || !bitmap)
59 		return FALSE;
60 	CFX_DIBitmap* pBmp = NULL;
61 	pBmp = (CFX_DIBitmap*)bitmap;
62 	CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object;
63 	pImgObj->m_GeneralState.GetModify();
64 	for (int index=0;index<nCount;index++)
65 	{
66 		CPDF_Page* pPage = (CPDF_Page*)pages[index];
67 		pImgObj->m_pImage->ResetCache(pPage,NULL);
68 	}
69 	pImgObj->m_pImage->SetImage(pBmp,FALSE);
70 	pImgObj->CalcBoundingBox();
71 	return TRUE;
72 }
73 
74