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

palette.cpp

Go to the documentation of this file.
00001 /*
00002         $Id: palette.cpp,v 1.1 2001/03/06 15:09:17 mbn Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 */
00014 
00015 #include "Core/precomp.h"
00016 #include <API/Display/Display/palette.h>
00017 #include <API/Core/IOData/inputsource_provider.h>
00018 #include <API/Core/System/cl_assert.h>
00019 #include <API/Core/IOData/inputsource.h>
00020 
00021 CL_Palette::CL_Palette()
00022 {
00023         num_colors = 256;
00024         palette = new unsigned char[num_colors*3];
00025 }
00026 
00027 CL_Palette::CL_Palette(char *palette_id, CL_InputSourceProvider *provider)
00028 {
00029         CL_InputSource *source = provider->open_source(palette_id);
00030         cl_assert(source != NULL);
00031 
00032         num_colors = source->read_int32();
00033         cl_assert(num_colors > 0 && num_colors < (256*256));
00034 
00035         palette = new unsigned char[num_colors*3];
00036         source->read(palette, num_colors*3);
00037 
00038         delete source;
00039 }
00040 
00041 CL_Palette::CL_Palette(CL_InputSource *source)
00042 {
00043         cl_assert(source != NULL);
00044 
00045         num_colors = source->read_int32();
00046         cl_assert(num_colors > 0 && num_colors < (256*256));
00047 
00048         palette = new unsigned char[num_colors*3];
00049         source->read(palette, num_colors*3);
00050 }
00051 
00052 CL_Palette::CL_Palette(unsigned char *_palette, int _num_colors)
00053 {
00054         num_colors = _num_colors;
00055         palette = new unsigned char[num_colors*3];
00056         memcpy(palette, _palette, num_colors*3);
00057 }
00058 
00059 CL_Palette::~CL_Palette()
00060 {
00061         delete[] palette;
00062 }

Generated at Wed Apr 4 19:54:02 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001