mirror of https://github.com/GNOME/gimp.git
removed commented-out message.
2004-06-03 Sven Neumann <sven@gimp.org> * app/core/gimpdatafactory.c (gimp_data_factory_load_data): removed commented-out message. * app/core/gimppattern.[ch]: fixed handling of errors and PNG comments in new pattern loader. Renamed functions for consistency with other data loaders. * app/core/gimp.c: changed accordingly.
This commit is contained in:
parent
d088fd3fe1
commit
532d42d012
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2004-06-03 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/core/gimpdatafactory.c (gimp_data_factory_load_data):
|
||||||
|
removed commented-out message.
|
||||||
|
|
||||||
|
* app/core/gimppattern.[ch]: fixed handling of errors and PNG
|
||||||
|
comments in new pattern loader. Renamed functions for consistency
|
||||||
|
with other data loaders.
|
||||||
|
|
||||||
|
* app/core/gimp.c: changed accordingly.
|
||||||
|
|
||||||
2004-06-03 Dave Neary <bolsh@gimp.org>
|
2004-06-03 Dave Neary <bolsh@gimp.org>
|
||||||
|
|
||||||
* app/core/gimp.c:
|
* app/core/gimp.c:
|
||||||
|
|
|
@ -567,20 +567,20 @@ gimp_real_initialize (Gimp *gimp,
|
||||||
|
|
||||||
static const GimpDataFactoryLoaderEntry pattern_loader_entries[] =
|
static const GimpDataFactoryLoaderEntry pattern_loader_entries[] =
|
||||||
{
|
{
|
||||||
{ gimp_pattern_native_load, GIMP_PATTERN_FILE_EXTENSION },
|
{ gimp_pattern_load, GIMP_PATTERN_FILE_EXTENSION },
|
||||||
{ gimp_pattern_load, NULL /* Fallback - try to load all files */ }
|
{ gimp_pattern_load_pixbuf, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GimpDataFactoryLoaderEntry gradient_loader_entries[] =
|
static const GimpDataFactoryLoaderEntry gradient_loader_entries[] =
|
||||||
{
|
{
|
||||||
{ gimp_gradient_load, GIMP_GRADIENT_FILE_EXTENSION },
|
{ gimp_gradient_load, GIMP_GRADIENT_FILE_EXTENSION },
|
||||||
{ gimp_gradient_load, NULL /* fallback loader */ }
|
{ gimp_gradient_load, NULL /* legacy loader */ }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GimpDataFactoryLoaderEntry palette_loader_entries[] =
|
static const GimpDataFactoryLoaderEntry palette_loader_entries[] =
|
||||||
{
|
{
|
||||||
{ gimp_palette_load, GIMP_PALETTE_FILE_EXTENSION },
|
{ gimp_palette_load, GIMP_PALETTE_FILE_EXTENSION },
|
||||||
{ gimp_palette_load, NULL /* fallback loader */ }
|
{ gimp_palette_load, NULL /* legacy loader */ }
|
||||||
};
|
};
|
||||||
|
|
||||||
if (gimp->be_verbose)
|
if (gimp->be_verbose)
|
||||||
|
|
|
@ -579,11 +579,6 @@ gimp_data_factory_load_data (const GimpDatafileData *file_data,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
g_message (_("Trying fallback loader on file '%s' "
|
|
||||||
"with unknown extension."),
|
|
||||||
gimp_filename_to_utf8 (file_data->filename));
|
|
||||||
*/
|
|
||||||
goto insert;
|
goto insert;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,9 +307,9 @@ gimp_pattern_get_standard (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
GimpData *
|
GimpData *
|
||||||
gimp_pattern_native_load (const gchar *filename,
|
gimp_pattern_load (const gchar *filename,
|
||||||
gboolean stingy_memory_use,
|
gboolean stingy_memory_use,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpPattern *pattern = NULL;
|
GimpPattern *pattern = NULL;
|
||||||
gint fd;
|
gint fd;
|
||||||
|
@ -438,95 +438,64 @@ gimp_pattern_native_load (const gchar *filename,
|
||||||
}
|
}
|
||||||
|
|
||||||
GimpData *
|
GimpData *
|
||||||
gimp_pattern_load (const gchar *filename,
|
gimp_pattern_load_pixbuf (const gchar *filename,
|
||||||
gboolean stingy_memory_use,
|
gboolean stingy_memory_use,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpPattern *pattern = NULL;
|
GimpPattern *pattern;
|
||||||
GdkPixbuf *pat_buf = NULL;
|
GdkPixbuf *pixbuf;
|
||||||
guchar *pat_data, *buf_data;
|
guchar *pat_data;
|
||||||
gchar *name = NULL;
|
guchar *buf_data;
|
||||||
gint width,
|
gchar *name;
|
||||||
height,
|
gint width;
|
||||||
bytes,
|
gint height;
|
||||||
rowstride,
|
gint bytes;
|
||||||
i;
|
gint rowstride;
|
||||||
gchar *utf8_filename;
|
gint i;
|
||||||
gsize filename_length;
|
|
||||||
|
|
||||||
g_return_val_if_fail (filename != NULL, NULL);
|
g_return_val_if_fail (filename != NULL, NULL);
|
||||||
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
|
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||||
|
|
||||||
pat_buf = gdk_pixbuf_new_from_file (filename, error);
|
pixbuf = gdk_pixbuf_new_from_file (filename, error);
|
||||||
|
|
||||||
if (*error)
|
if (! pixbuf)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
name = g_strdup (gdk_pixbuf_get_option (pixbuf, "tEXt::Comment"));
|
||||||
|
|
||||||
|
if (! name)
|
||||||
{
|
{
|
||||||
if ((*error)->domain == G_FILE_ERROR)
|
gchar *basename = g_path_get_basename (filename);
|
||||||
g_message (_("Could not open file %s: %s"),
|
|
||||||
gimp_filename_to_utf8 (filename),
|
name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
|
||||||
(*error)->message);
|
|
||||||
else if ((*error)->domain == GDK_PIXBUF_ERROR)
|
g_free (basename);
|
||||||
g_message (_("Filename %s is not a valid GdkPixbuf: %s"),
|
|
||||||
gimp_filename_to_utf8 (filename),
|
|
||||||
(*error)->message);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Read in the pattern name -
|
|
||||||
First try to get a "comment" option, this could be set for pnm,
|
|
||||||
jpeg and gif (it isn't yet)
|
|
||||||
Then try the tEXt option, which is set for pngs,
|
|
||||||
Then fall back to filename
|
|
||||||
*/
|
|
||||||
|
|
||||||
utf8_filename = g_filename_to_utf8 (filename, -1, NULL, &filename_length,
|
|
||||||
error);
|
|
||||||
if (*error)
|
|
||||||
{
|
|
||||||
g_message (_("Problem converting filename to UTF8: %s"),
|
|
||||||
(*error)->message);
|
|
||||||
utf8_filename = "Unnamed";
|
|
||||||
g_clear_error (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
name = g_strdup (gdk_pixbuf_get_option (pat_buf, "comment"));
|
|
||||||
|
|
||||||
if (name == NULL)
|
|
||||||
name = g_strdup (gdk_pixbuf_get_option (pat_buf, "tEXt"));
|
|
||||||
|
|
||||||
if (name == NULL)
|
|
||||||
name = g_strdup (utf8_filename);
|
|
||||||
|
|
||||||
pattern = g_object_new (GIMP_TYPE_PATTERN,
|
pattern = g_object_new (GIMP_TYPE_PATTERN,
|
||||||
"name", name,
|
"name", name,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_free (name);
|
g_free (name);
|
||||||
g_free (utf8_filename);
|
|
||||||
|
|
||||||
width = gdk_pixbuf_get_width (pat_buf);
|
width = gdk_pixbuf_get_width (pixbuf);
|
||||||
height = gdk_pixbuf_get_height (pat_buf);
|
height = gdk_pixbuf_get_height (pixbuf);
|
||||||
bytes = gdk_pixbuf_get_n_channels (pat_buf);
|
bytes = gdk_pixbuf_get_n_channels (pixbuf);
|
||||||
rowstride = gdk_pixbuf_get_rowstride (pat_buf);
|
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||||
|
|
||||||
pattern->mask = temp_buf_new (width, height, bytes,
|
pattern->mask = temp_buf_new (width, height, bytes, 0, 0, NULL);
|
||||||
0, 0, NULL);
|
|
||||||
|
pat_data = gdk_pixbuf_get_pixels (pixbuf);
|
||||||
pat_data = gdk_pixbuf_get_pixels (pat_buf);
|
|
||||||
buf_data = temp_buf_data (pattern->mask);
|
buf_data = temp_buf_data (pattern->mask);
|
||||||
|
|
||||||
for (i = 0; i < height; i++)
|
for (i = 0; i < height; i++)
|
||||||
{
|
{
|
||||||
memcpy(buf_data + i * width * bytes, pat_data, width * bytes);
|
memcpy (buf_data + i * width * bytes, pat_data, width * bytes);
|
||||||
pat_data += rowstride;
|
pat_data += rowstride;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free up loaded Pixbuf */
|
g_object_unref (pixbuf);
|
||||||
g_object_unref (pat_buf);
|
|
||||||
|
|
||||||
/* Swap the pattern to disk (if we're being stingy with memory) */
|
/* Swap the pattern to disk (if we're being stingy with memory) */
|
||||||
if (stingy_memory_use)
|
if (stingy_memory_use)
|
||||||
temp_buf_swap (pattern->mask);
|
temp_buf_swap (pattern->mask);
|
||||||
|
|
|
@ -307,9 +307,9 @@ gimp_pattern_get_standard (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
GimpData *
|
GimpData *
|
||||||
gimp_pattern_native_load (const gchar *filename,
|
gimp_pattern_load (const gchar *filename,
|
||||||
gboolean stingy_memory_use,
|
gboolean stingy_memory_use,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpPattern *pattern = NULL;
|
GimpPattern *pattern = NULL;
|
||||||
gint fd;
|
gint fd;
|
||||||
|
@ -438,95 +438,64 @@ gimp_pattern_native_load (const gchar *filename,
|
||||||
}
|
}
|
||||||
|
|
||||||
GimpData *
|
GimpData *
|
||||||
gimp_pattern_load (const gchar *filename,
|
gimp_pattern_load_pixbuf (const gchar *filename,
|
||||||
gboolean stingy_memory_use,
|
gboolean stingy_memory_use,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpPattern *pattern = NULL;
|
GimpPattern *pattern;
|
||||||
GdkPixbuf *pat_buf = NULL;
|
GdkPixbuf *pixbuf;
|
||||||
guchar *pat_data, *buf_data;
|
guchar *pat_data;
|
||||||
gchar *name = NULL;
|
guchar *buf_data;
|
||||||
gint width,
|
gchar *name;
|
||||||
height,
|
gint width;
|
||||||
bytes,
|
gint height;
|
||||||
rowstride,
|
gint bytes;
|
||||||
i;
|
gint rowstride;
|
||||||
gchar *utf8_filename;
|
gint i;
|
||||||
gsize filename_length;
|
|
||||||
|
|
||||||
g_return_val_if_fail (filename != NULL, NULL);
|
g_return_val_if_fail (filename != NULL, NULL);
|
||||||
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
|
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||||
|
|
||||||
pat_buf = gdk_pixbuf_new_from_file (filename, error);
|
pixbuf = gdk_pixbuf_new_from_file (filename, error);
|
||||||
|
|
||||||
if (*error)
|
if (! pixbuf)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
name = g_strdup (gdk_pixbuf_get_option (pixbuf, "tEXt::Comment"));
|
||||||
|
|
||||||
|
if (! name)
|
||||||
{
|
{
|
||||||
if ((*error)->domain == G_FILE_ERROR)
|
gchar *basename = g_path_get_basename (filename);
|
||||||
g_message (_("Could not open file %s: %s"),
|
|
||||||
gimp_filename_to_utf8 (filename),
|
name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
|
||||||
(*error)->message);
|
|
||||||
else if ((*error)->domain == GDK_PIXBUF_ERROR)
|
g_free (basename);
|
||||||
g_message (_("Filename %s is not a valid GdkPixbuf: %s"),
|
|
||||||
gimp_filename_to_utf8 (filename),
|
|
||||||
(*error)->message);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Read in the pattern name -
|
|
||||||
First try to get a "comment" option, this could be set for pnm,
|
|
||||||
jpeg and gif (it isn't yet)
|
|
||||||
Then try the tEXt option, which is set for pngs,
|
|
||||||
Then fall back to filename
|
|
||||||
*/
|
|
||||||
|
|
||||||
utf8_filename = g_filename_to_utf8 (filename, -1, NULL, &filename_length,
|
|
||||||
error);
|
|
||||||
if (*error)
|
|
||||||
{
|
|
||||||
g_message (_("Problem converting filename to UTF8: %s"),
|
|
||||||
(*error)->message);
|
|
||||||
utf8_filename = "Unnamed";
|
|
||||||
g_clear_error (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
name = g_strdup (gdk_pixbuf_get_option (pat_buf, "comment"));
|
|
||||||
|
|
||||||
if (name == NULL)
|
|
||||||
name = g_strdup (gdk_pixbuf_get_option (pat_buf, "tEXt"));
|
|
||||||
|
|
||||||
if (name == NULL)
|
|
||||||
name = g_strdup (utf8_filename);
|
|
||||||
|
|
||||||
pattern = g_object_new (GIMP_TYPE_PATTERN,
|
pattern = g_object_new (GIMP_TYPE_PATTERN,
|
||||||
"name", name,
|
"name", name,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_free (name);
|
g_free (name);
|
||||||
g_free (utf8_filename);
|
|
||||||
|
|
||||||
width = gdk_pixbuf_get_width (pat_buf);
|
width = gdk_pixbuf_get_width (pixbuf);
|
||||||
height = gdk_pixbuf_get_height (pat_buf);
|
height = gdk_pixbuf_get_height (pixbuf);
|
||||||
bytes = gdk_pixbuf_get_n_channels (pat_buf);
|
bytes = gdk_pixbuf_get_n_channels (pixbuf);
|
||||||
rowstride = gdk_pixbuf_get_rowstride (pat_buf);
|
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||||
|
|
||||||
pattern->mask = temp_buf_new (width, height, bytes,
|
pattern->mask = temp_buf_new (width, height, bytes, 0, 0, NULL);
|
||||||
0, 0, NULL);
|
|
||||||
|
pat_data = gdk_pixbuf_get_pixels (pixbuf);
|
||||||
pat_data = gdk_pixbuf_get_pixels (pat_buf);
|
|
||||||
buf_data = temp_buf_data (pattern->mask);
|
buf_data = temp_buf_data (pattern->mask);
|
||||||
|
|
||||||
for (i = 0; i < height; i++)
|
for (i = 0; i < height; i++)
|
||||||
{
|
{
|
||||||
memcpy(buf_data + i * width * bytes, pat_data, width * bytes);
|
memcpy (buf_data + i * width * bytes, pat_data, width * bytes);
|
||||||
pat_data += rowstride;
|
pat_data += rowstride;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free up loaded Pixbuf */
|
g_object_unref (pixbuf);
|
||||||
g_object_unref (pat_buf);
|
|
||||||
|
|
||||||
/* Swap the pattern to disk (if we're being stingy with memory) */
|
/* Swap the pattern to disk (if we're being stingy with memory) */
|
||||||
if (stingy_memory_use)
|
if (stingy_memory_use)
|
||||||
temp_buf_swap (pattern->mask);
|
temp_buf_swap (pattern->mask);
|
||||||
|
|
|
@ -54,10 +54,10 @@ GType gimp_pattern_get_type (void) G_GNUC_CONST;
|
||||||
GimpData * gimp_pattern_new (const gchar *name,
|
GimpData * gimp_pattern_new (const gchar *name,
|
||||||
gboolean stingy_memory_use);
|
gboolean stingy_memory_use);
|
||||||
GimpData * gimp_pattern_get_standard (void);
|
GimpData * gimp_pattern_get_standard (void);
|
||||||
GimpData * gimp_pattern_native_load (const gchar *filename,
|
GimpData * gimp_pattern_load (const gchar *filename,
|
||||||
gboolean stingy_memory_use,
|
gboolean stingy_memory_use,
|
||||||
GError **error);
|
GError **error);
|
||||||
GimpData * gimp_pattern_load (const gchar *filename,
|
GimpData * gimp_pattern_load_pixbuf (const gchar *filename,
|
||||||
gboolean stingy_memory_use,
|
gboolean stingy_memory_use,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue