claw 1.9.0
 
Loading...
Searching...
No Matches
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_typeiterator
 The type of the iterator on the pixels of the image.
 
typedef base_iterator< const image, const pixel_typeconst_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.
 
scanlineoperator[] (unsigned int i)
 Gets a line of the image.
 
const scanlineoperator[] (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 50 of file image.hpp.

Member Typedef Documentation

◆ 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

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.

◆ pixel_type

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

Definition at line 55 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 95 of file image.cpp.

◆ image() [2/3]

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

Constructor. Creates an empty image.

Parameters
wImage's width.
hImage's height.
Precondition
w > 0 and h > 0

Definition at line 113 of file image.cpp.

◆ image() [3/3]

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

Constructor. Reads an image from an input stream.

Parameters
fThe stream to read from.

Definition at line 102 of file image.cpp.

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

◆ begin() [2/2]

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

Get an iterator pointing on the first pixel.

Definition at line 165 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 157 of file image.cpp.

◆ 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 173 of file image.cpp.

◆ 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
rThe area to fill.
cThe color to fill with.

Definition at line 286 of file image.cpp.

◆ flip()

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

Set the image upside down.

Definition at line 275 of file image.cpp.

◆ height()

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

Gets image's height.

Definition at line 141 of file image.cpp.

◆ load()

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

Read the image from a stream.

Parameters
fThe stream to read from.

Definition at line 350 of file image.cpp.

◆ merge() [1/2]

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

Merge an image on the current image.

Parameters
thatThe image to merge.

Definition at line 182 of file image.cpp.

◆ 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
thatThe image to merge.
posThe position of the top left corner.

Definition at line 192 of file image.cpp.

◆ 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
thatThe image to copy.
posThe position of the top left corner.

Definition at line 245 of file image.cpp.

◆ 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 333 of file image.cpp.

◆ swap()

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

Swap the content of two images.

Parameters
thatThe image to swap with.

Definition at line 122 of file image.cpp.

◆ width()

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

Gets image's width.

Definition at line 130 of file image.cpp.


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