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