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