---
name: "CL_Canvas"
section: "3"
platform: "linux"
package: "clanlib0-common-dev"
version: "0.4.4-8"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/CL_Canvas"
---

# CL\_Canvas(3)

Empty surfaceprovider to be used as a rendering target.

## NAME

CL\_Canvas - Empty surfaceprovider to be used as a rendering target.

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

Inherited from public CL\_SurfaceProvider

## CLASS MEMBERS

- 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**()

  - virtual unsigned int **get\_width**()

  - virtual unsigned int **get\_height**()

  - virtual unsigned int **get\_num\_frames**()

  - virtual unsigned int **get\_red\_mask**()

  - virtual unsigned int **get\_green\_mask**()

  - virtual unsigned int **get\_blue\_mask**()

  - virtual unsigned int **get\_alpha\_mask**()

  - virtual unsigned int **get\_pitch**()

  - virtual bool **is\_indexed**()

  - virtual void **set\_palette**(

  ```
  CL_Palette* palette)
  ```

- virtual CL\_Palette \***get\_palette**()

  - virtual void **set\_src\_colorkey**(

  ```
  unsigned int transcol)
  ```

- virtual bool **uses\_src\_colorkey**()

  - virtual unsigned int **get\_src\_colorkey**()

  - virtual void \***get\_data**()

  - virtual void **lock**()

  - virtual void **unlock**()

  ## MEMBERS WITH DESCRIPTIONS

- 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)
  ```

  ```
  Parameters:
  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
  ```

  ```
  Description:
  ```

  Creates the surface. has to be blitted by the dynamic blitter at the moment

- **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)
  ```

  ```
  Parameters:
  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
  ```

  ```
  Description:
  ```

  Constructs the Canvas.

- virtual **~CL\_Canvas**()

  ```
  Description:
  ```

  Deletes the DynamicProvider and deletes the datawhich was allocated in the constructor

- virtual unsigned int **get\_width**()

  ```
  Description:
  ```

  Returns the width of the surface

- virtual unsigned int **get\_height**()

  ```
  Description:
  ```

  Returns the height of the surface

- virtual unsigned int **get\_num\_frames**()

  ```
  Description:
  ```

  Returns the number of frames (sprites) for this surface

- virtual unsigned int **get\_red\_mask**()

  ```
  Description:
  ```

  Returns the bit mask for red

- virtual unsigned int **get\_green\_mask**()

  ```
  Description:
  ```

  Returns the bit mask for green

- virtual unsigned int **get\_blue\_mask**()

  ```
  Description:
  ```

  Returns the bit mask for blue

- virtual unsigned int **get\_alpha\_mask**()

  ```
  Description:
  ```

  Returns the bit mask for the alpha

- virtual unsigned int **get\_pitch**()

  ```
  Description:
  ```

  returns the pitch of the surface

- virtual bool **is\_indexed**()

  ```
  Description:
  ```

  returns true if the surface uses indexed colorswhich is currently not supported (it alwaysreturns false)

- virtual void **set\_palette**(

  ```
  CL_Palette* palette)
  ```

  ```
  Description:
  ```

  CL\_Canvas doesn't work with PAL8

- virtual CL\_Palette \***get\_palette**()

  ```
  Description:
  ```

  CL\_Canvas doesn't work with PAL8 retval! NULL

- virtual void **set\_src\_colorkey**(

  ```
  unsigned int transcol)
  ```

  ```
  Description:
  ```

  Sets the transparent color

- virtual bool **uses\_src\_colorkey**()

  ```
  Description:
  ```

- virtual unsigned int **get\_src\_colorkey**()

  ```
  Description:
  ```

  Returns the transparent color, which was set in the constructor

- virtual void \***get\_data**()

  ```
  Description:
  ```

  Returns the pointer to the surface data, where youcan copy your data to. It should beonly called between lock() and unlock().

- virtual void **lock**()

  ```
  Description:
  ```

  Locks the surface so that writing to the surfacemay occur.

- virtual void **unlock**()

  ```
  Description:
  ```

  Unlocks the surface.( Call Unlock when all writing to the surface is done )\
   	CL\_Palette\* palette;

## SEE ALSO

All ClanLib API classes can be found in **clanlib (3)**.

## AUTHORS

Originally written by Magnus Norddahl \<*mbn@dark.x.dtu.dk*\> and Martin Starch \<*starch@dark.x.dtu.dk*\>. ClanLib is now developed by the ClanLib Development team as an Open Source project.

The ClanLib man pages was created using the Perceps documentation system (another excellent piece of Open Source software, available at **http://somewhere.in.the.world.org**).

See **clanlib (3)** to find out how to get a full list of contributors and details on how to submit bug reports, comments etc.
