Updates from Adam

-Yosh
This commit is contained in:
Manish Singh 1998-04-29 10:48:02 +00:00
parent c7712c9cb4
commit bb7b1ae3d2
7 changed files with 212 additions and 98 deletions

View File

@ -1,3 +1,9 @@
Wed Apr 29 03:46:44 PDT 1998 Manish Singh <yosh@gimp.org>
* plug-ins/animationplay/animationplay.c
* plug-ins/gif/gif.c
* plug-ins/psd/psd.c: updates from Adam
Wed Apr 29 01:43:30 PDT 1998 Manish Singh <yosh@gimp.org> Wed Apr 29 01:43:30 PDT 1998 Manish Singh <yosh@gimp.org>
* app/text_tool.c: don't die on corrupted fonts. Give some * app/text_tool.c: don't die on corrupted fonts. Give some

View File

@ -1,5 +1,5 @@
/* /*
* Animation Playback plug-in version 0.94.0 * Animation Playback plug-in version 0.94.2
* *
* Adam D. Moss : 1997-98 : adam@gimp.org : adam@foxbox.org * Adam D. Moss : 1997-98 : adam@gimp.org : adam@foxbox.org
* *
@ -11,6 +11,9 @@
/* /*
* REVISION HISTORY: * REVISION HISTORY:
* *
* 98.04.28 : version 0.94.2
* Fixed a time-parsing bug.
*
* 98.04.05 : version 0.94.0 * 98.04.05 : version 0.94.0
* Improved performance and removed flicker when shaped. * Improved performance and removed flicker when shaped.
* Shaped mode also works with RGB* images now. * Shaped mode also works with RGB* images now.
@ -246,6 +249,8 @@ parse_ms_tag (char *str)
length = strlen(str); length = strlen(str);
find_another_bra:
while ((offset<length) && (str[offset]!='(')) while ((offset<length) && (str[offset]!='('))
offset++; offset++;
@ -253,7 +258,7 @@ parse_ms_tag (char *str)
return(-1); return(-1);
if (!isdigit(str[++offset])) if (!isdigit(str[++offset]))
return(-2); goto find_another_bra;
do do
{ {

View File

@ -1,5 +1,5 @@
/* /*
* Animation Playback plug-in version 0.94.0 * Animation Playback plug-in version 0.94.2
* *
* Adam D. Moss : 1997-98 : adam@gimp.org : adam@foxbox.org * Adam D. Moss : 1997-98 : adam@gimp.org : adam@foxbox.org
* *
@ -11,6 +11,9 @@
/* /*
* REVISION HISTORY: * REVISION HISTORY:
* *
* 98.04.28 : version 0.94.2
* Fixed a time-parsing bug.
*
* 98.04.05 : version 0.94.0 * 98.04.05 : version 0.94.0
* Improved performance and removed flicker when shaped. * Improved performance and removed flicker when shaped.
* Shaped mode also works with RGB* images now. * Shaped mode also works with RGB* images now.
@ -246,6 +249,8 @@ parse_ms_tag (char *str)
length = strlen(str); length = strlen(str);
find_another_bra:
while ((offset<length) && (str[offset]!='(')) while ((offset<length) && (str[offset]!='('))
offset++; offset++;
@ -253,7 +258,7 @@ parse_ms_tag (char *str)
return(-1); return(-1);
if (!isdigit(str[++offset])) if (!isdigit(str[++offset]))
return(-2); goto find_another_bra;
do do
{ {

View File

@ -7,7 +7,7 @@
* Based around original GIF code by David Koblas. * Based around original GIF code by David Koblas.
* *
* *
* Version 2.0.1 - 98/03/16 * Version 2.0.2 - 98/04/28
* Adam D. Moss - <adam@gimp.org> <adam@foxbox.org> * Adam D. Moss - <adam@gimp.org> <adam@foxbox.org>
*/ */
/* /*
@ -23,6 +23,10 @@
/* /*
* REVISION HISTORY * REVISION HISTORY
* *
*
* 98/04/28
* 2.00.02 - Fixed a bug with (ms) tag parsing.
*
* 98/03/16 * 98/03/16
* 2.00.01 - Fixed a long-standing bug when loading GIFs which layer * 2.00.01 - Fixed a long-standing bug when loading GIFs which layer
* opaque frames onto transparent ones. * opaque frames onto transparent ones.
@ -1492,6 +1496,8 @@ parse_ms_tag (char *str)
length = strlen(str); length = strlen(str);
find_another_bra:
while ((offset<length) && (str[offset]!='(')) while ((offset<length) && (str[offset]!='('))
offset++; offset++;
@ -1499,7 +1505,7 @@ parse_ms_tag (char *str)
return(-1); return(-1);
if (!isdigit(str[++offset])) if (!isdigit(str[++offset]))
return(-2); goto find_another_bra;
do do
{ {

View File

@ -1,5 +1,5 @@
/* /*
* PSD Plugin version 1.9.9.8 (BETA) * PSD Plugin version 1.9.9.9 (BETA)
* This GIMP plug-in is designed to load Adobe Photoshop(tm) files (.PSD) * This GIMP plug-in is designed to load Adobe Photoshop(tm) files (.PSD)
* *
* Adam D. Moss <adam@gimp.org> <adam@foxbox.org> * Adam D. Moss <adam@gimp.org> <adam@foxbox.org>
@ -25,7 +25,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* /*
@ -36,6 +36,11 @@
/* /*
* Revision history: * Revision history:
* *
* 98.04.28 / v1.9.9.9 / Adam D. Moss
* Fixed the correct channel interlacing of 'raw' flat images.
* Thanks to Christian Kirsch and Jay Cox for spotting this.
* Changed some of the I/O routines.
*
* 98.04.26 / v1.9.9.8 / Adam D. Moss * 98.04.26 / v1.9.9.8 / Adam D. Moss
* Implemented Aux-channels for layered files. Got rid * Implemented Aux-channels for layered files. Got rid
* of <endian.h> nonsense. Improved Layer Mask padding. * of <endian.h> nonsense. Improved Layer Mask padding.
@ -173,7 +178,7 @@ typedef struct PsdLayer
gboolean protecttrans; gboolean protecttrans;
gboolean visible; gboolean visible;
gchar* name; guchar* name;
gint32 lm_x; gint32 lm_x;
gint32 lm_y; gint32 lm_y;
@ -212,7 +217,7 @@ static PSDimage psd_image;
static struct { static struct {
gchar signature[4]; guchar signature[4];
gushort version; gushort version;
guchar reserved[6]; guchar reserved[6];
gushort channels; gushort channels;
@ -248,9 +253,9 @@ static const gchar *prog_name = "PSD";
static void unpack_pb_channel(FILE *fd, guchar *dst, gint32 unpackedlen, static void unpack_pb_channel(FILE *fd, guchar *dst, gint32 unpackedlen,
guint32 *offset); guint32 *offset);
static void decode(long clen, long uclen, gchar *src, guchar *dst, int step); static void decode(long clen, long uclen, gchar *src, gchar *dst, int step);
static void packbitsdecode(long *clenp, long uclen, static void packbitsdecode(long *clenp, long uclen,
gchar *src, guchar *dst, int step); gchar *src, gchar *dst, int step);
static void cmyk2rgb(guchar *src, guchar *destp, static void cmyk2rgb(guchar *src, guchar *destp,
long width, long height, int alpha); long width, long height, int alpha);
static void cmykp2rgb(guchar *src, guchar *destp, static void cmykp2rgb(guchar *src, guchar *destp,
@ -260,12 +265,14 @@ static guchar getguchar(FILE *fd, gchar *why);
static gshort getgshort(FILE *fd, gchar *why); static gshort getgshort(FILE *fd, gchar *why);
static glong getglong(FILE *fd, gchar *why); static glong getglong(FILE *fd, gchar *why);
static void xfread(FILE *fd, void *buf, long len, gchar *why); static void xfread(FILE *fd, void *buf, long len, gchar *why);
static void xfread_interlaced(FILE *fd, guchar *buf, long len, gchar *why,
gint step);
static void *xmalloc(size_t n); static void *xmalloc(size_t n);
static void read_whole_file(FILE *fd); static void read_whole_file(FILE *fd);
static void reshuffle_cmap(guchar *map256); static void reshuffle_cmap(guchar *map256);
static gchar *getpascalstring(FILE *fd, gchar *why); static guchar *getpascalstring(FILE *fd, guchar *why);
void throwchunk(size_t n, FILE * fd, gchar *why); void throwchunk(size_t n, FILE * fd, guchar *why);
void dumpchunk(size_t n, FILE * fd, gchar *why); void dumpchunk(size_t n, FILE * fd, guchar *why);
MAIN() MAIN()
@ -1383,11 +1390,9 @@ load_image(char *name)
{ {
FILE *fd; FILE *fd;
gboolean want_aux; gboolean want_aux;
char *name_buf; char *name_buf, *cmykbuf;
unsigned char *cmykbuf;
static int number = 1; static int number = 1;
char *temp; unsigned char *dest, *temp;
guchar *dest;
long channels, nguchars; long channels, nguchars;
psd_imagetype imagetype; psd_imagetype imagetype;
int cmyk = 0, step = 1; int cmyk = 0, step = 1;
@ -1787,13 +1792,16 @@ load_image(char *name)
if (!cmyk) if (!cmyk)
{ {
gimp_progress_update ((double)0.50); gimp_progress_update ((double)0.50);
xfread(fd, dest, PSDheader.imgdatalen, "image data"); xfread_interlaced(fd, dest, PSDheader.imgdatalen,
"raw image data", step);
} }
else else
{ {
gimp_progress_update ((double)0.25); gimp_progress_update ((double)0.25);
cmykbuf = xmalloc(PSDheader.imgdatalen); cmykbuf = xmalloc(PSDheader.imgdatalen);
xfread(fd, cmykbuf, PSDheader.imgdatalen, "image data"); xfread_interlaced(fd, cmykbuf, PSDheader.imgdatalen,
"raw cmyk image data", step);
gimp_progress_update ((double)0.50); gimp_progress_update ((double)0.50);
cmykp2rgb(cmykbuf, dest, cmykp2rgb(cmykbuf, dest,
PSDheader.columns, PSDheader.rows, step > 4); PSDheader.columns, PSDheader.rows, step > 4);
@ -1807,7 +1815,8 @@ load_image(char *name)
extract_channels(dest, channels, step, extract_channels(dest, channels, step,
image_ID, image_ID,
PSDheader.columns, PSDheader.rows); PSDheader.columns, PSDheader.rows);
goto finish_up;
goto finish_up; /* Haha! Look! A goto! */
} }
else else
{ {
@ -1818,7 +1827,7 @@ load_image(char *name)
if (psd_type_to_gimp_type(imagetype)==INDEXEDA_IMAGE) if (psd_type_to_gimp_type(imagetype)==INDEXEDA_IMAGE)
{ {
printf("@@@@ Didn't know about this.\n"); printf("@@@@ Didn't know that this could happen...\n");
for (iter=0; iter<drawable->width*drawable->height; iter++) for (iter=0; iter<drawable->width*drawable->height; iter++)
{ {
dest[iter*2+1] = 255; dest[iter*2+1] = 255;
@ -1867,7 +1876,7 @@ load_image(char *name)
static void static void
decode(long clen, long uclen, char * src, guchar * dst, int step) decode(long clen, long uclen, char * src, char * dst, int step)
{ {
gint i, j; gint i, j;
gint32 l; gint32 l;
@ -1896,7 +1905,7 @@ decode(long clen, long uclen, char * src, guchar * dst, int step)
* Decode a PackBits data stream. * Decode a PackBits data stream.
*/ */
static void static void
packbitsdecode(long * clenp, long uclen, char * src, guchar * dst, int step) packbitsdecode(long * clenp, long uclen, char * src, char * dst, int step)
{ {
gint n, b; gint n, b;
gint32 clen = *clenp; gint32 clen = *clenp;
@ -2026,7 +2035,7 @@ cmykp2rgb(unsigned char * src, unsigned char * dst,
int r, g, b, k; int r, g, b, k;
int i, j; int i, j;
long n; long n;
guchar *rp, *gp, *bp, *kp, *ap; char *rp, *gp, *bp, *kp, *ap;
n = width * height; n = width * height;
rp = src; rp = src;
@ -2084,7 +2093,7 @@ cmyk_to_rgb(gint *c, gint *m, gint *y, gint *k)
void void
dumpchunk(size_t n, FILE * fd, gchar *why) dumpchunk(size_t n, FILE * fd, guchar *why)
{ {
guint32 i; guint32 i;
@ -2100,9 +2109,9 @@ dumpchunk(size_t n, FILE * fd, gchar *why)
void void
throwchunk(size_t n, FILE * fd, gchar *why) throwchunk(size_t n, FILE * fd, guchar *why)
{ {
gchar *tmpchunk; guchar *tmpchunk;
if (n==0) if (n==0)
{ {
@ -2128,10 +2137,10 @@ getchunk(size_t n, FILE * fd, char *why)
#endif #endif
static gchar * static guchar *
getpascalstring(FILE *fd, gchar *why) getpascalstring(FILE *fd, guchar *why)
{ {
gchar *tmpchunk; guchar *tmpchunk;
guchar len; guchar len;
xfread(fd, &len, 1, why); xfread(fd, &len, 1, why);
@ -2154,9 +2163,16 @@ getpascalstring(FILE *fd, gchar *why)
static guchar static guchar
getguchar(FILE *fd, char *why) getguchar(FILE *fd, char *why)
{ {
guchar tmp; gint tmp;
xfread(fd, &tmp, 1, why); tmp = fgetc(fd);
if (tmp == EOF)
{
printf("%s: unexpected EOF while reading '%s' chunk\n",
prog_name, why);
gimp_quit();
}
return(tmp); return(tmp);
} }
@ -2168,8 +2184,8 @@ getgshort(FILE *fd, char *why)
gushort w; gushort w;
guchar b1, b2; guchar b1, b2;
xfread(fd, &b1, 1, why); b1 = getguchar(fd, why);
xfread(fd, &b2, 1, why); b2 = getguchar(fd, why);
w = (b1*256) + b2; w = (b1*256) + b2;
@ -2180,27 +2196,54 @@ getgshort(FILE *fd, char *why)
static glong static glong
getglong(FILE *fd, char * why) getglong(FILE *fd, char * why)
{ {
unsigned char s1, s2, s3, s4; unsigned char s1, s2, s3, s4;
gulong w; gulong w;
xfread(fd, &s1, 1, why); s1 = getguchar(fd, why);
xfread(fd, &s2, 1, why); s2 = getguchar(fd, why);
xfread(fd, &s3, 1, why); s3 = getguchar(fd, why);
xfread(fd, &s4, 1, why); s4 = getguchar(fd, why);
w = (s1*256*256*256) + (s2*256*256) + (s3*256) + s4; w = (s1*256*256*256) + (s2*256*256) + (s3*256) + s4;
return (glong) w; return (glong) w;
} }
static void static void
xfread(FILE * fd, void * buf, long len, char * why) xfread(FILE * fd, void * buf, long len, char* why)
{ {
if (fread(buf, len, 1, fd) == 0) { if (fread(buf, len, 1, fd) == 0)
printf("%s: unexpected EOF while reading '%s' chunk\n", {
prog_name, why); printf("%s: unexpected EOF while reading '%s' chunk\n",
gimp_quit(); prog_name, why);
gimp_quit();
}
}
static void
xfread_interlaced(FILE* fd, guchar* buf, long len, gchar* why, gint step)
{
guchar* dest;
gint pix, pos, bpplane;
bpplane = len/step;
if (len%step != 0)
{
printf("PSD: Stern warning: data size is not a factor of step size.\n");
}
for (pix=0; pix<step; pix++)
{
dest = buf + pix;
for (pos=0; pos<bpplane; pos++)
{
*dest = getguchar(fd, why);
dest += step;
}
} }
} }

View File

@ -7,7 +7,7 @@
* Based around original GIF code by David Koblas. * Based around original GIF code by David Koblas.
* *
* *
* Version 2.0.1 - 98/03/16 * Version 2.0.2 - 98/04/28
* Adam D. Moss - <adam@gimp.org> <adam@foxbox.org> * Adam D. Moss - <adam@gimp.org> <adam@foxbox.org>
*/ */
/* /*
@ -23,6 +23,10 @@
/* /*
* REVISION HISTORY * REVISION HISTORY
* *
*
* 98/04/28
* 2.00.02 - Fixed a bug with (ms) tag parsing.
*
* 98/03/16 * 98/03/16
* 2.00.01 - Fixed a long-standing bug when loading GIFs which layer * 2.00.01 - Fixed a long-standing bug when loading GIFs which layer
* opaque frames onto transparent ones. * opaque frames onto transparent ones.
@ -1492,6 +1496,8 @@ parse_ms_tag (char *str)
length = strlen(str); length = strlen(str);
find_another_bra:
while ((offset<length) && (str[offset]!='(')) while ((offset<length) && (str[offset]!='('))
offset++; offset++;
@ -1499,7 +1505,7 @@ parse_ms_tag (char *str)
return(-1); return(-1);
if (!isdigit(str[++offset])) if (!isdigit(str[++offset]))
return(-2); goto find_another_bra;
do do
{ {

View File

@ -1,5 +1,5 @@
/* /*
* PSD Plugin version 1.9.9.8 (BETA) * PSD Plugin version 1.9.9.9 (BETA)
* This GIMP plug-in is designed to load Adobe Photoshop(tm) files (.PSD) * This GIMP plug-in is designed to load Adobe Photoshop(tm) files (.PSD)
* *
* Adam D. Moss <adam@gimp.org> <adam@foxbox.org> * Adam D. Moss <adam@gimp.org> <adam@foxbox.org>
@ -25,7 +25,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* /*
@ -36,6 +36,11 @@
/* /*
* Revision history: * Revision history:
* *
* 98.04.28 / v1.9.9.9 / Adam D. Moss
* Fixed the correct channel interlacing of 'raw' flat images.
* Thanks to Christian Kirsch and Jay Cox for spotting this.
* Changed some of the I/O routines.
*
* 98.04.26 / v1.9.9.8 / Adam D. Moss * 98.04.26 / v1.9.9.8 / Adam D. Moss
* Implemented Aux-channels for layered files. Got rid * Implemented Aux-channels for layered files. Got rid
* of <endian.h> nonsense. Improved Layer Mask padding. * of <endian.h> nonsense. Improved Layer Mask padding.
@ -173,7 +178,7 @@ typedef struct PsdLayer
gboolean protecttrans; gboolean protecttrans;
gboolean visible; gboolean visible;
gchar* name; guchar* name;
gint32 lm_x; gint32 lm_x;
gint32 lm_y; gint32 lm_y;
@ -212,7 +217,7 @@ static PSDimage psd_image;
static struct { static struct {
gchar signature[4]; guchar signature[4];
gushort version; gushort version;
guchar reserved[6]; guchar reserved[6];
gushort channels; gushort channels;
@ -248,9 +253,9 @@ static const gchar *prog_name = "PSD";
static void unpack_pb_channel(FILE *fd, guchar *dst, gint32 unpackedlen, static void unpack_pb_channel(FILE *fd, guchar *dst, gint32 unpackedlen,
guint32 *offset); guint32 *offset);
static void decode(long clen, long uclen, gchar *src, guchar *dst, int step); static void decode(long clen, long uclen, gchar *src, gchar *dst, int step);
static void packbitsdecode(long *clenp, long uclen, static void packbitsdecode(long *clenp, long uclen,
gchar *src, guchar *dst, int step); gchar *src, gchar *dst, int step);
static void cmyk2rgb(guchar *src, guchar *destp, static void cmyk2rgb(guchar *src, guchar *destp,
long width, long height, int alpha); long width, long height, int alpha);
static void cmykp2rgb(guchar *src, guchar *destp, static void cmykp2rgb(guchar *src, guchar *destp,
@ -260,12 +265,14 @@ static guchar getguchar(FILE *fd, gchar *why);
static gshort getgshort(FILE *fd, gchar *why); static gshort getgshort(FILE *fd, gchar *why);
static glong getglong(FILE *fd, gchar *why); static glong getglong(FILE *fd, gchar *why);
static void xfread(FILE *fd, void *buf, long len, gchar *why); static void xfread(FILE *fd, void *buf, long len, gchar *why);
static void xfread_interlaced(FILE *fd, guchar *buf, long len, gchar *why,
gint step);
static void *xmalloc(size_t n); static void *xmalloc(size_t n);
static void read_whole_file(FILE *fd); static void read_whole_file(FILE *fd);
static void reshuffle_cmap(guchar *map256); static void reshuffle_cmap(guchar *map256);
static gchar *getpascalstring(FILE *fd, gchar *why); static guchar *getpascalstring(FILE *fd, guchar *why);
void throwchunk(size_t n, FILE * fd, gchar *why); void throwchunk(size_t n, FILE * fd, guchar *why);
void dumpchunk(size_t n, FILE * fd, gchar *why); void dumpchunk(size_t n, FILE * fd, guchar *why);
MAIN() MAIN()
@ -1383,11 +1390,9 @@ load_image(char *name)
{ {
FILE *fd; FILE *fd;
gboolean want_aux; gboolean want_aux;
char *name_buf; char *name_buf, *cmykbuf;
unsigned char *cmykbuf;
static int number = 1; static int number = 1;
char *temp; unsigned char *dest, *temp;
guchar *dest;
long channels, nguchars; long channels, nguchars;
psd_imagetype imagetype; psd_imagetype imagetype;
int cmyk = 0, step = 1; int cmyk = 0, step = 1;
@ -1787,13 +1792,16 @@ load_image(char *name)
if (!cmyk) if (!cmyk)
{ {
gimp_progress_update ((double)0.50); gimp_progress_update ((double)0.50);
xfread(fd, dest, PSDheader.imgdatalen, "image data"); xfread_interlaced(fd, dest, PSDheader.imgdatalen,
"raw image data", step);
} }
else else
{ {
gimp_progress_update ((double)0.25); gimp_progress_update ((double)0.25);
cmykbuf = xmalloc(PSDheader.imgdatalen); cmykbuf = xmalloc(PSDheader.imgdatalen);
xfread(fd, cmykbuf, PSDheader.imgdatalen, "image data"); xfread_interlaced(fd, cmykbuf, PSDheader.imgdatalen,
"raw cmyk image data", step);
gimp_progress_update ((double)0.50); gimp_progress_update ((double)0.50);
cmykp2rgb(cmykbuf, dest, cmykp2rgb(cmykbuf, dest,
PSDheader.columns, PSDheader.rows, step > 4); PSDheader.columns, PSDheader.rows, step > 4);
@ -1807,7 +1815,8 @@ load_image(char *name)
extract_channels(dest, channels, step, extract_channels(dest, channels, step,
image_ID, image_ID,
PSDheader.columns, PSDheader.rows); PSDheader.columns, PSDheader.rows);
goto finish_up;
goto finish_up; /* Haha! Look! A goto! */
} }
else else
{ {
@ -1818,7 +1827,7 @@ load_image(char *name)
if (psd_type_to_gimp_type(imagetype)==INDEXEDA_IMAGE) if (psd_type_to_gimp_type(imagetype)==INDEXEDA_IMAGE)
{ {
printf("@@@@ Didn't know about this.\n"); printf("@@@@ Didn't know that this could happen...\n");
for (iter=0; iter<drawable->width*drawable->height; iter++) for (iter=0; iter<drawable->width*drawable->height; iter++)
{ {
dest[iter*2+1] = 255; dest[iter*2+1] = 255;
@ -1867,7 +1876,7 @@ load_image(char *name)
static void static void
decode(long clen, long uclen, char * src, guchar * dst, int step) decode(long clen, long uclen, char * src, char * dst, int step)
{ {
gint i, j; gint i, j;
gint32 l; gint32 l;
@ -1896,7 +1905,7 @@ decode(long clen, long uclen, char * src, guchar * dst, int step)
* Decode a PackBits data stream. * Decode a PackBits data stream.
*/ */
static void static void
packbitsdecode(long * clenp, long uclen, char * src, guchar * dst, int step) packbitsdecode(long * clenp, long uclen, char * src, char * dst, int step)
{ {
gint n, b; gint n, b;
gint32 clen = *clenp; gint32 clen = *clenp;
@ -2026,7 +2035,7 @@ cmykp2rgb(unsigned char * src, unsigned char * dst,
int r, g, b, k; int r, g, b, k;
int i, j; int i, j;
long n; long n;
guchar *rp, *gp, *bp, *kp, *ap; char *rp, *gp, *bp, *kp, *ap;
n = width * height; n = width * height;
rp = src; rp = src;
@ -2084,7 +2093,7 @@ cmyk_to_rgb(gint *c, gint *m, gint *y, gint *k)
void void
dumpchunk(size_t n, FILE * fd, gchar *why) dumpchunk(size_t n, FILE * fd, guchar *why)
{ {
guint32 i; guint32 i;
@ -2100,9 +2109,9 @@ dumpchunk(size_t n, FILE * fd, gchar *why)
void void
throwchunk(size_t n, FILE * fd, gchar *why) throwchunk(size_t n, FILE * fd, guchar *why)
{ {
gchar *tmpchunk; guchar *tmpchunk;
if (n==0) if (n==0)
{ {
@ -2128,10 +2137,10 @@ getchunk(size_t n, FILE * fd, char *why)
#endif #endif
static gchar * static guchar *
getpascalstring(FILE *fd, gchar *why) getpascalstring(FILE *fd, guchar *why)
{ {
gchar *tmpchunk; guchar *tmpchunk;
guchar len; guchar len;
xfread(fd, &len, 1, why); xfread(fd, &len, 1, why);
@ -2154,9 +2163,16 @@ getpascalstring(FILE *fd, gchar *why)
static guchar static guchar
getguchar(FILE *fd, char *why) getguchar(FILE *fd, char *why)
{ {
guchar tmp; gint tmp;
xfread(fd, &tmp, 1, why); tmp = fgetc(fd);
if (tmp == EOF)
{
printf("%s: unexpected EOF while reading '%s' chunk\n",
prog_name, why);
gimp_quit();
}
return(tmp); return(tmp);
} }
@ -2168,8 +2184,8 @@ getgshort(FILE *fd, char *why)
gushort w; gushort w;
guchar b1, b2; guchar b1, b2;
xfread(fd, &b1, 1, why); b1 = getguchar(fd, why);
xfread(fd, &b2, 1, why); b2 = getguchar(fd, why);
w = (b1*256) + b2; w = (b1*256) + b2;
@ -2180,27 +2196,54 @@ getgshort(FILE *fd, char *why)
static glong static glong
getglong(FILE *fd, char * why) getglong(FILE *fd, char * why)
{ {
unsigned char s1, s2, s3, s4; unsigned char s1, s2, s3, s4;
gulong w; gulong w;
xfread(fd, &s1, 1, why); s1 = getguchar(fd, why);
xfread(fd, &s2, 1, why); s2 = getguchar(fd, why);
xfread(fd, &s3, 1, why); s3 = getguchar(fd, why);
xfread(fd, &s4, 1, why); s4 = getguchar(fd, why);
w = (s1*256*256*256) + (s2*256*256) + (s3*256) + s4; w = (s1*256*256*256) + (s2*256*256) + (s3*256) + s4;
return (glong) w; return (glong) w;
} }
static void static void
xfread(FILE * fd, void * buf, long len, char * why) xfread(FILE * fd, void * buf, long len, char* why)
{ {
if (fread(buf, len, 1, fd) == 0) { if (fread(buf, len, 1, fd) == 0)
printf("%s: unexpected EOF while reading '%s' chunk\n", {
prog_name, why); printf("%s: unexpected EOF while reading '%s' chunk\n",
gimp_quit(); prog_name, why);
gimp_quit();
}
}
static void
xfread_interlaced(FILE* fd, guchar* buf, long len, gchar* why, gint step)
{
guchar* dest;
gint pix, pos, bpplane;
bpplane = len/step;
if (len%step != 0)
{
printf("PSD: Stern warning: data size is not a factor of step size.\n");
}
for (pix=0; pix<step; pix++)
{
dest = buf + pix;
for (pos=0; pos<bpplane; pos++)
{
*dest = getguchar(fd, why);
dest += step;
}
} }
} }