added gimp_palette_new_from_colormap().

2005-09-01  Sven Neumann  <sven@gimp.org>

	* app/core/gimppalette.[ch]: added gimp_palette_new_from_colormap().
This commit is contained in:
Sven Neumann 2005-09-01 17:18:26 +00:00 committed by Sven Neumann
parent 0b1a148b9c
commit cf538a33c2
5 changed files with 114 additions and 14 deletions

View file

@ -1,3 +1,7 @@
2005-09-01 Sven Neumann <sven@gimp.org>
* app/core/gimppalette.[ch]: added gimp_palette_new_from_colormap().
2005-09-01 Sven Neumann <sven@gimp.org>
* app/dialogs/quit-dialog.c

View file

@ -314,6 +314,37 @@ gimp_palette_new (const gchar *name)
NULL);
}
GimpData *
gimp_palette_new_from_colormap (const gchar *name,
const guchar *cmap,
gint n_colors)
{
GimpPalette *palette;
gint i;
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (n_colors == 0 || cmap != NULL, NULL);
palette = g_object_new (GIMP_TYPE_PALETTE,
"name", name,
NULL);
for (i = 0; i < n_colors; i++)
{
GimpRGB color;
gchar name[256];
g_snprintf (name, sizeof (name), _("Index %d"), i + 1);
gimp_rgba_set_uchar (&color,
cmap[i*3], cmap[i*3 + 1], cmap[i*3 + 2], 255);
gimp_palette_add_entry (palette, i, name, &color);
}
return GIMP_DATA (palette);
}
GimpData *
gimp_palette_get_standard (void)
{

View file

@ -314,6 +314,37 @@ gimp_palette_new (const gchar *name)
NULL);
}
GimpData *
gimp_palette_new_from_colormap (const gchar *name,
const guchar *cmap,
gint n_colors)
{
GimpPalette *palette;
gint i;
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (n_colors == 0 || cmap != NULL, NULL);
palette = g_object_new (GIMP_TYPE_PALETTE,
"name", name,
NULL);
for (i = 0; i < n_colors; i++)
{
GimpRGB color;
gchar name[256];
g_snprintf (name, sizeof (name), _("Index %d"), i + 1);
gimp_rgba_set_uchar (&color,
cmap[i*3], cmap[i*3 + 1], cmap[i*3 + 2], 255);
gimp_palette_add_entry (palette, i, name, &color);
}
return GIMP_DATA (palette);
}
GimpData *
gimp_palette_get_standard (void)
{

View file

@ -314,6 +314,37 @@ gimp_palette_new (const gchar *name)
NULL);
}
GimpData *
gimp_palette_new_from_colormap (const gchar *name,
const guchar *cmap,
gint n_colors)
{
GimpPalette *palette;
gint i;
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (n_colors == 0 || cmap != NULL, NULL);
palette = g_object_new (GIMP_TYPE_PALETTE,
"name", name,
NULL);
for (i = 0; i < n_colors; i++)
{
GimpRGB color;
gchar name[256];
g_snprintf (name, sizeof (name), _("Index %d"), i + 1);
gimp_rgba_set_uchar (&color,
cmap[i*3], cmap[i*3 + 1], cmap[i*3 + 2], 255);
gimp_palette_add_entry (palette, i, name, &color);
}
return GIMP_DATA (palette);
}
GimpData *
gimp_palette_get_standard (void)
{

View file

@ -62,23 +62,26 @@ struct _GimpPaletteClass
};
GType gimp_palette_get_type (void) G_GNUC_CONST;
GType gimp_palette_get_type (void) G_GNUC_CONST;
GimpData * gimp_palette_new (const gchar *name);
GimpData * gimp_palette_get_standard (void);
GList * gimp_palette_load (const gchar *filename,
GError **error);
GimpData * gimp_palette_new (const gchar *name);
GimpData * gimp_palette_new_from_colormap (const gchar *name,
const guchar *cmap,
gint n_colors);
GimpData * gimp_palette_get_standard (void);
GList * gimp_palette_load (const gchar *filename,
GError **error);
GimpPaletteEntry * gimp_palette_add_entry (GimpPalette *palette,
gint position,
const gchar *name,
const GimpRGB *color);
void gimp_palette_delete_entry (GimpPalette *palette,
GimpPaletteEntry *entry);
GimpPaletteEntry * gimp_palette_add_entry (GimpPalette *palette,
gint position,
const gchar *name,
const GimpRGB *color);
void gimp_palette_delete_entry (GimpPalette *palette,
GimpPaletteEntry *entry);
void gimp_palette_set_columns (GimpPalette *palette,
gint columns);
gint gimp_palette_get_columns (GimpPalette *palette);
void gimp_palette_set_columns (GimpPalette *palette,
gint columns);
gint gimp_palette_get_columns (GimpPalette *palette);
#endif /* __GIMP_PALETTE_H__ */