mirror of https://github.com/GNOME/gimp.git
applied a bunch of patches:
Simon Budigs patch sent to the list Sun, 20 Feb 2000 gimp-kirchgessner-000217-0 gimp-cosmin-20000212 gimp-mattias-000227-0 --Sven
This commit is contained in:
parent
64c30031a0
commit
24bbdbef07
37
ChangeLog
37
ChangeLog
|
@ -1,3 +1,40 @@
|
|||
Fri Mar 10 18:10:56 CET 2000 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/pygimp/plug-ins/pdbbrowse.py
|
||||
* plug-ins/pygimp/plug-ins/sphere.py: applied patch from Simon Budig
|
||||
makes the scripts use env instead of hardcoded path to python
|
||||
|
||||
* plug-ins/common/ps.c: applied gimp-kirchgessner-000217-0
|
||||
fixes problem with toggle PostScript Level 2
|
||||
fixes problem with reading EPS-files that have no showpage command
|
||||
adds runlength encoding to PostScript Level 2 files
|
||||
|
||||
* plug-ins/common/jpeg.c: applied gimp-cosmin-20000212
|
||||
guards parasite code with #ifdef GIMP_HAVE_PARASITES
|
||||
do not save comment if comment string is empty
|
||||
|
||||
* app/fileops.c
|
||||
* plug-ins/common/CEL.c
|
||||
* plug-ins/common/bz2.c
|
||||
* plug-ins/common/gicon.c
|
||||
* plug-ins/common/mpeg.c
|
||||
* plug-ins/common/psd.c
|
||||
* plug-ins/common/psp.c
|
||||
* plug-ins/common/tga.c
|
||||
* plug-ins/common/xpm.c
|
||||
* plug-ins/common/xwd.c: applied gimp-mattias-000227-0
|
||||
Changes the file format auto-detection algorithm to do the following:
|
||||
1. See if the file name matches extensions of formats that do NOT have
|
||||
any magic registered
|
||||
2. Check all file formats with registered magic
|
||||
3. Check all extensions
|
||||
Adds, removes or fixes existing magic in tga, cel, bz2, gicon, mpeg,
|
||||
psd, psp, xpm, xwd
|
||||
|
||||
Please test this heavily (especially the file magic). If this patch
|
||||
turns out to be bogus, we'll revert it. If the changes are correct,
|
||||
it's an important fix.
|
||||
|
||||
Fri Mar 10 12:29:57 CET 2000 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/sel2path/*.c: do not include malloc.h but use the
|
||||
|
|
105
app/fileops.c
105
app/fileops.c
|
@ -1754,16 +1754,63 @@ file_overwrite_no_callback (GtkWidget *widget,
|
|||
gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE);
|
||||
}
|
||||
|
||||
static PlugInProcDef *
|
||||
file_proc_find_by_name(GSList *procs,
|
||||
gchar *filename,
|
||||
gboolean skip_magic)
|
||||
{
|
||||
GSList *p;
|
||||
gchar *ext = strrchr(filename, '.');
|
||||
if (ext)
|
||||
ext++;
|
||||
|
||||
for (p = procs; p; p = p->next)
|
||||
{
|
||||
PlugInProcDef *proc = p->data;
|
||||
GSList *prefixes;
|
||||
|
||||
if (skip_magic && proc->magics_list)
|
||||
continue;
|
||||
for (prefixes = proc->prefixes_list; prefixes; prefixes = prefixes->next)
|
||||
{
|
||||
if (strncmp(filename, prefixes->data, strlen(prefixes->data)) == 0)
|
||||
return proc;
|
||||
}
|
||||
}
|
||||
|
||||
for (p = procs; p; p = p->next)
|
||||
{
|
||||
PlugInProcDef *proc = p->data;
|
||||
GSList *extensions;
|
||||
|
||||
for (extensions = proc->extensions_list; ext && extensions; extensions = extensions->next)
|
||||
{
|
||||
gchar *p1 = ext;
|
||||
gchar *p2 = (gchar *)extensions->data;
|
||||
|
||||
if (skip_magic && proc->magics_list)
|
||||
continue;
|
||||
while (*p1 && *p2)
|
||||
{
|
||||
if (tolower (*p1) != tolower (*p2))
|
||||
break;
|
||||
p1++;
|
||||
p2++;
|
||||
}
|
||||
if (!(*p1) && !(*p2))
|
||||
return proc;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PlugInProcDef *
|
||||
file_proc_find (GSList *procs,
|
||||
gchar *filename)
|
||||
{
|
||||
PlugInProcDef *file_proc, *size_matched_proc;
|
||||
GSList *all_procs = procs;
|
||||
GSList *extensions;
|
||||
GSList *prefixes;
|
||||
gchar *extension;
|
||||
gchar *p1, *p2;
|
||||
FILE *ifp = NULL;
|
||||
gint head_size = -2, size_match_count = 0;
|
||||
gint match_val;
|
||||
|
@ -1771,11 +1818,11 @@ file_proc_find (GSList *procs,
|
|||
|
||||
size_matched_proc = NULL;
|
||||
|
||||
extension = strrchr (filename, '.');
|
||||
if (extension)
|
||||
extension += 1;
|
||||
/* First, check magicless prefixes/suffixes */
|
||||
if ( (file_proc = file_proc_find_by_name(all_procs, filename, TRUE)) != NULL)
|
||||
return file_proc;
|
||||
|
||||
/* At first look for magics */
|
||||
/* Then look for magics */
|
||||
while (procs)
|
||||
{
|
||||
file_proc = procs->data;
|
||||
|
@ -1810,46 +1857,8 @@ file_proc_find (GSList *procs,
|
|||
if (size_match_count == 1)
|
||||
return (size_matched_proc);
|
||||
|
||||
procs = all_procs;
|
||||
while (procs)
|
||||
{
|
||||
file_proc = procs->data;
|
||||
procs = procs->next;
|
||||
|
||||
for (prefixes = file_proc->prefixes_list; prefixes; prefixes = prefixes->next)
|
||||
{
|
||||
p1 = filename;
|
||||
p2 = (gchar *) prefixes->data;
|
||||
|
||||
if (strncmp (filename, prefixes->data, strlen (prefixes->data)) == 0)
|
||||
return file_proc;
|
||||
}
|
||||
}
|
||||
|
||||
procs = all_procs;
|
||||
while (procs)
|
||||
{
|
||||
file_proc = procs->data;
|
||||
procs = procs->next;
|
||||
|
||||
for (extensions = file_proc->extensions_list; extension && extensions; extensions = extensions->next)
|
||||
{
|
||||
p1 = extension;
|
||||
p2 = (gchar *) extensions->data;
|
||||
|
||||
while (*p1 && *p2)
|
||||
{
|
||||
if (tolower (*p1) != tolower (*p2))
|
||||
break;
|
||||
p1 += 1;
|
||||
p2 += 1;
|
||||
}
|
||||
if (!(*p1) && !(*p2))
|
||||
return file_proc;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
/* As a last ditch, try matching by name */
|
||||
return file_proc_find_by_name(all_procs, filename, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -132,7 +132,7 @@ query (void)
|
|||
gimp_register_magic_load_handler ("file_cel_load",
|
||||
"cel",
|
||||
"",
|
||||
"0,string,KiSS\040");
|
||||
"0,string,KiSS\\040");
|
||||
gimp_register_save_handler ("file_cel_save",
|
||||
"cel",
|
||||
"");
|
||||
|
|
|
@ -132,9 +132,10 @@ query (void)
|
|||
nsave_args, 0,
|
||||
save_args, NULL);
|
||||
|
||||
gimp_register_load_handler ("file_bz2_load",
|
||||
"xcf.bz2,bz2,xcfbz2",
|
||||
"");
|
||||
gimp_register_magic_load_handler ("file_bz2_load",
|
||||
"xcf.bz2,bz2,xcfbz2",
|
||||
"",
|
||||
"0,string,BZh");
|
||||
gimp_register_save_handler ("file_bz2_save",
|
||||
"xcf.bz2,bz2,xcfbz2",
|
||||
"");
|
||||
|
|
|
@ -146,9 +146,11 @@ query (void)
|
|||
nsave_args, 0,
|
||||
save_args, NULL);
|
||||
|
||||
gimp_register_load_handler ("file_gicon_load",
|
||||
"ico",
|
||||
"");
|
||||
gimp_register_magic_load_handler ("file_gicon_load",
|
||||
"ico",
|
||||
"",
|
||||
"0,string,"
|
||||
"/*\\040\\040GIMP\\040icon\\040image");
|
||||
gimp_register_save_handler ("file_gicon_save",
|
||||
"ico",
|
||||
"");
|
||||
|
|
|
@ -1043,7 +1043,8 @@ load_image (gchar *filename,
|
|||
|
||||
/* pw - Last of all, attach the parasites (couldn't do it earlier -
|
||||
there was no image. */
|
||||
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
if (!preview)
|
||||
{
|
||||
if (comment_parasite)
|
||||
|
@ -1057,6 +1058,7 @@ load_image (gchar *filename,
|
|||
parasite_free (vals_parasite);
|
||||
}
|
||||
}
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
return image_ID;
|
||||
}
|
||||
|
@ -1382,7 +1384,7 @@ save_image (char *filename,
|
|||
jpeg_start_compress (&cinfo, TRUE);
|
||||
|
||||
/* Step 4.1: Write the comment out - pw */
|
||||
if (image_comment)
|
||||
if (image_comment && *image_comment)
|
||||
{
|
||||
jpeg_write_marker (&cinfo,
|
||||
JPEG_COM,
|
||||
|
|
|
@ -133,9 +133,10 @@ query (void)
|
|||
nload_args, nload_return_vals,
|
||||
load_args, load_return_vals);
|
||||
|
||||
gimp_register_load_handler ("file_mpeg_load",
|
||||
"mpg,mpeg",
|
||||
"");
|
||||
gimp_register_magic_load_handler ("file_mpeg_load",
|
||||
"mpg,mpeg",
|
||||
""
|
||||
"0,long,0x000001b3,0,long,0x000001ba");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -45,10 +45,13 @@
|
|||
* Ghostview may hang when displaying the files.
|
||||
* V 1.07, PK, 14-Sep-99: Add resolution to image
|
||||
* V 1.08, PK, 16-Jan-2000: Add PostScript-Level 2 by Austin Donnelly
|
||||
* V 1.09, PK, 15-Feb-2000: Force showpage on EPS-files
|
||||
* Add "RunLength" compression
|
||||
* Fix problem with "Level 2" toggle
|
||||
*/
|
||||
#define VERSIO 1.08
|
||||
static char dversio[] = "v1.08 16-Jan-2000";
|
||||
static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.08 16-Jan-2000";
|
||||
#define VERSIO 1.09
|
||||
static char dversio[] = "v1.09 15-Feb-2000";
|
||||
static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.09 15-Feb-2000";
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -196,8 +199,9 @@ static FILE *ps_open (gchar *filename,
|
|||
const PSLoadVals *loadopt,
|
||||
gint *llx,
|
||||
gint *lly,
|
||||
int *urx,
|
||||
gint *ury);
|
||||
gint *urx,
|
||||
gint *ury,
|
||||
gint *is_epsf);
|
||||
|
||||
static void ps_close (FILE *ifp);
|
||||
|
||||
|
@ -249,7 +253,6 @@ static void save_ok_callback (GtkWidget *widget,
|
|||
static void save_unit_toggle_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
GPlugInInfo PLUG_IN_INFO =
|
||||
{
|
||||
NULL, /* init_proc */
|
||||
|
@ -262,6 +265,11 @@ GPlugInInfo PLUG_IN_INFO =
|
|||
/* The run mode */
|
||||
static GRunModeType l_run_mode;
|
||||
|
||||
static void compress_packbits (int nin,
|
||||
unsigned char *src,
|
||||
int *nout,
|
||||
unsigned char *dst);
|
||||
|
||||
|
||||
static guint32 ascii85_buf;
|
||||
static int ascii85_len = 0;
|
||||
|
@ -321,6 +329,16 @@ ascii85_out (unsigned char byte, FILE *ofp)
|
|||
ascii85_len++;
|
||||
}
|
||||
|
||||
static void
|
||||
ascii85_nout (int n, unsigned char *uptr, FILE *ofp)
|
||||
{
|
||||
while (n-- > 0)
|
||||
{
|
||||
ascii85_out (*uptr, ofp);
|
||||
uptr++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ascii85_done (FILE *ofp)
|
||||
{
|
||||
|
@ -337,6 +355,88 @@ ascii85_done (FILE *ofp)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
compress_packbits (int nin,
|
||||
unsigned char *src,
|
||||
int *nout,
|
||||
unsigned char *dst)
|
||||
|
||||
{register unsigned char c;
|
||||
int nrepeat, nliteral;
|
||||
unsigned char *run_start;
|
||||
unsigned char *start_dst = dst;
|
||||
unsigned char *last_literal = NULL;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (nin <= 0) break;
|
||||
|
||||
run_start = src;
|
||||
c = *run_start;
|
||||
|
||||
/* Search repeat bytes */
|
||||
if ((nin > 1) && (c == src[1]))
|
||||
{
|
||||
nrepeat = 1;
|
||||
nin -= 2;
|
||||
src += 2;
|
||||
while ((nin > 0) && (c == *src))
|
||||
{
|
||||
nrepeat++;
|
||||
src++;
|
||||
nin--;
|
||||
if (nrepeat == 127) break; /* Maximum repeat */
|
||||
}
|
||||
|
||||
/* Add two-byte repeat to last literal run ? */
|
||||
if ( (nrepeat == 1)
|
||||
&& (last_literal != NULL) && (((*last_literal)+1)+2 <= 128))
|
||||
{
|
||||
*last_literal += 2;
|
||||
*(dst++) = c;
|
||||
*(dst++) = c;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Add repeat run */
|
||||
*(dst++) = (unsigned char)((-nrepeat) & 0xff);
|
||||
*(dst++) = c;
|
||||
last_literal = NULL;
|
||||
continue;
|
||||
}
|
||||
/* Search literal bytes */
|
||||
nliteral = 1;
|
||||
nin--;
|
||||
src++;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (nin <= 0) break;
|
||||
|
||||
if ((nin >= 2) && (src[0] == src[1])) /* A two byte repeat ? */
|
||||
break;
|
||||
|
||||
nliteral++;
|
||||
nin--;
|
||||
src++;
|
||||
if (nliteral == 128) break; /* Maximum literal run */
|
||||
}
|
||||
|
||||
/* Could be added to last literal run ? */
|
||||
if ((last_literal != NULL) && (((*last_literal)+1)+nliteral <= 128))
|
||||
{
|
||||
*last_literal += nliteral;
|
||||
}
|
||||
else
|
||||
{
|
||||
last_literal = dst;
|
||||
*(dst++) = (unsigned char)(nliteral-1);
|
||||
}
|
||||
while (nliteral-- > 0) *(dst++) = *(run_start++);
|
||||
}
|
||||
*nout = dst - start_dst;
|
||||
}
|
||||
|
||||
|
||||
MAIN ()
|
||||
|
||||
|
@ -421,7 +521,7 @@ query (void)
|
|||
gimp_install_procedure ("file_ps_save",
|
||||
"save file in PostScript file format",
|
||||
"PostScript saving handles all image types except those with alpha channels.",
|
||||
"Peter Kirchgessner <pkirchg@aol.com>",
|
||||
"Peter Kirchgessner <peter@kirchgessner.net>",
|
||||
"Peter Kirchgessner",
|
||||
dversio,
|
||||
"<Save>/PostScript",
|
||||
|
@ -562,13 +662,13 @@ run (gchar *name,
|
|||
image_ID = orig_image_ID = param[1].data.d_int32;
|
||||
drawable_ID = param[2].data.d_int32;
|
||||
|
||||
/* eventually export the image */
|
||||
/* eventually export the image */
|
||||
switch (run_mode)
|
||||
{
|
||||
case RUN_INTERACTIVE:
|
||||
case RUN_WITH_LAST_VALS:
|
||||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "PS",
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "PS",
|
||||
(CAN_HANDLE_RGB |
|
||||
CAN_HANDLE_GRAY |
|
||||
CAN_HANDLE_INDEXED));
|
||||
|
@ -697,6 +797,7 @@ load_image (gchar *filename)
|
|||
char *temp;
|
||||
int llx, lly, urx, ury;
|
||||
int k, n_images, max_images, max_pagenum;
|
||||
int is_epsf;
|
||||
|
||||
#ifdef PS_DEBUG
|
||||
g_print ("load_image:\n resolution = %d\n", plvals.resolution);
|
||||
|
@ -723,7 +824,7 @@ load_image (gchar *filename)
|
|||
g_free (temp);
|
||||
}
|
||||
|
||||
ifp = ps_open (filename, &plvals, &llx, &lly, &urx, &ury);
|
||||
ifp = ps_open (filename, &plvals, &llx, &lly, &urx, &ury, &is_epsf);
|
||||
if (!ifp)
|
||||
{
|
||||
g_message (_("PS: can't interprete file"));
|
||||
|
@ -735,6 +836,7 @@ load_image (gchar *filename)
|
|||
max_images = 10;
|
||||
|
||||
max_pagenum = 9999; /* Try to get the maximum pagenumber to read */
|
||||
if (is_epsf) max_pagenum = 1;
|
||||
if (!page_in_list (plvals.pages, max_pagenum)) /* Is there a limit in list ? */
|
||||
{
|
||||
max_pagenum = -1;
|
||||
|
@ -757,7 +859,7 @@ load_image (gchar *filename)
|
|||
image_ID = load_ps (filename, page_count, ifp, llx, lly, urx, ury);
|
||||
if (image_ID == -1) break;
|
||||
#ifdef GIMP_HAVE_RESOLUTION_INFO
|
||||
gimp_image_set_resolution (image_ID,
|
||||
gimp_image_set_resolution (image_ID,
|
||||
(double) plvals.resolution,
|
||||
(double) plvals.resolution);
|
||||
#endif
|
||||
|
@ -1059,7 +1161,8 @@ ps_open (gchar *filename,
|
|||
gint *llx,
|
||||
gint *lly,
|
||||
gint *urx,
|
||||
gint *ury)
|
||||
gint *ury,
|
||||
gint *is_epsf)
|
||||
{
|
||||
char *cmd, *gs, *gs_opts, *driver;
|
||||
FILE *fd_popen;
|
||||
|
@ -1077,6 +1180,8 @@ ps_open (gchar *filename,
|
|||
|
||||
/* Check if the file is a PDF. For PDF, we cant set geometry */
|
||||
is_pdf = 0;
|
||||
/* Check if it is a EPS-file */
|
||||
*is_epsf = 0;
|
||||
#ifndef __EMX__
|
||||
fd_popen = fopen (filename, "r");
|
||||
#else
|
||||
|
@ -1084,10 +1189,22 @@ ps_open (gchar *filename,
|
|||
#endif
|
||||
if (fd_popen != NULL)
|
||||
{
|
||||
char hdr[4];
|
||||
char hdr[512];
|
||||
|
||||
fread (hdr, 1, 4, fd_popen);
|
||||
fread (hdr, 1, sizeof(hdr), fd_popen);
|
||||
is_pdf = (strncmp (hdr, "%PDF", 4) == 0);
|
||||
|
||||
if (!is_pdf) /* Check for EPSF */
|
||||
{char *adobe, *epsf;
|
||||
int ds = 0;
|
||||
|
||||
hdr[sizeof(hdr)-1] = '\0';
|
||||
adobe = strstr (hdr, "PS-Adobe-");
|
||||
epsf = strstr (hdr, "EPSF-");
|
||||
if ((adobe != NULL) && (epsf != NULL))
|
||||
ds = epsf - adobe;
|
||||
*is_epsf = ((ds >= 11) && (ds <= 15));
|
||||
}
|
||||
fclose (fd_popen);
|
||||
}
|
||||
|
||||
|
@ -1153,10 +1270,11 @@ ps_open (gchar *filename,
|
|||
sprintf (geometry,"-g%dx%d ", width, height);
|
||||
|
||||
cmd = g_strdup_printf ("%s -sDEVICE=%s -r%d %s%s%s-q -dNOPAUSE %s \
|
||||
-sOutputFile=%s %s -c quit",
|
||||
-sOutputFile=%s %s %s-c quit",
|
||||
gs, driver, resolution, geometry,
|
||||
TextAlphaBits, GraphicsAlphaBits,
|
||||
gs_opts, pnmfile, filename);
|
||||
gs_opts, pnmfile, filename,
|
||||
*is_epsf ? "-c showpage " : "");
|
||||
#ifdef PS_DEBUG
|
||||
g_print ("Going to start ghostscript with:\n%s\n", cmd);
|
||||
#endif
|
||||
|
@ -1579,7 +1697,7 @@ save_ps_setup (FILE *ofp,
|
|||
|
||||
fprintf (ofp, "%%%%BeginProlog\n");
|
||||
fprintf (ofp, "%% Use own dictionary to avoid conflicts\n");
|
||||
fprintf (ofp, "5 dict begin\n");
|
||||
fprintf (ofp, "10 dict begin\n");
|
||||
fprintf (ofp, "%%%%EndProlog\n");
|
||||
fprintf (ofp, "%%%%Page: 1 1\n");
|
||||
fprintf (ofp, "%% Translate for offset\n");
|
||||
|
@ -1843,6 +1961,7 @@ save_gray (FILE *ofp,
|
|||
int height, width, i, j;
|
||||
int tile_height;
|
||||
unsigned char *data, *src;
|
||||
unsigned char *packb = NULL;
|
||||
GPixelRgn pixel_rgn;
|
||||
GDrawable *drawable;
|
||||
GDrawableType drawable_type;
|
||||
|
@ -1869,8 +1988,10 @@ save_gray (FILE *ofp,
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf (ofp, "currentfile /ASCII85Decode filter\n");
|
||||
fprintf (ofp,"currentfile /ASCII85Decode filter /RunLengthDecode filter\n");
|
||||
ascii85_init ();
|
||||
/* Allocate buffer for packbits data. Worst case: Less than 1% increase */
|
||||
packb = (guchar *)g_malloc ((width * 105)/100+2);
|
||||
}
|
||||
fprintf (ofp, "image\n");
|
||||
|
||||
|
@ -1894,16 +2015,23 @@ save_gray (FILE *ofp,
|
|||
putc ('\n', ofp);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
ascii85_out (*(src++), ofp);
|
||||
{int nout;
|
||||
|
||||
compress_packbits (width, src, &nout, packb);
|
||||
ascii85_nout (nout, packb, ofp);
|
||||
src += width;
|
||||
}
|
||||
if ((l_run_mode != RUN_NONINTERACTIVE) && ((i % 20) == 0))
|
||||
gimp_progress_update ((double) i / (double) height);
|
||||
}
|
||||
if (level2) ascii85_done (ofp);
|
||||
if (level2)
|
||||
{
|
||||
ascii85_out (128, ofp); /* Write EOD of RunLengthDecode filter */
|
||||
ascii85_done (ofp);
|
||||
}
|
||||
fprintf (ofp, "showpage\n");
|
||||
g_free (data);
|
||||
if (packb) g_free (packb);
|
||||
|
||||
gimp_drawable_detach (drawable);
|
||||
|
||||
|
@ -1927,6 +2055,7 @@ save_bw (FILE *ofp,
|
|||
int tile_height;
|
||||
guchar *cmap, *ct;
|
||||
guchar *data, *src;
|
||||
guchar *packb = NULL;
|
||||
guchar *scanline, *dst, mask;
|
||||
guchar *hex_scanline;
|
||||
GPixelRgn pixel_rgn;
|
||||
|
@ -1960,8 +2089,10 @@ save_bw (FILE *ofp,
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf (ofp, "currentfile /ASCII85Decode filter\n");
|
||||
fprintf (ofp,"currentfile /ASCII85Decode filter /RunLengthDecode filter\n");
|
||||
ascii85_init ();
|
||||
/* Allocate buffer for packbits data. Worst case: Less than 1% increase */
|
||||
packb = (guchar *)g_malloc (((nbsl+1) * 105)/100+2);
|
||||
}
|
||||
fprintf (ofp, "image\n");
|
||||
|
||||
|
@ -2006,20 +2137,25 @@ save_bw (FILE *ofp,
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dst = scanline;
|
||||
for (j = 0; j < nbsl; j++)
|
||||
ascii85_out (*(dst++), ofp);
|
||||
{int nout;
|
||||
|
||||
compress_packbits (nbsl, scanline, &nout, packb);
|
||||
ascii85_nout (nout, packb, ofp);
|
||||
}
|
||||
if ((l_run_mode != RUN_NONINTERACTIVE) && ((i % 20) == 0))
|
||||
gimp_progress_update ((double) i / (double) height);
|
||||
}
|
||||
if (level2) ascii85_done (ofp);
|
||||
if (level2)
|
||||
{
|
||||
ascii85_out (128, ofp); /* Write EOD of RunLengthDecode filter */
|
||||
ascii85_done (ofp);
|
||||
}
|
||||
fprintf (ofp, "showpage\n");
|
||||
|
||||
g_free (hex_scanline);
|
||||
g_free (scanline);
|
||||
g_free (data);
|
||||
if (packb != NULL) g_free (packb);
|
||||
|
||||
gimp_drawable_detach (drawable);
|
||||
|
||||
|
@ -2041,8 +2177,9 @@ save_index (FILE *ofp,
|
|||
int height, width, i, j;
|
||||
int ncols, bw;
|
||||
int tile_height;
|
||||
unsigned char *cmap, *cmap_start;
|
||||
unsigned char *data, *src;
|
||||
guchar *cmap, *cmap_start;
|
||||
guchar *data, *src;
|
||||
guchar *packb = NULL, *plane = NULL;
|
||||
char coltab[256*6], *ct;
|
||||
GPixelRgn pixel_rgn;
|
||||
GDrawable *drawable;
|
||||
|
@ -2096,8 +2233,24 @@ save_index (FILE *ofp,
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf (ofp, "currentfile /ASCII85Decode filter false 3\n");
|
||||
ascii85_init ();
|
||||
fprintf (ofp, "%% Strings to hold RGB-samples per scanline\n");
|
||||
fprintf (ofp, "/rstr %d string def\n", width);
|
||||
fprintf (ofp, "/gstr %d string def\n", width);
|
||||
fprintf (ofp, "/bstr %d string def\n", width);
|
||||
fprintf (ofp,
|
||||
"{currentfile /ASCII85Decode filter /RunLengthDecode filter\
|
||||
rstr readstring pop}\n");
|
||||
fprintf (ofp,
|
||||
"{currentfile /ASCII85Decode filter /RunLengthDecode filter\
|
||||
gstr readstring pop}\n");
|
||||
fprintf (ofp,
|
||||
"{currentfile /ASCII85Decode filter /RunLengthDecode filter\
|
||||
bstr readstring pop}\n");
|
||||
fprintf (ofp, "true 3\n");
|
||||
|
||||
/* Allocate buffer for packbits data. Worst case: Less than 1% increase */
|
||||
packb = (guchar *)g_malloc ((width * 105)/100+2);
|
||||
plane = (guchar *)g_malloc (width);
|
||||
}
|
||||
fprintf (ofp, "colorimage\n");
|
||||
|
||||
|
@ -2120,22 +2273,31 @@ save_index (FILE *ofp,
|
|||
putc ('\n', ofp);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
cmap = cmap_start + 3 * (*(src++));
|
||||
ascii85_out (*(cmap++), ofp);
|
||||
ascii85_out (*(cmap++), ofp);
|
||||
ascii85_out (*(cmap++), ofp);
|
||||
}
|
||||
}
|
||||
{guchar *plane_ptr, *src_ptr;
|
||||
int rgb, nout;
|
||||
|
||||
for (rgb = 0; rgb < 3; rgb++)
|
||||
{
|
||||
src_ptr = src;
|
||||
plane_ptr = plane;
|
||||
for (j = 0; j < width; j++)
|
||||
*(plane_ptr++) = cmap_start[3 * *(src_ptr++) + rgb];
|
||||
compress_packbits (width, plane, &nout, packb);
|
||||
ascii85_init ();
|
||||
ascii85_nout (nout, packb, ofp);
|
||||
ascii85_out (128, ofp); /* Write EOD of RunLengthDecode filter */
|
||||
ascii85_done (ofp);
|
||||
}
|
||||
src += width;
|
||||
}
|
||||
if ((l_run_mode != RUN_NONINTERACTIVE) && ((i % 20) == 0))
|
||||
gimp_progress_update ((double) i / (double) height);
|
||||
}
|
||||
if (level2) ascii85_done (ofp);
|
||||
fprintf (ofp, "showpage\n");
|
||||
|
||||
g_free (data);
|
||||
if (packb != NULL) g_free (packb);
|
||||
if (plane != NULL) g_free (plane);
|
||||
|
||||
gimp_drawable_detach (drawable);
|
||||
|
||||
|
@ -2157,6 +2319,7 @@ save_rgb (FILE *ofp,
|
|||
int height, width, tile_height;
|
||||
int i, j;
|
||||
guchar *data, *src;
|
||||
guchar *packb = NULL, *plane = NULL;
|
||||
GPixelRgn pixel_rgn;
|
||||
GDrawable *drawable;
|
||||
GDrawableType drawable_type;
|
||||
|
@ -2183,8 +2346,24 @@ save_rgb (FILE *ofp,
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf (ofp, "currentfile /ASCII85Decode filter false 3\n");
|
||||
ascii85_init ();
|
||||
fprintf (ofp, "%% Strings to hold RGB-samples per scanline\n");
|
||||
fprintf (ofp, "/rstr %d string def\n", width);
|
||||
fprintf (ofp, "/gstr %d string def\n", width);
|
||||
fprintf (ofp, "/bstr %d string def\n", width);
|
||||
fprintf (ofp,
|
||||
"{currentfile /ASCII85Decode filter /RunLengthDecode filter\
|
||||
rstr readstring pop}\n");
|
||||
fprintf (ofp,
|
||||
"{currentfile /ASCII85Decode filter /RunLengthDecode filter\
|
||||
gstr readstring pop}\n");
|
||||
fprintf (ofp,
|
||||
"{currentfile /ASCII85Decode filter /RunLengthDecode filter\
|
||||
bstr readstring pop}\n");
|
||||
fprintf (ofp, "true 3\n");
|
||||
|
||||
/* Allocate buffer for packbits data. Worst case: Less than 1% increase */
|
||||
packb = (guchar *)g_malloc ((width * 105)/100+2);
|
||||
plane = (guchar *)g_malloc (width);
|
||||
}
|
||||
fprintf (ofp, "colorimage\n");
|
||||
|
||||
|
@ -2212,20 +2391,33 @@ save_rgb (FILE *ofp,
|
|||
putc ('\n', ofp);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{guchar *plane_ptr, *src_ptr;
|
||||
int rgb, nout;
|
||||
|
||||
for (rgb = 0; rgb < 3; rgb++)
|
||||
{
|
||||
src_ptr = src + rgb;
|
||||
plane_ptr = plane;
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
ascii85_out (*(src++), ofp);
|
||||
ascii85_out (*(src++), ofp);
|
||||
ascii85_out (*(src++), ofp);
|
||||
}
|
||||
*(plane_ptr++) = *src_ptr;
|
||||
src_ptr += 3;
|
||||
}
|
||||
compress_packbits (width, plane, &nout, packb);
|
||||
ascii85_init ();
|
||||
ascii85_nout (nout, packb, ofp);
|
||||
ascii85_out (128, ofp); /* Write EOD of RunLengthDecode filter */
|
||||
ascii85_done (ofp);
|
||||
}
|
||||
src += 3*width;
|
||||
}
|
||||
if ((l_run_mode != RUN_NONINTERACTIVE) && ((i % 20) == 0))
|
||||
gimp_progress_update ((double) i / (double) height);
|
||||
}
|
||||
if (level2) ascii85_done (ofp);
|
||||
fprintf (ofp, "showpage\n");
|
||||
g_free (data);
|
||||
if (packb != NULL) g_free (packb);
|
||||
if (plane != NULL) g_free (plane);
|
||||
|
||||
gimp_drawable_detach (drawable);
|
||||
|
||||
|
@ -2238,7 +2430,7 @@ save_rgb (FILE *ofp,
|
|||
#undef GET_RGB_TILE
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
init_gtk (void)
|
||||
{
|
||||
gchar **argv;
|
||||
|
@ -2633,7 +2825,7 @@ save_dialog (void)
|
|||
gtk_main ();
|
||||
gdk_flush ();
|
||||
|
||||
psvals.level = (vals->level < 1);
|
||||
psvals.level = (vals->level) ? 2 : 1;
|
||||
|
||||
g_free (vals);
|
||||
|
||||
|
|
|
@ -45,10 +45,13 @@
|
|||
* Ghostview may hang when displaying the files.
|
||||
* V 1.07, PK, 14-Sep-99: Add resolution to image
|
||||
* V 1.08, PK, 16-Jan-2000: Add PostScript-Level 2 by Austin Donnelly
|
||||
* V 1.09, PK, 15-Feb-2000: Force showpage on EPS-files
|
||||
* Add "RunLength" compression
|
||||
* Fix problem with "Level 2" toggle
|
||||
*/
|
||||
#define VERSIO 1.08
|
||||
static char dversio[] = "v1.08 16-Jan-2000";
|
||||
static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.08 16-Jan-2000";
|
||||
#define VERSIO 1.09
|
||||
static char dversio[] = "v1.09 15-Feb-2000";
|
||||
static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.09 15-Feb-2000";
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -196,8 +199,9 @@ static FILE *ps_open (gchar *filename,
|
|||
const PSLoadVals *loadopt,
|
||||
gint *llx,
|
||||
gint *lly,
|
||||
int *urx,
|
||||
gint *ury);
|
||||
gint *urx,
|
||||
gint *ury,
|
||||
gint *is_epsf);
|
||||
|
||||
static void ps_close (FILE *ifp);
|
||||
|
||||
|
@ -249,7 +253,6 @@ static void save_ok_callback (GtkWidget *widget,
|
|||
static void save_unit_toggle_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
GPlugInInfo PLUG_IN_INFO =
|
||||
{
|
||||
NULL, /* init_proc */
|
||||
|
@ -262,6 +265,11 @@ GPlugInInfo PLUG_IN_INFO =
|
|||
/* The run mode */
|
||||
static GRunModeType l_run_mode;
|
||||
|
||||
static void compress_packbits (int nin,
|
||||
unsigned char *src,
|
||||
int *nout,
|
||||
unsigned char *dst);
|
||||
|
||||
|
||||
static guint32 ascii85_buf;
|
||||
static int ascii85_len = 0;
|
||||
|
@ -321,6 +329,16 @@ ascii85_out (unsigned char byte, FILE *ofp)
|
|||
ascii85_len++;
|
||||
}
|
||||
|
||||
static void
|
||||
ascii85_nout (int n, unsigned char *uptr, FILE *ofp)
|
||||
{
|
||||
while (n-- > 0)
|
||||
{
|
||||
ascii85_out (*uptr, ofp);
|
||||
uptr++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ascii85_done (FILE *ofp)
|
||||
{
|
||||
|
@ -337,6 +355,88 @@ ascii85_done (FILE *ofp)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
compress_packbits (int nin,
|
||||
unsigned char *src,
|
||||
int *nout,
|
||||
unsigned char *dst)
|
||||
|
||||
{register unsigned char c;
|
||||
int nrepeat, nliteral;
|
||||
unsigned char *run_start;
|
||||
unsigned char *start_dst = dst;
|
||||
unsigned char *last_literal = NULL;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (nin <= 0) break;
|
||||
|
||||
run_start = src;
|
||||
c = *run_start;
|
||||
|
||||
/* Search repeat bytes */
|
||||
if ((nin > 1) && (c == src[1]))
|
||||
{
|
||||
nrepeat = 1;
|
||||
nin -= 2;
|
||||
src += 2;
|
||||
while ((nin > 0) && (c == *src))
|
||||
{
|
||||
nrepeat++;
|
||||
src++;
|
||||
nin--;
|
||||
if (nrepeat == 127) break; /* Maximum repeat */
|
||||
}
|
||||
|
||||
/* Add two-byte repeat to last literal run ? */
|
||||
if ( (nrepeat == 1)
|
||||
&& (last_literal != NULL) && (((*last_literal)+1)+2 <= 128))
|
||||
{
|
||||
*last_literal += 2;
|
||||
*(dst++) = c;
|
||||
*(dst++) = c;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Add repeat run */
|
||||
*(dst++) = (unsigned char)((-nrepeat) & 0xff);
|
||||
*(dst++) = c;
|
||||
last_literal = NULL;
|
||||
continue;
|
||||
}
|
||||
/* Search literal bytes */
|
||||
nliteral = 1;
|
||||
nin--;
|
||||
src++;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (nin <= 0) break;
|
||||
|
||||
if ((nin >= 2) && (src[0] == src[1])) /* A two byte repeat ? */
|
||||
break;
|
||||
|
||||
nliteral++;
|
||||
nin--;
|
||||
src++;
|
||||
if (nliteral == 128) break; /* Maximum literal run */
|
||||
}
|
||||
|
||||
/* Could be added to last literal run ? */
|
||||
if ((last_literal != NULL) && (((*last_literal)+1)+nliteral <= 128))
|
||||
{
|
||||
*last_literal += nliteral;
|
||||
}
|
||||
else
|
||||
{
|
||||
last_literal = dst;
|
||||
*(dst++) = (unsigned char)(nliteral-1);
|
||||
}
|
||||
while (nliteral-- > 0) *(dst++) = *(run_start++);
|
||||
}
|
||||
*nout = dst - start_dst;
|
||||
}
|
||||
|
||||
|
||||
MAIN ()
|
||||
|
||||
|
@ -421,7 +521,7 @@ query (void)
|
|||
gimp_install_procedure ("file_ps_save",
|
||||
"save file in PostScript file format",
|
||||
"PostScript saving handles all image types except those with alpha channels.",
|
||||
"Peter Kirchgessner <pkirchg@aol.com>",
|
||||
"Peter Kirchgessner <peter@kirchgessner.net>",
|
||||
"Peter Kirchgessner",
|
||||
dversio,
|
||||
"<Save>/PostScript",
|
||||
|
@ -562,13 +662,13 @@ run (gchar *name,
|
|||
image_ID = orig_image_ID = param[1].data.d_int32;
|
||||
drawable_ID = param[2].data.d_int32;
|
||||
|
||||
/* eventually export the image */
|
||||
/* eventually export the image */
|
||||
switch (run_mode)
|
||||
{
|
||||
case RUN_INTERACTIVE:
|
||||
case RUN_WITH_LAST_VALS:
|
||||
init_gtk ();
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "PS",
|
||||
export = gimp_export_image (&image_ID, &drawable_ID, "PS",
|
||||
(CAN_HANDLE_RGB |
|
||||
CAN_HANDLE_GRAY |
|
||||
CAN_HANDLE_INDEXED));
|
||||
|
@ -697,6 +797,7 @@ load_image (gchar *filename)
|
|||
char *temp;
|
||||
int llx, lly, urx, ury;
|
||||
int k, n_images, max_images, max_pagenum;
|
||||
int is_epsf;
|
||||
|
||||
#ifdef PS_DEBUG
|
||||
g_print ("load_image:\n resolution = %d\n", plvals.resolution);
|
||||
|
@ -723,7 +824,7 @@ load_image (gchar *filename)
|
|||
g_free (temp);
|
||||
}
|
||||
|
||||
ifp = ps_open (filename, &plvals, &llx, &lly, &urx, &ury);
|
||||
ifp = ps_open (filename, &plvals, &llx, &lly, &urx, &ury, &is_epsf);
|
||||
if (!ifp)
|
||||
{
|
||||
g_message (_("PS: can't interprete file"));
|
||||
|
@ -735,6 +836,7 @@ load_image (gchar *filename)
|
|||
max_images = 10;
|
||||
|
||||
max_pagenum = 9999; /* Try to get the maximum pagenumber to read */
|
||||
if (is_epsf) max_pagenum = 1;
|
||||
if (!page_in_list (plvals.pages, max_pagenum)) /* Is there a limit in list ? */
|
||||
{
|
||||
max_pagenum = -1;
|
||||
|
@ -757,7 +859,7 @@ load_image (gchar *filename)
|
|||
image_ID = load_ps (filename, page_count, ifp, llx, lly, urx, ury);
|
||||
if (image_ID == -1) break;
|
||||
#ifdef GIMP_HAVE_RESOLUTION_INFO
|
||||
gimp_image_set_resolution (image_ID,
|
||||
gimp_image_set_resolution (image_ID,
|
||||
(double) plvals.resolution,
|
||||
(double) plvals.resolution);
|
||||
#endif
|
||||
|
@ -1059,7 +1161,8 @@ ps_open (gchar *filename,
|
|||
gint *llx,
|
||||
gint *lly,
|
||||
gint *urx,
|
||||
gint *ury)
|
||||
gint *ury,
|
||||
gint *is_epsf)
|
||||
{
|
||||
char *cmd, *gs, *gs_opts, *driver;
|
||||
FILE *fd_popen;
|
||||
|
@ -1077,6 +1180,8 @@ ps_open (gchar *filename,
|
|||
|
||||
/* Check if the file is a PDF. For PDF, we cant set geometry */
|
||||
is_pdf = 0;
|
||||
/* Check if it is a EPS-file */
|
||||
*is_epsf = 0;
|
||||
#ifndef __EMX__
|
||||
fd_popen = fopen (filename, "r");
|
||||
#else
|
||||
|
@ -1084,10 +1189,22 @@ ps_open (gchar *filename,
|
|||
#endif
|
||||
if (fd_popen != NULL)
|
||||
{
|
||||
char hdr[4];
|
||||
char hdr[512];
|
||||
|
||||
fread (hdr, 1, 4, fd_popen);
|
||||
fread (hdr, 1, sizeof(hdr), fd_popen);
|
||||
is_pdf = (strncmp (hdr, "%PDF", 4) == 0);
|
||||
|
||||
if (!is_pdf) /* Check for EPSF */
|
||||
{char *adobe, *epsf;
|
||||
int ds = 0;
|
||||
|
||||
hdr[sizeof(hdr)-1] = '\0';
|
||||
adobe = strstr (hdr, "PS-Adobe-");
|
||||
epsf = strstr (hdr, "EPSF-");
|
||||
if ((adobe != NULL) && (epsf != NULL))
|
||||
ds = epsf - adobe;
|
||||
*is_epsf = ((ds >= 11) && (ds <= 15));
|
||||
}
|
||||
fclose (fd_popen);
|
||||
}
|
||||
|
||||
|
@ -1153,10 +1270,11 @@ ps_open (gchar *filename,
|
|||
sprintf (geometry,"-g%dx%d ", width, height);
|
||||
|
||||
cmd = g_strdup_printf ("%s -sDEVICE=%s -r%d %s%s%s-q -dNOPAUSE %s \
|
||||
-sOutputFile=%s %s -c quit",
|
||||
-sOutputFile=%s %s %s-c quit",
|
||||
gs, driver, resolution, geometry,
|
||||
TextAlphaBits, GraphicsAlphaBits,
|
||||
gs_opts, pnmfile, filename);
|
||||
gs_opts, pnmfile, filename,
|
||||
*is_epsf ? "-c showpage " : "");
|
||||
#ifdef PS_DEBUG
|
||||
g_print ("Going to start ghostscript with:\n%s\n", cmd);
|
||||
#endif
|
||||
|
@ -1579,7 +1697,7 @@ save_ps_setup (FILE *ofp,
|
|||
|
||||
fprintf (ofp, "%%%%BeginProlog\n");
|
||||
fprintf (ofp, "%% Use own dictionary to avoid conflicts\n");
|
||||
fprintf (ofp, "5 dict begin\n");
|
||||
fprintf (ofp, "10 dict begin\n");
|
||||
fprintf (ofp, "%%%%EndProlog\n");
|
||||
fprintf (ofp, "%%%%Page: 1 1\n");
|
||||
fprintf (ofp, "%% Translate for offset\n");
|
||||
|
@ -1843,6 +1961,7 @@ save_gray (FILE *ofp,
|
|||
int height, width, i, j;
|
||||
int tile_height;
|
||||
unsigned char *data, *src;
|
||||
unsigned char *packb = NULL;
|
||||
GPixelRgn pixel_rgn;
|
||||
GDrawable *drawable;
|
||||
GDrawableType drawable_type;
|
||||
|
@ -1869,8 +1988,10 @@ save_gray (FILE *ofp,
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf (ofp, "currentfile /ASCII85Decode filter\n");
|
||||
fprintf (ofp,"currentfile /ASCII85Decode filter /RunLengthDecode filter\n");
|
||||
ascii85_init ();
|
||||
/* Allocate buffer for packbits data. Worst case: Less than 1% increase */
|
||||
packb = (guchar *)g_malloc ((width * 105)/100+2);
|
||||
}
|
||||
fprintf (ofp, "image\n");
|
||||
|
||||
|
@ -1894,16 +2015,23 @@ save_gray (FILE *ofp,
|
|||
putc ('\n', ofp);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
ascii85_out (*(src++), ofp);
|
||||
{int nout;
|
||||
|
||||
compress_packbits (width, src, &nout, packb);
|
||||
ascii85_nout (nout, packb, ofp);
|
||||
src += width;
|
||||
}
|
||||
if ((l_run_mode != RUN_NONINTERACTIVE) && ((i % 20) == 0))
|
||||
gimp_progress_update ((double) i / (double) height);
|
||||
}
|
||||
if (level2) ascii85_done (ofp);
|
||||
if (level2)
|
||||
{
|
||||
ascii85_out (128, ofp); /* Write EOD of RunLengthDecode filter */
|
||||
ascii85_done (ofp);
|
||||
}
|
||||
fprintf (ofp, "showpage\n");
|
||||
g_free (data);
|
||||
if (packb) g_free (packb);
|
||||
|
||||
gimp_drawable_detach (drawable);
|
||||
|
||||
|
@ -1927,6 +2055,7 @@ save_bw (FILE *ofp,
|
|||
int tile_height;
|
||||
guchar *cmap, *ct;
|
||||
guchar *data, *src;
|
||||
guchar *packb = NULL;
|
||||
guchar *scanline, *dst, mask;
|
||||
guchar *hex_scanline;
|
||||
GPixelRgn pixel_rgn;
|
||||
|
@ -1960,8 +2089,10 @@ save_bw (FILE *ofp,
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf (ofp, "currentfile /ASCII85Decode filter\n");
|
||||
fprintf (ofp,"currentfile /ASCII85Decode filter /RunLengthDecode filter\n");
|
||||
ascii85_init ();
|
||||
/* Allocate buffer for packbits data. Worst case: Less than 1% increase */
|
||||
packb = (guchar *)g_malloc (((nbsl+1) * 105)/100+2);
|
||||
}
|
||||
fprintf (ofp, "image\n");
|
||||
|
||||
|
@ -2006,20 +2137,25 @@ save_bw (FILE *ofp,
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dst = scanline;
|
||||
for (j = 0; j < nbsl; j++)
|
||||
ascii85_out (*(dst++), ofp);
|
||||
{int nout;
|
||||
|
||||
compress_packbits (nbsl, scanline, &nout, packb);
|
||||
ascii85_nout (nout, packb, ofp);
|
||||
}
|
||||
if ((l_run_mode != RUN_NONINTERACTIVE) && ((i % 20) == 0))
|
||||
gimp_progress_update ((double) i / (double) height);
|
||||
}
|
||||
if (level2) ascii85_done (ofp);
|
||||
if (level2)
|
||||
{
|
||||
ascii85_out (128, ofp); /* Write EOD of RunLengthDecode filter */
|
||||
ascii85_done (ofp);
|
||||
}
|
||||
fprintf (ofp, "showpage\n");
|
||||
|
||||
g_free (hex_scanline);
|
||||
g_free (scanline);
|
||||
g_free (data);
|
||||
if (packb != NULL) g_free (packb);
|
||||
|
||||
gimp_drawable_detach (drawable);
|
||||
|
||||
|
@ -2041,8 +2177,9 @@ save_index (FILE *ofp,
|
|||
int height, width, i, j;
|
||||
int ncols, bw;
|
||||
int tile_height;
|
||||
unsigned char *cmap, *cmap_start;
|
||||
unsigned char *data, *src;
|
||||
guchar *cmap, *cmap_start;
|
||||
guchar *data, *src;
|
||||
guchar *packb = NULL, *plane = NULL;
|
||||
char coltab[256*6], *ct;
|
||||
GPixelRgn pixel_rgn;
|
||||
GDrawable *drawable;
|
||||
|
@ -2096,8 +2233,24 @@ save_index (FILE *ofp,
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf (ofp, "currentfile /ASCII85Decode filter false 3\n");
|
||||
ascii85_init ();
|
||||
fprintf (ofp, "%% Strings to hold RGB-samples per scanline\n");
|
||||
fprintf (ofp, "/rstr %d string def\n", width);
|
||||
fprintf (ofp, "/gstr %d string def\n", width);
|
||||
fprintf (ofp, "/bstr %d string def\n", width);
|
||||
fprintf (ofp,
|
||||
"{currentfile /ASCII85Decode filter /RunLengthDecode filter\
|
||||
rstr readstring pop}\n");
|
||||
fprintf (ofp,
|
||||
"{currentfile /ASCII85Decode filter /RunLengthDecode filter\
|
||||
gstr readstring pop}\n");
|
||||
fprintf (ofp,
|
||||
"{currentfile /ASCII85Decode filter /RunLengthDecode filter\
|
||||
bstr readstring pop}\n");
|
||||
fprintf (ofp, "true 3\n");
|
||||
|
||||
/* Allocate buffer for packbits data. Worst case: Less than 1% increase */
|
||||
packb = (guchar *)g_malloc ((width * 105)/100+2);
|
||||
plane = (guchar *)g_malloc (width);
|
||||
}
|
||||
fprintf (ofp, "colorimage\n");
|
||||
|
||||
|
@ -2120,22 +2273,31 @@ save_index (FILE *ofp,
|
|||
putc ('\n', ofp);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
cmap = cmap_start + 3 * (*(src++));
|
||||
ascii85_out (*(cmap++), ofp);
|
||||
ascii85_out (*(cmap++), ofp);
|
||||
ascii85_out (*(cmap++), ofp);
|
||||
}
|
||||
}
|
||||
{guchar *plane_ptr, *src_ptr;
|
||||
int rgb, nout;
|
||||
|
||||
for (rgb = 0; rgb < 3; rgb++)
|
||||
{
|
||||
src_ptr = src;
|
||||
plane_ptr = plane;
|
||||
for (j = 0; j < width; j++)
|
||||
*(plane_ptr++) = cmap_start[3 * *(src_ptr++) + rgb];
|
||||
compress_packbits (width, plane, &nout, packb);
|
||||
ascii85_init ();
|
||||
ascii85_nout (nout, packb, ofp);
|
||||
ascii85_out (128, ofp); /* Write EOD of RunLengthDecode filter */
|
||||
ascii85_done (ofp);
|
||||
}
|
||||
src += width;
|
||||
}
|
||||
if ((l_run_mode != RUN_NONINTERACTIVE) && ((i % 20) == 0))
|
||||
gimp_progress_update ((double) i / (double) height);
|
||||
}
|
||||
if (level2) ascii85_done (ofp);
|
||||
fprintf (ofp, "showpage\n");
|
||||
|
||||
g_free (data);
|
||||
if (packb != NULL) g_free (packb);
|
||||
if (plane != NULL) g_free (plane);
|
||||
|
||||
gimp_drawable_detach (drawable);
|
||||
|
||||
|
@ -2157,6 +2319,7 @@ save_rgb (FILE *ofp,
|
|||
int height, width, tile_height;
|
||||
int i, j;
|
||||
guchar *data, *src;
|
||||
guchar *packb = NULL, *plane = NULL;
|
||||
GPixelRgn pixel_rgn;
|
||||
GDrawable *drawable;
|
||||
GDrawableType drawable_type;
|
||||
|
@ -2183,8 +2346,24 @@ save_rgb (FILE *ofp,
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf (ofp, "currentfile /ASCII85Decode filter false 3\n");
|
||||
ascii85_init ();
|
||||
fprintf (ofp, "%% Strings to hold RGB-samples per scanline\n");
|
||||
fprintf (ofp, "/rstr %d string def\n", width);
|
||||
fprintf (ofp, "/gstr %d string def\n", width);
|
||||
fprintf (ofp, "/bstr %d string def\n", width);
|
||||
fprintf (ofp,
|
||||
"{currentfile /ASCII85Decode filter /RunLengthDecode filter\
|
||||
rstr readstring pop}\n");
|
||||
fprintf (ofp,
|
||||
"{currentfile /ASCII85Decode filter /RunLengthDecode filter\
|
||||
gstr readstring pop}\n");
|
||||
fprintf (ofp,
|
||||
"{currentfile /ASCII85Decode filter /RunLengthDecode filter\
|
||||
bstr readstring pop}\n");
|
||||
fprintf (ofp, "true 3\n");
|
||||
|
||||
/* Allocate buffer for packbits data. Worst case: Less than 1% increase */
|
||||
packb = (guchar *)g_malloc ((width * 105)/100+2);
|
||||
plane = (guchar *)g_malloc (width);
|
||||
}
|
||||
fprintf (ofp, "colorimage\n");
|
||||
|
||||
|
@ -2212,20 +2391,33 @@ save_rgb (FILE *ofp,
|
|||
putc ('\n', ofp);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{guchar *plane_ptr, *src_ptr;
|
||||
int rgb, nout;
|
||||
|
||||
for (rgb = 0; rgb < 3; rgb++)
|
||||
{
|
||||
src_ptr = src + rgb;
|
||||
plane_ptr = plane;
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
ascii85_out (*(src++), ofp);
|
||||
ascii85_out (*(src++), ofp);
|
||||
ascii85_out (*(src++), ofp);
|
||||
}
|
||||
*(plane_ptr++) = *src_ptr;
|
||||
src_ptr += 3;
|
||||
}
|
||||
compress_packbits (width, plane, &nout, packb);
|
||||
ascii85_init ();
|
||||
ascii85_nout (nout, packb, ofp);
|
||||
ascii85_out (128, ofp); /* Write EOD of RunLengthDecode filter */
|
||||
ascii85_done (ofp);
|
||||
}
|
||||
src += 3*width;
|
||||
}
|
||||
if ((l_run_mode != RUN_NONINTERACTIVE) && ((i % 20) == 0))
|
||||
gimp_progress_update ((double) i / (double) height);
|
||||
}
|
||||
if (level2) ascii85_done (ofp);
|
||||
fprintf (ofp, "showpage\n");
|
||||
g_free (data);
|
||||
if (packb != NULL) g_free (packb);
|
||||
if (plane != NULL) g_free (plane);
|
||||
|
||||
gimp_drawable_detach (drawable);
|
||||
|
||||
|
@ -2238,7 +2430,7 @@ save_rgb (FILE *ofp,
|
|||
#undef GET_RGB_TILE
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
init_gtk (void)
|
||||
{
|
||||
gchar **argv;
|
||||
|
@ -2633,7 +2825,7 @@ save_dialog (void)
|
|||
gtk_main ();
|
||||
gdk_flush ();
|
||||
|
||||
psvals.level = (vals->level < 1);
|
||||
psvals.level = (vals->level) ? 2 : 1;
|
||||
|
||||
g_free (vals);
|
||||
|
||||
|
|
|
@ -402,7 +402,8 @@ query ()
|
|||
nload_args, nload_return_vals,
|
||||
load_args, load_return_vals);
|
||||
|
||||
gimp_register_load_handler ("file_psd_load", "psd", "");
|
||||
gimp_register_magic_load_handler ("file_psd_load", "psd", "",
|
||||
"0,string,8BPS");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -398,7 +398,7 @@ query (void)
|
|||
gimp_register_magic_load_handler ("file_psp_load",
|
||||
"psp,tub",
|
||||
"",
|
||||
"0,string,Paint Shop Pro Image File\n\032");
|
||||
"0,string,Paint\\040Shop\\040Pro\\040Image\\040File\n\032");
|
||||
/* Removed until Saving is implemented -- njl195@zepler.org
|
||||
gimp_register_save_handler ("file_psp_save",
|
||||
"psp,tub",
|
||||
|
|
|
@ -252,10 +252,10 @@ query (void)
|
|||
nsave_args, 0,
|
||||
save_args, NULL);
|
||||
|
||||
gimp_register_magic_load_handler ("file_tga_load",
|
||||
"tga",
|
||||
"",
|
||||
"0&,byte,10,2&,byte,1,3&,byte,>0,3,byte,<9");
|
||||
gimp_register_load_handler ("file_tga_load",
|
||||
"tga",
|
||||
"");
|
||||
|
||||
gimp_register_save_handler ("file_tga_save",
|
||||
"tga",
|
||||
"");
|
||||
|
|
|
@ -180,7 +180,7 @@ query (void)
|
|||
gimp_register_magic_load_handler ("file_xpm_load",
|
||||
"xpm",
|
||||
"<Load>/Xpm",
|
||||
"0, string, /* XPM */");
|
||||
"0, string,/*\\040XPM\\040*/");
|
||||
gimp_register_save_handler ("file_xpm_save",
|
||||
"xpm",
|
||||
"<Save>/Xpm");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
* XWD reading and writing code Copyright (C) 1996 Peter Kirchgessner
|
||||
* (email: pkirchg@aol.com, WWW: http://members.aol.com/pkirchg)
|
||||
* (email: peter@kirchgessner.net, WWW: http://www.kirchgessner.net)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -35,6 +35,7 @@
|
|||
* 2 | 1,...,24 | 32
|
||||
*/
|
||||
/* Event history:
|
||||
* PK = Peter Kirchgessner, ME = Mattias Engdegård
|
||||
* V 1.00, PK, xx-Aug-96: First try
|
||||
* V 1.01, PK, 03-Sep-96: Check for bitmap_bit_order
|
||||
* V 1.90, PK, 17-Mar-97: Upgrade to work with GIMP V0.99
|
||||
|
@ -43,8 +44,10 @@
|
|||
* V 1.91, PK, 05-Apr-97: Return all arguments, even in case of an error
|
||||
* V 1.92, PK, 12-Oct-97: No progress bars for non-interactive mode
|
||||
* V 1.93, PK, 11-Apr-98: Fix problem with overwriting memory
|
||||
* V 1.94, ME, 27-Feb-00: Remove superfluous little-endian support (format is
|
||||
specified as big-endian). Trim magic header
|
||||
*/
|
||||
static char ident[] = "@(#) GIMP XWD file-plugin v1.93 11-Apr-98";
|
||||
static char ident[] = "@(#) GIMP XWD file-plugin v1.94 27-Feb-2000";
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -183,8 +186,6 @@ static gint save_index (FILE *, gint32, gint32, int);
|
|||
static gint save_rgb (FILE *, gint32, gint32);
|
||||
|
||||
|
||||
static int read_msb_first = 1;
|
||||
|
||||
|
||||
GPlugInInfo PLUG_IN_INFO =
|
||||
{
|
||||
|
@ -260,7 +261,7 @@ those with alpha channels.",
|
|||
gimp_register_magic_load_handler ("file_xwd_load",
|
||||
"xwd",
|
||||
"",
|
||||
"4,long,0x00000007,4,long,0x07000000");
|
||||
"4,long,0x00000007");
|
||||
gimp_register_save_handler ("file_xwd_save",
|
||||
"xwd",
|
||||
"");
|
||||
|
@ -399,22 +400,12 @@ load_image (gchar *filename)
|
|||
return (-1);
|
||||
}
|
||||
|
||||
read_msb_first = 1; /* Start reading with most significant byte first */
|
||||
|
||||
read_xwd_header (ifp, &xwdhdr);
|
||||
if (xwdhdr.l_file_version != 7)
|
||||
{
|
||||
read_msb_first = 0; /* Try reading with least significant byte first */
|
||||
|
||||
fseek (ifp, 0, SEEK_SET);
|
||||
|
||||
read_xwd_header (ifp, &xwdhdr);
|
||||
if (xwdhdr.l_file_version != 7)
|
||||
{
|
||||
g_message(_("can't open file as XWD file"));
|
||||
fclose (ifp);
|
||||
return (-1);
|
||||
}
|
||||
g_message(_("can't open file as XWD file"));
|
||||
fclose (ifp);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Position to start of XWDColor structures */
|
||||
|
@ -585,20 +576,10 @@ read_card32 (FILE *ifp,
|
|||
{
|
||||
L_CARD32 c;
|
||||
|
||||
if (read_msb_first)
|
||||
{
|
||||
c = (((L_CARD32)(getc (ifp))) << 24);
|
||||
c |= (((L_CARD32)(getc (ifp))) << 16);
|
||||
c |= (((L_CARD32)(getc (ifp))) << 8);
|
||||
c |= ((L_CARD32)(*err = getc (ifp)));
|
||||
}
|
||||
else
|
||||
{
|
||||
c = ((L_CARD32)(getc (ifp)));
|
||||
c |= (((L_CARD32)(getc (ifp))) << 8);
|
||||
c |= (((L_CARD32)(getc (ifp))) << 16);
|
||||
c |= (((L_CARD32)(*err = getc (ifp))) << 24);
|
||||
}
|
||||
c = (((L_CARD32)(getc (ifp))) << 24);
|
||||
c |= (((L_CARD32)(getc (ifp))) << 16);
|
||||
c |= (((L_CARD32)(getc (ifp))) << 8);
|
||||
c |= ((L_CARD32)(*err = getc (ifp)));
|
||||
|
||||
*err = (*err < 0);
|
||||
return (c);
|
||||
|
@ -612,16 +593,8 @@ read_card16 (FILE *ifp,
|
|||
{
|
||||
L_CARD16 c;
|
||||
|
||||
if (read_msb_first)
|
||||
{
|
||||
c = (((L_CARD16)(getc (ifp))) << 8);
|
||||
c |= ((L_CARD16)(*err = getc (ifp)));
|
||||
}
|
||||
else
|
||||
{
|
||||
c = ((L_CARD16)(getc (ifp)));
|
||||
c |= (((L_CARD16)(*err = getc (ifp))) << 8);
|
||||
}
|
||||
c = (((L_CARD16)(getc (ifp))) << 8);
|
||||
c |= ((L_CARD16)(*err = getc (ifp)));
|
||||
|
||||
*err = (*err < 0);
|
||||
return (c);
|
||||
|
|
|
@ -1043,7 +1043,8 @@ load_image (gchar *filename,
|
|||
|
||||
/* pw - Last of all, attach the parasites (couldn't do it earlier -
|
||||
there was no image. */
|
||||
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
if (!preview)
|
||||
{
|
||||
if (comment_parasite)
|
||||
|
@ -1057,6 +1058,7 @@ load_image (gchar *filename,
|
|||
parasite_free (vals_parasite);
|
||||
}
|
||||
}
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
return image_ID;
|
||||
}
|
||||
|
@ -1382,7 +1384,7 @@ save_image (char *filename,
|
|||
jpeg_start_compress (&cinfo, TRUE);
|
||||
|
||||
/* Step 4.1: Write the comment out - pw */
|
||||
if (image_comment)
|
||||
if (image_comment && *image_comment)
|
||||
{
|
||||
jpeg_write_marker (&cinfo,
|
||||
JPEG_COM,
|
||||
|
|
|
@ -1043,7 +1043,8 @@ load_image (gchar *filename,
|
|||
|
||||
/* pw - Last of all, attach the parasites (couldn't do it earlier -
|
||||
there was no image. */
|
||||
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
if (!preview)
|
||||
{
|
||||
if (comment_parasite)
|
||||
|
@ -1057,6 +1058,7 @@ load_image (gchar *filename,
|
|||
parasite_free (vals_parasite);
|
||||
}
|
||||
}
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
return image_ID;
|
||||
}
|
||||
|
@ -1382,7 +1384,7 @@ save_image (char *filename,
|
|||
jpeg_start_compress (&cinfo, TRUE);
|
||||
|
||||
/* Step 4.1: Write the comment out - pw */
|
||||
if (image_comment)
|
||||
if (image_comment && *image_comment)
|
||||
{
|
||||
jpeg_write_marker (&cinfo,
|
||||
JPEG_COM,
|
||||
|
|
|
@ -1043,7 +1043,8 @@ load_image (gchar *filename,
|
|||
|
||||
/* pw - Last of all, attach the parasites (couldn't do it earlier -
|
||||
there was no image. */
|
||||
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
if (!preview)
|
||||
{
|
||||
if (comment_parasite)
|
||||
|
@ -1057,6 +1058,7 @@ load_image (gchar *filename,
|
|||
parasite_free (vals_parasite);
|
||||
}
|
||||
}
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
return image_ID;
|
||||
}
|
||||
|
@ -1382,7 +1384,7 @@ save_image (char *filename,
|
|||
jpeg_start_compress (&cinfo, TRUE);
|
||||
|
||||
/* Step 4.1: Write the comment out - pw */
|
||||
if (image_comment)
|
||||
if (image_comment && *image_comment)
|
||||
{
|
||||
jpeg_write_marker (&cinfo,
|
||||
JPEG_COM,
|
||||
|
|
|
@ -1043,7 +1043,8 @@ load_image (gchar *filename,
|
|||
|
||||
/* pw - Last of all, attach the parasites (couldn't do it earlier -
|
||||
there was no image. */
|
||||
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
if (!preview)
|
||||
{
|
||||
if (comment_parasite)
|
||||
|
@ -1057,6 +1058,7 @@ load_image (gchar *filename,
|
|||
parasite_free (vals_parasite);
|
||||
}
|
||||
}
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
return image_ID;
|
||||
}
|
||||
|
@ -1382,7 +1384,7 @@ save_image (char *filename,
|
|||
jpeg_start_compress (&cinfo, TRUE);
|
||||
|
||||
/* Step 4.1: Write the comment out - pw */
|
||||
if (image_comment)
|
||||
if (image_comment && *image_comment)
|
||||
{
|
||||
jpeg_write_marker (&cinfo,
|
||||
JPEG_COM,
|
||||
|
|
|
@ -1043,7 +1043,8 @@ load_image (gchar *filename,
|
|||
|
||||
/* pw - Last of all, attach the parasites (couldn't do it earlier -
|
||||
there was no image. */
|
||||
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
if (!preview)
|
||||
{
|
||||
if (comment_parasite)
|
||||
|
@ -1057,6 +1058,7 @@ load_image (gchar *filename,
|
|||
parasite_free (vals_parasite);
|
||||
}
|
||||
}
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
return image_ID;
|
||||
}
|
||||
|
@ -1382,7 +1384,7 @@ save_image (char *filename,
|
|||
jpeg_start_compress (&cinfo, TRUE);
|
||||
|
||||
/* Step 4.1: Write the comment out - pw */
|
||||
if (image_comment)
|
||||
if (image_comment && *image_comment)
|
||||
{
|
||||
jpeg_write_marker (&cinfo,
|
||||
JPEG_COM,
|
||||
|
|
|
@ -1043,7 +1043,8 @@ load_image (gchar *filename,
|
|||
|
||||
/* pw - Last of all, attach the parasites (couldn't do it earlier -
|
||||
there was no image. */
|
||||
|
||||
|
||||
#ifdef GIMP_HAVE_PARASITES
|
||||
if (!preview)
|
||||
{
|
||||
if (comment_parasite)
|
||||
|
@ -1057,6 +1058,7 @@ load_image (gchar *filename,
|
|||
parasite_free (vals_parasite);
|
||||
}
|
||||
}
|
||||
#endif /* GIMP_HAVE_PARASITES */
|
||||
|
||||
return image_ID;
|
||||
}
|
||||
|
@ -1382,7 +1384,7 @@ save_image (char *filename,
|
|||
jpeg_start_compress (&cinfo, TRUE);
|
||||
|
||||
/* Step 4.1: Write the comment out - pw */
|
||||
if (image_comment)
|
||||
if (image_comment && *image_comment)
|
||||
{
|
||||
jpeg_write_marker (&cinfo,
|
||||
JPEG_COM,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Gimp-Python - allows the writing of Gimp plugins in Python.
|
||||
# Copyright (C) 1997 James Henstridge <james@daa.com.au>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Gimp-Python - allows the writing of Gimp plugins in Python.
|
||||
# Copyright (C) 1997 James Henstridge <james@daa.com.au>
|
||||
|
|
Loading…
Reference in New Issue