Commit fd536b64 authored by Tim Janik's avatar Tim Janik Committed by Tim Janik
Browse files

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).
parent 7e9353a7
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>
* libgimp/gimpparasite.c: fixed gimp_detach_parasite.
......
......@@ -31,6 +31,7 @@ typedef struct {
gchar *comment;
gboolean use_comment;
gboolean glib_types;
gboolean stringify;
gboolean alpha;
gdouble opacity;
} Config;
......@@ -119,6 +120,7 @@ run (gchar *name,
NULL,
FALSE,
TRUE,
TRUE,
(drawable_type == RGBA_IMAGE ||
drawable_type == GRAYA_IMAGE ||
drawable_type == INDEXEDA_IMAGE),
......@@ -162,10 +164,10 @@ run (gchar *name,
}
}
static inline guint
save_uchar (FILE *fp,
guint c,
guint8 d)
static guint
save_uchar_n (FILE *fp,
guint c,
guint8 d)
{
if (c > 74)
{
......@@ -178,6 +180,53 @@ save_uchar (FILE *fp,
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
save_image (Config *config,
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;
FILE *fp;
guint c;
guint (*save_uchar) (FILE*, guint, guint8);
fp = fopen (config->file_name, "w");
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);
if (config->stringify)
save_uchar = save_uchar_s;
else
save_uchar = save_uchar_n;
if (config->glib_types)
{
s_uint_8 = "guint8 ";
......@@ -263,7 +318,10 @@ save_image (Config *config,
fprintf (fp, "\\%03o", *p);
fprintf (fp, "\",\n");
}
fprintf (fp, " {");
if (config->stringify)
fprintf (fp, " \"");
else
fprintf (fp, " {");
c = 3;
switch (drawable_type)
{
......@@ -300,7 +358,10 @@ save_image (Config *config,
g_warning ("unhandled drawable type (%d)", drawable_type);
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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment