diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2016-03-14 13:51:24 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2016-03-14 13:51:24 -0400 |
commit | f766ad219f66543654520f6a1955836f519e26d1 (patch) | |
tree | 2edf8bc93b89503a3669f7add5b6c2a407b8a78c /fpdfsdk/fpdfeditimg.cpp | |
parent | 54b0abed08048008498471e39b7c72b034474090 (diff) | |
download | pdfium-f766ad219f66543654520f6a1955836f519e26d1.tar.xz |
Move fpdfsdk/src up to fpdfsdk/.
This CL moves the files in fpdfsdk/src/ up one level to fpdfsdk/ and fixes
up the include paths, include guards and build files.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1799773002 .
Diffstat (limited to 'fpdfsdk/fpdfeditimg.cpp')
-rw-r--r-- | fpdfsdk/fpdfeditimg.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfeditimg.cpp b/fpdfsdk/fpdfeditimg.cpp new file mode 100644 index 0000000000..de5c72f659 --- /dev/null +++ b/fpdfsdk/fpdfeditimg.cpp @@ -0,0 +1,83 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "public/fpdf_edit.h" + +#include "fpdfsdk/include/fsdk_define.h" + +DLLEXPORT FPDF_PAGEOBJECT STDCALL +FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document) { + CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); + if (!pDoc) + return nullptr; + CPDF_ImageObject* pImageObj = new CPDF_ImageObject; + CPDF_Image* pImg = new CPDF_Image(pDoc); + pImageObj->m_pImage = pImg; + return pImageObj; +} + +DLLEXPORT FPDF_BOOL STDCALL +FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, + int nCount, + FPDF_PAGEOBJECT image_object, + FPDF_FILEACCESS* fileAccess) { + if (!image_object || !fileAccess || !pages) + return FALSE; + + IFX_FileRead* pFile = new CPDF_CustomAccess(fileAccess); + CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object; + pImgObj->m_GeneralState.GetModify(); + for (int index = 0; index < nCount; index++) { + CPDF_Page* pPage = CPDFPageFromFPDFPage(pages[index]); + if (!pPage) + continue; + pImgObj->m_pImage->ResetCache(pPage, NULL); + } + pImgObj->m_pImage->SetJpegImage(pFile); + + return TRUE; +} + +DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, + double a, + double b, + double c, + double d, + double e, + double f) { + if (!image_object) + return FALSE; + CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object; + pImgObj->m_Matrix.a = (FX_FLOAT)a; + pImgObj->m_Matrix.b = (FX_FLOAT)b; + pImgObj->m_Matrix.c = (FX_FLOAT)c; + pImgObj->m_Matrix.d = (FX_FLOAT)d; + pImgObj->m_Matrix.e = (FX_FLOAT)e; + pImgObj->m_Matrix.f = (FX_FLOAT)f; + pImgObj->CalcBoundingBox(); + return TRUE; +} + +DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages, + int nCount, + FPDF_PAGEOBJECT image_object, + FPDF_BITMAP bitmap) { + if (!image_object || !bitmap || !pages) + return FALSE; + CFX_DIBitmap* pBmp = NULL; + pBmp = (CFX_DIBitmap*)bitmap; + CPDF_ImageObject* pImgObj = (CPDF_ImageObject*)image_object; + pImgObj->m_GeneralState.GetModify(); + for (int index = 0; index < nCount; index++) { + CPDF_Page* pPage = CPDFPageFromFPDFPage(pages[index]); + if (!pPage) + continue; + pImgObj->m_pImage->ResetCache(pPage, NULL); + } + pImgObj->m_pImage->SetImage(pBmp, FALSE); + pImgObj->CalcBoundingBox(); + return TRUE; +} |