PoDoFo  1.0.0-dev
Public Member Functions | Friends | List of all members
PoDoFo::PdfImage Class Referencefinal

A PdfImage object is needed when ever you want to embed an image file into a PDF document. More...

#include <PdfImage.h>

Inheritance diagram for PoDoFo::PdfImage:
PoDoFo::PdfXObject

Public Member Functions

void DecodeTo (charbuff &buff, PdfPixelFormat format, int scanLineSize=-1) const
 
void DecodeTo (const bufferspan &buff, PdfPixelFormat format, int scanLineSize=-1) const
 
void DecodeTo (OutputStream &stream, PdfPixelFormat format, int scanLineSize=-1) const
 
charbuff GetDecodedCopy (PdfPixelFormat format)
 
void SetSoftMask (const PdfImage &softmask)
 Set a softmask for this image. More...
 
void SetData (const bufferview &buffer, unsigned width, unsigned height, PdfPixelFormat format, int rowSize=-1)
 Set the actual image data from a buffer. More...
 
void SetData (InputStream &stream, unsigned width, unsigned height, PdfPixelFormat format, int rowSize=-1)
 Set the actual image data from an input stream. More...
 
void SetDataRaw (const bufferview &buffer, const PdfImageInfo &info)
 Set the actual image encoded data from a buffer. More...
 
void SetDataRaw (InputStream &stream, const PdfImageInfo &info)
 Set the actual image encoded data from an input stream. More...
 
void Load (const std::string_view &filepath, unsigned imageIndex=0)
 Load the image data from bytes. More...
 
void LoadFromBuffer (const bufferview &buffer, unsigned imageIndex=0)
 Load the image data from bytes. More...
 
void ExportTo (charbuff &buff, PdfExportFormat format, PdfArray args={}) const
 
void SetChromaKeyMask (int64_t r, int64_t g, int64_t b, int64_t threshold=0)
 Set an color/chroma-key mask on an image. More...
 
void SetInterpolate (bool value)
 Apply an interpolation to the image if the source resolution is lower than the resolution of the output device. More...
 
Rect GetRect () const override
 
const PdfColorSpaceFilterGetColorSpace () const
 Get the color space of the image. More...
 
unsigned GetWidth () const
 Get the width of the image when drawn in PDF units. More...
 
unsigned GetHeight () const
 Get the height of the image when drawn in PDF units. More...
 
- Public Member Functions inherited from PoDoFo::PdfXObject
Matrix GetMatrix () const
 
PdfXObjectType GetType () const
 

Friends

class PdfXObject
 
class PdfDocument
 

Additional Inherited Members

- Static Public Member Functions inherited from PoDoFo::PdfXObject
static bool TryCreateFromObject (PdfObject &obj, std::unique_ptr< PdfXObject > &xobj)
 
static bool TryCreateFromObject (const PdfObject &obj, std::unique_ptr< const PdfXObject > &xobj)
 
template<typename XObjectT >
static bool TryCreateFromObject (PdfObject &obj, std::unique_ptr< XObjectT > &xobj)
 
template<typename XObjectT >
static bool TryCreateFromObject (const PdfObject &obj, std::unique_ptr< const XObjectT > &xobj)
 

Detailed Description

A PdfImage object is needed when ever you want to embed an image file into a PDF document.

The PdfImage object is embedded once and can be drawn as often as you want on any page in the document using PdfPainter

See also
GetImageReference
PdfPainter::DrawImage

Member Function Documentation

◆ GetColorSpace()

const PdfColorSpaceFilter& PoDoFo::PdfImage::GetColorSpace ( ) const
inline

Get the color space of the image.

Returns
the color space of the image

◆ GetHeight()

unsigned PoDoFo::PdfImage::GetHeight ( ) const
inline

Get the height of the image when drawn in PDF units.

Returns
the height in PDF units

◆ GetWidth()

unsigned PoDoFo::PdfImage::GetWidth ( ) const
inline

Get the width of the image when drawn in PDF units.

Returns
the width in PDF units

◆ Load()

void PdfImage::Load ( const std::string_view &  filepath,
unsigned  imageIndex = 0 
)

Load the image data from bytes.

Parameters
imageIndeximage index to be fed to multi image/page formats (eg. TIFF). Ignored by the other formats

◆ LoadFromBuffer()

void PdfImage::LoadFromBuffer ( const bufferview buffer,
unsigned  imageIndex = 0 
)

Load the image data from bytes.

Parameters
imageIndeximage index to be fed to multi image/page formats (eg. TIFF). Ignored by the other formats

◆ SetChromaKeyMask()

void PdfImage::SetChromaKeyMask ( int64_t  r,
int64_t  g,
int64_t  b,
int64_t  threshold = 0 
)

Set an color/chroma-key mask on an image.

The masked color will not be painted, i.e. masked as being transparent.

Parameters
rred RGB value of color that should be masked
ggreen RGB value of color that should be masked
bblue RGB value of color that should be masked
thresholdcolors are masked that are in the range [(r-threshold, r+threshold),(g-threshold, g+threshold),(b-threshold, b+threshold)]

◆ SetData() [1/2]

void PdfImage::SetData ( const bufferview buffer,
unsigned  width,
unsigned  height,
PdfPixelFormat  format,
int  rowSize = -1 
)

Set the actual image data from a buffer.

Parameters
bufferbuffer supplying image data
widthwidth of the image in pixels
heightheight of the image in pixels
formatpixel format of the bitmap
rowSizelength of the row, if negative the default is used

◆ SetData() [2/2]

void PdfImage::SetData ( InputStream stream,
unsigned  width,
unsigned  height,
PdfPixelFormat  format,
int  rowSize = -1 
)

Set the actual image data from an input stream.

Parameters
streamstream supplying raw image data
widthwidth of the image in pixels
heightheight of the image in pixels
formatpixel format of the bitmap
rowSizelength of the row, if negative the default is used

◆ SetDataRaw() [1/2]

void PdfImage::SetDataRaw ( const bufferview buffer,
const PdfImageInfo &  info 
)

Set the actual image encoded data from a buffer.

Parameters
bufferbuffer supplying image data
infoparameters describing the encoded image data

◆ SetDataRaw() [2/2]

void PdfImage::SetDataRaw ( InputStream stream,
const PdfImageInfo &  info 
)

Set the actual image encoded data from an input stream.

Parameters
streamstream supplying encoded image data
infoparameters describing the encoded image data

◆ SetInterpolate()

void PdfImage::SetInterpolate ( bool  value)

Apply an interpolation to the image if the source resolution is lower than the resolution of the output device.

Default is false.

Parameters
valuewhether the image should be interpolated

◆ SetSoftMask()

void PdfImage::SetSoftMask ( const PdfImage softmask)

Set a softmask for this image.

Parameters
pSoftmaska PdfImage pointer to the image, which is to be set as softmask, must be 8-Bit-Grayscale

The documentation for this class was generated from the following files: