1
/* GIMP - The GNU Image Manipulation Program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29
#include <glib-object.h>
30
#include <glib/gstdio.h>
32
#include "libgimpbase/gimpbase.h"
33
#include "libgimpcolor/gimpcolor.h"
35
#include "core-types.h"
37
#include "gimppalette.h"
38
#include "gimppalette-save.h"
40
#include "gimp-intl.h"
44
gimp_palette_save (GimpData *data,
47
GimpPalette *palette = GIMP_PALETTE (data);
51
file = g_fopen (data->filename, "wb");
55
g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
56
_("Could not open '%s' for writing: %s"),
57
gimp_filename_to_utf8 (data->filename),
62
fprintf (file, "GIMP Palette\n");
63
fprintf (file, "Name: %s\n", GIMP_OBJECT (palette)->name);
64
fprintf (file, "Columns: %d\n#\n", CLAMP (palette->n_columns, 0, 256));
66
for (list = palette->colors; list; list = g_list_next (list))
68
GimpPaletteEntry *entry = list->data;
71
gimp_rgb_get_uchar (&entry->color, &r, &g, &b);
73
fprintf (file, "%3d %3d %3d\t%s\n", r, g, b, entry->name);