Poppler CPP 24.12.0
|
#include "poppler/cpp/poppler-image.h"
Public Types | |
enum | format_enum { format_invalid , format_mono , format_rgb24 , format_argb32 , format_gray8 , format_bgr24 } |
Public Member Functions | |
image () | |
image (char *idata, int iwidth, int iheight, format_enum iformat) | |
image (const image &img) | |
image (int iwidth, int iheight, format_enum iformat) | |
~image () | |
int | bytes_per_row () const |
const char * | const_data () const |
image | copy () const |
char * | data () |
format_enum | format () const |
int | height () const |
bool | is_valid () const |
image & | operator= (const image &img) |
bool | save (const std::string &file_name, const std::string &out_format, int dpi=-1) const |
int | width () const |
Static Public Member Functions | |
static std::vector< std::string > | supported_image_formats () |
A simple representation of image, with direct access to the data.
This class uses implicit sharing for the internal data, so it can be used as value class. This also means any non-const operation will make sure that the data used by current instance is not shared with other instances (ie detaching), copying the shared data.
The possible formats for an image.
format_gray8 and format_bgr24 were introduced in poppler 0.65.
image::image | ( | ) |
Construct an invalid image.
image::image | ( | int | iwidth, |
int | iheight, | ||
image::format_enum | iformat | ||
) |
Construct a new image.
It allocates the storage needed for the image data; if the allocation fails, the image is an invalid one.
iwidth | the width for the image |
iheight | the height for the image |
iformat | the format for the bits of the image |
image::image | ( | char * | idata, |
int | iwidth, | ||
int | iheight, | ||
image::format_enum | iformat | ||
) |
Construct a new image.
It uses the provide data buffer for the image, so you must ensure it remains valid for the whole lifetime of the image.
idata | the buffer to use for the image |
iwidth | the width for the image |
iheight | the height for the image |
iformat | the format for the bits of the image |
image::image | ( | const image & | img | ) |
Copy constructor.
image::~image | ( | ) |
Destructor.
int image::bytes_per_row | ( | ) | const |
const char * image::const_data | ( | ) | const |
Access to the image bits.
This function provides const access to the data.
image image::copy | ( | ) | const |
Copies the image (i.e.
detaches)
char * image::data | ( | ) |
Access to the image bits.
This function will detach and copy the shared data.
image::format_enum image::format | ( | ) | const |
int image::height | ( | ) | const |
bool image::is_valid | ( | ) | const |
Image validity check.
bool image::save | ( | const std::string & | file_name, |
const std::string & | out_format, | ||
int | dpi = -1 |
||
) | const |
Saves the current image to file.
Using this function it is possible to save the image to the specified file_name
, in the specified out_format
and with a resolution of the specified dpi
.
Image formats commonly supported are:
png
jpeg
, jpg
tiff
pnm
(with Poppler >= 0.18)If an image format is not supported (check the result of supported_image_formats()), the saving fails.
|
static |
int image::width | ( | ) | const |