plug mem leak in message_box

* app/interface.c: plug mem leak in message_box

* plug-ins/mail/mail.c: use g_message

* plug-ins/script-fu/scripts/carve-it.scm: fix for gimp-layer-new params from
Kevin Cozens <kcozens@interlog.com>

* plug-ins/CEL/CEL.c
* plug-ins/pcx/pcx.c
* plug-ins/tiff/tiff.c: updates from author

* plug-ins/png/png.c: correct copyright

* plug-ins/print/print.h: use correct version

-Yosh
This commit is contained in:
Manish Singh 1998-05-31 06:49:20 +00:00
parent 619a2eb0a0
commit a7b50bbeca
16 changed files with 222 additions and 152 deletions

View File

@ -1,3 +1,20 @@
Sat May 30 23:42:12 PDT 1998 Manish Singh <yosh@gimp.org>
* app/interface.c: plug mem leak in message_box
* plug-ins/mail/mail.c: use g_message
* plug-ins/script-fu/scripts/carve-it.scm: fix for gimp-layer-new
params from Kevin Cozens <kcozens@interlog.com>
* plug-ins/CEL/CEL.c
* plug-ins/pcx/pcx.c
* plug-ins/tiff/tiff.c: updates from author
* plug-ins/png/png.c: correct copyright
* plug-ins/print/print.h: use correct version
Fri May 29 23:54:42 PDT 1998 Manish Singh <yosh@gimp.org> Fri May 29 23:54:42 PDT 1998 Manish Singh <yosh@gimp.org>
* more changes to use g_message. All of app uses it now, plus * more changes to use g_message. All of app uses it now, plus

View File

@ -943,6 +943,8 @@ message_box (char *message,
gtk_widget_show (label); gtk_widget_show (label);
} }
g_free (message);
msg_box->mbox = mbox; msg_box->mbox = mbox;
msg_box->callback = callback; msg_box->callback = callback;
msg_box->data = data; msg_box->data = data;

View File

@ -943,6 +943,8 @@ message_box (char *message,
gtk_widget_show (label); gtk_widget_show (label);
} }
g_free (message);
msg_box->mbox = mbox; msg_box->mbox = mbox;
msg_box->callback = callback; msg_box->callback = callback;
msg_box->data = data; msg_box->data = data;

View File

@ -943,6 +943,8 @@ message_box (char *message,
gtk_widget_show (label); gtk_widget_show (label);
} }
g_free (message);
msg_box->mbox = mbox; msg_box->mbox = mbox;
msg_box->callback = callback; msg_box->callback = callback;
msg_box->data = data; msg_box->data = data;

View File

@ -1,5 +1,5 @@
/* cel.c -- KISS CEL file format plug-in for The GIMP /* cel.c -- KISS CEL file format plug-in for The GIMP
* (copyright) 1997,1998 Nick Lamb (njl195@ecs.soton.ac.uk) * (copyright) 1997,1998 Nick Lamb (njl195@zepler.org.uk)
* *
* Skeleton cloned from Michael Sweet's PNG plug-in. KISS format courtesy * Skeleton cloned from Michael Sweet's PNG plug-in. KISS format courtesy
* of the KISS/GS documentation. Problem reports to the above address * of the KISS/GS documentation. Problem reports to the above address
@ -91,7 +91,8 @@ static void query(void) {
gimp_install_procedure("file_cel_load", gimp_install_procedure("file_cel_load",
"Loads files in KISS CEL file format", "Loads files in KISS CEL file format",
"This plug-in loads individual KISS cell files.", "This plug-in loads individual KISS cell files.",
"Nick Lamb", "Nick Lamb", "May 1998", "<Load>/CEL", NULL, PROC_PLUG_IN, "Nick Lamb", "Nick Lamb <njl195@zepler.org.uk>", "May 1998",
"<Load>/CEL", NULL, PROC_PLUG_IN,
nload_args, nload_return_vals, load_args, load_return_vals); nload_args, nload_return_vals, load_args, load_return_vals);
gimp_register_magic_load_handler("file_cel_load", "cel", gimp_register_magic_load_handler("file_cel_load", "cel",
@ -100,7 +101,8 @@ static void query(void) {
gimp_install_procedure("file_cel_save", gimp_install_procedure("file_cel_save",
"Saves files in KISS CEL file format", "Saves files in KISS CEL file format",
"This plug-in saves individual KISS cell files.", "This plug-in saves individual KISS cell files.",
"Nick Lamb", "Nick Lamb", "May 1998", "<Save>/CEL", "INDEXEDA", "Nick Lamb", "Nick Lamb <njl195@zepler.org.uk>", "May 1998",
"<Save>/CEL", "INDEXEDA",
PROC_PLUG_IN, nsave_args, 0, save_args, NULL); PROC_PLUG_IN, nsave_args, 0, save_args, NULL);
gimp_register_save_handler("file_cel_save", "cel", ""); gimp_register_save_handler("file_cel_save", "cel", "");
@ -226,7 +228,7 @@ static gint32 load_image(char *file, char *brief) {
image = gimp_image_new(width + offx, height + offy, INDEXED); image = gimp_image_new(width + offx, height + offy, INDEXED);
if (image == -1) { if (image == -1) {
g_message("Can't create a new image"); g_message("CEL Can't create a new image");
gimp_quit(); gimp_quit();
} }
@ -286,7 +288,7 @@ static gint32 load_image(char *file, char *brief) {
} }
break; break;
default: default:
g_error("Unsupported number of colours (%d)\n", colours); g_message("Unsupported number of colours (%d)", colours);
gimp_quit(); gimp_quit();
} }
@ -397,7 +399,7 @@ static gint save_image(char *file, char *brief, gint32 image, gint32 layer) {
fp = fopen(file, "w"); fp = fopen(file, "w");
if (fp == NULL) { if (fp == NULL) {
g_message("Couldn't write image to\n%s", file); g_message("CEL Couldn't write image to\n%s", file);
gimp_quit(); gimp_quit();
} }

View File

@ -1,5 +1,5 @@
/* cel.c -- KISS CEL file format plug-in for The GIMP /* cel.c -- KISS CEL file format plug-in for The GIMP
* (copyright) 1997,1998 Nick Lamb (njl195@ecs.soton.ac.uk) * (copyright) 1997,1998 Nick Lamb (njl195@zepler.org.uk)
* *
* Skeleton cloned from Michael Sweet's PNG plug-in. KISS format courtesy * Skeleton cloned from Michael Sweet's PNG plug-in. KISS format courtesy
* of the KISS/GS documentation. Problem reports to the above address * of the KISS/GS documentation. Problem reports to the above address
@ -91,7 +91,8 @@ static void query(void) {
gimp_install_procedure("file_cel_load", gimp_install_procedure("file_cel_load",
"Loads files in KISS CEL file format", "Loads files in KISS CEL file format",
"This plug-in loads individual KISS cell files.", "This plug-in loads individual KISS cell files.",
"Nick Lamb", "Nick Lamb", "May 1998", "<Load>/CEL", NULL, PROC_PLUG_IN, "Nick Lamb", "Nick Lamb <njl195@zepler.org.uk>", "May 1998",
"<Load>/CEL", NULL, PROC_PLUG_IN,
nload_args, nload_return_vals, load_args, load_return_vals); nload_args, nload_return_vals, load_args, load_return_vals);
gimp_register_magic_load_handler("file_cel_load", "cel", gimp_register_magic_load_handler("file_cel_load", "cel",
@ -100,7 +101,8 @@ static void query(void) {
gimp_install_procedure("file_cel_save", gimp_install_procedure("file_cel_save",
"Saves files in KISS CEL file format", "Saves files in KISS CEL file format",
"This plug-in saves individual KISS cell files.", "This plug-in saves individual KISS cell files.",
"Nick Lamb", "Nick Lamb", "May 1998", "<Save>/CEL", "INDEXEDA", "Nick Lamb", "Nick Lamb <njl195@zepler.org.uk>", "May 1998",
"<Save>/CEL", "INDEXEDA",
PROC_PLUG_IN, nsave_args, 0, save_args, NULL); PROC_PLUG_IN, nsave_args, 0, save_args, NULL);
gimp_register_save_handler("file_cel_save", "cel", ""); gimp_register_save_handler("file_cel_save", "cel", "");
@ -226,7 +228,7 @@ static gint32 load_image(char *file, char *brief) {
image = gimp_image_new(width + offx, height + offy, INDEXED); image = gimp_image_new(width + offx, height + offy, INDEXED);
if (image == -1) { if (image == -1) {
g_message("Can't create a new image"); g_message("CEL Can't create a new image");
gimp_quit(); gimp_quit();
} }
@ -286,7 +288,7 @@ static gint32 load_image(char *file, char *brief) {
} }
break; break;
default: default:
g_error("Unsupported number of colours (%d)\n", colours); g_message("Unsupported number of colours (%d)", colours);
gimp_quit(); gimp_quit();
} }
@ -397,7 +399,7 @@ static gint save_image(char *file, char *brief, gint32 image, gint32 layer) {
fp = fopen(file, "w"); fp = fopen(file, "w");
if (fp == NULL) { if (fp == NULL) {
g_message("Couldn't write image to\n%s", file); g_message("CEL Couldn't write image to\n%s", file);
gimp_quit(); gimp_quit();
} }

View File

@ -335,19 +335,19 @@ save_image (char *filename,
/* fork off a uuencode process */ /* fork off a uuencode process */
if ((pid = fork ()) < 0) if ((pid = fork ()) < 0)
{ {
g_warning ("mail: fork failed: %s\n", g_strerror (errno)); g_message ("mail: fork failed: %s\n", g_strerror (errno));
return -1; return -1;
} }
else if (pid == 0) else if (pid == 0)
{ {
if (-1 == dup2 (fileno (mailpipe), fileno (stdout))) if (-1 == dup2 (fileno (mailpipe), fileno (stdout)))
{ {
g_warning ("mail: dup2 failed: %s\n", g_strerror (errno)); g_message ("mail: dup2 failed: %s\n", g_strerror (errno));
} }
execlp (UUENCODE, UUENCODE, tmpname, filename, NULL); execlp (UUENCODE, UUENCODE, tmpname, filename, NULL);
/* What are we doing here? exec must have failed */ /* What are we doing here? exec must have failed */
g_warning ("mail: exec failed: uuencode: %s\n", g_strerror (errno)); g_message ("mail: exec failed: uuencode: %s\n", g_strerror (errno));
/* close the pipe now */ /* close the pipe now */
@ -361,7 +361,7 @@ save_image (char *filename,
if (!WIFEXITED (status) || if (!WIFEXITED (status) ||
WEXITSTATUS (status) != 0) WEXITSTATUS (status) != 0)
{ {
g_warning ("mail: mail didnt work or something on file %s\n", tmpname); g_message ("mail: mail didnt work or something on file %s\n", tmpname);
return 0; return 0;
} }
} }
@ -656,7 +656,7 @@ find_extension (char *filename)
{ {
if (!ext || ext[1] == 0 || strchr (ext, '/')) if (!ext || ext[1] == 0 || strchr (ext, '/'))
{ {
g_warning ("mail: some sort of error with the file extension or lack thereof \n"); g_message ("mail: some sort of error with the file extension or lack thereof \n");
return NULL; return NULL;
} }

View File

@ -2,12 +2,14 @@
/* This code is based in parts on code by Francisco Bustamante, but the /* This code is based in parts on code by Francisco Bustamante, but the
largest portion of the code has been rewritten and is now maintained largest portion of the code has been rewritten and is now maintained
occasionally by Nick Lamb njl195@ecs.soton.ac.uk */ occasionally by Nick Lamb njl195@zepler.org.uk */
/* New for 1998 -- Load 1, 4, 8 & 24 bit PCX files */ /* New for 1998 -- Load 1, 4, 8 & 24 bit PCX files */
/* -- Save 8 & 24 bit PCX files */ /* -- Save 8 & 24 bit PCX files */
/* 1998-01-19 - fixed some endianness problems (Raphael Quinet) */ /* 1998-01-19 - fixed some endianness problems (Raphael Quinet) */
/* 1998-02-05 - merged patch with "official" tree, some tidying up (njl) */ /* 1998-02-05 - merged patch with "official" tree, some tidying up (njl) */
/* 1998-05-17 - changed email address, more tidying up (njl) */
/* 1998-05-31 - g_message (njl) */
/* Please contact me if you can't use your PCXs with this tool, I want /* Please contact me if you can't use your PCXs with this tool, I want
The GIMP to have the best file filters on the planet */ The GIMP to have the best file filters on the planet */
@ -15,7 +17,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include "gtk/gtk.h" #include "gtk/gtk.h"
#include "libgimp/gimp.h" #include "libgimp/gimp.h"
@ -73,7 +74,7 @@ static void query () {
"Loads files in Zsoft PCX file format", "Loads files in Zsoft PCX file format",
"FIXME: write help for pcx_load", "FIXME: write help for pcx_load",
"Francisco Bustamante & Nick Lamb", "Francisco Bustamante & Nick Lamb",
"Nick Lamb <njl195@ecs.soton.ac.uk>", "Nick Lamb <njl195@zepler.org.uk>",
"January 1997", "January 1997",
"<Load>/PCX", "<Load>/PCX",
NULL, NULL,
@ -85,7 +86,7 @@ static void query () {
"Saves files in ZSoft PCX file format", "Saves files in ZSoft PCX file format",
"FIXME: write help for pcx_save", "FIXME: write help for pcx_save",
"Francisco Bustamante & Nick Lamb", "Francisco Bustamante & Nick Lamb",
"Nick Lamb <njl195@ecs.soton.ac.uk>", "Nick Lamb <njl195@zepler.org.uk>",
"January 1997", "January 1997",
"<Save>/PCX", "<Save>/PCX",
"INDEXED, RGB, GRAY", "INDEXED, RGB, GRAY",
@ -101,10 +102,10 @@ static void query () {
/* Declare internal functions. */ /* Declare internal functions. */
static gint32 load_image (char *filename); static gint32 load_image (char *filename);
static void load_1(FILE *fp, int width, int height, guchar *buffer, int bytes); static void load_1(FILE *fp, int width, int height, char *buffer, int bytes);
static void load_4(FILE *fp, int width, int height, guchar *buffer, int bytes); static void load_4(FILE *fp, int width, int height, char *buffer, int bytes);
static void load_8(FILE *fp, int width, int height, guchar *buffer, int bytes); static void load_8(FILE *fp, int width, int height, char *buffer, int bytes);
static void load_24(FILE *fp, int width, int height, guchar *buffer, int bytes); static void load_24(FILE *fp, int width, int height, char *buffer, int bytes);
static void readline(FILE *fp, guchar* buffer, int bytes); static void readline(FILE *fp, guchar* buffer, int bytes);
static gint save_image (char *filename, gint32 image, gint32 layer); static gint save_image (char *filename, gint32 image, gint32 layer);
@ -128,21 +129,17 @@ static void run (char *name, int nparams, GParam *param, int *nreturn_vals,
values[0].type = PARAM_STATUS; values[0].type = PARAM_STATUS;
values[0].data.d_status = STATUS_CALLING_ERROR; values[0].data.d_status = STATUS_CALLING_ERROR;
if (strcmp (name, "file_pcx_load") == 0) if (strcmp (name, "file_pcx_load") == 0) {
{
image_ID = load_image (param[1].data.d_string); image_ID = load_image (param[1].data.d_string);
if (image_ID != -1) if (image_ID != -1) {
{ *nreturn_vals = 2;
*nreturn_vals = 2; values[0].data.d_status = STATUS_SUCCESS;
values[0].data.d_status = STATUS_SUCCESS; values[1].type = PARAM_IMAGE;
values[1].type = PARAM_IMAGE; values[1].data.d_image = image_ID;
values[1].data.d_image = image_ID; } else {
} values[0].data.d_status = STATUS_EXECUTION_ERROR;
else }
{
values[0].data.d_status = STATUS_EXECUTION_ERROR;
}
} }
else if (strcmp (name, "file_pcx_save") == 0) else if (strcmp (name, "file_pcx_save") == 0)
{ {
@ -208,17 +205,17 @@ static gint32 load_image (char *filename) {
fd = fopen (filename, "rb"); fd = fopen (filename, "rb");
if (!fd) { if (!fd) {
fprintf(stderr, "PCX: Can't open \"%s\"\n", filename); g_message("PCX Can't open\n%s", filename);
return -1; return -1;
} }
if (fread(&pcx_header, 128, 1, fd) == 0) { if (fread(&pcx_header, 128, 1, fd) == 0) {
fprintf(stderr, "PCX: Can't read header from \"%s\"\n", filename); g_message("PCX Can't read header from\n%s", filename);
return -1; return -1;
} }
if(pcx_header.manufacturer != 10) { if(pcx_header.manufacturer != 10) {
fprintf(stderr, "PCX: File \"%s\" is not a PCX file\n", filename); g_message("%s\nis not a PCX file", filename);
return -1; return -1;
} }
@ -259,7 +256,7 @@ static gint32 load_image (char *filename) {
dest = (guchar *) g_malloc (width * height * 3); dest = (guchar *) g_malloc (width * height * 3);
load_24(fd, width, height, dest, qtohs (pcx_header.bytesperline)); load_24(fd, width, height, dest, qtohs (pcx_header.bytesperline));
} else { } else {
fprintf(stderr, "PCX: Unusual PCX flavour, giving up\n"); g_message("Unusual PCX flavour, giving up");
return -1; return -1;
} }
@ -274,7 +271,7 @@ static gint32 load_image (char *filename) {
return image; return image;
} }
static void load_8(FILE *fp, int width, int height, guchar *buffer, int bytes) { static void load_8(FILE *fp, int width, int height, char *buffer, int bytes) {
int row; int row;
guchar *line; guchar *line;
line= (guchar *) g_malloc(bytes); line= (guchar *) g_malloc(bytes);
@ -288,7 +285,7 @@ static void load_8(FILE *fp, int width, int height, guchar *buffer, int bytes) {
g_free(line); g_free(line);
} }
static void load_24(FILE *fp, int width, int height, guchar *buffer, int bytes) { static void load_24(FILE *fp, int width, int height, char *buffer, int bytes) {
int x, y, c; int x, y, c;
guchar *line; guchar *line;
line= (guchar *) g_malloc(bytes * 3); line= (guchar *) g_malloc(bytes * 3);
@ -306,7 +303,7 @@ static void load_24(FILE *fp, int width, int height, guchar *buffer, int bytes)
g_free(line); g_free(line);
} }
static void load_1(FILE *fp, int width, int height, guchar *buffer, int bytes) { static void load_1(FILE *fp, int width, int height, char *buffer, int bytes) {
int x, y; int x, y;
guchar *line; guchar *line;
line= (guchar *) g_malloc(bytes); line= (guchar *) g_malloc(bytes);
@ -325,7 +322,7 @@ static void load_1(FILE *fp, int width, int height, guchar *buffer, int bytes) {
g_free(line); g_free(line);
} }
static void load_4(FILE *fp, int width, int height, guchar *buffer, int bytes) { static void load_4(FILE *fp, int width, int height, char *buffer, int bytes) {
int x, y, c; int x, y, c;
guchar *line; guchar *line;
line= (guchar *) g_malloc(bytes); line= (guchar *) g_malloc(bytes);
@ -367,7 +364,7 @@ static void readline(FILE *fp, guchar *buffer, int bytes) {
} }
} }
static gint save_image (char *filename, gint32 image, gint32 layer) { gint save_image (char *filename, gint32 image, gint32 layer) {
FILE *fp; FILE *fp;
GPixelRgn pixel_rgn; GPixelRgn pixel_rgn;
GDrawable *drawable; GDrawable *drawable;
@ -417,13 +414,13 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
break; break;
default: default:
fprintf(stderr, "PCX: Can't save this image type\n"); g_message("PCX Can't save this image type\nFlatten your image");
return -1; return -1;
break; break;
} }
if ((fp = fopen(filename, "wb")) == NULL) { if ((fp = fopen(filename, "wb")) == NULL) {
fprintf(stderr, "PCX: Can't open \"%s\"\n", filename); g_message("PCX Can't open \n%s", filename);
return -1; return -1;
} }
@ -461,7 +458,7 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
} }
break; break;
default: default:
fprintf(stderr, "PCX: Can't save this image type\n"); g_message("Can't save this image as PCX\nFlatten your image");
return -1; return -1;
break; break;
} }

View File

@ -4,7 +4,7 @@
* Portable Network Graphics (PNG) plug-in for The GIMP -- an image * Portable Network Graphics (PNG) plug-in for The GIMP -- an image
* manipulation program * manipulation program
* *
* Copyright 1997 Michael Sweet (mike@easysw.com) and * Copyright 1997-1998 Michael Sweet (mike@easysw.com) and
* Daniel Skarda (0rfelyus@atrey.karlin.mff.cuni.cz). * Daniel Skarda (0rfelyus@atrey.karlin.mff.cuni.cz).
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -37,6 +37,24 @@
* Revision History: * Revision History:
* *
* $Log$ * $Log$
* Revision 1.7 1998/05/31 06:49:16 yosh
* * app/interface.c: plug mem leak in message_box
*
* * plug-ins/mail/mail.c: use g_message
*
* * plug-ins/script-fu/scripts/carve-it.scm: fix for gimp-layer-new params from
* Kevin Cozens <kcozens@interlog.com>
*
* * plug-ins/CEL/CEL.c
* * plug-ins/pcx/pcx.c
* * plug-ins/tiff/tiff.c: updates from author
*
* * plug-ins/png/png.c: correct copyright
*
* * plug-ins/print/print.h: use correct version
*
* -Yosh
*
* Revision 1.6 1998/04/13 05:43:08 yosh * Revision 1.6 1998/04/13 05:43:08 yosh
* Have fun recompiling gimp everyone. It's the great FSF address change! * Have fun recompiling gimp everyone. It's the great FSF address change!
* *

View File

@ -124,7 +124,7 @@ query ()
"loads files of the tiff file format", "loads files of the tiff file format",
"FIXME: write help for tiff_load", "FIXME: write help for tiff_load",
"Spencer Kimball, Peter Mattis & Nick Lamb", "Spencer Kimball, Peter Mattis & Nick Lamb",
"Nick Lamb <njl195@.ecs.soton.ac.uk>", "Nick Lamb <njl195@zepler.org.uk>",
"1995-1996,1998", "1995-1996,1998",
"<Load>/Tiff", "<Load>/Tiff",
NULL, NULL,
@ -248,7 +248,7 @@ static gint32 load_image (char *filename) {
unsigned short *redmap, *greenmap, *bluemap; unsigned short *redmap, *greenmap, *bluemap;
guchar cmap[768]; guchar cmap[768];
int image_type= 0, layer_type= 0; int image_type= 0, layer_type= 0;
unsigned short *extra_types, extra = 0; unsigned short extra, *extra_types;
int col, row, start, i, j; int col, row, start, i, j;
unsigned char sample; unsigned char sample;
@ -274,7 +274,7 @@ static gint32 load_image (char *filename) {
tif = TIFFOpen (filename, "r"); tif = TIFFOpen (filename, "r");
if (!tif) { if (!tif) {
g_error ("TIFF Can't open \"%s\"\n", filename); g_message("TIFF Can't open \n%s", filename);
gimp_quit (); gimp_quit ();
} }
@ -287,7 +287,7 @@ static gint32 load_image (char *filename) {
bps = 1; bps = 1;
if (bps > 8) { if (bps > 8) {
g_error("TIFF Can't handle samples wider than 8-bit\n"); g_message("TIFF Can't handle samples wider than 8-bit");
gimp_quit(); gimp_quit();
} }
@ -297,17 +297,17 @@ static gint32 load_image (char *filename) {
extra = 0; extra = 0;
if (!TIFFGetField (tif, TIFFTAG_IMAGEWIDTH, &cols)) { if (!TIFFGetField (tif, TIFFTAG_IMAGEWIDTH, &cols)) {
g_error ("TIFF Can't get image width\n"); g_message("TIFF Can't get image width");
gimp_quit (); gimp_quit ();
} }
if (!TIFFGetField (tif, TIFFTAG_IMAGELENGTH, &rows)) { if (!TIFFGetField (tif, TIFFTAG_IMAGELENGTH, &rows)) {
g_error ("TIFF Can't get image length\n"); g_message("TIFF Can't get image length");
gimp_quit (); gimp_quit ();
} }
if (!TIFFGetField (tif, TIFFTAG_PHOTOMETRIC, &photomet)) { if (!TIFFGetField (tif, TIFFTAG_PHOTOMETRIC, &photomet)) {
g_error ("TIFF Can't get photometric\n"); g_message("TIFF Can't get photometric");
gimp_quit (); gimp_quit ();
} }
@ -318,9 +318,12 @@ static gint32 load_image (char *filename) {
alpha = 0; alpha = 0;
} }
/* some programs seem to think alpha etc. aren't "extra" samples (?) */ if (photomet == PHOTOMETRIC_RGB && spp > extra + 3) {
if (spp > 3) {
extra= spp - 3; extra= spp - 3;
alpha= 1;
} else if (photomet != PHOTOMETRIC_RGB && spp > extra + 1) {
extra= spp - 1;
alpha= 1;
} }
maxval = (1 << bps) - 1; maxval = (1 << bps) - 1;
@ -343,16 +346,16 @@ static gint32 load_image (char *filename) {
break; break;
case PHOTOMETRIC_MASK: case PHOTOMETRIC_MASK:
g_error ("TIFF Can't handle PHOTOMETRIC_MASK\n"); g_message ("TIFF Can't handle PHOTOMETRIC_MASK");
gimp_quit (); gimp_quit ();
break; break;
default: default:
g_error ("TIFF Unknown photometric: %d\n", photomet); g_message ("TIFF Unknown photometric\n Number %d", photomet);
gimp_quit (); gimp_quit ();
} }
if ((image = gimp_image_new (cols, rows, image_type)) == -1) { if ((image = gimp_image_new (cols, rows, image_type)) == -1) {
g_error ("TIFF Can't allocate new image\n"); g_message("TIFF Can't create a new image\n");
gimp_quit (); gimp_quit ();
} }
gimp_image_set_filename (image, filename); gimp_image_set_filename (image, filename);
@ -360,7 +363,7 @@ static gint32 load_image (char *filename) {
/* Install colormap for INDEXED images only */ /* Install colormap for INDEXED images only */
if (image_type == INDEXED) { if (image_type == INDEXED) {
if (!TIFFGetField (tif, TIFFTAG_COLORMAP, &redmap, &greenmap, &bluemap)) { if (!TIFFGetField (tif, TIFFTAG_COLORMAP, &redmap, &greenmap, &bluemap)) {
g_error ("TIFF Can't get colormaps\n"); g_message("TIFF Can't get colormaps");
gimp_quit (); gimp_quit ();
} }
@ -416,14 +419,14 @@ static gint32 load_image (char *filename) {
/* Special cases: Scanline is compatible with GIMP storage */ /* Special cases: Scanline is compatible with GIMP storage */
if (extra == 0 && bps == 8) { if (extra == 0 && bps == 8) {
if (TIFFReadScanline (tif, d, row, 0) < 0) { if (TIFFReadScanline (tif, d, row, 0) < 0) {
g_error ("TIFF Bad data read on line %d\n", row); g_message("TIFF Bad data read on line %d", row);
gimp_quit (); gimp_quit ();
} }
/* Or read in and process each sample -- slower */ /* Or read in and process each sample -- slower */
} else { } else {
if (TIFFReadScanline (tif, source, row, 0) < 0) { if (TIFFReadScanline (tif, source, row, 0) < 0) {
g_error ("TIFF Bad data read on line %d\n", row); g_message("TIFF Bad data read on line %d\n", row);
gimp_quit (); gimp_quit ();
} }
@ -602,11 +605,10 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
rowsperstrip = 0; rowsperstrip = 0;
tif = TIFFOpen (filename, "w"); tif = TIFFOpen (filename, "w");
if (!tif) if (!tif) {
{ g_print ("Can't write image to\n%s", filename);
g_print ("can't open \"%s\"\n", filename); return 0;
return 0; }
}
name = malloc (strlen (filename) + 11); name = malloc (strlen (filename) + 11);
sprintf (name, "Saving %s:", filename); sprintf (name, "Saving %s:", filename);
@ -752,11 +754,10 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
break; break;
} }
if (!success) if (!success) {
{ g_message("TIFF Failed a scanline write on row %d", row);
g_print ("failed a scanline write on row %d\n", row);
return 0; return 0;
} }
} }
gimp_progress_update ((double) row / (double) rows); gimp_progress_update ((double) row / (double) rows);

View File

@ -335,19 +335,19 @@ save_image (char *filename,
/* fork off a uuencode process */ /* fork off a uuencode process */
if ((pid = fork ()) < 0) if ((pid = fork ()) < 0)
{ {
g_warning ("mail: fork failed: %s\n", g_strerror (errno)); g_message ("mail: fork failed: %s\n", g_strerror (errno));
return -1; return -1;
} }
else if (pid == 0) else if (pid == 0)
{ {
if (-1 == dup2 (fileno (mailpipe), fileno (stdout))) if (-1 == dup2 (fileno (mailpipe), fileno (stdout)))
{ {
g_warning ("mail: dup2 failed: %s\n", g_strerror (errno)); g_message ("mail: dup2 failed: %s\n", g_strerror (errno));
} }
execlp (UUENCODE, UUENCODE, tmpname, filename, NULL); execlp (UUENCODE, UUENCODE, tmpname, filename, NULL);
/* What are we doing here? exec must have failed */ /* What are we doing here? exec must have failed */
g_warning ("mail: exec failed: uuencode: %s\n", g_strerror (errno)); g_message ("mail: exec failed: uuencode: %s\n", g_strerror (errno));
/* close the pipe now */ /* close the pipe now */
@ -361,7 +361,7 @@ save_image (char *filename,
if (!WIFEXITED (status) || if (!WIFEXITED (status) ||
WEXITSTATUS (status) != 0) WEXITSTATUS (status) != 0)
{ {
g_warning ("mail: mail didnt work or something on file %s\n", tmpname); g_message ("mail: mail didnt work or something on file %s\n", tmpname);
return 0; return 0;
} }
} }
@ -656,7 +656,7 @@ find_extension (char *filename)
{ {
if (!ext || ext[1] == 0 || strchr (ext, '/')) if (!ext || ext[1] == 0 || strchr (ext, '/'))
{ {
g_warning ("mail: some sort of error with the file extension or lack thereof \n"); g_message ("mail: some sort of error with the file extension or lack thereof \n");
return NULL; return NULL;
} }

View File

@ -2,12 +2,14 @@
/* This code is based in parts on code by Francisco Bustamante, but the /* This code is based in parts on code by Francisco Bustamante, but the
largest portion of the code has been rewritten and is now maintained largest portion of the code has been rewritten and is now maintained
occasionally by Nick Lamb njl195@ecs.soton.ac.uk */ occasionally by Nick Lamb njl195@zepler.org.uk */
/* New for 1998 -- Load 1, 4, 8 & 24 bit PCX files */ /* New for 1998 -- Load 1, 4, 8 & 24 bit PCX files */
/* -- Save 8 & 24 bit PCX files */ /* -- Save 8 & 24 bit PCX files */
/* 1998-01-19 - fixed some endianness problems (Raphael Quinet) */ /* 1998-01-19 - fixed some endianness problems (Raphael Quinet) */
/* 1998-02-05 - merged patch with "official" tree, some tidying up (njl) */ /* 1998-02-05 - merged patch with "official" tree, some tidying up (njl) */
/* 1998-05-17 - changed email address, more tidying up (njl) */
/* 1998-05-31 - g_message (njl) */
/* Please contact me if you can't use your PCXs with this tool, I want /* Please contact me if you can't use your PCXs with this tool, I want
The GIMP to have the best file filters on the planet */ The GIMP to have the best file filters on the planet */
@ -15,7 +17,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include "gtk/gtk.h" #include "gtk/gtk.h"
#include "libgimp/gimp.h" #include "libgimp/gimp.h"
@ -73,7 +74,7 @@ static void query () {
"Loads files in Zsoft PCX file format", "Loads files in Zsoft PCX file format",
"FIXME: write help for pcx_load", "FIXME: write help for pcx_load",
"Francisco Bustamante & Nick Lamb", "Francisco Bustamante & Nick Lamb",
"Nick Lamb <njl195@ecs.soton.ac.uk>", "Nick Lamb <njl195@zepler.org.uk>",
"January 1997", "January 1997",
"<Load>/PCX", "<Load>/PCX",
NULL, NULL,
@ -85,7 +86,7 @@ static void query () {
"Saves files in ZSoft PCX file format", "Saves files in ZSoft PCX file format",
"FIXME: write help for pcx_save", "FIXME: write help for pcx_save",
"Francisco Bustamante & Nick Lamb", "Francisco Bustamante & Nick Lamb",
"Nick Lamb <njl195@ecs.soton.ac.uk>", "Nick Lamb <njl195@zepler.org.uk>",
"January 1997", "January 1997",
"<Save>/PCX", "<Save>/PCX",
"INDEXED, RGB, GRAY", "INDEXED, RGB, GRAY",
@ -101,10 +102,10 @@ static void query () {
/* Declare internal functions. */ /* Declare internal functions. */
static gint32 load_image (char *filename); static gint32 load_image (char *filename);
static void load_1(FILE *fp, int width, int height, guchar *buffer, int bytes); static void load_1(FILE *fp, int width, int height, char *buffer, int bytes);
static void load_4(FILE *fp, int width, int height, guchar *buffer, int bytes); static void load_4(FILE *fp, int width, int height, char *buffer, int bytes);
static void load_8(FILE *fp, int width, int height, guchar *buffer, int bytes); static void load_8(FILE *fp, int width, int height, char *buffer, int bytes);
static void load_24(FILE *fp, int width, int height, guchar *buffer, int bytes); static void load_24(FILE *fp, int width, int height, char *buffer, int bytes);
static void readline(FILE *fp, guchar* buffer, int bytes); static void readline(FILE *fp, guchar* buffer, int bytes);
static gint save_image (char *filename, gint32 image, gint32 layer); static gint save_image (char *filename, gint32 image, gint32 layer);
@ -128,21 +129,17 @@ static void run (char *name, int nparams, GParam *param, int *nreturn_vals,
values[0].type = PARAM_STATUS; values[0].type = PARAM_STATUS;
values[0].data.d_status = STATUS_CALLING_ERROR; values[0].data.d_status = STATUS_CALLING_ERROR;
if (strcmp (name, "file_pcx_load") == 0) if (strcmp (name, "file_pcx_load") == 0) {
{
image_ID = load_image (param[1].data.d_string); image_ID = load_image (param[1].data.d_string);
if (image_ID != -1) if (image_ID != -1) {
{ *nreturn_vals = 2;
*nreturn_vals = 2; values[0].data.d_status = STATUS_SUCCESS;
values[0].data.d_status = STATUS_SUCCESS; values[1].type = PARAM_IMAGE;
values[1].type = PARAM_IMAGE; values[1].data.d_image = image_ID;
values[1].data.d_image = image_ID; } else {
} values[0].data.d_status = STATUS_EXECUTION_ERROR;
else }
{
values[0].data.d_status = STATUS_EXECUTION_ERROR;
}
} }
else if (strcmp (name, "file_pcx_save") == 0) else if (strcmp (name, "file_pcx_save") == 0)
{ {
@ -208,17 +205,17 @@ static gint32 load_image (char *filename) {
fd = fopen (filename, "rb"); fd = fopen (filename, "rb");
if (!fd) { if (!fd) {
fprintf(stderr, "PCX: Can't open \"%s\"\n", filename); g_message("PCX Can't open\n%s", filename);
return -1; return -1;
} }
if (fread(&pcx_header, 128, 1, fd) == 0) { if (fread(&pcx_header, 128, 1, fd) == 0) {
fprintf(stderr, "PCX: Can't read header from \"%s\"\n", filename); g_message("PCX Can't read header from\n%s", filename);
return -1; return -1;
} }
if(pcx_header.manufacturer != 10) { if(pcx_header.manufacturer != 10) {
fprintf(stderr, "PCX: File \"%s\" is not a PCX file\n", filename); g_message("%s\nis not a PCX file", filename);
return -1; return -1;
} }
@ -259,7 +256,7 @@ static gint32 load_image (char *filename) {
dest = (guchar *) g_malloc (width * height * 3); dest = (guchar *) g_malloc (width * height * 3);
load_24(fd, width, height, dest, qtohs (pcx_header.bytesperline)); load_24(fd, width, height, dest, qtohs (pcx_header.bytesperline));
} else { } else {
fprintf(stderr, "PCX: Unusual PCX flavour, giving up\n"); g_message("Unusual PCX flavour, giving up");
return -1; return -1;
} }
@ -274,7 +271,7 @@ static gint32 load_image (char *filename) {
return image; return image;
} }
static void load_8(FILE *fp, int width, int height, guchar *buffer, int bytes) { static void load_8(FILE *fp, int width, int height, char *buffer, int bytes) {
int row; int row;
guchar *line; guchar *line;
line= (guchar *) g_malloc(bytes); line= (guchar *) g_malloc(bytes);
@ -288,7 +285,7 @@ static void load_8(FILE *fp, int width, int height, guchar *buffer, int bytes) {
g_free(line); g_free(line);
} }
static void load_24(FILE *fp, int width, int height, guchar *buffer, int bytes) { static void load_24(FILE *fp, int width, int height, char *buffer, int bytes) {
int x, y, c; int x, y, c;
guchar *line; guchar *line;
line= (guchar *) g_malloc(bytes * 3); line= (guchar *) g_malloc(bytes * 3);
@ -306,7 +303,7 @@ static void load_24(FILE *fp, int width, int height, guchar *buffer, int bytes)
g_free(line); g_free(line);
} }
static void load_1(FILE *fp, int width, int height, guchar *buffer, int bytes) { static void load_1(FILE *fp, int width, int height, char *buffer, int bytes) {
int x, y; int x, y;
guchar *line; guchar *line;
line= (guchar *) g_malloc(bytes); line= (guchar *) g_malloc(bytes);
@ -325,7 +322,7 @@ static void load_1(FILE *fp, int width, int height, guchar *buffer, int bytes) {
g_free(line); g_free(line);
} }
static void load_4(FILE *fp, int width, int height, guchar *buffer, int bytes) { static void load_4(FILE *fp, int width, int height, char *buffer, int bytes) {
int x, y, c; int x, y, c;
guchar *line; guchar *line;
line= (guchar *) g_malloc(bytes); line= (guchar *) g_malloc(bytes);
@ -367,7 +364,7 @@ static void readline(FILE *fp, guchar *buffer, int bytes) {
} }
} }
static gint save_image (char *filename, gint32 image, gint32 layer) { gint save_image (char *filename, gint32 image, gint32 layer) {
FILE *fp; FILE *fp;
GPixelRgn pixel_rgn; GPixelRgn pixel_rgn;
GDrawable *drawable; GDrawable *drawable;
@ -417,13 +414,13 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
break; break;
default: default:
fprintf(stderr, "PCX: Can't save this image type\n"); g_message("PCX Can't save this image type\nFlatten your image");
return -1; return -1;
break; break;
} }
if ((fp = fopen(filename, "wb")) == NULL) { if ((fp = fopen(filename, "wb")) == NULL) {
fprintf(stderr, "PCX: Can't open \"%s\"\n", filename); g_message("PCX Can't open \n%s", filename);
return -1; return -1;
} }
@ -461,7 +458,7 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
} }
break; break;
default: default:
fprintf(stderr, "PCX: Can't save this image type\n"); g_message("Can't save this image as PCX\nFlatten your image");
return -1; return -1;
break; break;
} }

View File

@ -4,7 +4,7 @@
* Portable Network Graphics (PNG) plug-in for The GIMP -- an image * Portable Network Graphics (PNG) plug-in for The GIMP -- an image
* manipulation program * manipulation program
* *
* Copyright 1997 Michael Sweet (mike@easysw.com) and * Copyright 1997-1998 Michael Sweet (mike@easysw.com) and
* Daniel Skarda (0rfelyus@atrey.karlin.mff.cuni.cz). * Daniel Skarda (0rfelyus@atrey.karlin.mff.cuni.cz).
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -37,6 +37,24 @@
* Revision History: * Revision History:
* *
* $Log$ * $Log$
* Revision 1.7 1998/05/31 06:49:16 yosh
* * app/interface.c: plug mem leak in message_box
*
* * plug-ins/mail/mail.c: use g_message
*
* * plug-ins/script-fu/scripts/carve-it.scm: fix for gimp-layer-new params from
* Kevin Cozens <kcozens@interlog.com>
*
* * plug-ins/CEL/CEL.c
* * plug-ins/pcx/pcx.c
* * plug-ins/tiff/tiff.c: updates from author
*
* * plug-ins/png/png.c: correct copyright
*
* * plug-ins/print/print.h: use correct version
*
* -Yosh
*
* Revision 1.6 1998/04/13 05:43:08 yosh * Revision 1.6 1998/04/13 05:43:08 yosh
* Have fun recompiling gimp everyone. It's the great FSF address change! * Have fun recompiling gimp everyone. It's the great FSF address change!
* *

View File

@ -22,13 +22,27 @@
* Revision History: * Revision History:
* *
* $Log$ * $Log$
* Revision 1.6 1998/05/14 00:32:53 yosh * Revision 1.7 1998/05/31 06:49:17 yosh
* updated print plugin * * app/interface.c: plug mem leak in message_box
* *
* stubbed out nonworking frac code * * plug-ins/mail/mail.c: use g_message
*
* * plug-ins/script-fu/scripts/carve-it.scm: fix for gimp-layer-new params from
* Kevin Cozens <kcozens@interlog.com>
*
* * plug-ins/CEL/CEL.c
* * plug-ins/pcx/pcx.c
* * plug-ins/tiff/tiff.c: updates from author
*
* * plug-ins/png/png.c: correct copyright
*
* * plug-ins/print/print.h: use correct version
* *
* -Yosh * -Yosh
* *
* Revision 1.12 1998/05/16 14:25:51 mike
* Updated for v2.0.2.
*
* Revision 1.11 1998/05/08 19:20:50 mike * Revision 1.11 1998/05/08 19:20:50 mike
* Updated for new driver interface. * Updated for new driver interface.
* Added media size, imageable area, and parameter functions. * Added media size, imageable area, and parameter functions.
@ -92,15 +106,9 @@
* Constants... * Constants...
*/ */
#define PLUG_IN_VERSION "2.0 - 8 May 1998" #define PLUG_IN_VERSION "2.0.2 - 16 May 1998"
#define PLUG_IN_NAME "Print" #define PLUG_IN_NAME "Print"
#define MEDIA_LETTER 0 /* 8.5x11" a.k.a. "A" size */
#define MEDIA_LEGAL 1 /* 8.5x14" */
#define MEDIA_TABLOID 2 /* 11x17" a.k.a. "B" size */
#define MEDIA_A4 3 /* 8.27x11.69" (210x297mm) */
#define MEDIA_A3 4 /* 11.69x16.54" (297x420mm) */
#define OUTPUT_GRAY 0 /* Grayscale output */ #define OUTPUT_GRAY 0 /* Grayscale output */
#define OUTPUT_COLOR 1 /* Color output */ #define OUTPUT_COLOR 1 /* Color output */

View File

@ -4,6 +4,9 @@
; http://www.peachpit.com ; http://www.peachpit.com
; This script requires a grayscale image containing a single layer. ; This script requires a grayscale image containing a single layer.
; This layer is used as the mask for the carving effect ; This layer is used as the mask for the carving effect
; NOTE: This script requires the image to be carved to either be an
; RGB colour or grayscale image with a single layer. An indexed file
; can not be used due to the use of gimp-histogram and gimp-levels.
(define (carve-brush brush-size) (define (carve-brush brush-size)
@ -65,12 +68,12 @@
(csl-mask 0) (csl-mask 0)
(inset-layer 0) (inset-layer 0)
(il-mask 0) (il-mask 0)
(bg-height (car (gimp-drawable-height bg-layer)))
(bg-width (car (gimp-drawable-width bg-layer))) (bg-width (car (gimp-drawable-width bg-layer)))
(bg-height (car (gimp-drawable-height bg-layer)))
(bg-type (car (gimp-drawable-type bg-layer))) (bg-type (car (gimp-drawable-type bg-layer)))
(bg-image (car (gimp-drawable-image bg-layer))) (bg-image (car (gimp-drawable-image bg-layer)))
(layer1 (car (gimp-layer-new img bg-height bg-width bg-type "Layer1" 100 NORMAL))) (layer1 (car (gimp-layer-new img bg-width bg-height bg-type "Layer1" 100 NORMAL)))
(inset-layer (car (gimp-layer-new img bg-height bg-width bg-type "inset1" 100 NORMAL))) (inset-layer (car (gimp-layer-new img bg-width bg-height bg-type "inset1" 100 NORMAL)))
(old-fg (car (gimp-palette-get-foreground))) (old-fg (car (gimp-palette-get-foreground)))
(old-bg (car (gimp-palette-get-background))) (old-bg (car (gimp-palette-get-background)))
(old-brush (car (gimp-brushes-get-brush)))) (old-brush (car (gimp-brushes-get-brush))))
@ -175,7 +178,7 @@
(script-fu-register "script-fu-carve-it" (script-fu-register "script-fu-carve-it"
"<Image>/Script-Fu/Stencil Ops/Carve-It" "<Image>/Script-Fu/Stencil Ops/Carve-It"
"Use the specified [GRAY] drawable as a stencil to carve from the specified image" "Use the specified [GRAY] drawable as a stencil to carve from the specified image. The specified image must be either RGB colour or grayscale, not indexed."
"Spencer Kimball" "Spencer Kimball"
"Spencer Kimball" "Spencer Kimball"
"1997" "1997"

View File

@ -124,7 +124,7 @@ query ()
"loads files of the tiff file format", "loads files of the tiff file format",
"FIXME: write help for tiff_load", "FIXME: write help for tiff_load",
"Spencer Kimball, Peter Mattis & Nick Lamb", "Spencer Kimball, Peter Mattis & Nick Lamb",
"Nick Lamb <njl195@.ecs.soton.ac.uk>", "Nick Lamb <njl195@zepler.org.uk>",
"1995-1996,1998", "1995-1996,1998",
"<Load>/Tiff", "<Load>/Tiff",
NULL, NULL,
@ -248,7 +248,7 @@ static gint32 load_image (char *filename) {
unsigned short *redmap, *greenmap, *bluemap; unsigned short *redmap, *greenmap, *bluemap;
guchar cmap[768]; guchar cmap[768];
int image_type= 0, layer_type= 0; int image_type= 0, layer_type= 0;
unsigned short *extra_types, extra = 0; unsigned short extra, *extra_types;
int col, row, start, i, j; int col, row, start, i, j;
unsigned char sample; unsigned char sample;
@ -274,7 +274,7 @@ static gint32 load_image (char *filename) {
tif = TIFFOpen (filename, "r"); tif = TIFFOpen (filename, "r");
if (!tif) { if (!tif) {
g_error ("TIFF Can't open \"%s\"\n", filename); g_message("TIFF Can't open \n%s", filename);
gimp_quit (); gimp_quit ();
} }
@ -287,7 +287,7 @@ static gint32 load_image (char *filename) {
bps = 1; bps = 1;
if (bps > 8) { if (bps > 8) {
g_error("TIFF Can't handle samples wider than 8-bit\n"); g_message("TIFF Can't handle samples wider than 8-bit");
gimp_quit(); gimp_quit();
} }
@ -297,17 +297,17 @@ static gint32 load_image (char *filename) {
extra = 0; extra = 0;
if (!TIFFGetField (tif, TIFFTAG_IMAGEWIDTH, &cols)) { if (!TIFFGetField (tif, TIFFTAG_IMAGEWIDTH, &cols)) {
g_error ("TIFF Can't get image width\n"); g_message("TIFF Can't get image width");
gimp_quit (); gimp_quit ();
} }
if (!TIFFGetField (tif, TIFFTAG_IMAGELENGTH, &rows)) { if (!TIFFGetField (tif, TIFFTAG_IMAGELENGTH, &rows)) {
g_error ("TIFF Can't get image length\n"); g_message("TIFF Can't get image length");
gimp_quit (); gimp_quit ();
} }
if (!TIFFGetField (tif, TIFFTAG_PHOTOMETRIC, &photomet)) { if (!TIFFGetField (tif, TIFFTAG_PHOTOMETRIC, &photomet)) {
g_error ("TIFF Can't get photometric\n"); g_message("TIFF Can't get photometric");
gimp_quit (); gimp_quit ();
} }
@ -318,9 +318,12 @@ static gint32 load_image (char *filename) {
alpha = 0; alpha = 0;
} }
/* some programs seem to think alpha etc. aren't "extra" samples (?) */ if (photomet == PHOTOMETRIC_RGB && spp > extra + 3) {
if (spp > 3) {
extra= spp - 3; extra= spp - 3;
alpha= 1;
} else if (photomet != PHOTOMETRIC_RGB && spp > extra + 1) {
extra= spp - 1;
alpha= 1;
} }
maxval = (1 << bps) - 1; maxval = (1 << bps) - 1;
@ -343,16 +346,16 @@ static gint32 load_image (char *filename) {
break; break;
case PHOTOMETRIC_MASK: case PHOTOMETRIC_MASK:
g_error ("TIFF Can't handle PHOTOMETRIC_MASK\n"); g_message ("TIFF Can't handle PHOTOMETRIC_MASK");
gimp_quit (); gimp_quit ();
break; break;
default: default:
g_error ("TIFF Unknown photometric: %d\n", photomet); g_message ("TIFF Unknown photometric\n Number %d", photomet);
gimp_quit (); gimp_quit ();
} }
if ((image = gimp_image_new (cols, rows, image_type)) == -1) { if ((image = gimp_image_new (cols, rows, image_type)) == -1) {
g_error ("TIFF Can't allocate new image\n"); g_message("TIFF Can't create a new image\n");
gimp_quit (); gimp_quit ();
} }
gimp_image_set_filename (image, filename); gimp_image_set_filename (image, filename);
@ -360,7 +363,7 @@ static gint32 load_image (char *filename) {
/* Install colormap for INDEXED images only */ /* Install colormap for INDEXED images only */
if (image_type == INDEXED) { if (image_type == INDEXED) {
if (!TIFFGetField (tif, TIFFTAG_COLORMAP, &redmap, &greenmap, &bluemap)) { if (!TIFFGetField (tif, TIFFTAG_COLORMAP, &redmap, &greenmap, &bluemap)) {
g_error ("TIFF Can't get colormaps\n"); g_message("TIFF Can't get colormaps");
gimp_quit (); gimp_quit ();
} }
@ -416,14 +419,14 @@ static gint32 load_image (char *filename) {
/* Special cases: Scanline is compatible with GIMP storage */ /* Special cases: Scanline is compatible with GIMP storage */
if (extra == 0 && bps == 8) { if (extra == 0 && bps == 8) {
if (TIFFReadScanline (tif, d, row, 0) < 0) { if (TIFFReadScanline (tif, d, row, 0) < 0) {
g_error ("TIFF Bad data read on line %d\n", row); g_message("TIFF Bad data read on line %d", row);
gimp_quit (); gimp_quit ();
} }
/* Or read in and process each sample -- slower */ /* Or read in and process each sample -- slower */
} else { } else {
if (TIFFReadScanline (tif, source, row, 0) < 0) { if (TIFFReadScanline (tif, source, row, 0) < 0) {
g_error ("TIFF Bad data read on line %d\n", row); g_message("TIFF Bad data read on line %d\n", row);
gimp_quit (); gimp_quit ();
} }
@ -602,11 +605,10 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
rowsperstrip = 0; rowsperstrip = 0;
tif = TIFFOpen (filename, "w"); tif = TIFFOpen (filename, "w");
if (!tif) if (!tif) {
{ g_print ("Can't write image to\n%s", filename);
g_print ("can't open \"%s\"\n", filename); return 0;
return 0; }
}
name = malloc (strlen (filename) + 11); name = malloc (strlen (filename) + 11);
sprintf (name, "Saving %s:", filename); sprintf (name, "Saving %s:", filename);
@ -752,11 +754,10 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
break; break;
} }
if (!success) if (!success) {
{ g_message("TIFF Failed a scanline write on row %d", row);
g_print ("failed a scanline write on row %d\n", row);
return 0; return 0;
} }
} }
gimp_progress_update ((double) row / (double) rows); gimp_progress_update ((double) row / (double) rows);