All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Image.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2020 by PDFTron Systems Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5 #ifndef PDFTRON_H_CPPPDFImage
6 #define PDFTRON_H_CPPPDFImage
7 
8 #include <PDF/GState.h>
9 #include <C/PDF/TRN_Image.h>
10 
11 
12 namespace pdftron {
13  namespace PDF {
14 
22 class Image
23 {
24 public:
25 
88  static Image Create(SDF::SDFDoc& doc, const UString& filename, SDF::Obj encoder_hints = 0);
89 
113  static Image Create(SDF::SDFDoc& doc,
114  const unsigned char* buf,
115  size_t buf_size,
116  int width,
117  int height,
118  int bpc,
119  ColorSpace color_space,
120  SDF::Obj encoder_hints = 0);
121 
127  static Image Create(SDF::SDFDoc& doc,
128  Filters::FilterReader& image_data,
129  int width,
130  int height,
131  int bpc,
132  ColorSpace color_space,
133  SDF::Obj encoder_hints = 0);
134 
140  static Image Create(SDF::SDFDoc& doc,
141  const unsigned char* buf,
142  size_t buf_size,
143  SDF::Obj encoder_hints = 0);
144 
152  static Image Create(SDF::SDFDoc& doc,
153  Filters::Filter image_data,
154  SDF::Obj encoder_hints = 0);
155 
169  #if defined(_WIN32)
170  static Image Create(SDF::SDFDoc& doc, Gdiplus::Bitmap* bmp, SDF::Obj encoder_hints = 0);
171  #endif
172 
194  static Image CreateImageMask(SDF::SDFDoc& doc,
195  const char* buf,
196  size_t buf_size,
197  int width,
198  int height,
199  SDF::Obj encoder_hints = 0);
200 
205  static Image CreateImageMask(SDF::SDFDoc& doc,
206  Filters::FilterReader& image_data,
207  int width,
208  int height,
209  SDF::Obj encoder_hints = 0);
210 
233  static Image CreateSoftMask(SDF::SDFDoc& doc,
234  const char* buf,
235  size_t buf_size,
236  int width,
237  int height,
238  int bpc,
239  SDF::Obj encoder_hints = 0);
240 
246  static Image CreateSoftMask(SDF::SDFDoc& doc,
247  Filters::FilterReader& image_data,
248  int width,
249  int height,
250  int bpc,
251  SDF::Obj encoder_hints = 0);
252 
253  // ------------------------------------------------
254 
256  {
257  e_none, // Input stream is not compressed
258  e_jpeg, // Input image is a JPEG image
259  e_jp2, // Input image is a JP2 (JPEG2000) image
260  e_flate, // Input image is a Flate compressed
261  e_g3, // Input image is a G3 stream
262  e_g4, // Input image is a G4 stream
263  e_ascii_hex // Input image stream compressed using ASCIIHexDecode filter
264  };
265 
285  static Image Create(SDF::SDFDoc& doc,
286  const char* buf,
287  size_t buf_size,
288  int width,
289  int height,
290  int bpc,
291  ColorSpace color_space,
292  InputFilter input_format);
293 
294 
299  static Image Create(SDF::SDFDoc& doc,
300  Filters::FilterReader& image_data,
301  int width,
302  int height,
303  int bpc,
304  ColorSpace color_space,
305  InputFilter input_format);
306 
313  Image(SDF::Obj image_xobject = 0);
314 
315  Image(const Image&);
316  Image& operator=(const Image&);
317 
321  SDF::Obj GetSDFObj () const;
322 
328  bool IsValid() const;
329 
334 
338  int GetImageDataSize() const;
339 
351  #if defined(_WIN32)
352  Gdiplus::Bitmap* GetBitmap() const;
353  #endif
354 
364 
368  int GetImageWidth() const;
369 
373  int GetImageHeight() const;
374 
383  SDF::Obj GetDecodeArray() const;
384 
390  int GetBitsPerComponent() const;
391 
395  int GetComponentNum() const;
396 
400  bool IsImageMask() const;
401 
405  bool IsImageInterpolate() const;
406 
414  SDF::Obj GetMask() const;
415 
431  void SetMask(Image& image_mask);
432 
444  void SetMask(SDF::Obj mask);
445 
452 
462  void SetSoftMask(Image& soft_mask);
463 
468 
488  int Export(const UString& filename);
489 
501  int Export(Filters::FilterWriter& writer);
502 
509  void ExportAsTiff(const UString& filename);
510 
516  void ExportAsTiff(Filters::FilterWriter& writer);
517 
524  void ExportAsPng(const UString& filename);
525 
531  void ExportAsPng(Filters::FilterWriter& writer);
532 
533 
534 // @cond PRIVATE_DOC
535 #ifndef SWIGHIDDEN
536  Image(TRN_Image impl);
537  TRN_Image mp_image;
538 #endif
539 // @endcond
540 };
541 
542 
543 
544 #include <Impl/Image.inl>
545 
546  }; // namespace PDF
547 }; // namespace pdftron
548 
549 #endif // PDFTRON_H_CPPPDFImage
bool IsImageMask() const
void SetMask(Image &image_mask)
void SetSoftMask(Image &soft_mask)
int GetImageWidth() const
Filters::Filter GetImageData() const
int Export(const UString &filename)
Image & operator=(const Image &)
int GetImageDataSize() const
int GetComponentNum() const
SDF::Obj GetMask() const
Image(SDF::Obj image_xobject=0)
SDF::Obj GetSDFObj() const
ColorSpace GetImageColorSpace() const
SDF::Obj GetSoftMask()
SDF::Obj GetDecodeArray() const
bool IsValid() const
int GetImageHeight() const
void ExportAsPng(const UString &filename)
static Image CreateSoftMask(SDF::SDFDoc &doc, const char *buf, size_t buf_size, int width, int height, int bpc, SDF::Obj encoder_hints=0)
void ExportAsTiff(const UString &filename)
static Image Create(SDF::SDFDoc &doc, const UString &filename, SDF::Obj encoder_hints=0)
GState::RenderingIntent GetImageRenderingIntent() const
int GetBitsPerComponent() const
bool IsImageInterpolate() const
static Image CreateImageMask(SDF::SDFDoc &doc, const char *buf, size_t buf_size, int width, int height, SDF::Obj encoder_hints=0)