Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-10 10:23:45

0001 //========================================================================
0002 //
0003 // AnnotStampImageHelper.h
0004 //
0005 // Copyright (C) 2021 Mahmoud Ahmed Khalil <mahmoudkhalil11@gmail.com>
0006 // Copyright (C) 2021 Albert Astals Cid <aacid@kde.org>
0007 //
0008 // Licensed under GPLv2 or later
0009 //
0010 //========================================================================
0011 
0012 #ifndef ANNOTSTAMPIMAGEHELPER_H
0013 #define ANNOTSTAMPIMAGEHELPER_H
0014 
0015 #include "Object.h"
0016 
0017 class PDFDoc;
0018 
0019 enum ColorSpace
0020 {
0021     DeviceGray,
0022     DeviceRGB,
0023     DeviceCMYK
0024 };
0025 
0026 /**
0027  * This class is used only to load Image XObjects into stamp annotations. It takes in
0028  * the image parameters in its constructors and creates a new Image XObject that gets
0029  * added to the XRef table, so that the annotations that would like to use it be able
0030  * to get its ref number.
0031  *
0032  * To have transparency in the image, you should first try to create the soft
0033  * mask of the image, by creating a AnnotStampImageHelper object giving it the soft
0034  * image data normally. You would then need to pass in the created soft mask Image XObject
0035  * ref to the actual image you'd like to be created by this helper class.
0036  */
0037 class POPPLER_PRIVATE_EXPORT AnnotStampImageHelper
0038 {
0039 public:
0040     AnnotStampImageHelper(PDFDoc *docA, int widthA, int heightA, ColorSpace colorSpace, int bitsPerComponent, char *data, int dataLength);
0041     AnnotStampImageHelper(PDFDoc *docA, int widthA, int heightA, ColorSpace colorSpace, int bitsPerComponent, char *data, int dataLength, Ref softMaskRef);
0042     ~AnnotStampImageHelper() { }
0043 
0044     // Returns the ref to the created Image XObject
0045     Ref getRef() const { return ref; }
0046 
0047     // Returns the width of the image
0048     int getWidth() const { return width; }
0049     // Returns the height of the image
0050     int getHeight() const { return height; }
0051 
0052     // Removes the created Image XObject as well as its soft mask from the XRef Table
0053     void removeAnnotStampImageObject();
0054 
0055 private:
0056     void initialize(PDFDoc *docA, int widthA, int heightA, ColorSpace colorSpace, int bitsPerComponent, char *data, int dataLength);
0057 
0058     PDFDoc *doc;
0059 
0060     Object imgObj;
0061     Ref ref;
0062     Ref sMaskRef;
0063 
0064     int width;
0065     int height;
0066 };
0067 
0068 #endif