XImageCollection.h
1 #pragma once
2 // Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved.
3 
4 #include <system/collections/ienumerator.h>
5 #include <system/collections/icollection.h>
6 #include <system/array.h>
7 #include <cstdint>
8 
9 #include "Aspose.PDF.Cpp/aspose_pdf_api_defs.h"
10 
11 namespace Aspose
12 {
13 namespace Imaging
14 {
15 namespace FileFormats
16 {
17 namespace Tiff
18 {
19 namespace Enums
20 {
21 enum class TiffCompressions : uint16_t;
22 } // namespace Enums
23 class TiffImage;
24 } // namespace Tiff
25 } // namespace FileFormats
26 } // namespace Imaging
27 namespace Pdf
28 {
29 namespace Annotations
30 {
31 class Redaction;
32 class StampAnnotation;
33 } // namespace Annotations
34 class ApsToPdfGraphicStateBuilder;
35 class ArtifactCollection;
36 namespace Collections
37 {
38 template <typename, typename> class AsposeHashDictionary;
39 } // namespace Collections
40 class DataUtils;
41 namespace Engine
42 {
43 namespace Data
44 {
45 class IPdfDataStream;
46 class IPdfDictionary;
47 class IPdfObject;
48 class ITrailerable;
49 } // namespace Data
50 namespace IO
51 {
52 namespace ConvertStrategies
53 {
54 class PdfConvertStrategy;
55 class TransparentContentRemoval;
56 } // namespace ConvertStrategies
57 } // namespace IO
58 } // namespace Engine
59 namespace Facades
60 {
61 class PdfFileMend;
62 } // namespace Facades
63 enum class ImageFilterType;
64 class ImagePlacementAbsorber;
65 class ImageStamp;
66 namespace Interchange
67 {
68 class ContentSequenceXObject;
69 } // namespace Interchange
70 namespace OFD
71 {
72 namespace Converters
73 {
74 class PageBlockConverter;
75 } // namespace Converters
76 } // namespace OFD
77 namespace Optimization
78 {
79 class ImageCompressor;
80 class ImageCompressor2;
81 } // namespace Optimization
82 class Page;
83 class Resources;
84 class RgbToDeviceGrayConversionStrategy;
85 namespace Tests
86 {
87 class RegressionTests_v11_6;
88 class RegressionTests_v19_5;
89 class RegressionTests_v20_07;
90 class RegressionTests_v20_10;
91 class RegressionTests_v8_1;
92 } // namespace Tests
93 class XForm;
94 class XImage;
95 class XImageAddingParams;
96 } // namespace Pdf
97 } // namespace Aspose
98 namespace System
99 {
100 namespace Collections
101 {
102 namespace Generic
103 {
104 template <typename> class List;
105 } // namespace Generic
106 } // namespace Collections
107 namespace Drawing
108 {
109 class Bitmap;
110 class Image;
111 namespace Imaging
112 {
113 class ColorPalette;
114 class ImageCodecInfo;
115 class ImageFormat;
116 enum class PixelFormat;
117 } // namespace Imaging
118 } // namespace Drawing
119 namespace IO
120 {
121 class Stream;
122 } // namespace IO
123 } // namespace System
124 
125 namespace Aspose {
126 
127 namespace Pdf {
128 
133 {
137  KeepContents,
141  None,
146  ForceDelete,
150  Check
151 };
152 
156 class ASPOSE_PDF_SHARED_CLASS XImageCollection final : public System::Collections::Generic::ICollection<System::SharedPtr<Aspose::Pdf::XImage>>
157 {
158  typedef XImageCollection ThisType;
160 
161  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
162  ASPOSE_PDF_SHARED_RTTI_INFO_DECL();
163 
164  friend class Aspose::Pdf::Interchange::ContentSequenceXObject;
165  friend class Aspose::Pdf::Engine::IO::ConvertStrategies::PdfConvertStrategy;
166  friend class Aspose::Pdf::Optimization::ImageCompressor;
167  friend class Aspose::Pdf::Optimization::ImageCompressor2;
169  friend class Aspose::Pdf::Annotations::Redaction;
173  friend class Aspose::Pdf::Page;
176  friend class Aspose::Pdf::XForm;
177  friend class Aspose::Pdf::XImage;
178  friend class Aspose::Pdf::DataUtils;
179  friend class Aspose::Pdf::ApsToPdfGraphicStateBuilder;
181  friend class Aspose::Pdf::Engine::IO::ConvertStrategies::TransparentContentRemoval;
182  friend class Aspose::Pdf::OFD::Converters::PageBlockConverter;
183  friend class Aspose::Pdf::Tests::RegressionTests_v8_1;
184  friend class Aspose::Pdf::Tests::RegressionTests_v11_6;
185  friend class Aspose::Pdf::Tests::RegressionTests_v19_5;
186  friend class Aspose::Pdf::Tests::RegressionTests_v20_07;
187  friend class Aspose::Pdf::Tests::RegressionTests_v20_10;
188 
189 protected:
190 
192  {
193  typedef ThresholdMaskParameters ThisType;
194  typedef System::Object BaseType;
195 
196  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
197  RTTI_INFO_DECL();
198 
199  public:
200 
201  uint8_t get_BlackOverWhiteThreshold() const;
202  void set_BlackOverWhiteThreshold(uint8_t value);
203  uint8_t get_WhiteOverBlackThreshold() const;
204  void set_WhiteOverBlackThreshold(uint8_t value);
205  uint8_t get_BitMask() const;
206  void set_BitMask(uint8_t value);
207 
209 
210  private:
211 
212  uint8_t _blackOverWhiteThreshold;
213  uint8_t _whiteOverBlackThreshold;
214  uint8_t _bitMask;
215 
216  };
217 
218 
219 private:
220 
221  class ImagesEnumerator : public System::Collections::Generic::IEnumerator<System::SharedPtr<Aspose::Pdf::XImage>>
222  {
223  typedef ImagesEnumerator ThisType;
225 
226  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
227  RTTI_INFO_DECL();
228  CODEPORTING_ENUMERATOR_ITERATOR_METHODS_DECLARATION(CODEPORTING_ARGS(System::SharedPtr<Aspose::Pdf::XImage>), CODEPORTING_NO_API_KEYWORD);
229 
230  public:
231 
232  const System::SharedPtr<Aspose::Pdf::XImage>& get_Current() const override;
233 
235 
236  bool MoveNext() override;
237  void Reset() override;
238  void Dispose() override;
239 
240  private:
241 
244  int32_t _cursor;
245 
246  bool MoveNextImplementation();
247  System::SharedPtr<Aspose::Pdf::XImage>* GetCurrentElementPointer();
248 
249  };
250 
251 
252 public:
253 
257  ASPOSE_PDF_SHARED_API int32_t get_Count() const override;
261  ASPOSE_PDF_SHARED_API bool get_IsSynchronized();
265  ASPOSE_PDF_SHARED_API System::SharedPtr<System::Object> get_SyncRoot() const;
269  //[Obfuscation(Feature = "virtualization", Exclude = false)]
270  ASPOSE_PDF_SHARED_API System::ArrayPtr<System::String> get_Names();
274  ASPOSE_PDF_SHARED_API bool get_IsReadOnly() const override;
275 
281  ASPOSE_PDF_SHARED_API System::String AddWithName(System::SharedPtr<Aspose::Pdf::XImage> image);
287  ASPOSE_PDF_SHARED_API System::String Add(System::SharedPtr<System::IO::Stream> image);
294  ASPOSE_PDF_SHARED_API System::String Add(System::SharedPtr<System::IO::Stream> image, Aspose::Pdf::ImageFilterType filterType);
300  ASPOSE_PDF_SHARED_API void Add(System::SharedPtr<System::IO::Stream> image, int32_t quality);
305  ASPOSE_PDF_SHARED_API void Delete(int32_t index);
311  ASPOSE_PDF_SHARED_API void Delete(int32_t index, Aspose::Pdf::ImageDeleteAction action);
316  ASPOSE_PDF_SHARED_API void Delete(System::String name);
322  ASPOSE_PDF_SHARED_API void Delete(System::String name, Aspose::Pdf::ImageDeleteAction action);
326  ASPOSE_PDF_SHARED_API void Delete();
337  ASPOSE_PDF_SHARED_API void CopyTo(System::ArrayPtr<System::SharedPtr<Aspose::Pdf::XImage>> array, int32_t index) override;
343  ASPOSE_PDF_SHARED_API void Replace(int32_t index, System::SharedPtr<System::IO::Stream> stream);
351  ASPOSE_PDF_SHARED_API void Replace(int32_t index, System::SharedPtr<System::IO::Stream> stream, int32_t quality, bool isBlackAndWhite);
358  ASPOSE_PDF_SHARED_API void Replace(int32_t index, System::SharedPtr<System::IO::Stream> stream, int32_t quality);
359 
365  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::XImage> idx_get(int32_t index);
371  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::XImage> idx_get(System::String name);
372 
378  ASPOSE_PDF_SHARED_API System::String GetImageName(System::SharedPtr<Aspose::Pdf::XImage> image);
382  ASPOSE_PDF_SHARED_API void Clear() override;
388  ASPOSE_PDF_SHARED_API bool Contains(const System::SharedPtr<Aspose::Pdf::XImage>& item) const override;
394  ASPOSE_PDF_SHARED_API bool Remove(const System::SharedPtr<Aspose::Pdf::XImage>& item) override;
395 
396 protected:
397 
399 
406  System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfObject> AddOrReplace(int32_t index, System::SharedPtr<System::IO::Stream> stream, int32_t quality, bool isBlackWhite, Aspose::Pdf::ImageFilterType filterType, uint8_t bitMask, bool isMasked);
407  System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfObject> AddOrReplaceGrayScaled(int32_t index, System::SharedPtr<System::IO::Stream> stream, int32_t quality, bool hasSoftMask);
419  System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfObject> Add(System::SharedPtr<System::IO::Stream> stream, int32_t quality, bool isBlackWhite, Aspose::Pdf::ImageFilterType filterType, bool isMasked, System::SharedPtr<System::IO::Stream> predefinedStream = nullptr);
420  System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfObject> Add(System::SharedPtr<System::IO::Stream> stream, int32_t quality, bool isBlackWhite, Aspose::Pdf::ImageFilterType filterType, bool isMasked, System::String& name, System::SharedPtr<System::IO::Stream> predefinedStream = nullptr);
426  bool ContainsName(System::String imageName);
434 
436 
437  MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(XImageCollection, CODEPORTING_ARGS(System::SharedPtr<Aspose::Pdf::Resources> parent, System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfDictionary> xobject));
440  bool HasImage(System::String imgName);
443 
444  virtual ASPOSE_PDF_SHARED_API ~XImageCollection();
445 
446 private:
447 
449  int32_t lastKeyUsed;
450  static uint8_t BinarizationBlackOverWhiteThreshold;
456 
458  static System::ArrayPtr<uint8_t> ReadMonochromeImageData(System::SharedPtr<System::Drawing::Bitmap> image);
462  static void GetColorSpaceAndBitsPerComponent(System::Drawing::Imaging::PixelFormat pixelFormat, System::String& colorSpaceName, int32_t& bitsPerComponent);
463  static void GetColorSpaceAndBitsPerComponentV1(System::Drawing::Imaging::PixelFormat pixelFormat, System::String& colorSpaceName, int32_t& bitsPerComponent);
466  static void SaveImageStream(System::SharedPtr<Aspose::Imaging::FileFormats::Tiff::TiffImage> tiff, System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfDataStream> img, Aspose::Imaging::FileFormats::Tiff::Enums::TiffCompressions compression);
467  static bool CheckTiff(System::SharedPtr<Aspose::Imaging::FileFormats::Tiff::TiffImage> tiff, Aspose::Imaging::FileFormats::Tiff::Enums::TiffCompressions& compression);
469  static void AddCCITTDecodeParams(System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfDataStream> dest, int32_t width, int32_t height, int32_t k, bool blackIs1);
470  static void ReverseColors(System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfDataStream> dest);
471  static void AddXImageDictionaryData(System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfDataStream> img, System::String filterName, System::String colorSpaceName, int32_t bitsPerComponent, int32_t width, int32_t height);
473  static void UpdateXImageDictionaryData(System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfDataStream> img, System::String colorSpaceName, int32_t bitsPerComponent, int32_t width, int32_t height);
474  System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfObject> AddOrReplace(int32_t index, System::SharedPtr<System::IO::Stream> stream, int32_t quality, bool isBlackWhite, Aspose::Pdf::ImageFilterType filterType, bool isMasked, System::SharedPtr<System::IO::Stream> predefinedStream = nullptr);
479  System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfObject> AddOrReplace(int32_t index, System::SharedPtr<System::IO::Stream> stream, int32_t quality, bool isBlackWhite, Aspose::Pdf::ImageFilterType filterType);
480  System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfObject> AddOrReplace(int32_t index, System::SharedPtr<System::IO::Stream> stream, int32_t quality, bool isBlackWhite, Aspose::Pdf::ImageFilterType filterType, System::String& name);
482  bool HasReferences(System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfObject> imageObject);
484  System::SharedPtr<Aspose::Pdf::XImage> get(int32_t index);
486  void CopyToInner(System::ArrayPtr<System::SharedPtr<Aspose::Pdf::XImage>> array, int32_t index);
487  System::String GetUniqueImageName();
493  void Add(const System::SharedPtr<Aspose::Pdf::XImage>& item) override;
494 
495 };
496 
498 {
500  typedef System::Object BaseType;
501 
502  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
503  RTTI_INFO_DECL();
504 
505 public:
506 
507  const System::SharedPtr<System::IO::Stream>& get_ImageStream() const;
508  void set_ImageStream(System::SharedPtr<System::IO::Stream> value);
509  const System::SharedPtr<System::Drawing::Image>& get_Image() const;
510  void set_Image(System::SharedPtr<System::Drawing::Image> value);
511  int32_t get_Quality() const;
512  void set_Quality(int32_t value);
513  bool get_IsBlackWhite() const;
514  void set_IsBlackWhite(bool value);
515  Aspose::Pdf::ImageFilterType get_FilterType() const;
516  void set_FilterType(Aspose::Pdf::ImageFilterType value);
517  bool get_IsMasked() const;
518  void set_IsMasked(bool value);
519  uint8_t get_BitMask() const;
520  void set_BitMask(uint8_t value);
521  bool get_IsGrayScaled() const;
522  void set_IsGrayScaled(bool value);
523  bool get_IsGrayScaleSoftMasked() const;
524  void set_IsGrayScaleSoftMasked(bool value);
525 
527 
528 private:
529 
532  int32_t pr_Quality;
533  bool pr_IsBlackWhite;
534  Aspose::Pdf::ImageFilterType pr_FilterType;
535  bool pr_IsMasked;
536  uint8_t pr_BitMask;
537  bool pr_IsGrayScaled;
538  bool pr_IsGrayScaleSoftMasked;
539 
540 };
541 
542 } // namespace Pdf
543 } // namespace Aspose
544 
545 
Reresents graphic stamp.
Definition: ImageStamp.h:41
String class used across the library. Is a substitute for C# System.String when translating code...
Definition: string.h:121
Represents rubber stamp annotation. This type of annotation displays text or graphics intended to loo...
Definition: StampAnnotation.h:86
Represents a class for adding texts and images on the pages of existing PDF document.
Definition: PdfFileMend.h:49
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:64
Definition: Artifact.h:67
ImageFilterType
Enumeration representing image filter type.
Definition: ImageFilterType.h:11
ImageDeleteAction
Action which performed with image object when image is removed from collection. If image object is re...
Definition: XImageCollection.h:132
PixelFormat
Specifies the color data format of a pixel.
Definition: pixel_format.h:17
Definition: signed_info.h:13
Represents rgb to device gray color spaces conversion strategy.
Definition: RgbToDeviceGrayConversionStrategy.h:46
Class represents artifact collection.
Definition: ArtifactCollection.h:48
Class representing page resources.
Definition: Resources.h:248
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: fwd.h:22
Image will be removed from the collection. If page contents contains references to the image they wil...
Represents an absorber object of image placement objects. Performs search of image usages and provide...
Definition: ImagePlacementAbsorber.h:77
Interface of enumerator which can be used to iterate through some elements. Objects of this class sho...
Definition: BaseOperatorCollection.h:47
Class representing page of PDF document.
Definition: Page.h:364
Definition: AFRelationship.h:4
Class representing image X-Object.
Definition: XImage.h:173
Interface of collection of elements. Objects of this class should only be allocated using System::Mak...
Definition: Form.h:84
List forward declaration.
Definition: Artifact.h:74
Class representing XImage collection.
Definition: XImageCollection.h:156
Class represent XForm
Definition: XForm.h:185
Definition: XImageCollection.h:497
Image will be removed from the collection and image object will be removed from the document...