Ejemplo n.º 1
0
/*********************************************************************
*
*       LCD_Color2Index_0
*/
unsigned LCD_Color2Index_0(LCD_COLOR Color, const LCD_PHYSPALETTE* pPhysPal) {
  int i;
  int NumEntries = pPhysPal->NumEntries;
  int BestIndex = 0;
  U32 BestDiff = 0xffffff; /* Initialize to worst match */
  const LCD_COLOR* pPalEntry;
/* Try to find perfect match */
  i=0; pPalEntry = &pPhysPal->pPalEntries[0];
  do {
	  if (Color==*(pPalEntry+i))
	    return i;
  } while (++i<NumEntries);
/* Find best match */
  i=0; pPalEntry = &pPhysPal->pPalEntries[0];
  do {
    U32 Diff = GUI_CalcColorDist (Color, *(pPalEntry+i));
    if (Diff < BestDiff) {
      BestDiff  = Diff;
      BestIndex = i;
    }
  } while (++i<NumEntries);
  return BestIndex;
}
Ejemplo n.º 2
0
/*********************************************************************
*
*       GUI_CalcVisColorError
*/
U32 GUI_CalcVisColorError(GUI_COLOR color) {
  return GUI_CalcColorDist(color, GUI_Color2VisColor(color));
}