Allow FPDFBookmark_GetFirstChild to return the top level bookmark
[pdfium.git] / fpdfsdk / src / fpdfeditimg.cpp
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 "../include/fsdk_define.h"
8 #include "../include/fpdfedit.h"
9
10
11 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document)
12 {
13         if (!document)
14                 return NULL;
15         CPDF_ImageObject* pImageObj = FX_NEW CPDF_ImageObject;
16         CPDF_Image* pImg = FX_NEW CPDF_Image((CPDF_Document *)document);
17         pImageObj->m_pImage = pImg;
18         return pImageObj;
19 }
20
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 = FX_NEW CPDF_CustomAccess(fileAccess);
27
28         CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object;
29         pImgObj->m_GeneralState.GetModify();
30         for (int index=0;index<nCount;index++)
31         {
32                 CPDF_Page* pPage = (CPDF_Page*)pages[index]; 
33                 pImgObj->m_pImage->ResetCache(pPage,NULL);
34         }
35         pImgObj->m_pImage->SetJpegImage(pFile);
36
37         return TRUE;
38 }
39
40
41 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix      (FPDF_PAGEOBJECT image_object,
42                                                                                                  double a, double b, double c, double d, double e, double f)
43 {
44         if (!image_object)
45                 return FALSE;
46         CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object;
47         pImgObj->m_Matrix.a = (FX_FLOAT)a;
48         pImgObj->m_Matrix.b = (FX_FLOAT)b;
49         pImgObj->m_Matrix.c = (FX_FLOAT)c;
50         pImgObj->m_Matrix.d = (FX_FLOAT)d;
51         pImgObj->m_Matrix.e = (FX_FLOAT)e;
52         pImgObj->m_Matrix.f = (FX_FLOAT)f;
53         pImgObj->CalcBoundingBox();
54         return  TRUE;
55 }
56
57 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,int nCount,FPDF_PAGEOBJECT image_object,FPDF_BITMAP bitmap)
58 {
59         if (!image_object || !bitmap)
60                 return FALSE;
61         CFX_DIBitmap* pBmp = NULL;
62         pBmp = (CFX_DIBitmap*)bitmap;
63         CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object;
64         pImgObj->m_GeneralState.GetModify();
65         for (int index=0;index<nCount;index++)
66         {
67                 CPDF_Page* pPage = (CPDF_Page*)pages[index]; 
68                 pImgObj->m_pImage->ResetCache(pPage,NULL);
69         }
70         pImgObj->m_pImage->SetImage(pBmp,FALSE);
71         pImgObj->CalcBoundingBox();
72         return TRUE;
73 }
74