claw::graphic::image Class Reference

A class to deal with images. More...

`#include <image.hpp>`

Inheritance diagram for claw::graphic::image:

## Classes

class | scanline
| One line in the image. More...
class | base_iterator
| Base class for iterators on an image. More...

## Public Types

typedef rgba_pixel | pixel_type
| The type representing the colors of the pixels in the image.
typedef base_iterator< image, pixel_type > | iterator
| The type of the iterator on the pixels of the image.
typedef base_iterator< const image, const pixel_type > | const_iterator
| The type of the iterator to access constant pixels.

## Public Member Functions

| image ()
| Constructor. Creates an image without datas.
| image (unsigned int w, unsigned int h)
| Constructor. Creates an empty image.
| image (std::istream &f)
| Constructor. Reads an image from an input stream.
void | swap (image &that)
| Swap the content of two images.
unsigned int | width () const
| Gets image's width.
unsigned int | height () const
| Gets image's height.
scanline & | operator[] (unsigned int i)
| Gets a line of the image.
const scanline & | operator[] (unsigned int i) const
| Gets a line of the image.
iterator | begin ()
| Get an iterator pointing on the first pixel.
iterator | end ()
| Get an iterator pointing just past the last pixel.
const_iterator | begin () const
| Get an iterator pointing on the first pixel.
const_iterator | end () const
| Get an iterator pointing just past the last pixel.
void | merge (const image &that)
| Merge an image on the current image.
void | merge (const image &that, const math::coordinate_2d< int > &pos)
| Merge an image on the current image.
void | partial_copy (const image &that, const math::coordinate_2d< int > &pos)
| Copy an image on the current image.
void | flip ()
| Set the image upside down.
void | fill (const math::rectangle< int > r, const pixel_type &c)
| Fill an area of the image with a given color.
void | set_size (unsigned int w, unsigned int h)
| Set a new size to the image.
void | load (std::istream &f)
| Read the image from a stream.

## Detailed Description

A class to deal with images.

Author
  Julien Jorge

Definition at line 49 of file image.hpp.

## Member Typedef Documentation

## const_iterator

typedef base_iterator<const image, const pixel_type> claw::graphic::image::const_iterator

The type of the iterator to access constant pixels.

The pixels are accessed from the top line to the bottom line, and from the left to the right.

Definition at line 202 of file image.hpp.

## iterator

typedef base_iterator<image, pixel_type> claw::graphic::image::iterator

The type of the iterator on the pixels of the image.

The pixels are accessed from the top line to the bottom line, and from the left to the right.

Definition at line 194 of file image.hpp.

## pixel_type

typedef rgba_pixel claw::graphic::image::pixel_type

The type representing the colors of the pixels in the image.

Definition at line 53 of file image.hpp.

## Constructor & Destructor Documentation

## image() [1/3]

claw::graphic::image::image | ( |  | ) |

Constructor. Creates an image without datas.

Postcondition
  width() == height() == 0

Definition at line 106 of file image.cpp.

Referenced by claw::graphic::bitmap::bitmap(), claw::graphic::bitmap::bitmap(), claw::graphic::gif::gif(), claw::graphic::jpeg::jpeg(), claw::graphic::jpeg::jpeg(), merge(), merge(), partial_copy(), claw::graphic::pcx::pcx(), claw::graphic::pcx::pcx(), claw::graphic::png::png(), claw::graphic::png::png(), claw::graphic::bitmap::reader::reader(), claw::graphic::bitmap::reader::reader(), claw::graphic::gif::reader::reader(), claw::graphic::gif::reader::reader(), claw::graphic::gif::reader::reader(), claw::graphic::jpeg::reader::reader(), claw::graphic::jpeg::reader::reader(), claw::graphic::pcx::reader::reader(), claw::graphic::pcx::reader::reader(), claw::graphic::png::reader::reader(), claw::graphic::png::reader::reader(), claw::graphic::targa::reader::reader(), claw::graphic::targa::reader::reader(), claw::graphic::xbm::reader::reader(), claw::graphic::xbm::reader::reader(), swap(), claw::graphic::targa::targa(), claw::graphic::targa::targa(), claw::graphic::bitmap::writer::writer(), claw::graphic::bitmap::writer::writer(), claw::graphic::jpeg::writer::writer(), claw::graphic::jpeg::writer::writer(), claw::graphic::pcx::writer::writer(), claw::graphic::pcx::writer::writer(), claw::graphic::png::writer::writer(), claw::graphic::png::writer::writer(), claw::graphic::targa::writer::writer(), claw::graphic::targa::writer::writer(), claw::graphic::xbm::writer::writer(), claw::graphic::xbm::writer::writer(), claw::graphic::xbm::xbm(), and claw::graphic::xbm::xbm().

## image() [2/3]

claw::graphic::image::image | ( | unsigned int | w,
|  | unsigned int | h )

Constructor. Creates an empty image.

Parameters

  w | Image's width.
  h | Image's height.

Precondition
  w > 0 and h > 0

Definition at line 128 of file image.cpp.

References set_size().

## image() [3/3]

claw::graphic::image::image | ( | std::istream & | f | ) |

Constructor. Reads an image from an input stream.

Parameters

  f | The stream to read from.

Definition at line 116 of file image.cpp.

References load().

## Member Function Documentation

## begin() [1/2]

claw::graphic::image::iterator claw::graphic::image::begin | ( |  | ) |

Get an iterator pointing on the first pixel.

Definition at line 168 of file image.cpp.

Referenced by merge(), and partial_copy().

## begin() [2/2]

claw::graphic::image::const_iterator claw::graphic::image::begin | ( |  | ) | const

Get an iterator pointing on the first pixel.

Definition at line 186 of file image.cpp.

## end() [1/2]

claw::graphic::image::iterator claw::graphic::image::end | ( |  | ) |

Get an iterator pointing just past the last pixel.

Definition at line 177 of file image.cpp.

References height(), and width().

## end() [2/2]

claw::graphic::image::const_iterator claw::graphic::image::end | ( |  | ) | const

Get an iterator pointing just past the last pixel.

Definition at line 195 of file image.cpp.

References height(), and width().

## fill()

void claw::graphic::image::fill | ( | const math::rectangle< int > | r,
|  | const pixel_type & | c )

Fill an area of the image with a given color.

Parameters

  r | The area to fill.
  c | The color to fill with.

Definition at line 313 of file image.cpp.

References claw::graphic::rgba_pixel::alpha, claw::graphic::rgba_pixel::blue, claw::graphic::rgba_pixel::components, claw::graphic::rgba_pixel::green, height(), claw::math::rectangle< T >::height, claw::math::rectangle< T >::position, claw::graphic::rgba_pixel::red, width(), claw::math::rectangle< T >::width, claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.

## flip()

void claw::graphic::image::flip | ( |  | ) |

Set the image upside down.

Definition at line 301 of file image.cpp.

References height().

## height()

unsigned int claw::graphic::image::height | ( |  | ) | const

Gets image's height.

Definition at line 159 of file image.cpp.

Referenced by end(), end(), fill(), flip(), merge(), partial_copy(), and set_size().

## load()

void claw::graphic::image::load | ( | std::istream & | f | ) |

Read the image from a stream.

Parameters

  f | The stream to read from.

Definition at line 381 of file image.cpp.

Referenced by image().

## merge() [1/2]

void claw::graphic::image::merge | ( | const image & | that | ) |

Merge an image on the current image.

Parameters

  that | The image to merge.

Definition at line 205 of file image.cpp.

References image(), and merge().

Referenced by merge().

## merge() [2/2]

void claw::graphic::image::merge | ( | const image & | that,
|  | const math::coordinate_2d< int > & | pos )

Merge an image on the current image.

Parameters

  that | The image to merge.
  pos | The position of the top left corner.

Definition at line 216 of file image.cpp.

References begin(), height(), claw::math::rectangle< T >::height, image(), claw::math::rectangle< T >::position, width(), claw::math::rectangle< T >::width, claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.

## operator[]() [1/2]

claw::graphic::image::scanline & claw::graphic::image::operator[] | ( | unsigned int | i | ) |

inline

Gets a line of the image.

Definition at line 429 of file image.ipp.

## operator[]() [2/2]

const claw::graphic::image::scanline & claw::graphic::image::operator[] | ( | unsigned int | i | ) | const

inline

Gets a line of the image.

Definition at line 439 of file image.ipp.

## partial_copy()

void claw::graphic::image::partial_copy | ( | const image & | that,
|  | const math::coordinate_2d< int > & | pos )

Copy an image on the current image.

Parameters

  that | The image to copy.
  pos | The position of the top left corner.

Definition at line 271 of file image.cpp.

References begin(), height(), claw::math::rectangle< T >::height, image(), claw::math::rectangle< T >::position, width(), claw::math::rectangle< T >::width, claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.

## set_size()

void claw::graphic::image::set_size | ( | unsigned int | w,
|  | unsigned int | h )

Set a new size to the image.

Remarks
  Image's data won't be lost. If a dimension is set larger than its current value, extra pixels won't be initialized.

Precondition
  (w!=0) && (h!=0)

Definition at line 363 of file image.cpp.

References height().

Referenced by image().

## swap()

void claw::graphic::image::swap | ( | image & | that | ) |

Swap the content of two images.

Parameters

  that | The image to swap with.

Definition at line 138 of file image.cpp.

References image().

Referenced by claw::graphic::gif::swap(), and std::swap().

## width()

unsigned int claw::graphic::image::width | ( |  | ) | const

Gets image's width.

Definition at line 147 of file image.cpp.

Referenced by end(), end(), fill(), merge(), and partial_copy().

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

- image.hpp
- code/image.cpp
- impl/image.ipp