##

Image Class Reference
Common

Encapsulates an image. More...

`#include <common/common.hh>`

## Public Types

enum | PixelFormat { UNKNOWN_PIXEL_FORMAT = 0, L_INT8, L_INT16, RGB_INT8, RGBA_INT8, BGRA_INT8, RGB_INT16, RGB_INT32, BGR_INT8, BGR_INT16, BGR_INT32, R_FLOAT16, RGB_FLOAT16, R_FLOAT32, RGB_FLOAT32, BAYER_RGGB8, BAYER_RGGR8, BAYER_GBRG8, BAYER_GRBG8, PIXEL_FORMAT_COUNT }
| Pixel formats enumeration. More...

## Public Member Functions

| Image (const std::string &_filename="")
| Constructor. More...
virtual | ~Image ()
| Destructor. More...
ignition::math::Color | AvgColor ()
| Get the average color. More...
Color | GetAvgColor () GAZEBO_DEPRECATED(9.0)
| Get the average color. More...
unsigned int | GetBPP () const
| Get the size of one pixel in bits. More...
void | GetData (unsigned char **_data, unsigned int &_count) const
| Get the image as a data array. More...
std::string | GetFilename () const
| Get the full filename of the image. More...
unsigned int | GetHeight () const
| Get the height. More...
Color | GetMaxColor () const GAZEBO_DEPRECATED(9.0)
| Get the max color. More...
int | GetPitch () const
Color | GetPixel (unsigned int _x, unsigned int _y) const GAZEBO_DEPRECATED(9.0)
| Get a pixel color value. More...
PixelFormat | GetPixelFormat () const
| Get the pixel format. More...
void | GetRGBData (unsigned char **_data, unsigned int &_count) const
| Get only the RGB data from the image. More...
unsigned int | GetWidth () const
| Get the width. More...
int | Load (const std::string &_filename)
| Load an image. More...
ignition::math::Color | MaxColor () const
| Get the max color. More...
ignition::math::Color | Pixel (const unsigned int _x, const unsigned int _y) const
| Get a pixel color value. More...
void | Rescale (int _width, int _height)
| Rescale the image. More...
void | SavePNG (const std::string &_filename)
| Save the image in PNG format. More...
void | SetFromData (const unsigned char *_data, unsigned int _width, unsigned int _height, Image::PixelFormat _format)
| Set the image from raw data. More...
bool | Valid () const
| Returns whether this is a valid image. More...

## Static Public Member Functions

static Image::PixelFormat | ConvertPixelFormat (const std::string &_format)
| Convert a string to a Image::PixelFormat. More...

## Detailed Description

Encapsulates an image.

## Member Enumeration Documentation

## PixelFormat

enum PixelFormat

Pixel formats enumeration.

Enumerator
UNKNOWN_PIXEL_FORMAT |
L_INT8 |
L_INT16 |
RGB_INT8 |
RGBA_INT8 |
BGRA_INT8 |
RGB_INT16 |
RGB_INT32 |
BGR_INT8 |
BGR_INT16 |
BGR_INT32 |
R_FLOAT16 |
RGB_FLOAT16 |
R_FLOAT32 |
RGB_FLOAT32 |
BAYER_RGGB8 |
BAYER_RGGR8 |
BAYER_GBRG8 |
BAYER_GRBG8 |
PIXEL_FORMAT_COUNT |

## Constructor & Destructor Documentation

## Image()

Image | ( | const std::string & | _filename = `""` | ) |

explicit

Constructor.

Parameters

  [in] | _filename | the path to the image

## ~Image()

virtual ~Image | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## AvgColor()

ignition::math::Color AvgColor | ( |  | ) |

Get the average color.

Returns
  The average color

## ConvertPixelFormat()

static Image::PixelFormat ConvertPixelFormat | ( | const std::string & | _format | ) |

static

Convert a string to a Image::PixelFormat.

Parameters

  [in] | _format | Pixel format string.

See also
  Image::PixelFormatNames

Returns
  Image::PixelFormat

## GetAvgColor()

Color GetAvgColor | ( |  | ) |

Get the average color.

Returns
  The average color

Deprecated:
  See function that returns ignition::math::Color.

## GetBPP()

unsigned int GetBPP | ( |  | ) | const

Get the size of one pixel in bits.

Returns
  The BPP of the image

## GetData()

void GetData | ( | unsigned char ** | _data,
|  | unsigned int & | _count
| ) |  | const

Get the image as a data array.

Parameters

  [out] | _data | Pointer to a nullptr array of char.
  [out] | _count | The resulting data array size

## GetFilename()

std::string GetFilename | ( |  | ) | const

Get the full filename of the image.

Returns
  The filename used to load the image

## GetHeight()

unsigned int GetHeight | ( |  | ) | const

Get the height.

Returns
  The image height

## GetMaxColor()

Color GetMaxColor | ( |  | ) | const

Get the max color.

Returns
  The max color

Deprecated:
  See function that returns ignition::math::Color.

## GetPitch()

int GetPitch | ( |  | ) | const

Returns
  The pitch of the image

## GetPixel()

Color GetPixel | ( | unsigned int | _x,
|  | unsigned int | _y
| ) |  | const

Get a pixel color value.

Parameters

  [in] | _x | Column location in the image
  [in] | _y | Row location in the image

Returns
  The color of the given pixel

Deprecated:
  See function that returns ignition::math::Color.

## GetPixelFormat()

PixelFormat GetPixelFormat | ( |  | ) | const

Get the pixel format.

Returns
  PixelFormat

## GetRGBData()

void GetRGBData | ( | unsigned char ** | _data,
|  | unsigned int & | _count
| ) |  | const

Get only the RGB data from the image.

This will drop the alpha channel if one is present.

Parameters

  [out] | _data | Pointer to a nullptr array of char.
  [out] | _count | The resulting data array size

## GetWidth()

unsigned int GetWidth | ( |  | ) | const

Get the width.

Returns
  The image width

## Load()

int Load | ( | const std::string & | _filename | ) |

Load an image.

Return 0 on success

Parameters

  [in] | _filename | the path to the image file

Returns
  0 when the operation succeeds to open a file or -1 when fails.

## MaxColor()

ignition::math::Color MaxColor | ( |  | ) | const

Get the max color.

Returns
  The max color

## Pixel()

ignition::math::Color Pixel | ( | const unsigned int | _x,
|  | const unsigned int | _y
| ) |  | const

Get a pixel color value.

Parameters

  [in] | _x | Column location in the image
  [in] | _y | Row location in the image

Returns
  The color of the given pixel

## Rescale()

void Rescale | ( | int | _width,
|  | int | _height
| ) |  |

Rescale the image.

Parameters

  [in] | _width | New image width
  [in] | _height | New image height

## SavePNG()

void SavePNG | ( | const std::string & | _filename | ) |

Save the image in PNG format.

Parameters

  [in] | _filename | The name of the saved image

## SetFromData()

void SetFromData | ( | const unsigned char * | _data,
|  | unsigned int | _width,
|  | unsigned int | _height,
|  | Image::PixelFormat | _format
| ) |  |

Set the image from raw data.

Parameters

  [in] | _data | Pointer to the raw image data
  [in] | _width | Width in pixels
  [in] | _height | Height in pixels
  [in] | _format | Pixel format of the provided data

## Valid()

bool Valid | ( |  | ) | const

Returns whether this is a valid image.

Returns
  true if image has a bitmap

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

- Image.hh