poppler::image Class Reference

A simple representation of image, with direct access to the data. More...

#include "poppler/cpp/poppler-image.h"

List of all members.

Public Types

enum  format_enum {
  format_invalid,
  format_mono,
  format_rgb24,
  format_argb32
}

Public Member Functions

 image (const image &img)
 image (char *idata, int iwidth, int iheight, format_enum iformat)
 image (int iwidth, int iheight, format_enum iformat)
 image ()
 ~image ()
int bytes_per_row () const
const char * const_data () const
image copy (const rect &r=rect()) const
char * data ()
format_enum format () const
int height () const
bool is_valid () const
imageoperator= (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 ()

Detailed Description

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.

Since:
0.16

Member Enumeration Documentation

The possible formats for an image.


Constructor & Destructor Documentation

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.

Parameters:
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.

Parameters:
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.


Member Function Documentation

int image::bytes_per_row (  )  const
Returns:
the number of bytes in each row of the image
const char * image::const_data (  )  const

Access to the image bits.

This function provides const access to the data.

Returns:
the pointer to the first pixel
image image::copy ( const rect r = rect()  )  const

Copy of a slice of the image.

Parameters:
r the sub-area of this image to copy; if empty, the whole image is copied
Returns:
a new image representing the specified part of the current image
char * image::data (  ) 

Access to the image bits.

This function will detach and copy the shared data.

Returns:
the pointer to the first pixel
image::format_enum image::format (  )  const
Returns:
the format of the image
int image::height (  )  const
Returns:
whether the height of the image
bool image::is_valid (  )  const

Image validity check.

Returns:
whether the image is valid.
image & image::operator= ( const image img  ) 

Assignment operator.

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: png
  • JPEG: jpeg, jpg
  • TIFF: tiff
  • PNM: pnm (with Poppler >= 0.18)

If an image format is not supported (check the result of supported_image_formats()), the saving fails.

Returns:
whether the saving succeeded
std::vector< std::string > image::supported_image_formats (  )  [static]
Returns:
a list of the supported image formats
int image::width (  )  const
Returns:
whether the width of the image

Generated on 27 Dec 2015 for Poppler CPP by  doxygen 1.6.1