summaryrefslogtreecommitdiff
path: root/external/pdfium/0003-svx-import-PDF-images-as-BGRA.patch.2
blob: c6dd469c07a96d36dd082e7076899eab961397bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From faeac63865eeb791501d7535f1e7a7c7fc807b04 Mon Sep 17 00:00:00 2001
From: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Date: Tue, 5 Jun 2018 11:29:15 +0200
Subject: [PATCH 03/14] svx: import PDF images as BGRA

---
 pdfium/fpdfsdk/fpdf_editimg.cpp | 20 ++++++++++++++++++++
 pdfium/public/fpdfview.h        |  3 +++
 2 files changed, 23 insertions(+)

diff --git a/pdfium/fpdfsdk/fpdf_editimg.cpp b/pdfium/fpdfsdk/fpdf_editimg.cpp
index fed1581..3f400c7 100644
--- a/pdfium/fpdfsdk/fpdf_editimg.cpp
+++ b/pdfium/fpdfsdk/fpdf_editimg.cpp
@@ -186,6 +186,26 @@ FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object) {
   return FPDFBitmapFromCFXDIBitmap(pBitmap.Leak());
 }
 
+FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV
+FPDFImageObj_GetBitmapBgra(FPDF_PAGEOBJECT image_object) {
+  CPDF_PageObject* pObj = CPDFPageObjectFromFPDFPageObject(image_object);
+  if (!pObj || !pObj->IsImage())
+    return nullptr;
+
+  RetainPtr<CPDF_Image> pImg = pObj->AsImage()->GetImage();
+  if (!pImg)
+    return nullptr;
+
+  RetainPtr<CFX_DIBSource> pSource = pImg->LoadDIBSource();
+  if (!pSource)
+    return nullptr;
+
+  RetainPtr<CFX_DIBitmap> pBitmap;
+  pBitmap = pSource->CloneConvert(FXDIB_Argb);
+
+  return FPDFBitmapFromCFXDIBitmap(pBitmap.Leak());
+}
+
 FPDF_EXPORT unsigned long FPDF_CALLCONV
 FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object,
                                  void* buffer,
diff --git a/pdfium/public/fpdfview.h b/pdfium/public/fpdfview.h
index 0ccd140..b451b9c 100644
--- a/pdfium/public/fpdfview.h
+++ b/pdfium/public/fpdfview.h
@@ -905,6 +905,9 @@ FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_CreateEx(int width,
 //          function; see the list of such formats above.
 FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetFormat(FPDF_BITMAP bitmap);
 
+FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV
+FPDFImageObj_GetBitmapBgra(FPDF_PAGEOBJECT image_object);
+
 // Function: FPDFBitmap_FillRect
 //          Fill a rectangle in a bitmap.
 // Parameters:
-- 
2.16.3