1 /* === S I N F G =========================================================== */
3 ** \brief Template Header
5 ** $Id: palette.h,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === S T A R T =========================================================== */
24 #ifndef __SINFG_PALETTE_H
25 #define __SINFG_PALETTE_H
27 /* === H E A D E R S ======================================================= */
33 /* === M A C R O S ========================================================= */
35 /* === T Y P E D E F S ===================================================== */
37 /* === C L A S S E S & S T R U C T S ======================================= */
49 PaletteItem():weight(1) { }
51 PaletteItem(const Color& color, const String& name, int weight=1):
52 color(color),name(name),weight(weight) { }
54 PaletteItem(const Color& color, int weight=1):
55 color(color),weight(weight) { }
57 void add(const Color& x, int weight=1);
59 bool operator<(const PaletteItem& rhs)const { return weight<rhs.weight; }
60 }; // END of struct PaletteItem
62 class Palette : public std::vector<PaletteItem>
68 Palette(const String& name_);
70 /*! Generates a palette for the given
73 Palette(const Surface& surface, int size=256);
75 iterator find_closest(const Color& color, float* dist=0);
76 const_iterator find_closest(const Color& color, float* dist=0)const;
78 iterator find_heavy();
80 iterator find_light();
82 static Palette grayscale(int steps=16);
84 void save_to_file(const sinfg::String& filename)const;
86 static Palette load_from_file(const sinfg::String& filename);
87 }; // END of class Palette
89 }; // END of namespace sinfg
91 /* === E N D =============================================================== */