Commit 6ff6f358 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

plug-ins/bmp/bmp.[ch] plug-ins/bmp/bmpread.c return STATUS_CANCEL if

2000-02-12  Michael Natterer  <mitch@gimp.org>

	* plug-ins/bmp/bmp.[ch]
	* plug-ins/bmp/bmpread.c
	* plug-ins/bmp/bmpwrite.c: return STATUS_CANCEL if "Cancel" was
	pressed, code & ui cleanups.
parent 80acd3bf
2000-02-12 Michael Natterer <mitch@gimp.org>
* plug-ins/bmp/bmp.[ch]
* plug-ins/bmp/bmpread.c
* plug-ins/bmp/bmpwrite.c: return STATUS_CANCEL if "Cancel" was
pressed, code & ui cleanups.
Sat Feb 12 16:02:12 CET 2000 Sven Neumann <sven@gimp.org>
* app/menus.c: ooops, must have been late
......
......@@ -259,10 +259,7 @@ run (gchar *name,
if (status == STATUS_SUCCESS)
{
if (! WriteBMP (param[3].data.d_string, image_ID, drawable_ID))
{
status = STATUS_EXECUTION_ERROR;
}
status = WriteBMP (param[3].data.d_string, image_ID, drawable_ID);
}
if (export == EXPORT_EXPORT)
......@@ -292,18 +289,18 @@ void
FromL (gint32 wert,
guchar *bopuffer)
{
bopuffer[0]=(wert & 0x000000ff)>>0x00;
bopuffer[1]=(wert & 0x0000ff00)>>0x08;
bopuffer[2]=(wert & 0x00ff0000)>>0x10;
bopuffer[3]=(wert & 0xff000000)>>0x18;
bopuffer[0] = (wert & 0x000000ff)>>0x00;
bopuffer[1] = (wert & 0x0000ff00)>>0x08;
bopuffer[2] = (wert & 0x00ff0000)>>0x10;
bopuffer[3] = (wert & 0xff000000)>>0x18;
}
void
FromS (gint16 wert,
guchar *bopuffer)
{
bopuffer[0]=(wert & 0x00ff)>>0x00;
bopuffer[1]=(wert & 0xff00)>>0x08;
bopuffer[0] = (wert & 0x00ff)>>0x00;
bopuffer[1] = (wert & 0xff00)>>0x08;
}
static void
......@@ -319,5 +316,3 @@ init_gtk (void)
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
}
......@@ -9,50 +9,78 @@
#define Write(file,buffer,len) fwrite(buffer, len, 1, file)
#define WriteOK(file,buffer,len) (Write(buffer, len, file) != 0)
extern gint32 ToL(guchar *);
extern void FromL(gint32, guchar *);
extern gint16 ToS(guchar *);
extern void FromS(gint16, guchar *);
extern gint32 ReadBMP (char *);
extern gint WriteBMP (char *,gint32,gint32);
extern gint ReadColorMap(FILE *, unsigned char[256][3], int, int, int *);
extern Image ReadImage(FILE *, int, int, unsigned char[256][3], int, int, int, int, int);
extern void WriteColorMap(FILE *, int *, int *, int *, int);
extern void WriteImage(FILE *,guchar *,int,int,int,int,int,int,int);
extern int interactive_bmp;
extern char *prog_name;
extern char *filename;
extern FILE *errorfile;
extern gint32 ToL (guchar *);
extern void FromL (gint32,
guchar *);
extern gint16 ToS (guchar *);
extern void FromS (gint16,
guchar *);
extern gint32 ReadBMP (gchar *);
extern GStatusType WriteBMP (gchar *,
gint32,
gint32);
extern gint ReadColorMap (FILE *,
guchar[256][3],
gint,
gint,
gint *);
extern Image ReadImage (FILE *,
gint,
gint,
guchar[256][3],
gint,
gint,
gint,
gint,
gint);
extern void WriteColorMap (FILE *,
gint *,
gint *,
gint *,
gint);
extern void WriteImage (FILE *,
guchar *,
gint,
gint,
gint,
gint,
gint,
gint,
gint);
extern gint interactive_bmp;
extern gchar *prog_name;
extern gchar *filename;
extern FILE *errorfile;
extern struct Bitmap_File_Head_Struct
{
unsigned long bfSize; /* 02 */
unsigned long reserverd; /* 06 */
unsigned long bfOffs; /* 0A */
unsigned long biSize; /* 0E */
}Bitmap_File_Head;
{
gulong bfSize; /* 02 */
gulong reserverd; /* 06 */
gulong bfOffs; /* 0A */
gulong biSize; /* 0E */
} Bitmap_File_Head;
extern struct Bitmap_Head_Struct
{
unsigned long biWidth; /* 12 */
unsigned long biHeight; /* 16 */
unsigned short biPlanes; /* 1A */
unsigned short biBitCnt; /* 1C */
unsigned long biCompr; /* 1E */
unsigned long biSizeIm; /* 22 */
unsigned long biXPels; /* 26 */
unsigned long biYPels; /* 2A */
unsigned long biClrUsed; /* 2E */
unsigned long biClrImp; /* 32 */
/* 36 */
}Bitmap_Head;
{
gulong biWidth; /* 12 */
gulong biHeight; /* 16 */
gushort biPlanes; /* 1A */
gushort biBitCnt; /* 1C */
gulong biCompr; /* 1E */
gulong biSizeIm; /* 22 */
gulong biXPels; /* 26 */
gulong biYPels; /* 2A */
gulong biClrUsed; /* 2E */
gulong biClrImp; /* 32 */
/* 36 */
} Bitmap_Head;
extern struct Bitmap_OS2_Head_Struct
{
unsigned short bcWidth; /* 12 */
unsigned short bcHeight; /* 14 */
unsigned short bcPlanes; /* 16 */
unsigned short bcBitCnt; /* 18 */
}Bitmap_OS2_Head;
{
gushort bcWidth; /* 12 */
gushort bcHeight; /* 14 */
gushort bcPlanes; /* 16 */
gushort bcBitCnt; /* 18 */
} Bitmap_OS2_Head;
......@@ -23,23 +23,28 @@
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include "bmp.h"
#include <libgimp/gimp.h>
#include "bmp.h"
#include "libgimp/stdplugins-intl.h"
gint32
ReadBMP (char *name)
ReadBMP (gchar *name)
{
FILE *fd;
char *temp_buf;
char buf[5];
int ColormapSize, SpeicherZeile, Maps, Grey;
unsigned char ColorMap[256][3];
gchar *temp_buf;
gchar buf[5];
gint ColormapSize, SpeicherZeile, Maps, Grey;
guchar ColorMap[256][3];
guchar puffer[50];
gint32 image_ID;
......@@ -79,35 +84,36 @@ ReadBMP (char *name)
/* bring them to the right byteorder. Not too nice, but it should work */
Bitmap_File_Head.bfSize=ToL(&puffer[0]);
Bitmap_File_Head.reserverd=ToL(&puffer[4]);
Bitmap_File_Head.bfOffs=ToL(&puffer[8]);
Bitmap_File_Head.biSize=ToL(&puffer[12]);
Bitmap_File_Head.bfSize = ToL (&puffer[0]);
Bitmap_File_Head.reserverd = ToL (&puffer[4]);
Bitmap_File_Head.bfOffs = ToL (&puffer[8]);
Bitmap_File_Head.biSize = ToL (&puffer[12]);
/* Is it a Windows (R) Bitmap or not */
if (Bitmap_File_Head.biSize!=40)
if (Bitmap_File_Head.biSize != 40)
{
g_warning("OS/2 unsupported!\n");
g_warning ("OS/2 unsupported!\n");
if (!ReadOK (fd, puffer, Bitmap_File_Head.biSize))
{
g_message (_("%s: error reading BMP file header\n"), prog_name);
return -1;
}
Bitmap_OS2_Head.bcWidth=ToS(&puffer[0]);
Bitmap_OS2_Head.bcHeight=ToS(&puffer[2]);
Bitmap_OS2_Head.bcPlanes=ToS(&puffer[4]);
Bitmap_OS2_Head.bcBitCnt=ToS(&puffer[6]);
Bitmap_Head.biPlanes=Bitmap_OS2_Head.bcPlanes;
Bitmap_Head.biBitCnt=Bitmap_OS2_Head.bcBitCnt;
Bitmap_File_Head.bfSize=(Bitmap_File_Head.bfSize*4)-(Bitmap_File_Head.bfOffs*3);
Bitmap_Head.biHeight=Bitmap_OS2_Head.bcHeight;
Bitmap_Head.biWidth=Bitmap_OS2_Head.bcWidth;
Bitmap_Head.biClrUsed=0;
Bitmap_Head.biCompr=0;
Maps=3;
Bitmap_OS2_Head.bcWidth = ToS (&puffer[0]);
Bitmap_OS2_Head.bcHeight = ToS (&puffer[2]);
Bitmap_OS2_Head.bcPlanes = ToS (&puffer[4]);
Bitmap_OS2_Head.bcBitCnt = ToS (&puffer[6]);
Bitmap_Head.biPlanes = Bitmap_OS2_Head.bcPlanes;
Bitmap_Head.biBitCnt = Bitmap_OS2_Head.bcBitCnt;
Bitmap_File_Head.bfSize = ((Bitmap_File_Head.bfSize * 4) -
(Bitmap_File_Head.bfOffs * 3));
Bitmap_Head.biHeight = Bitmap_OS2_Head.bcHeight;
Bitmap_Head.biWidth = Bitmap_OS2_Head.bcWidth;
Bitmap_Head.biClrUsed = 0;
Bitmap_Head.biCompr = 0;
Maps = 3;
}
else
{
......@@ -116,36 +122,45 @@ ReadBMP (char *name)
g_message (_("%s: error reading BMP file header\n"), prog_name);
return -1;
}
Bitmap_Head.biWidth=ToL(&puffer[0x00]); /* 12 */
Bitmap_Head.biHeight=ToL(&puffer[0x04]); /* 16 */
Bitmap_Head.biPlanes=ToS(&puffer[0x08]); /* 1A */
Bitmap_Head.biBitCnt=ToS(&puffer[0x0A]); /* 1C */
Bitmap_Head.biCompr=ToL(&puffer[0x0C]); /* 1E */
Bitmap_Head.biSizeIm=ToL(&puffer[0x10]); /* 22 */
Bitmap_Head.biXPels=ToL(&puffer[0x14]); /* 26 */
Bitmap_Head.biYPels=ToL(&puffer[0x18]); /* 2A */
Bitmap_Head.biClrUsed=ToL(&puffer[0x1C]); /* 2E */
Bitmap_Head.biClrImp=ToL(&puffer[0x20]); /* 32 */
Bitmap_Head.biWidth =ToL (&puffer[0x00]); /* 12 */
Bitmap_Head.biHeight =ToL (&puffer[0x04]); /* 16 */
Bitmap_Head.biPlanes =ToS (&puffer[0x08]); /* 1A */
Bitmap_Head.biBitCnt =ToS (&puffer[0x0A]); /* 1C */
Bitmap_Head.biCompr =ToL (&puffer[0x0C]); /* 1E */
Bitmap_Head.biSizeIm =ToL (&puffer[0x10]); /* 22 */
Bitmap_Head.biXPels =ToL (&puffer[0x14]); /* 26 */
Bitmap_Head.biYPels =ToL (&puffer[0x18]); /* 2A */
Bitmap_Head.biClrUsed =ToL (&puffer[0x1C]); /* 2E */
Bitmap_Head.biClrImp =ToL (&puffer[0x20]); /* 32 */
/* 36 */
Maps=4;
Maps = 4;
}
/* This means wrong file Format. I test this because it could crash the */
/* entire gimp. */
/* This means wrong file Format. I test this because it could crash the
* entire gimp.
*/
if (Bitmap_Head.biBitCnt>24)
{
g_message(_("%s: too many colors: %u\n"),prog_name,
(unsigned int) Bitmap_Head.biBitCnt);
return -1;
}
if (Bitmap_Head.biBitCnt > 24)
{
g_message (_("%s: too many colors: %u\n"), prog_name,
(guint) Bitmap_Head.biBitCnt);
return -1;
}
/* There should be some colors used! */
ColormapSize = (Bitmap_File_Head.bfOffs-Bitmap_File_Head.biSize-14) / Maps;
if ((Bitmap_Head.biClrUsed==0) && (Bitmap_Head.biBitCnt<24)) Bitmap_Head.biClrUsed=ColormapSize;
if (Bitmap_Head.biBitCnt==24) SpeicherZeile=((Bitmap_File_Head.bfSize-Bitmap_File_Head.bfOffs)/Bitmap_Head.biHeight);
else SpeicherZeile=((Bitmap_File_Head.bfSize-Bitmap_File_Head.bfOffs)/Bitmap_Head.biHeight)*(8/Bitmap_Head.biBitCnt);
ColormapSize = (Bitmap_File_Head.bfOffs - Bitmap_File_Head.biSize - 14) / Maps;
if ((Bitmap_Head.biClrUsed == 0) &&
(Bitmap_Head.biBitCnt < 24))
Bitmap_Head.biClrUsed = ColormapSize;
if (Bitmap_Head.biBitCnt == 24)
SpeicherZeile = ((Bitmap_File_Head.bfSize - Bitmap_File_Head.bfOffs) /
Bitmap_Head.biHeight);
else
SpeicherZeile = ((Bitmap_File_Head.bfSize - Bitmap_File_Head.bfOffs) /
Bitmap_Head.biHeight) * (8 / Bitmap_Head.biBitCnt);
#ifdef DEBUG
printf("\nSize: %u, Colors: %u, Bits: %u, Width: %u, Height: %u, Comp: %u, Zeile: %u\n",
......@@ -155,7 +170,8 @@ ReadBMP (char *name)
/* Get the Colormap */
if (ReadColorMap(fd, ColorMap, ColormapSize, Maps, &Grey) == -1) return -1;
if (ReadColorMap (fd, ColorMap, ColormapSize, Maps, &Grey) == -1)
return -1;
#ifdef DEBUG
printf("Colormap read\n");
......@@ -175,8 +191,8 @@ ReadBMP (char *name)
#ifdef GIMP_HAVE_RESOLUTION_INFO
{
/* quick hack by the muppet, scott@asofyet.org, 19 dec 1999 */
double xresolution;
double yresolution;
gdouble xresolution;
gdouble yresolution;
/*
* xresolution and yresolution are in dots per inch.
......@@ -202,14 +218,14 @@ ReadBMP (char *name)
}
gint
ReadColorMap (FILE *fd,
unsigned char buffer[256][3],
int number,
int size,
int *grey)
ReadColorMap (FILE *fd,
guchar buffer[256][3],
gint number,
gint size,
gint *grey)
{
int i;
unsigned char rgb[4];
gint i;
guchar rgb[4];
*grey=(number>2);
for (i = 0; i < number ; i++)
......@@ -222,51 +238,55 @@ ReadColorMap (FILE *fd,
/* Bitmap save the colors in another order! But change only once! */
if (size==4) {
buffer[i][0] = rgb[2];
buffer[i][1] = rgb[1];
buffer[i][2] = rgb[0];
} else {
/* this one is for old os2 Bitmaps, but it dosn't work well */
buffer[i][0] = rgb[1];
buffer[i][1] = rgb[0];
buffer[i][2] = rgb[2];
}
*grey=((*grey) && (rgb[0]==rgb[1]) && (rgb[1]==rgb[2]));
if (size == 4)
{
buffer[i][0] = rgb[2];
buffer[i][1] = rgb[1];
buffer[i][2] = rgb[0];
}
else
{
/* this one is for old os2 Bitmaps, but it dosn't work well */
buffer[i][0] = rgb[1];
buffer[i][1] = rgb[0];
buffer[i][2] = rgb[2];
}
*grey = ((*grey) && (rgb[0]==rgb[1]) && (rgb[1]==rgb[2]));
}
return(0);
return 0;
}
Image
ReadImage (FILE *fd,
int len,
int height,
unsigned char cmap[256][3],
int ncols,
int bpp,
int compression,
int spzeile,
int grey)
ReadImage (FILE *fd,
gint len,
gint height,
guchar cmap[256][3],
gint ncols,
gint bpp,
gint compression,
gint spzeile,
gint grey)
{
char *name_buf;
unsigned char v,wieviel;
gchar *name_buf;
guchar v,wieviel;
GPixelRgn pixel_rgn;
char buf[16];
int xpos = 0, ypos = 0;
gchar buf[16];
gint xpos = 0, ypos = 0;
Image image;
gint32 layer;
GDrawable *drawable;
guchar *dest, *temp;
guchar gimp_cmap[768];
long rowstride, channels;
int i, j, cur_progress, max_progress, egal;
gint i, j, cur_progress, max_progress, egal;
/* Make a new image in the gimp */
if (grey)
{
image = gimp_image_new (len, height, GRAY);
layer = gimp_layer_new (image, _("Background"), len, height, GRAY_IMAGE, 100, NORMAL_MODE);
layer = gimp_layer_new (image, _("Background"),
len, height, GRAY_IMAGE, 100, NORMAL_MODE);
channels = 1;
}
else
......@@ -274,13 +294,15 @@ ReadImage (FILE *fd,
if (bpp<24)
{
image = gimp_image_new (len, height, INDEXED);
layer = gimp_layer_new (image, _("Background"), len, height, INDEXED_IMAGE, 100, NORMAL_MODE);
layer = gimp_layer_new (image, _("Background"),
len, height, INDEXED_IMAGE, 100, NORMAL_MODE);
channels = 1;
}
else
{
image = gimp_image_new (len, height, RGB);
layer = gimp_layer_new (image, _("Background"), len, height, RGB_IMAGE, 100, NORMAL_MODE);
layer = gimp_layer_new (image, _("Background"),
len, height, RGB_IMAGE, 100, NORMAL_MODE);
channels = 3;
}
}
......@@ -296,13 +318,13 @@ ReadImage (FILE *fd,
dest = g_malloc(drawable->width*drawable->height*channels);
rowstride = drawable->width * channels;
ypos=height-1; /* Bitmaps begin in the lower left corner */
ypos = height - 1; /* Bitmaps begin in the lower left corner */
cur_progress = 0;
max_progress = height;
if (bpp==24)
if (bpp == 24)
{
while (ReadOK(fd,buf,3))
while (ReadOK (fd, buf, 3))
{
temp = dest + (ypos * rowstride) + (xpos * channels);
*temp=buf[2];
......@@ -313,124 +335,156 @@ ReadImage (FILE *fd,
xpos++;
if (xpos == len)
{
egal=ReadOK(fd,buf,spzeile-(len*3));
egal=ReadOK (fd, buf, spzeile - (len * 3));
ypos--;
xpos=0;
xpos = 0;
cur_progress++;
if ((interactive_bmp) &&((cur_progress % 5) == 0))
gimp_progress_update ((double) cur_progress / (double) max_progress);
if ((interactive_bmp) &&
((cur_progress % 5) == 0))
gimp_progress_update ((gdouble) cur_progress /
(gdouble) max_progress);
}
if (ypos < 0) break;
if (ypos < 0)
break;
}
}
else { switch(compression)
else
{
case 0: /* uncompressed */
{
while (ReadOK(fd,&v,1))
switch(compression)
{
case 0: /* uncompressed */
{
for (i=1;(i<=(8/bpp)) && (xpos<len);i++,xpos++)
{
temp = dest + (ypos * rowstride) + (xpos * channels);
*temp=( v & ( ((1<<bpp)-1) << (8-(i*bpp)) ) ) >> (8-(i*bpp));
if (grey) *temp=cmap[*temp][0];
}
if (xpos == len)
{
egal=ReadOK(fd,buf,(spzeile-len)/(8/bpp));
ypos--;
xpos=0;
cur_progress++;
if ((interactive_bmp) && ((cur_progress % 5) == 0))
gimp_progress_update ((double) cur_progress / (double) max_progress);
}
if (ypos < 0) break;
while (ReadOK (fd, &v, 1))
{
for (i = 1; (i <= (8 / bpp)) && (xpos < len); i++, xpos++)
{
temp = dest + (ypos * rowstride) + (xpos * channels);
*temp=( v & ( ((1<<bpp)-1) << (8-(i*bpp)) ) ) >> (8-(i*bpp));
if (grey)
*temp = cmap[*temp][0];
}
if (xpos == len)
{
egal = ReadOK (fd, buf, (spzeile - len) / (8 / bpp));
ypos--;
xpos = 0;
cur_progress++;
if ((interactive_bmp) &&
((cur_progress % 5) == 0))
gimp_progress_update ((gdouble) cur_progress /
(gdouble) max_progress);
}
if (ypos < 0)
break;
}
break;
}
break;
}
default: /* Compressed images */
{
while (TRUE)
default: /* Compressed images */
{
egal=ReadOK(fd,buf,2);
if ((unsigned char) buf[0]!=0)
/* Count + Color - record */
while (TRUE)
{
for (j=0;((unsigned char) j < (unsigned char) buf[0]) && (xpos<len);)
egal = ReadOK (fd, buf, 2);
if ((guchar) buf[0] != 0)
/* Count + Color - record */
{
for (j = 0; ((guchar) j < (guchar) buf[0]) && (xpos < len);)
{
#ifdef DEBUG2
printf("%u %u | ",xpos,len);
printf("%u %u | ",xpos,len);
#endif
for (i=1;((i<=(8/bpp)) && (xpos<len) && ((unsigned char) j < (unsigned char) buf[0]));i++,xpos++,j++)
{
temp = dest + (ypos * rowstride) + (xpos * channels);
*temp=( buf[1] & ( ((1<<bpp)-1) << (8-(i*bpp)) ) ) >> (8-(i*bpp));
if (grey) *temp=cmap[*temp][0];
for (i = 1;
((i <= (8 / bpp)) &&
(xpos < len) &&
((guchar) j < (unsigned char) buf[0]));
i++, xpos++, j++)
{
temp = dest + (ypos * rowstride) + (xpos * channels);
*temp = (buf[1] & (((1<<bpp)-1) << (8 - (i * bpp)))) >> (8 - (i * bpp));
if (grey)
*temp = cmap[*temp][0];
}
}
}
}
if (((unsigned char) buf[0]==0) && ((unsigned char) buf[1]>2))
/* uncompressed record */
{
wieviel=buf[1];
for (j=0;j<wieviel;j+=(8/bpp))
if (((guchar) buf[0] == 0) && ((guchar) buf[1] > 2))
/* uncompressed record */
{
egal=ReadOK(fd,&v,1);
i=1;
while ((i<=(8/bpp)) && (xpos<len))
wieviel = buf[1];
for (j = 0; j < wieviel; j += (8 / bpp))
{
temp = dest + (ypos * rowstride) + (xpos * channels);
*temp=(v & ( ((1<<bpp)-1) << (8-(i*bpp)) ) ) >> (8-(i*bpp));
if (grey) *temp=cmap[*temp][0];
i++;
xpos++;
egal = ReadOK (fd, &v, 1);
i = 1;
while ((i <= (8 / bpp)) && (xpos < len))
{
temp = dest + (ypos * rowstride) + (xpos * channels);
*temp = (v & (((1<<bpp)-1) << (8-(i*bpp)))) >> (8-(i*bpp));
if (grey)
*temp = cmap[*temp][0];
i++;
xpos++;
}
}
if ((wieviel % 2) && (bpp==4))
wieviel++;
if ((wieviel / (8 / bpp)) % 2)
egal = ReadOK (fd, &v, 1);
/*if odd(x div (8 div bpp )) then blockread(f,z^,1);*/
}
if (((guchar) buf[0] == 0) && ((guchar) buf[1]==0))
/* Zeilenende */
{
ypos--;
xpos = 0;
cur_progress++;
if ((interactive_bmp) &&
((cur_progress % 5) == 0))
gimp_progress_update ((gdouble) cur_progress /
(gdouble) max_progress);
}
if (((guchar) buf[0]==0) && ((guchar) buf[1]==1))
/* Bitmapende */
{
break;
}
if (((guchar) buf[0]==0) && ((guchar) buf[1]==2))
/* Deltarecord */
{
xpos += (guchar) buf[2];
ypos += (guchar) buf[3];
}
if ((wieviel % 2) && (bpp==4)) wieviel++;
if ( (wieviel / (8/bpp)) % 2) egal=ReadOK(fd,&v,1);
/*if odd(x div (8 div bpp )) then blockread(f,z^,1);*/
}
if (((unsigned char) buf[0]==0) && ((unsigned char) buf[1]==0))
/* Zeilenende */
{
ypos--;
xpos=0;
cur_progress++;
if ((interactive_bmp) && ((cur_progress % 5) == 0))
gimp_progress_update ((double) cur_progress / (double) max_progress);
}
if (((unsigned char) buf[0]==0) && ((unsigned char) buf[1]==1))
/* Bitmapende */
{
break;
}
if (((unsigned char) buf[0]==0) && ((unsigned char) buf[1]==2))
/* Deltarecord */
{
xpos+=(unsigned char) buf[2];
ypos+=(unsigned char) buf[3];
}
break;
}
break;
}
}
}
}
fclose(fd);
if (bpp<24) for (i = 0, j = 0; i < ncols; i++)
{
gimp_cmap[j++] = cmap[i][0];
gimp_cmap[j++] = cmap[i][1];
gimp_cmap[j++] = cmap[i][2];
}