Add Palette::findExactMatch() member function

This commit is contained in:
David Capello 2014-06-01 18:08:31 -03:00
parent 2b1e190913
commit f99423dec4
2 changed files with 10 additions and 0 deletions

View File

@ -472,6 +472,15 @@ bool Palette::save(const char *filename) const
return success;
}
int Palette::findExactMatch(int r, int g, int b) const
{
for (int i=0; i<(int)m_colors.size(); ++i)
if (getEntry(i) == rgba(r, g, b, 255))
return i;
return -1;
}
//////////////////////////////////////////////////////////////////////
// Based on Allegro's bestfit_color

View File

@ -101,6 +101,7 @@ namespace raster {
static Palette* load(const char *filename);
bool save(const char *filename) const;
int findExactMatch(int r, int g, int b) const;
int findBestfit(int r, int g, int b, int mask_index = 0) const;
private: