save RGBA data as string and not seuqences of numbers and commas. this
Wed Jul 7 02:24:22 1999 Tim Janik <timj@gtk.org> * plug-ins/common/csource.c: save RGBA data as string and not seuqences of numbers and commas. this reduces the output file size significantly (by 50-70%) and reduces compile time memory requirement majorly (down to 20% for gcc).
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
Wed Jul 7 02:24:22 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* plug-ins/common/csource.c: save RGBA data as string and not seuqences
|
||||||
|
of numbers and commas. this reduces the output file size significantly
|
||||||
|
(by 50-70%) and reduces compile time memory requirement majorly (down
|
||||||
|
to 20% for gcc).
|
||||||
|
|
||||||
Tue Jul 6 22:26:24 CEST 1999 Marc Lehmann <pcg@goof.com>
|
Tue Jul 6 22:26:24 CEST 1999 Marc Lehmann <pcg@goof.com>
|
||||||
|
|
||||||
* libgimp/gimpparasite.c: fixed gimp_detach_parasite.
|
* libgimp/gimpparasite.c: fixed gimp_detach_parasite.
|
||||||
|
@ -31,6 +31,7 @@ typedef struct {
|
|||||||
gchar *comment;
|
gchar *comment;
|
||||||
gboolean use_comment;
|
gboolean use_comment;
|
||||||
gboolean glib_types;
|
gboolean glib_types;
|
||||||
|
gboolean stringify;
|
||||||
gboolean alpha;
|
gboolean alpha;
|
||||||
gdouble opacity;
|
gdouble opacity;
|
||||||
} Config;
|
} Config;
|
||||||
@ -119,6 +120,7 @@ run (gchar *name,
|
|||||||
NULL,
|
NULL,
|
||||||
FALSE,
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
|
TRUE,
|
||||||
(drawable_type == RGBA_IMAGE ||
|
(drawable_type == RGBA_IMAGE ||
|
||||||
drawable_type == GRAYA_IMAGE ||
|
drawable_type == GRAYA_IMAGE ||
|
||||||
drawable_type == INDEXEDA_IMAGE),
|
drawable_type == INDEXEDA_IMAGE),
|
||||||
@ -162,10 +164,10 @@ run (gchar *name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline guint
|
static guint
|
||||||
save_uchar (FILE *fp,
|
save_uchar_n (FILE *fp,
|
||||||
guint c,
|
guint c,
|
||||||
guint8 d)
|
guint8 d)
|
||||||
{
|
{
|
||||||
if (c > 74)
|
if (c > 74)
|
||||||
{
|
{
|
||||||
@ -178,6 +180,53 @@ save_uchar (FILE *fp,
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static guint
|
||||||
|
save_uchar_s (FILE *fp,
|
||||||
|
guint c,
|
||||||
|
guint8 d)
|
||||||
|
{
|
||||||
|
static guint8 pad = 0;
|
||||||
|
|
||||||
|
if (c > 74)
|
||||||
|
{
|
||||||
|
fprintf (fp, "\"\n \"");
|
||||||
|
c = 3;
|
||||||
|
}
|
||||||
|
if (d < 33 || d > 126)
|
||||||
|
{
|
||||||
|
fprintf (fp, "\\%o", d);
|
||||||
|
c += 1 + 1 + (d > 7) + (d > 63);
|
||||||
|
pad = d < 64;
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d == '\\')
|
||||||
|
{
|
||||||
|
fputs ("\\\\", fp);
|
||||||
|
c += 2;
|
||||||
|
}
|
||||||
|
else if (d == '"')
|
||||||
|
{
|
||||||
|
fputs ("\\\"", fp);
|
||||||
|
c += 2;
|
||||||
|
}
|
||||||
|
else if (pad && d >= '0' && d <= '9')
|
||||||
|
{
|
||||||
|
fputs ("\"\"", fp);
|
||||||
|
fputc (d, fp);
|
||||||
|
c += 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fputc (d, fp);
|
||||||
|
c += 1;
|
||||||
|
}
|
||||||
|
pad = 0;
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
save_image (Config *config,
|
save_image (Config *config,
|
||||||
gint32 image_ID,
|
gint32 image_ID,
|
||||||
@ -189,6 +238,7 @@ save_image (Config *config,
|
|||||||
gchar *s_uint_8, *s_uint_32, *s_int, *s_uint, *s_char, *s_null;
|
gchar *s_uint_8, *s_uint_32, *s_int, *s_uint, *s_char, *s_null;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
guint c;
|
guint c;
|
||||||
|
guint (*save_uchar) (FILE*, guint, guint8);
|
||||||
|
|
||||||
fp = fopen (config->file_name, "w");
|
fp = fopen (config->file_name, "w");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
@ -196,6 +246,11 @@ save_image (Config *config,
|
|||||||
|
|
||||||
gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0, drawable->width, drawable->height, FALSE, FALSE);
|
gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0, drawable->width, drawable->height, FALSE, FALSE);
|
||||||
|
|
||||||
|
if (config->stringify)
|
||||||
|
save_uchar = save_uchar_s;
|
||||||
|
else
|
||||||
|
save_uchar = save_uchar_n;
|
||||||
|
|
||||||
if (config->glib_types)
|
if (config->glib_types)
|
||||||
{
|
{
|
||||||
s_uint_8 = "guint8 ";
|
s_uint_8 = "guint8 ";
|
||||||
@ -263,7 +318,10 @@ save_image (Config *config,
|
|||||||
fprintf (fp, "\\%03o", *p);
|
fprintf (fp, "\\%03o", *p);
|
||||||
fprintf (fp, "\",\n");
|
fprintf (fp, "\",\n");
|
||||||
}
|
}
|
||||||
fprintf (fp, " {");
|
if (config->stringify)
|
||||||
|
fprintf (fp, " \"");
|
||||||
|
else
|
||||||
|
fprintf (fp, " {");
|
||||||
c = 3;
|
c = 3;
|
||||||
switch (drawable_type)
|
switch (drawable_type)
|
||||||
{
|
{
|
||||||
@ -300,7 +358,10 @@ save_image (Config *config,
|
|||||||
g_warning ("unhandled drawable type (%d)", drawable_type);
|
g_warning ("unhandled drawable type (%d)", drawable_type);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
fprintf (fp, "\n },\n};\n\n");
|
if (config->stringify)
|
||||||
|
fprintf (fp, "\",\n};\n\n");
|
||||||
|
else
|
||||||
|
fprintf (fp, "\n },\n};\n\n");
|
||||||
|
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user