10#include "PdfColorSpace.h"
12#ifdef PODOFO_HAVE_JPEG_LIB
13struct jpeg_decompress_struct;
24enum class PdfImageOrientation : uint8_t
37struct PODOFO_API PdfImageInfo final
41 nullable<PdfFilterList> Filters;
42 unsigned char BitsPerComponent = 0;
43 PdfColorSpaceInitializer ColorSpace;
44 std::vector<double> DecodeArray;
45 PdfImageOrientation Orientation = PdfImageOrientation::TopLeft;
54struct PODOFO_API PdfImageLoadParams final
56 unsigned ImageIndex = 0;
57 PdfImageLoadFlags Flags = PdfImageLoadFlags::None;
67class PODOFO_API PdfImage final :
public PdfXObject
69 friend class PdfXObject;
70 friend class PdfDocument;
77 PdfImage(PdfDocument& doc);
80 void DecodeTo(charbuff& buff,
PdfPixelFormat format,
int scanLineSize = -1)
const;
133 PdfImageInfo
Load(
const std::string_view& filepath,
const PdfImageLoadParams& params = { });
151 void SetChromaKeyMask(int64_t r, int64_t g, int64_t b, int64_t threshold = 0);
159 Rect GetRect()
const override;
174 PdfXObjectForm* getForm()
const override;
184#ifdef PODOFO_HAVE_JPEG_LIB
185 void loadFromJpegInfo(jpeg_decompress_struct& ctx, PdfImageInfo& info);
186 void exportToJpeg(charbuff& buff,
const PdfArray& args)
const;
189 void loadFromJpeg(
const std::string_view& filename, PdfImageInfo& info);
194 void loadFromJpegData(
const unsigned char* data,
size_t len, PdfImageInfo& info);
197#ifdef PODOFO_HAVE_TIFF_LIB
198 void loadFromTiffHandle(
void* handle,
const PdfImageLoadParams& params, charbuff& buffer, PdfImageInfo& info);
201 void loadFromTiff(
const std::string_view& filename,
const PdfImageLoadParams& params, charbuff& buffer, PdfImageInfo& info);
206 void loadFromTiffData(
const unsigned char* data,
size_t len,
const PdfImageLoadParams& params, charbuff& buffer, PdfImageInfo& info);
209#ifdef PODOFO_HAVE_PNG_LIB
210 void loadFromPngHandle(FILE* stream, charbuff& buffer, PdfImageInfo& info);
213 void loadFromPng(
const std::string_view& filename, charbuff& buffer, PdfImageInfo& info);
218 void loadFromPngData(
const unsigned char* data,
size_t len, charbuff& buffer, PdfImageInfo& info);
220 void loadFromPngContent(png_struct_def* png, png_info_def* pngInfo, charbuff& buffer, PdfImageInfo& info);
225 std::unique_ptr<PdfXObjectForm> getTransformation(PdfImageOrientation orientation);
231 unsigned char m_BitsPerComponent;
232 std::unique_ptr<PdfXObjectForm> m_Transformation;
An interface for writing blocks of data to a data source.
Definition OutputStream.h:15
This class represents a PdfArray Use it for all arrays that are written to a PDF file.
Definition PdfArray.h:77
A class that implements methods to sample colors from a scanline buffer.
Definition PdfColorSpaceFilter.h:27
PdfDocument is the core interface for working with PDF documents.
Definition PdfDocument.h:108
A PdfImage object is needed when ever you want to embed an image file into a PDF document.
Definition PdfImage.h:68
void SetChromaKeyMask(int64_t r, int64_t g, int64_t b, int64_t threshold=0)
Set an color/chroma-key mask on an image.
Definition PdfImage.cpp:1402
unsigned GetWidth() const
Get the width of the image when drawn in PDF units.
Definition PdfImage.h:167
PdfImageInfo Load(const std::string_view &filepath, const PdfImageLoadParams ¶ms={ })
Load the image data from a file.
Definition PdfImage.cpp:482
void SetSoftMask(const PdfImage &softmask)
Set a softmask for this image.
Definition PdfImage.cpp:353
void SetDataRaw(const bufferview &buffer, const PdfImageInfo &info)
Set the actual image encoded data from a buffer.
Definition PdfImage.cpp:433
void SetInterpolate(bool value)
Apply an interpolation to the image if the source resolution is lower than the resolution of the outp...
Definition PdfImage.cpp:1415
void SetData(const bufferview &buffer, unsigned width, unsigned height, PdfPixelFormat format, int rowSize=-1)
Set the actual image data from a buffer.
Definition PdfImage.cpp:358
const PdfColorSpaceFilter & GetColorSpace() const
Get the color space of the image.
Definition PdfImage.h:163
unsigned GetHeight() const
Get the height of the image when drawn in PDF units.
Definition PdfImage.h:171
bool TryFetchRawImageInfo(PdfImageInfo &info)
Try read image info, when available as read from internal image codecs (eg.
Definition PdfImage.cpp:228
PdfImageInfo LoadFromBuffer(const bufferview &buffer, const PdfImageLoadParams ¶ms={ })
Load the image data from bytes.
Definition PdfImage.cpp:529
This class represents a PDF indirect Object in memory.
Definition PdfObject.h:31
An normalized rectangle defined by position (left-bottom) and size.
Definition Rect.h:17
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13
PdfPixelFormat
Definition PdfDeclarations.h:349
cspan< char > bufferview
Convenient read-only char buffer span.
Definition basetypes.h:15
std::shared_ptr< const PdfColorSpaceFilter > PdfColorSpaceFilterPtr
Convenience alias for a constant PdfColorSpaceFilter shared ptr.
Definition PdfColorSpaceFilter.h:71
@ None
Do not add a default appearance.
Definition PdfAcroForm.h:16
PdfImageLoadFlags
Definition PdfImage.h:49
@ SkipTransform
Skip applying orientation transform.
Definition PdfImage.h:51
PdfExportFormat
Definition PdfDeclarations.h:224
mspan< char > bufferspan
Convenient writable char buffer span.
Definition basetypes.h:18