/src/poppler/poppler/AnnotStampImageHelper.h
Line | Count | Source |
1 | | //======================================================================== |
2 | | // |
3 | | // AnnotStampImageHelper.h |
4 | | // |
5 | | // Copyright (C) 2021 Mahmoud Ahmed Khalil <mahmoudkhalil11@gmail.com> |
6 | | // Copyright (C) 2021, 2026 Albert Astals Cid <aacid@kde.org> |
7 | | // Copyright (C) 2026 Malika Asman <asmanodeny@gmail.com> |
8 | | // Copyright (C) 2026 g10 Code GmbH, Author: Sune Stolborg Vuorela <sune@vuorela.dk> |
9 | | // |
10 | | // Licensed under GPLv2 or later |
11 | | // |
12 | | //======================================================================== |
13 | | |
14 | | #ifndef ANNOTSTAMPIMAGEHELPER_H |
15 | | #define ANNOTSTAMPIMAGEHELPER_H |
16 | | |
17 | | #include "Ref.h" |
18 | | #include "poppler_private_export.h" |
19 | | |
20 | | #include <vector> |
21 | | |
22 | | class PDFDoc; |
23 | | |
24 | | enum ColorSpace |
25 | | { |
26 | | DeviceGray, |
27 | | DeviceRGB, |
28 | | DeviceCMYK |
29 | | }; |
30 | | |
31 | | /** |
32 | | * This class is used only to load Image XObjects into stamp annotations. It takes in |
33 | | * the image parameters in its constructors and creates a new Image XObject that gets |
34 | | * added to the XRef table, so that the annotations that would like to use it be able |
35 | | * to get its ref number. |
36 | | * |
37 | | * To have transparency in the image, you should first try to create the soft |
38 | | * mask of the image, by creating a AnnotStampImageHelper object giving it the soft |
39 | | * image data normally. You would then need to pass in the created soft mask Image XObject |
40 | | * ref to the actual image you'd like to be created by this helper class. |
41 | | */ |
42 | | class POPPLER_PRIVATE_EXPORT AnnotStampImageHelper |
43 | | { |
44 | | public: |
45 | | AnnotStampImageHelper(PDFDoc *docA, int widthA, int heightA, ColorSpace colorSpace, int bitsPerComponent, std::vector<char> &&data); |
46 | | AnnotStampImageHelper(PDFDoc *docA, int widthA, int heightA, ColorSpace colorSpace, int bitsPerComponent, std::vector<char> &&data, Ref softMaskRef); |
47 | | ~AnnotStampImageHelper() = default; |
48 | | |
49 | | // Returns the ref to the created Image XObject |
50 | 0 | Ref getRef() const { return ref; } |
51 | | |
52 | | // Returns the width of the image |
53 | 0 | int getWidth() const { return width; } |
54 | | // Returns the height of the image |
55 | 0 | int getHeight() const { return height; } |
56 | | |
57 | | // Removes the created Image XObject as well as its soft mask from the XRef Table |
58 | | void removeAnnotStampImageObject(); |
59 | | |
60 | | private: |
61 | | PDFDoc *doc; |
62 | | |
63 | | Ref ref; |
64 | | Ref sMaskRef; |
65 | | |
66 | | int width; |
67 | | int height; |
68 | | }; |
69 | | |
70 | | #endif |