- wxFAIL_MSG("not implemented");
-
- return 0;
-};
-
-bool wxPalette::GetRGB( int WXUNUSED(pixel),
- unsigned char *WXUNUSED(red),
- unsigned char *WXUNUSED(green),
- unsigned char *WXUNUSED(blue) ) const
+ if (!m_refData) return FALSE;
+
+ int closest = 0;
+ double d,distance = 1000.0; // max. dist is 256
+
+ wxPaletteEntry *e = M_PALETTEDATA->m_entries;
+ for (int i = 0; i < M_PALETTEDATA->m_count; i++, e++)
+ {
+ if ((d = 0.299 * abs(red - e->red) +
+ 0.587 * abs(green - e->green) +
+ 0.114 * abs(blue - e->blue)) < distance) {
+ distance = d;
+ closest = i;
+ }
+ }
+ return closest;
+}
+
+bool wxPalette::GetRGB(int pixel,
+ unsigned char *red,
+ unsigned char *green,
+ unsigned char *blue) const