[goffice] GOFormat: simplify palette api.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] GOFormat: simplify palette api.
- Date: Sun, 30 Mar 2014 15:31:53 +0000 (UTC)
commit a2e38fd5a89bcfd6ae5e79f1296aef3046a9c78e
Author: Morten Welinder <terra gnome org>
Date: Sun Mar 30 11:31:28 2014 -0400
GOFormat: simplify palette api.
goffice/utils/go-format.c | 14 ++++++++++----
goffice/utils/go-format.h | 2 +-
2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index 5d6fa56..52b9723 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -820,8 +820,15 @@ color_dist (GOColor c1, GOColor c2)
return dr * dr + dg * dg + db * db;
}
+/**
+ * go_format_palette_index_from_color:
+ * @c: color
+ *
+ * Returns: the index of the color closest to the argument color in some
+ * sense.
+ */
int
-go_format_palette_index_from_color (GOColor c, gboolean *exact)
+go_format_palette_index_from_color (GOColor c)
{
int mindist = G_MAXINT;
unsigned ui;
@@ -833,12 +840,11 @@ go_format_palette_index_from_color (GOColor c, gboolean *exact)
if (d < mindist) {
mindist = d;
res = ui;
+ if (d == 0)
+ break;
}
}
- if (exact)
- *exact = (mindist == 0);
-
return res;
}
diff --git a/goffice/utils/go-format.h b/goffice/utils/go-format.h
index 5eec5e0..e7791e6 100644
--- a/goffice/utils/go-format.h
+++ b/goffice/utils/go-format.h
@@ -280,7 +280,7 @@ GOFormatCurrency const *go_format_locale_currency (void);
/*************************************************************************/
GOColor go_format_palette_color_of_index (int i);
-int go_format_palette_index_from_color (GOColor c, gboolean *exact);
+int go_format_palette_index_from_color (GOColor c);
char *go_format_palette_name_of_index (int i);
/*************************************************************************/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]