mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-22 12:32:37 +00:00
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:
parent
0b1a148b9c
commit
cf538a33c2
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -65,6 +65,9 @@ struct _GimpPaletteClass
|
|||
GType gimp_palette_get_type (void) G_GNUC_CONST;
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue