Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   Namespace Members   Compound Members  

PLMPal Class Reference

Palette resource. More...

#include <PLMPal.hpp>

Inheritance diagram for PLMPal:

Inheritance graph
[legend]
List of all members.

Public Types

enum  { FORMAT_UNK = 0, FORMAT_DEF = 1 }

Public Methods

 PLMPal (u32 number=0)
 PLMPal (const char *filename, int format=PLMResource::FORMAT_UNK)
 PLMPal (PLMResFile &file, int format=PLMResource::FORMAT_UNK)
 PLMPal (const PLMPal *src)
const PLMRGBAColorsData () const
void SetFromRGB (const u8 *src, u32 nb=256, u32 start=0)
void SetFromRGBA (const u8 *src, u32 nb=256, u32 start=0)
u32 Length () const
void Resize (u32 nb)
void SetColor (u32 col, u8 new_r, u8 new_g, u8 new_b, u8 new_a=0)
void SetColor (u32 col, PLMRGBA newcolor)
PLMRGBA GetColor (u32 col)
PLMRGBA operator[] (u32 col)
void GenerateGreyScale (u32 nb=256)
void ToGreyScale ()
virtual bool Load (PLMResFile &src, int format=PLMResource::FORMAT_UNK)
virtual bool Save (PLMResFile &dest, int format=PLMResource::FORMAT_DEF)
virtual u32 MemoryUsed () const
void PrintInfo () const
virtual bool LoadName (const char *filename, int format=FORMAT_UNK)
virtual bool SaveName (const char *filename, int format=FORMAT_DEF)

Detailed Description

Palette resource.

Collection of colors for 8 bits palettized images.


Member Enumeration Documentation

anonymous enum [inherited]
 

Enumeration values:
FORMAT_UNK  unknown format (usually for load)
FORMAT_DEF  default format (usually for save)


Constructor & Destructor Documentation

PLMPal::PLMPal u32    number = 0
 

Create a new palette and pre-allocate number undefined colors.

PLMPal::PLMPal const char *    filename,
int    format = PLMResource::FORMAT_UNK
 

Create a new palette and try to load palette data from the file filename.

PLMPal::PLMPal PLMResFile   file,
int    format = PLMResource::FORMAT_UNK
 

Create a new palette and try to load palette data from the file file.

PLMPal::PLMPal const PLMPal *    src
 

Make a copy of the palette src.


Member Function Documentation

const PLMRGBA * PLMPal::ColorsData   [inline]
 

Get a (read-only!) pointer on color data.

void PLMPal::SetFromRGB const u8 *    src,
u32    nb = 256,
u32    start = 0
 

Copy a sequence of nb colors from a source vector (3 components).

Parameters:
src  a color vector (size = 3*nb, content = RGBRGBRGB...).
nb  number of colors defined in the vector.
start  index in the palette to copy the first color from the vector. Modified colors in the palette range from start to (start + nb - 1). Note: the copy starts at index start in the palette, but at index 0 in the vector.

void PLMPal::SetFromRGBA const u8 *    src,
u32    nb = 256,
u32    start = 0
 

Copy a sequence of nb colors from a source vector (4 components).

Parameters:
src  a color vector (size = 4*nb, content = RGBARGBARGBA...).
nb  number of colors defined in the vector.
start  index in the palette to copy the first color from the vector. Modified colors in the palette range from start to (start + nb - 1). Note: the copy starts at index start in the palette, but at index 0 in the vector.

u32 PLMPal::Length   [inline]
 

Get the current size of the palette (number of colors allocated).

void PLMPal::Resize u32    nb
 

Modify the size of the palette.

Memory is reallocated to exactly match the requested size (nb colors).

void PLMPal::SetColor u32    col,
u8    new_r,
u8    new_g,
u8    new_b,
u8    new_a = 0
[inline]
 

Modify the color at index col.

void PLMPal::SetColor u32    col,
PLMRGBA    newcolor
[inline]
 

Modify the color at index col.

PLMRGBA PLMPal::GetColor u32    col [inline]
 

Get color at index col.

PLMRGBA PLMPal::operator[] u32    col [inline]
 

Get color at index col.

void PLMPal::GenerateGreyScale u32    nb = 256
 

Reset the palette to a shade of nb greys, from black (index 0) to white (index nb-1).

The palette is resized if nb is greater than current length.

void PLMPal::ToGreyScale  
 

Change all colors to the nearest shade of grey.

virtual bool PLMPal::Load PLMResFile   src,
int    format = PLMResource::FORMAT_UNK
[virtual]
 

Load data from the file src, using a specific format.

Implements PLMResource.

virtual bool PLMPal::Save PLMResFile   dest,
int    format = PLMResource::FORMAT_DEF
[virtual]
 

Save data to the file dest, using a specific format.

Implements PLMResource.

virtual u32 PLMPal::MemoryUsed   [virtual]
 

Get the total amount of memory used by this resource.

Implements PLMResource.

void PLMPal::PrintInfo  
 

Print some informations on current log.

virtual bool PLMResource::LoadName const char *    filename,
int    format = FORMAT_UNK
[virtual, inherited]
 

Load data from the file filename.

Reimplemented in PLMMusic.

virtual bool PLMResource::SaveName const char *    filename,
int    format = FORMAT_DEF
[virtual, inherited]
 

Save data to the file filename.


The documentation for this class was generated from the following file:
  • PLMPal.hpp

Generated by Doxygen 1.2.18 on Tue Oct 26 12:07:39 2004.