claw::graphic::image Class Reference

A class to deal with images. More...

`#include <image.hpp>`

Inheritance diagram for claw::graphic::image:

## Classes

class | base_iterator
| Base class for iterators on an image. More...
class | scanline
| One line in the 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. More...
typedef base_iterator< const image, const pixel_type > | const_iterator
| The type of the iterator to access constant pixels. More...

## Public Member Functions

| image ()
| Constructor. Creates an image without datas. More...
| image (unsigned int w, unsigned int h)
| Constructor. Creates an empty image. More...
| image (std::istream &f)
| Constructor. Reads an image from an input stream. More...
void | swap (image &that)
| Swap the content of two images. More...
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. More...
void | merge (const image &that, const math::coordinate_2d< int > &pos)
| Merge an image on the current image. More...
void | partial_copy (const image &that, const math::coordinate_2d< int > &pos)
| Copy an image on the current image. More...
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. More...
void | set_size (unsigned int w, unsigned int h)
| Set a new size to the image. More...
void | load (std::istream &f)
| Read the image from a stream. More...

## 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 203 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 195 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.

## 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

## 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 314 of file image.cpp.

References claw::graphic::rgba_pixel::components, height(), and width().

Referenced by flip().

## 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.

Referenced by claw::graphic::gif::reader::load().

## 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 217 of file image.cpp.

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

## 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 272 of file image.cpp.

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

Referenced by merge().

## 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(), claw::graphic::xbm::reader::load(), claw::graphic::png::reader::load(), claw::graphic::jpeg::reader::load(), claw::graphic::bitmap::reader::load(), claw::graphic::pcx::reader::load(), claw::graphic::targa::reader::load(), and claw::graphic::gif::reader::load().

## 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.

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

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

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