Canola  0.8.D001
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
image Class Reference

#include <image.h>

Inheritance diagram for image:
image_format image_invert image_monochrome image_threshold image_format_jpeg image_format_png

List of all members.

Public Types

typedef boost::shared_ptr< imagepointer

Public Member Functions

virtual ~image ()
virtual const char * type_name (void) const =0
void copy (const image::pointer &src)
void copy (const image::pointer &src, int ox, int oy)
void overlay (const image::pointer &src, int ox, int oy)
virtual void get_pixel (int x, int y, icon_pixel &value) const =0
icon_pixel get_pixel (int x, int y) const
virtual void set_pixel (int x, int y, const icon_pixel &value)=0
void set_pixel (int x, int y)
virtual void overlay_pixel (int x, int y, const icon_pixel &value)
virtual void overlay_pixel (int x, int y)
virtual unsigned get_width (void) const =0
virtual unsigned get_height (void) const =0
virtual void save_to_file (const std::string &filename) const =0
void get_pen_position (int &x, int &y)
void set_pen_position (int x, int y)
void set_pen_color (const icon_pixel &clr)
void draw_rectangle (int x, int y, int w, int h)
void draw_rectangle (int x, int y, int w, int h, const icon_pixel &clr)
bool same (const image::pointer &rhs) const
icon_pixel average (void) const

Static Public Member Functions

static pointer create_from_file (const std::string &filename)
static bool known_file_extension (const std::string &ext)
static pointer create_blank_from_file (const std::string &filename, int width, int height)

Protected Member Functions

 image ()

Private Member Functions

 image (const image &)
imageoperator= (const image &)

Private Attributes

int pen_x
int pen_y
icon_pixel pen_clr

Detailed Description

The image class is used to represent a generic image.

Definition at line 30 of file image.h.


Member Typedef Documentation

typedef boost::shared_ptr<image> image::pointer

The pointer type is to be sed to point at any image instance.

Reimplemented in image_threshold.

Definition at line 36 of file image.h.


Constructor & Destructor Documentation

image::~image ( ) [virtual]

The destructor.

Definition at line 21 of file image.cc.

image::image ( ) [protected]

The default constructor. May only be used by derived classes.

Definition at line 26 of file image.cc.

image::image ( const image ) [private]

The copy constructor. Do not use.


Member Function Documentation

icon_pixel image::average ( void  ) const

The average method may be used to calculate the average pixel color of an image. It understands transparency.

Definition at line 22 of file average.cc.

void image::copy ( const image::pointer src)

The copy method is used to copy the contents of another image into this image.

The copy is range checked. If the other image is too small, only the portion of this image covered by the other image will be over-written. If the other image is too large, only the portion of the other image which covers this image will be used.

Parameters:
srcThe image to copy.

Definition at line 22 of file copy.cc.

void image::copy ( const image::pointer src,
int  ox,
int  oy 
)

The copy method is used to copy the contents of another image into this image.

The copy is range checked. If the other image is too small, only the portion of this image covered by the other image will be over-written. If the other image is too large, only the portion of the other image which covers this image will be used.

Parameters:
srcThe image to copy.
oxThe X coordinate to start copying TO
oyThe Y coordinate to start copying TO

Definition at line 29 of file copy.cc.

image::pointer image::create_blank_from_file ( const std::string &  filename,
int  width,
int  height 
) [static]

The create_blank_from_file class method is used to examine the file's extension and create a new image capable of writing that format. The file is not written now, you will have to call the save_to_file method for that.

Parameters:
filenameThe name of the file to be written, eventually.
widthThe width of the image in pixels.
heightThe height of the image in pixels.

Definition at line 74 of file create_from_file.cc.

image::pointer image::create_from_file ( const std::string &  filename) [static]

The create_from_file class method is used to read a file and create a new image by reading a file.

Parameters:
filenameThe name of the file to be read

Definition at line 54 of file create_from_file.cc.

void image::draw_rectangle ( int  x,
int  y,
int  w,
int  h 
)

The draw_rectangle method is used to draw a simple aligned rectangle on the image.

Parameters:
xThe left edge of the rectangle, in pixels
yThe top edge of the rectangle, in pixels
wThe width of the rectangle, in pixels
hThe height of the ractangle, in pixels

Definition at line 22 of file rectangle.cc.

void image::draw_rectangle ( int  x,
int  y,
int  w,
int  h,
const icon_pixel clr 
)

The draw_rectangle method is used to draw a simple aligned rectangle on the image.

Parameters:
xThe left edge of the rectangle, in pixels
yThe top edge of the rectangle, in pixels
wThe width of the rectangle, in pixels
hThe height of the ractangle, in pixels
clrThe color to draw the rectangle

Definition at line 29 of file rectangle.cc.

virtual unsigned image::get_height ( void  ) const [pure virtual]

The get_height method may be used to obtain the height of the image, in pixels.

Implemented in image_threshold, image_monochrome, image_invert, and image_format.

void image::get_pen_position ( int &  x,
int &  y 
) [inline]

Definition at line 245 of file image.h.

virtual void image::get_pixel ( int  x,
int  y,
icon_pixel value 
) const [pure virtual]

The get_pixel method may be used to obtain the value of the pixel at the given location.

Parameters:
xThe X cordinate of the pixel
yThe Y cordinate of the pixel
valueThe place where the pixel value is to be stored on return.

Implemented in image_threshold, image_monochrome, image_invert, and image_format.

icon_pixel image::get_pixel ( int  x,
int  y 
) const [inline]

The get_pixel method may be used to obtain the value of the pixel at the given location.

Parameters:
xThe X cordinate of the pixel
yThe Y cordinate of the pixel
Returns:
the pixel value

Definition at line 161 of file image.h.

virtual unsigned image::get_width ( void  ) const [pure virtual]

The get_width method may be used to obtain the width of the image, in pixels.

Implemented in image_threshold, image_monochrome, image_invert, and image_format.

bool image::known_file_extension ( const std::string &  ext) [static]

The known_file_extension class method may be used to determine whether or not the given file extension is a known image type.

Parameters:
extThe file extension, without the dot.
Returns:
true if known, false if not

Definition at line 95 of file create_from_file.cc.

image& image::operator= ( const image ) [private]

The assignment operator. Do not use.

void image::overlay ( const image::pointer src,
int  ox,
int  oy 
)

The overlay method is used to copy the contents of another image into this image, taking the alpha channel of the other image into account.

The operation is range checked. If the other image is too small, only the portion of this image covered by the other image will be over-written. If the other image is too large, only the portion of the other image which covers this image will be used.

Parameters:
srcThe image to copy.
oxThe X coordinate to start copying TO
oyThe Y coordinate to start copying TO
void image::overlay_pixel ( int  x,
int  y,
const icon_pixel value 
) [virtual]

The overlay_pixel method may be used to set the value of the pixel at the given location. Transparency is taken into account if the value has alpha of less than 255.

Parameters:
xThe X coordinate of the pixel to be set
yThe Y coordinate of the pixel to be set
valueThe value of the pixel to be set.

Definition at line 29 of file overlay_pixel.cc.

void image::overlay_pixel ( int  x,
int  y 
) [virtual]

The overlay_pixel method may be used to set the value of the pixel at the given location. The pen_clr is used. Transparency is taken into account if pen_clr has alpha of less than 255.

Parameters:
xThe X coordinate of the pixel to be set
yThe Y coordinate of the pixel to be set

Definition at line 22 of file overlay_pixel.cc.

bool image::same ( const image::pointer rhs) const

The same method is used to determine if two images are the same as each other. This is a size comparison, and only a pixel-by-pixel comparison if the sizes are identical.

virtual void image::save_to_file ( const std::string &  filename) const [pure virtual]

The save_to_file method is used to store the image data into a file on disk.

Parameters:
filenameThe name of the file to be written.

Implemented in image_format, image_threshold, image_monochrome, image_format_jpeg, image_invert, and image_format_png.

void image::set_pen_color ( const icon_pixel clr) [inline]

Definition at line 259 of file image.h.

void image::set_pen_position ( int  x,
int  y 
) [inline]

Definition at line 252 of file image.h.

virtual void image::set_pixel ( int  x,
int  y,
const icon_pixel value 
) [pure virtual]

The set_pixel method may be used to set the value of the pixel at the given location. Transparency is ignored, the pixel becomes exactly as given; if you want transparentcy taken into account, use overlay_pixel. The pen_clr tracks the given value.

Parameters:
xThe X coordinate of the pixel to be set
yThe Y coordinate of the pixel to be set
valueThe value of the pixel to be set.

Implemented in image_threshold, image_monochrome, image_invert, and image_format.

void image::set_pixel ( int  x,
int  y 
)

The set_pixel method may be used to set the value of the pixel at the given location. Transparency is ignored, the pixel becomes exactly as given; if you want transparentcy taken into account, use overlay_pixel. The pen_clr tracks the given value.

Parameters:
xThe X coordinate of the pixel to be set
yThe Y coordinate of the pixel to be set

Definition at line 35 of file image.cc.

virtual const char* image::type_name ( void  ) const [pure virtual]

The type_name method is used to obtain the name of the type of this image format.

Implemented in image_format_jpeg, image_format_png, image_threshold, image_monochrome, and image_invert.


Member Data Documentation

Definition at line 318 of file image.h.

int image::pen_x [private]

Definition at line 316 of file image.h.

int image::pen_y [private]

Definition at line 317 of file image.h.


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