Initial commit.
[pdfium.git] / fpdfsdk / src / fpdfeditimg.cpp
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4  \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #include "../include/fsdk_define.h"\r
8 #include "../include/fpdfedit.h"\r
9 \r
10 \r
11 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document)\r
12 {\r
13         if (!document)\r
14                 return NULL;\r
15         CPDF_ImageObject* pImageObj = FX_NEW CPDF_ImageObject;\r
16         CPDF_Image* pImg = FX_NEW CPDF_Image((CPDF_Document *)document);\r
17         pImageObj->m_pImage = pImg;\r
18         return pImageObj;\r
19 }\r
20 \r
21 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, int nCount,FPDF_PAGEOBJECT image_object, FPDF_FILEACCESS* fileAccess)\r
22 {\r
23         if (!image_object || !fileAccess)\r
24                 return FALSE;\r
25 \r
26         IFX_FileRead* pFile = FX_NEW CPDF_CustomAccess(fileAccess);\r
27 \r
28         CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object;\r
29         pImgObj->m_GeneralState.GetModify();\r
30         for (int index=0;index<nCount;index++)\r
31         {\r
32                 CPDF_Page* pPage = (CPDF_Page*)pages[index]; \r
33                 pImgObj->m_pImage->ResetCache(pPage,NULL);\r
34         }\r
35         pImgObj->m_pImage->SetJpegImage(pFile);\r
36 \r
37         return TRUE;\r
38 }\r
39 \r
40 \r
41 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix      (FPDF_PAGEOBJECT image_object,\r
42                                                                                                  double a, double b, double c, double d, double e, double f)\r
43 {\r
44         if (!image_object)\r
45                 return FALSE;\r
46         CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object;\r
47         pImgObj->m_Matrix.a = (FX_FLOAT)a;\r
48         pImgObj->m_Matrix.b = (FX_FLOAT)b;\r
49         pImgObj->m_Matrix.c = (FX_FLOAT)c;\r
50         pImgObj->m_Matrix.d = (FX_FLOAT)d;\r
51         pImgObj->m_Matrix.e = (FX_FLOAT)e;\r
52         pImgObj->m_Matrix.f = (FX_FLOAT)f;\r
53         pImgObj->CalcBoundingBox();\r
54         return  TRUE;\r
55 }\r
56 \r
57 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,int nCount,FPDF_PAGEOBJECT image_object,FPDF_BITMAP bitmap)\r
58 {\r
59         if (!image_object || !bitmap)\r
60                 return FALSE;\r
61         CFX_DIBitmap* pBmp = NULL;\r
62         pBmp = (CFX_DIBitmap*)bitmap;\r
63         CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object;\r
64         pImgObj->m_GeneralState.GetModify();\r
65         for (int index=0;index<nCount;index++)\r
66         {\r
67                 CPDF_Page* pPage = (CPDF_Page*)pages[index]; \r
68                 pImgObj->m_pImage->ResetCache(pPage,NULL);\r
69         }\r
70         pImgObj->m_pImage->SetImage(pBmp,FALSE);\r
71         pImgObj->CalcBoundingBox();\r
72         return TRUE;\r
73 }\r
74 \r