ClanSoft logo
ClanSoft logo
Entire Class Index Main Class Index Cross Index Global Index

Class CL_Canvas

Empty surfaceprovider to be used as a rendering target.
Contained in: global
Derived from: CL_SurfaceProvider
Derived by: none
Group: Display (Surface Providers)

#include <ClanLib/display.h>


public function member index:

Construction:

static CL_Surface* create(int width, int height, int no_sprs = 1, int red_mask = 0xff000000, int green_mask = 0x00ff0000, int blue_mask = 0x0000ff00, int alpha_mask = 0x000000ff, bool use_transcol = false, unsigned int transcol = 0);
CL_Canvas(int width, int height, int no_sprs = 1, int red_mask = 0xff000000, int green_mask = 0x00ff0000, int blue_mask = 0x0000ff00, int alpha_mask = 0x000000ff, bool use_transcol = false, unsigned int transcol = 0);
virtual ~CL_Canvas();

Attributes:

virtual unsigned int get_width() const;
virtual unsigned int get_height() const;
virtual unsigned int get_num_frames() const;
virtual unsigned int get_red_mask() const;
virtual unsigned int get_green_mask() const;
virtual unsigned int get_blue_mask() const;
virtual unsigned int get_alpha_mask() const;
virtual unsigned int get_pitch() const;

Operations:

virtual bool is_indexed() const;
virtual void set_palette(CL_Palette* palette);
virtual CL_Palette* get_palette() const;
virtual void set_src_colorkey(unsigned int transcol);
virtual bool uses_src_colorkey() const;
virtual unsigned int get_src_colorkey() const;
virtual void* get_data() const;
virtual void lock();
virtual void unlock();
 

Description:

CL_Canvas is a surface provider useful to create images at run-time.

When constructed, the surface provider will contain an empty image buffer of the specified dimensions. It is then the intention that the game fills the buffer with data.

There are three ways to do this (and you can mix them as you please):


Lock() the provider, and then call get_data() to get a pointer to the image buffer. Party on it. And then finally unlock() the provider.

Use the drawing primitives available in CL_Target. This includes line drawing, fill rects and clipping.

Use the put_target() function in CL_Surface (create the image from other surfaces).


Function Member Descriptions:

CL_Canvas::CL_Canvas - Constructs the Canvas.
CL_Canvas(int width, int height, int no_sprs = 1, int red_mask = 0xff000000, int green_mask = 0x00ff0000, int blue_mask = 0x0000ff00, int alpha_mask = 0x000000ff, bool use_transcol = false, unsigned int transcol = 0);
width - the width of the surface to be created
height - the height of the surface to be created
no_sprs - the number of sprites the surface will have
red_mask - the bit mask for red
blue_mask - the bit mask for blue
green_mask - the bit mask for green
alpha_mask - the bit mask for the alpha
use_transcol - whether the surface should use source key transparancy
transcol - the (optional) source key color



CL_Canvas::create - Creates the surface.
static CL_Surface* create(int width, int height, int no_sprs = 1, int red_mask = 0xff000000, int green_mask = 0x00ff0000, int blue_mask = 0x0000ff00, int alpha_mask = 0x000000ff, bool use_transcol = false, unsigned int transcol = 0);
width - the width of the surface to be created
height - the height of the surface to be created
no_sprs - the number of sprites the surface will have
red_mask - the bit mask for red
blue_mask - the bit mask for blue
green_mask - the bit mask for green
alpha_mask - the bit mask for the alpha
use_transcol - whether the surface should use source key transparancy
transcol - the (optional) source key color



CL_Canvas::get_alpha_mask - Returns the bit mask for the alpha
virtual unsigned int get_alpha_mask() const;


CL_Canvas::get_blue_mask - Returns the bit mask for blue
virtual unsigned int get_blue_mask() const;


CL_Canvas::get_data - Returns the pointer to the surface data, where you can copy your data to. It should be only called between lock() and unlock().
virtual void* get_data() const;


CL_Canvas::get_green_mask - Returns the bit mask for green
virtual unsigned int get_green_mask() const;


CL_Canvas::get_height - Returns the height of the surface
virtual unsigned int get_height() const;


CL_Canvas::get_num_frames - Returns the number of frames (sprites) for this surface
virtual unsigned int get_num_frames() const;


CL_Canvas::get_palette - CL_Canvas doesn't work with PAL8
virtual CL_Palette* get_palette() const;
Returns - NULL



CL_Canvas::get_pitch - returns the pitch of the surface
virtual unsigned int get_pitch() const;


CL_Canvas::get_red_mask - Returns the bit mask for red
virtual unsigned int get_red_mask() const;


CL_Canvas::get_src_colorkey - Returns the transparent color, which was set in the constructor
virtual unsigned int get_src_colorkey() const;


CL_Canvas::get_width - Returns the width of the surface
virtual unsigned int get_width() const;


CL_Canvas::is_indexed - returns true if the surface uses indexed colors which is currently not supported (it always returns false)
virtual bool is_indexed() const;


CL_Canvas::lock - Locks the surface so that writing to the surface may occur.
virtual void lock();


CL_Canvas::set_palette - CL_Canvas doesn't work with PAL8
virtual void set_palette(CL_Palette* palette);


CL_Canvas::set_src_colorkey - Sets the transparent color
virtual void set_src_colorkey(unsigned int transcol);


CL_Canvas::unlock - Unlocks the surface.
( Call Unlock when all writing to the surface is done )
virtual void unlock();


CL_Canvas::uses_src_colorkey - Uses Src Colourkey
virtual bool uses_src_colorkey() const;


CL_Canvas::~CL_Canvas - Deletes the DynamicProvider and deletes the data
which was allocated in the constructor
virtual ~CL_Canvas();



Variable Member Descriptions: