Entire Class Index | Main Class Index | Cross Index | Global Index

# Class CL_PCXProvider

Surface provider that can load PCX files.
Contained in: global
Derived from: CL_SurfaceProvider_Generic
Derived by: none
Group: Display (Surface Providers)

#include <ClanLib/display.h>

### public function member index:

### Construction:

``static` `CL_Surface`*` | `create` | `(`std::string` `handle`, `CL_InputSourceProvider`* `provider`, `bool` `transparent`=false, `unsigned` `char` `trans_col`=0)`;
`` | `CL_PCXProvider` | `(`std::string` `name`, `CL_InputSourceProvider`* `provider`, `bool` `transparent`=false, `unsigned` `char` `trans_col`=0)`;
``virtual`` | `~CL_PCXProvider` | `()`;

### Attributes:

``virtual` `unsigned` `int`` | `get_pitch` | `() `const``;
``virtual` `int`` | `get_translate_x` | `() `const``;
``virtual` `int`` | `get_translate_y` | `() `const``;
``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_depth` | `() `const``;
``virtual` `CL_Palette`*` | `get_palette` | `() `const``;
``virtual` `bool`` | `is_indexed` | `() `const``;
``virtual` `bool`` | `uses_src_colorkey` | `() `const``;
``virtual` `unsigned` `int`` | `get_src_colorkey` | `() `const``;
``virtual` `void`*` | `get_data` | `() `const``;

### Operations:

``virtual` `void`` | `perform_lock` | `()`;
``virtual` `void`` | `perform_unlock` | `()`;
``virtual` `void`` | `read_header` | `(`CL_InputSource`* `_datafile`)`;
``virtual` `void`` | `read_data` | `()`;

## Description:

The PCX decoder has been modified to load most PCX files (instead of just the ones created by Deluxe Paint IIe). It now support 1,2,4,8, or 24 bit files... and has been tested in all but a few situations.
Technically, the implementation cheats in that it doesnt store images with less than 8 bits per pixel in their native format. It simply converts them to PAL8 pixelformat instead of creating other pixelformats.
Also note that the PCX decoder creates more bytes per line than the image is supposed to contain. We rely on the clipping capabilities of ClanLib to take care of that. Also note that some default palettes were defined in the read_header() method. These definitions might be better placed in palette.h. Since the scope of the PCX_Provider rewrite was limited to the provider itself, no files outside of pcx_provider.h and pcx_provider.cpp were modified.
The PCX decoding code was moved to read_data() and read_header() to make it easier to follow the code (called from perform_unlock()).

## Function Member Descriptions:

CL_PCXProvider::CL_PCXProvider - Constructs a surface provider that can read pcx files.
`` `CL_PCXProvider` `(`std::string` `name`, `CL_InputSourceProvider`* `provider`, `bool` `transparent`=false, `unsigned` `char` `trans_col`=0)`;

> name - Name of the pcx file to load.
> provider - Input source provider that delivers the pcx file.
> transparent - True if a color in image should be transparent.
> trans_col - Transparency color used if 'transparent' is true. Defaults to color 0.

CL_PCXProvider::create - Loads the pcx file 'handle' from the inputsource provider 'provider.
Creates a CL_Surface using the pcx image and returns it.
If you just want to load a file, use 'handle' for filename, and set provider to NULL
``static` `CL_Surface`*` `create` `(`std::string` `handle`, `CL_InputSourceProvider`* `provider`, `bool` `transparent`=false, `unsigned` `char` `trans_col`=0)`;

CL_PCXProvider::get_alpha_mask - Get alpha mask
``virtual` `unsigned` `int`` `get_alpha_mask` `() `const``;

CL_PCXProvider::get_blue_mask - Get blue mask
``virtual` `unsigned` `int`` `get_blue_mask` `() `const``;

CL_PCXProvider::get_data - Returns the image data. Provider must be locked before pointer is valid.
``virtual` `void`*` `get_data` `() `const``;

CL_PCXProvider::get_depth - Get depth
``virtual` `unsigned` `int`` `get_depth` `() `const``;

CL_PCXProvider::get_green_mask - Get green mask
``virtual` `unsigned` `int`` `get_green_mask` `() `const``;

CL_PCXProvider::get_height - Returns the height of the image.
``virtual` `unsigned` `int`` `get_height` `() `const``;

CL_PCXProvider::get_num_frames - Returns the number of subsprites in the image.
``virtual` `unsigned` `int`` `get_num_frames` `() `const``;

CL_PCXProvider::get_palette - Returns the palette used by the image. NULL if system palette.
``virtual` `CL_Palette`*` `get_palette` `() `const``;

CL_PCXProvider::get_pitch - Returns the pitch of the image (bytes per line).
``virtual` `unsigned` `int`` `get_pitch` `() `const``;

CL_PCXProvider::get_red_mask - Get red mask
``virtual` `unsigned` `int`` `get_red_mask` `() `const``;

CL_PCXProvider::get_src_colorkey - Returns the transparency color used, -1 if none.
``virtual` `unsigned` `int`` `get_src_colorkey` `() `const``;

CL_PCXProvider::get_translate_x - Returns how many pixels to translate the image (X axis).
``virtual` `int`` `get_translate_x` `() `const``;

CL_PCXProvider::get_translate_y - Returns how many pixels to translate the image (Y axis).
``virtual` `int`` `get_translate_y` `() `const``;

CL_PCXProvider::get_width - Returns the width of the image.
``virtual` `unsigned` `int`` `get_width` `() `const``;

CL_PCXProvider::is_indexed - Is indexed
``virtual` `bool`` `is_indexed` `() `const``;

CL_PCXProvider::perform_lock - Locks the surface provider.
``virtual` `void`` `perform_lock` `()`;

CL_PCXProvider::perform_unlock - Unlocks the surface provider.
``virtual` `void`` `perform_unlock` `()`;

CL_PCXProvider::read_data - Decodes image data
``virtual` `void`` `read_data` `()`;

CL_PCXProvider::read_header - Loads header data into class variables. Called by read_data().
``virtual` `void`` `read_header` `(`CL_InputSource`* `_datafile`)`;

CL_PCXProvider::uses_src_colorkey - Uses src colour key
``virtual` `bool`` `uses_src_colorkey` `() `const``;

CL_PCXProvider::~CL_PCXProvider - PCX Provider destructor
``virtual`` `~CL_PCXProvider` `()`;

## Variable Member Descriptions: