pdfmm 0.9.20
Public Member Functions | List of all members
mm::PdfImage Class Referencefinal

#include <PdfImage.h>

Inheritance diagram for mm::PdfImage:
mm::PdfXObject

Public Member Functions

 PdfImage (PdfDocument &doc, const std::string_view &prefix={ })
 
void SetImageColorSpace (PdfColorSpace colorSpace, const PdfArray *indexedData=nullptr)
 
PdfColorSpace GetImageColorSpace ()
 
void SetImageICCProfile (PdfInputStream &stream, unsigned colorComponents, PdfColorSpace alternateColorSpace=PdfColorSpace::DeviceRGB)
 
void SetImageSoftmask (const PdfImage &softmask)
 
unsigned GetWidth () const
 
unsigned GetHeight () const
 
void SetImageData (PdfInputStream &stream, unsigned width, unsigned height, unsigned bitsPerComponent)
 
void SetImageData (PdfInputStream &stream, unsigned width, unsigned height, unsigned bitsPerComponent, PdfFilterList &filters)
 
void SetImageDataRaw (PdfInputStream &stream, unsigned width, unsigned height, unsigned bitsPerComponent)
 
void LoadFromFile (const std::string_view &filename)
 
void LoadFromData (const unsigned char *data, size_t len)
 
void SetImageChromaKeyMask (int64_t r, int64_t g, int64_t b, int64_t threshold=0)
 
void SetInterpolate (bool value)
 
- Public Member Functions inherited from mm::PdfXObject
const PdfNameGetIdentifier () const
 

Detailed Description

A PdfImage object is needed when ever you want to embedd 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
SetImageData

Constructor & Destructor Documentation

◆ PdfImage()

mm::PdfImage::PdfImage ( PdfDocument doc,
const std::string_view &  prefix = { } 
)

Constuct a new PdfImage object This is an overloaded constructor.

Parameters
parentparent document
prefixoptional prefix for XObject-name

Member Function Documentation

◆ GetHeight()

unsigned PdfImage::GetHeight ( ) const

Get the height of the image when drawn in PDF units

Returns
the height in PDF units

◆ GetImageColorSpace()

PdfColorSpace PdfImage::GetImageColorSpace ( )

Get the color space of the image

Returns
the color space of the image

◆ GetWidth()

unsigned PdfImage::GetWidth ( ) const

Get the width of the image when drawn in PDF units

Returns
the width in PDF units

◆ LoadFromData()

void PdfImage::LoadFromData ( const unsigned char *  data,
size_t  len 
)

Load the image data from bytes

Parameters
databytes
lennumber of bytes

◆ LoadFromFile()

void PdfImage::LoadFromFile ( const std::string_view &  filename)

Load the image data from a file

Parameters
filename

◆ SetImageChromaKeyMask()

void PdfImage::SetImageChromaKeyMask ( 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)]

◆ SetImageColorSpace()

void PdfImage::SetImageColorSpace ( PdfColorSpace  colorSpace,
const PdfArray indexedData = nullptr 
)

Set the color space of this image. The default value is PdfColorSpace::DeviceRGB.

Parameters
colorSpaceone of PdfColorSpace::DeviceGray, PdfColorSpace::DeviceRGB and PdfColorSpace::DeviceCMYK, PdfColorSpace::Indexed
indexedDatathis parameter is required only for PdfColorSpace::Indexed and it contains string with one number and then color palette, like "/DeviceRGB 15 <000000 00FF00...>" or the string array can be a resource name.
See also
SetImageICCProfile to set an ICC profile instead of a simple colorspace

◆ SetImageData() [1/2]

void PdfImage::SetImageData ( PdfInputStream stream,
unsigned  width,
unsigned  height,
unsigned  bitsPerComponent 
)

Set the actual image data from an input stream

The image data will be flate compressed. If you want no compression or another filter to be applied use the overload of SetImageData which takes a TVecFilters as argument.

Parameters
streamstream supplieding raw image data
widthwidth of the image in pixels
heightheight of the image in pixels
bitsPerComponentbits per color component of the image (depends on the image colorspace you have set but is 8 in most cases)
See also
SetImageData

◆ SetImageData() [2/2]

void PdfImage::SetImageData ( PdfInputStream stream,
unsigned  width,
unsigned  height,
unsigned  bitsPerComponent,
PdfFilterList &  filters 
)

Set the actual image data from an input stream

Parameters
streamstream suplying raw image data
widthwidth of the image in pixels
heightheight of the image in pixels
bitsPerComponentbits per color component of the image (depends on the image colorspace you have set but is 8 in most cases)
filtersthese filters will be applied to compress the image data

◆ SetImageDataRaw()

void PdfImage::SetImageDataRaw ( PdfInputStream stream,
unsigned  width,
unsigned  height,
unsigned  bitsPerComponent 
)

Set the actual image data from an input stream. The data has to be encoded already and an appropriate filters key entry has to be set manually before!

Parameters
streamstream supplieding raw image data
widthwidth of the image in pixels
heightheight of the image in pixels
bitsPerComponentbits per color component of the image (depends on the image colorspace you have set but is 8 in most cases)

◆ SetImageICCProfile()

void PdfImage::SetImageICCProfile ( PdfInputStream stream,
unsigned  colorComponents,
PdfColorSpace  alternateColorSpace = PdfColorSpace::DeviceRGB 
)

Set an ICC profile for this image.

Parameters
streaman input stream from which the ICC profiles data can be read
colorComponentsthe number of colorcomponents of the ICC profile
alternateColorSpacean alternate colorspace to use if the ICC profile cannot be used
See also
SetImageColorSpace to set an colorspace instead of an ICC profile for this image

◆ SetImageSoftmask()

void PdfImage::SetImageSoftmask ( 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

◆ 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