Adonthell  0.4
image Class Reference

Image manipulation class. More...

#include <image.h>

Inheritance diagram for image:
Collaboration diagram for image:

Public Member Functions

 image ()
 Default constructor.
 image (u_int16 l, u_int16 h, bool mode=true)
 Creates an image with a specified size.
 image (SDL_Surface *s, const SDL_Color &color)
 Create image from SDL_Surface.
 ~image ()
 Destructor.
void resize (u_int16 l, u_int16 h)
 Resize this image.
void clear ()
 Resets the image to it's initial state, that is totally empty.
imageoperator= (const image &src)
 Image copy (similar to copy ()).
void copy (const image &src)
 Synonym of operator = to guarantee its access from Python.
Loading / Saving Methods.

These methods allows you to load and save an image in different formats.

s_int8 get (igzstream &file)
 Loads an image from an opened file, saved in game internal format, with alpha and mask values.
s_int8 load (string fname)
 Loads an image from a file name, in game internal format, with alpha and mask values.
s_int8 get_raw (igzstream &file)
 Loads an image from an opened file, saved in game internal format, without alpha and mask values.
s_int8 load_raw (string fname)
 Loads an image from a file name, in game internal format, without alpha and mask values.
s_int8 get_pnm (SDL_RWops *file)
 Loads an image from an opened file, in PNM format, without alpha and mask values.
s_int8 load_pnm (string fname)
 Loads an image from a file name, in PNM format, without alpha and mask values.
s_int8 put (ogzstream &file) const
 Saves an image into an opened file, in game format, with alpha and mask values.
s_int8 save (string fname) const
 Saves an image into an file, in game format, with alpha and mask values.
s_int8 put_raw (ogzstream &file) const
 Saves an image into an opened file, in game format, without alpha and mask values.
s_int8 save_raw (string fname) const
 Saves an image into an file, in game format, without alpha and mask values.
s_int8 put_pnm (SDL_RWops *file) const
 Saves an image into an opened file, in PNM format, without alpha and mask values.
s_int8 save_pnm (string fname) const
 Saves an image into an file, in PNM format, without alpha and mask values.
Special FX Methods.

Allows you to put fantasy in your image manipulations! Can eventually even be usefull...

void zoom (const surface &src)
 Zooms a surface.
void zoom (const surface &src, u_int16 l, u_int16 h, u_int16 x=0, u_int16 y=0)
 Zooms a surface.
void zoom_to (const surface &src, u_int16 l, u_int16 h, u_int16 x=0, u_int16 y=0)
 Synonym of zoom () to guarantee its access from Python.
void tile (const surface &src)
 Tiles a surface.
void tile (const surface &src, u_int16 l, u_int16 h, u_int16 x=0, u_int16 y=0)
 Tiles a surface.
void tile_to (const surface &src, u_int16 l, u_int16 h, u_int16 x=0, u_int16 y=0)
 Synonym of tile () to guarantee its access from Python.
void brightness (const surface &src, u_int8 cont, bool proceed_mask=false)
 Applies a "brightness" to a surface.
- Public Member Functions inherited from surface
 surface (bool mode=true)
 Default constructor.
virtual ~surface ()
 Destructor.
surfaceoperator= (surface &src)
 Surface copy (similar to copy ()).
void copy (surface &src)
 Synonym of operator = to guarantee its access from Python.
bool is_masked () const
 Returns whether a surface is masked or not.
void set_mask (bool m)
 Sets the mask parameter of the surface.
u_int8 alpha () const
 Returns the alpha value of the surface.
void set_alpha (u_int8 a)
 Sets the alpha value of the surface.
bool is_dbl_mode () const
void set_dbl_mode (bool mode)
void draw (s_int16 x, s_int16 y, const drawing_area *da_opt=NULL, surface *target=NULL) const
 Draw the surface.
void draw (s_int16 x, s_int16 y, s_int16 sx, s_int16 sy, u_int16 sl, u_int16 sh, const drawing_area *da_opt=NULL, surface *target=NULL) const
 Draw a part of the surface.
void draw_part (s_int16 x, s_int16 y, s_int16 sx, s_int16 sy, u_int16 sl, u_int16 sh, const drawing_area *da_opt=NULL, surface *target=NULL) const
 Synonym of draw () to guarantee its access from Python.
void fillrect (s_int16 x, s_int16 y, u_int16 l, u_int16 h, u_int32 col, drawing_area *da_opt=NULL)
 Fills an area of the surface with a given color.
void fillrect (s_int16 x, s_int16 y, u_int16 l, u_int16 h, u_int8 r, u_int8 g, u_int8 b, drawing_area *da_opt=NULL)
 Fills an area of the surface with a given color.
void fillrect_rgb (s_int16 x, s_int16 y, u_int16 l, u_int16 h, u_int8 r, u_int8 g, u_int8 b, drawing_area *da_opt=NULL)
 Synonym of fillrect () to guarantee its access from Python.
void lock () const
 Locks the surface.
void unlock () const
 Unlock the surface after you've worked on it's pixels with the get_pix () and put_pix () methods.
void put_pix (u_int16 x, u_int16 y, u_int32 col)
 Puts a pixel of a given color.
void put_pix (u_int16 x, u_int16 y, u_int8 r, u_int8 g, u_int8 b)
 Puts a pixel of a given color.
void put_pix_rgb (u_int16 x, u_int16 y, u_int8 r, u_int8 g, u_int8 b)
 Synonym of put_pix () to guarantee its access from Python.
void get_pix (u_int16 x, u_int16 y, u_int32 &col) const
 Gets a pixel from the surface.
void get_pix (u_int16 x, u_int16 y, u_int8 &r, u_int8 &g, u_int8 &b) const
 Gets a pixel from a surface.
void get_pix_rgb (u_int16 x, u_int16 y, u_int8 r, u_int8 g, u_int8 b) const
 Synonym of get_pix () to guarantee its access from Python.
- Public Member Functions inherited from drawable
 drawable ()
 Default constructor.
virtual ~drawable ()
 Destructor.
u_int16 length () const
 Returns the length of the drawable.
u_int16 height () const
 Returns the height of the drawable.
virtual bool update ()
 Virtual update function, provided for objects which doesn't need one.
virtual bool input_update ()
 Virtual input update function, provided for objects which doesn't need one.

Additional Inherited Members

- Public Attributes inherited from surface
SDL_Surface * vis
 The actual surface.
- Protected Member Functions inherited from surface
void resize_aux (u_int16 l, u_int16 h)
void double_size (const surface &src)
void half_size (const surface &src)
void get_pix_aux (u_int16 x, u_int16 y, u_int32 &col) const
void put_pix_aux (u_int16 x, u_int16 y, u_int32 col)
- Protected Attributes inherited from surface
bool changed
 Must be set to true when you change the surface by something else than class surface operations.
bool dbl_mode
 double mode

Detailed Description

Image manipulation class.

Designed to work with single images, without having to care about the bit depth. This class is widely used through the game - in fact it handles everything that is displayed on the screen. This class highly relies on surface, so you'll probably want to have a look at it before using image.

Definition at line 41 of file image.h.

Constructor & Destructor Documentation

image::image ( )

Default constructor.

The image created via this constructor is totally empty.

Definition at line 43 of file image.cc.

image::image ( u_int16  l,
u_int16  h,
bool  mode = true 
)

Creates an image with a specified size.

Parameters
llength of the image.
hheight of the image.
modeuse screen::dblmode or set dbl_mode to false
Attention
Not accessible from Python.

Definition at line 47 of file image.cc.

image::image ( SDL_Surface *  s,
const SDL_Color &  color 
)

Create image from SDL_Surface.

Parameters
ssurface

Definition at line 52 of file image.cc.

image::~image ( )

Destructor.

Definition at line 69 of file image.cc.

Member Function Documentation

void image::resize ( u_int16  l,
u_int16  h 
)

Resize this image.

All the content will be lost. If you want to zoom the image you'll want to see the zoom () function instead.

Parameters
lnew length.
hnew height.
See Also
zoom ()

Reimplemented from surface.

Reimplemented in label.

Definition at line 73 of file image.cc.

void image::clear ( )

Resets the image to it's initial state, that is totally empty.

Reimplemented from surface.

Definition at line 78 of file image.cc.

s_int8 image::get ( igzstream file)

Loads an image from an opened file, saved in game internal format, with alpha and mask values.

Parameters
filethe opened file from which to read.
Returns
  • 0 in case of success.
  • -1 in case of error.
See Also
load ()

Definition at line 83 of file image.cc.

s_int8 image::load ( string  fname)

Loads an image from a file name, in game internal format, with alpha and mask values.

Parameters
fnamethe name of the file to load.
Returns
  • 0 in case of success.
  • -1 in case of error.
See Also
get ()

Definition at line 102 of file image.cc.

s_int8 image::get_raw ( igzstream file)

Loads an image from an opened file, saved in game internal format, without alpha and mask values.

Parameters
filethe opened file from which to read.
Returns
  • 0 in case of success.
  • -1 in case of error.
See Also
load_raw ()

Definition at line 114 of file image.cc.

s_int8 image::load_raw ( string  fname)

Loads an image from a file name, in game internal format, without alpha and mask values.

Parameters
fnamethe name of the file to load.
Returns
  • 0 in case of success.
  • -1 in case of error.
See Also
get_raw ()

Definition at line 139 of file image.cc.

s_int8 image::get_pnm ( SDL_RWops *  file)

Loads an image from an opened file, in PNM format, without alpha and mask values.

Parameters
filethe opened file from which to read.
Returns
  • 0 in case of success.
  • -1 in case of error.
See Also
load_pnm ()

Definition at line 152 of file image.cc.

s_int8 image::load_pnm ( string  fname)

Loads an image from a file name, in PNM format, without alpha and mask values.

Parameters
fnamethe name of the file to load.
Returns
  • 0 in case of success.
  • -1 in case of error.
See Also
get_pnm ()

Definition at line 172 of file image.cc.

s_int8 image::put ( ogzstream file) const

Saves an image into an opened file, in game format, with alpha and mask values.

Warning
as the image which is saved comes from a screen's depth surface, it will be slightly altered during the save. If you want a class capable of saving images with full truecolor quality, use image_edit instead.
Parameters
fileopened file where to save into.
Returns
  • 0 in case of success.
  • -1 in case of error.
See Also
save ()

Definition at line 185 of file image.cc.

s_int8 image::save ( string  fname) const

Saves an image into an file, in game format, with alpha and mask values.

Warning
as the image which is saved comes from a screen's depth surface, it will be slightly altered during the save. If you want a class capable of saving images with full truecolor quality, use image_edit instead.
Parameters
fnamefile name where to save into.
Returns
  • 0 in case of success.
  • -1 in case of error.
See Also
put ()

Definition at line 198 of file image.cc.

s_int8 image::put_raw ( ogzstream file) const

Saves an image into an opened file, in game format, without alpha and mask values.

Warning
as the image which is saved comes from a screen's depth surface, it will be slightly altered during the save. If you want a class capable of saving images with full truecolor quality, use image_edit instead.
Parameters
fileopened file where to save into.
Returns
  • 0 in case of success.
  • -1 in case of error.
See Also
save_raw ()

Definition at line 210 of file image.cc.

s_int8 image::save_raw ( string  fname) const

Saves an image into an file, in game format, without alpha and mask values.

Warning
as the image which is saved comes from a screen's depth surface, it will be slightly altered during the save. If you want a class capable of saving images with full truecolor quality, use image_edit instead.
Parameters
fnamefile name where to save into.
Returns
  • 0 in case of success.
  • -1 in case of error.
See Also
put_raw ()

Definition at line 254 of file image.cc.

s_int8 image::put_pnm ( SDL_RWops *  file) const

Saves an image into an opened file, in PNM format, without alpha and mask values.

Warning
as the image which is saved comes from a screen's depth surface, it will be slightly altered during the save. If you want a class capable of saving images with full truecolor quality, use image_edit instead.
Parameters
fileopened file where to save into.
Returns
  • 0 in case of success.
  • -1 in case of error.
See Also
save_pnm ()

Definition at line 266 of file image.cc.

s_int8 image::save_pnm ( string  fname) const

Saves an image into an file, in PNM format, without alpha and mask values.

Warning
as the image which is saved comes from a screen's depth surface, it will be slightly altered during the save. If you want a class capable of saving images with full truecolor quality, use image_edit instead.
Parameters
fnamefile name where to save into.
Returns
  • 0 in case of success.
  • -1 in case of error.
See Also
put_pnm ()

Definition at line 293 of file image.cc.

void image::zoom ( const surface src)
inline

Zooms a surface.

Zoom the content of the src surface into this image, to it's own size.

Parameters
srcthe source image to zoom.

Definition at line 261 of file image.h.

void image::zoom ( const surface src,
u_int16  l,
u_int16  h,
u_int16  x = 0,
u_int16  y = 0 
)

Zooms a surface.

Zoom the content of the src surface into this image, to the size (l, h), at position (x, y) on this image.

Parameters
srcThe source surface to zoom.
llength of the zoomed image.
hheight of the zoomed image.
xX offset on the destination image.
yY offset on the destination image.
Attention
Not available from Python. Use zoom_to () from Python instead.
See Also
zoom_to ()

Definition at line 306 of file image.cc.

void image::zoom_to ( const surface src,
u_int16  l,
u_int16  h,
u_int16  x = 0,
u_int16  y = 0 
)
inline

Synonym of zoom () to guarantee its access from Python.

See Also
zoom ()

Definition at line 290 of file image.h.

void image::tile ( const surface src)
inline

Tiles a surface.

Tiles the src surface so this image is totally filled.

Parameters
sourcethe source surface to tile.

Definition at line 299 of file image.h.

void image::tile ( const surface src,
u_int16  l,
u_int16  h,
u_int16  x = 0,
u_int16  y = 0 
)

Tiles a surface.

Tiles the src surface so the area of this image starting at position (x, y) and (l, h) sized is totally filled.

Parameters
sourcethe source surface to tile.
llength of the area to tile.
hheight of the area to tile.
xX offset on the destination image.
yY offset on the destination image.
Attention
Not available from Python. Use tile_to () from Python instead.
See Also
tile_to ()

Definition at line 340 of file image.cc.

void image::tile_to ( const surface src,
u_int16  l,
u_int16  h,
u_int16  x = 0,
u_int16  y = 0 
)
inline

Synonym of tile () to guarantee its access from Python.

See Also
tile ()

Definition at line 327 of file image.h.

void image::brightness ( const surface src,
u_int8  cont,
bool  proceed_mask = false 
)

Applies a "brightness" to a surface.

Lighten (or darken) the src surface and put the result into this image. This image will be resized to the src surface's size.

Parameters
srcthe source surface to lighten/darken.
contthe "brightness" value, if < 256 the image will be darkened.
Todo:
modify it so when < 128 -> darken, > 128 -> brighten.
Parameters
proceed_maskif set to true, then the translucent pixels will be lightened/darkened too.

Definition at line 352 of file image.cc.

image & image::operator= ( const image src)

Image copy (similar to copy ()).

Attention
Not available from Python. Use copy () from Python instead.
See Also
copy ()

Definition at line 384 of file image.cc.

void image::copy ( const image src)
inline

Synonym of operator = to guarantee its access from Python.

See Also
operator =

Definition at line 362 of file image.h.


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