gimp/plug-ins/bmp/bmpread.c

437 lines
13 KiB
C
Raw Normal View History

1997-11-25 06:05:25 +08:00
/* bmpread.c reads any bitmap I could get for testing */
/* except OS2 bitmaps (wrong colors) */
/* Alexander.Schulz@stud.uni-karlsruhe.de */
/*
* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* ----------------------------------------------------------------------------
*/
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
#include "config.h"
1997-11-25 06:05:25 +08:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libgimp/gimp.h>
#include <gtk/gtk.h>
#include "bmp.h"
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
#include "libgimp/stdplugins-intl.h"
1997-11-25 06:05:25 +08:00
gint32
ReadBMP (char *name)
1997-11-25 06:05:25 +08:00
{
FILE *fd;
char *temp_buf;
char buf[5];
int ColormapSize, SpeicherZeile, Maps, Grey;
unsigned char ColorMap[256][3];
1998-03-17 17:39:40 +08:00
guchar puffer[50];
gint32 image_ID;
1997-11-25 06:05:25 +08:00
1998-03-17 17:39:40 +08:00
if (interactive_bmp)
{
temp_buf = g_malloc (strlen (name) + 11);
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
sprintf (temp_buf, _("Loading %s:"), name);
1998-03-17 17:39:40 +08:00
gimp_progress_init (temp_buf);
g_free (temp_buf);
}
1997-11-25 06:05:25 +08:00
filename = name;
fd = fopen (filename, "rb");
/* Is this a valid File? Should never be used because gimp tests it. */
if (!fd)
{
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
g_message (_("%s: can't open \"%s\"\n"), prog_name, filename);
1997-11-25 06:05:25 +08:00
return -1;
}
/* It is a File. Now is it a Bitmap? */
if (!ReadOK(fd,buf,2) || (strncmp(buf,"BM",2)))
{
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
g_message (_("%s: not a valid BMP file %s\n"), prog_name,buf);
1997-11-25 06:05:25 +08:00
return -1;
}
/* How long is the Header? */
1998-03-17 17:39:40 +08:00
if (!ReadOK (fd, puffer, 0x10))
1997-11-25 06:05:25 +08:00
{
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
g_message (_("%s: error reading BMP file header\n"), prog_name);
1997-11-25 06:05:25 +08:00
return -1;
}
1998-03-17 17:39:40 +08:00
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
/* bring them to the right byteorder. Not too nice, but it should work */
1998-03-17 17:39:40 +08:00
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]);
1997-11-25 06:05:25 +08:00
/* Is it a Windows (R) Bitmap or not */
if (Bitmap_File_Head.biSize!=40)
{
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
g_warning(_("OS/2 unsupported!\n"));
1998-03-17 17:39:40 +08:00
if (!ReadOK (fd, puffer, Bitmap_File_Head.biSize))
1997-11-25 06:05:25 +08:00
{
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
g_message (_("%s: error reading BMP file header\n"), prog_name);
1997-11-25 06:05:25 +08:00
return -1;
}
1998-03-17 17:39:40 +08:00
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;
1997-11-25 06:05:25 +08:00
Bitmap_File_Head.bfSize=(Bitmap_File_Head.bfSize*4)-(Bitmap_File_Head.bfOffs*3);
1998-03-17 17:39:40 +08:00
Bitmap_Head.biHeight=Bitmap_OS2_Head.bcHeight;
Bitmap_Head.biWidth=Bitmap_OS2_Head.bcWidth;
1997-11-25 06:05:25 +08:00
Bitmap_Head.biClrUsed=0;
Bitmap_Head.biCompr=0;
Maps=3;
}
else
{
1998-03-17 17:39:40 +08:00
if (!ReadOK (fd, puffer, 36))
1997-11-25 06:05:25 +08:00
{
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
g_message (_("%s: error reading BMP file header\n"), prog_name);
1997-11-25 06:05:25 +08:00
return -1;
}
1998-03-17 17:39:40 +08:00
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 */
1997-11-25 06:05:25 +08:00
Maps=4;
}
/* This means wrong file Format. I test this because it could crash the */
/* entire gimp. */
1998-03-17 17:39:40 +08:00
if (Bitmap_Head.biBitCnt>24)
1997-11-25 06:05:25 +08:00
{
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
g_message(_("%s: too many colors: %u\n"),prog_name,
(unsigned int) Bitmap_Head.biBitCnt);
1997-11-25 06:05:25 +08:00
return -1;
}
/* There should be some colors used! */
ColormapSize = (Bitmap_File_Head.bfOffs-Bitmap_File_Head.biSize-14) / Maps;
1998-03-17 17:39:40 +08:00
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);
1997-11-25 06:05:25 +08:00
#ifdef DEBUG
printf("\nSize: %u, Colors: %u, Bits: %u, Width: %u, Height: %u, Comp: %u, Zeile: %u\n",
1998-03-17 17:39:40 +08:00
Bitmap_File_Head.bfSize,Bitmap_Head.biClrUsed,Bitmap_Head.biBitCnt,Bitmap_Head.biWidth,
1997-11-25 06:05:25 +08:00
Bitmap_Head.biHeight, Bitmap_Head.biCompr, SpeicherZeile);
#endif
/* Get the Colormap */
if (ReadColorMap(fd, ColorMap, ColormapSize, Maps, &Grey) == -1) return -1;
#ifdef DEBUG
printf("Colormap read\n");
#endif
/* Get the Image and return the ID or -1 on error*/
image_ID = ReadImage (fd,
Bitmap_Head.biWidth,
Bitmap_Head.biHeight,
ColorMap,
Bitmap_Head.biClrUsed,
Bitmap_Head.biBitCnt,
Bitmap_Head.biCompr,
SpeicherZeile,
Grey);
#ifdef GIMP_HAVE_RESOLUTION_INFO
{
/* quick hack by the muppet, scott@asofyet.org, 19 dec 1999 */
double xresolution;
double yresolution;
1997-11-25 06:05:25 +08:00
/*
* xresolution and yresolution are in dots per inch.
* the BMP spec says that biXPels and biYPels are in
* pixels per meter as long ints (actually, "DWORDS").
* this means we've lost some accuracy in the numbers.
* typically, the dots per inch settings on BMPs will
* be integer numbers of dots per inch, which is freaky
* because they're stored in the BMP as metric. *sigh*
* so, we'll round this off, even though the gimp wants
* a floating point number...
*/
#define LROUND(x) ((long int)((x)+0.5))
xresolution = LROUND((Bitmap_Head.biXPels * 2.54 / 100.0));
yresolution = LROUND((Bitmap_Head.biYPels * 2.54 / 100.0));
#undef LROUND
gimp_image_set_resolution (image_ID, xresolution, yresolution);
}
#endif /* GIMP_HAVE_RESOLUTION_INFO */
1997-11-25 06:05:25 +08:00
return (image_ID);
1997-11-25 06:05:25 +08:00
}
gint
ReadColorMap (FILE *fd,
unsigned char buffer[256][3],
int number,
int size,
int *grey)
1997-11-25 06:05:25 +08:00
{
int i;
unsigned char rgb[4];
*grey=(number>2);
for (i = 0; i < number ; i++)
{
if (!ReadOK (fd, rgb, size))
{
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
g_message (_("%s: bad colormap\n"), prog_name);
1997-11-25 06:05:25 +08:00
return -1;
}
/* 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]));
}
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)
1997-11-25 06:05:25 +08:00
{
char *name_buf;
unsigned char v,wieviel;
GPixelRgn pixel_rgn;
char buf[16];
int 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;
/* Make a new image in the gimp */
if (grey)
{
1998-03-17 17:39:40 +08:00
image = gimp_image_new (len, height, GRAY);
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
layer = gimp_layer_new (image, _("Background"), len, height, GRAY_IMAGE, 100, NORMAL_MODE);
1998-03-17 17:39:40 +08:00
channels = 1;
1997-11-25 06:05:25 +08:00
}
else
1997-11-25 06:05:25 +08:00
{
1998-03-17 17:39:40 +08:00
if (bpp<24)
{
image = gimp_image_new (len, height, INDEXED);
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
layer = gimp_layer_new (image, _("Background"), len, height, INDEXED_IMAGE, 100, NORMAL_MODE);
1998-03-17 17:39:40 +08:00
channels = 1;
}
else
{
image = gimp_image_new (len, height, RGB);
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
layer = gimp_layer_new (image, _("Background"), len, height, RGB_IMAGE, 100, NORMAL_MODE);
1998-03-17 17:39:40 +08:00
channels = 3;
}
1997-11-25 06:05:25 +08:00
}
name_buf = g_malloc (strlen (filename) + 10);
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
strcpy (name_buf, filename);
1997-11-25 06:05:25 +08:00
gimp_image_set_filename(image,name_buf);
applied gimp-lecorfec-99041[02]-0, changes follow * applied gimp-lecorfec-99041[02]-0, changes follow * plug-ins/FractalExplorer/Dialogs.h (make_color_map): replaced free with g_free to fix segfault. * plug-ins/Lighting/lighting_preview.c (compute_preview): allocate xpostab and ypostab only when needed (it could also be allocated on stack with a compilation-fixed size like MapObject). It avoids to lose some Kb on each preview :) Also reindented (unfortunate C-c C-q) some other lines. * plug-ins/Lighting/lighting_main.c (run): release allocated postabs. * plug-ins/Lighting/lighting_ui.c: callbacks now have only one argument because gck widget use gtk_signal_connect_object. Caused segfault for scale widget. * plug-ins/autocrop/autocrop.c (doit): return if image has only background (thus fixing a segfault). * plug-ins/emboss/emboss.c (pluginCore, emboss_do_preview): replaced malloc/free with g_malloc/g_free (unneeded, but shouldn't everyone use glib calls ? :) * plug-ins/flame/flame.c : replaced a segfaulting free, and several harmless malloc/free pairs. * plug-ins/flame/megawidget.c (mw_preview_build): replaced harmless malloc/free pair. Note : mwp->bits is malloc'ed but seems to be never freed. * plug-ins/fractaltrace/fractaltrace.c (pixels_free): replaced a bunch of segfaulting free. (pixels_get, dialog_show): replaced gtk_signal_connect_object with gtk_signal_connect to accomodate callbacks (caused STRANGE dialog behaviour, coz you destroyed buttons one by one). * plug-ins/illusion/illusion.c (dialog): same gtk_signal_connect_object replacement for same reasons. * plug-ins/libgck/gck/gckcolor.c : changed all gck_rgb_to_color* functions to use a static GdkColor instead of a malloc'ed area. Provided reentrant functions with the old behaviour (gck_rgb_to_color*_r). Made some private functions static, too. gck_rgb_to_gdkcolor now use the new functions while gck_rgb_to_gdkcolor_r is the reentrant version. Also affected by this change: gck_gc_set_foreground and gck_gc_set_background (no more free(color)). * plug-ins/libgck/gck/gckcolor.h : added the gck_rgb_to_gdkcolor_r proto. * plug-ins/lic/lic.c (ok_button_clicked, cancel_button_clicked) : segfault on gtk_widget_destroy, now calls gtk_main_quit. (dialog_destroy) : segfault on window closure when called by "destroy" event. Now called by "delete_event". * plug-ins/megawidget/megawidget.c (mw_preview_build): replaced harmless malloc/free pair. Note : mwp->bits is malloc'ed but seems to be never freed. * plug-ins/png/png.c (load_image): replaced 2 segfaulting free. * plug-ins/print/print-ps.c (ps_print): replaced a segfaulting free (called many times :). * plug-ins/sgi/sgi.c (load_image, save_image): replaced a bunch of segfaulting free, and did some harmless inits to avoid a few gcc warnings. * plug-ins/wind/wind.c (render_wind): replaced a segfaulting free. (render_blast): replaced harmless malloc/free pair. * plug-ins/bmp/bmpread.c (ReadImage): yet another free()/g_free() problem fixed. * plug-ins/exchange/exchange.c (real_exchange): ditto. * plug-ins/fp/fp.h: added Frames_Check_Button_In_A_Box proto. * plug-ins/fp/fp_gtk.c: closing subdialogs via window manager wasn't handled, thus leading to errors and crashes. Now delete_event signals the dialog control button to close a dialog with the good way. * plug-ins/ifscompose/ifscompose.c (value_pair_create): tried to set events mask on scale widget (a NO_WINDOW widget). * plug-ins/png/png.c (save_image): Replaced 2 free() with g_free() for g_malloc'ed memory. Mysteriously I corrected the loading bug but not the saving one :) -Yosh
1999-04-16 05:49:09 +08:00
g_free (name_buf);
1997-11-25 06:05:25 +08:00
gimp_image_add_layer(image,layer,0);
drawable = gimp_drawable_get(layer);
1998-03-17 17:39:40 +08:00
1997-11-25 06:05:25 +08:00
dest = g_malloc(drawable->width*drawable->height*channels);
rowstride = drawable->width * channels;
ypos=height-1; /* Bitmaps begin in the lower left corner */
cur_progress = 0;
max_progress = height;
if (bpp==24)
{
while (ReadOK(fd,buf,3))
{
temp = dest + (ypos * rowstride) + (xpos * channels);
*temp=buf[2];
temp++;
*temp=buf[1];
temp++;
*temp=buf[0];
xpos++;
if (xpos == len)
{
egal=ReadOK(fd,buf,spzeile-(len*3));
ypos--;
xpos=0;
cur_progress++;
1998-03-17 17:39:40 +08:00
if ((interactive_bmp) &&((cur_progress % 5) == 0))
1997-11-25 06:05:25 +08:00
gimp_progress_update ((double) cur_progress / (double) max_progress);
1998-03-17 17:39:40 +08:00
}
if (ypos < 0) break;
1997-11-25 06:05:25 +08:00
}
}
else { switch(compression)
{
case 0: /* uncompressed */
{
1998-03-17 17:39:40 +08:00
while (ReadOK(fd,&v,1))
{
1997-11-25 06:05:25 +08:00
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];
1997-11-25 06:05:25 +08:00
}
if (xpos == len)
{
egal=ReadOK(fd,buf,(spzeile-len)/(8/bpp));
ypos--;
xpos=0;
cur_progress++;
1998-03-17 17:39:40 +08:00
if ((interactive_bmp) && ((cur_progress % 5) == 0))
1997-11-25 06:05:25 +08:00
gimp_progress_update ((double) cur_progress / (double) max_progress);
}
1998-03-17 17:39:40 +08:00
if (ypos < 0) break;
}
break;
}
default: /* Compressed images */
{
while (TRUE)
{
egal=ReadOK(fd,buf,2);
if ((unsigned char) buf[0]!=0)
/* Count + Color - record */
{
for (j=0;((unsigned char) j < (unsigned char) buf[0]) && (xpos<len);)
{
#ifdef DEBUG2
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];
1998-03-17 17:39:40 +08:00
}
}
}
if (((unsigned char) buf[0]==0) && ((unsigned char) buf[1]>2))
/* uncompressed record */
{
wieviel=buf[1];
for (j=0;j<wieviel;j+=(8/bpp))
{
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];
1998-03-17 17:39:40 +08:00
i++;
xpos++;
}
}
if ((wieviel % 2) && (bpp==4)) wieviel++;
1998-03-17 17:39:40 +08:00
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;
1997-11-25 06:05:25 +08:00
}
1998-03-17 17:39:40 +08:00
}
}
1997-11-25 06:05:25 +08:00
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];
}
1998-03-17 17:39:40 +08:00
if (interactive_bmp) gimp_progress_update (1);
1997-11-25 06:05:25 +08:00
gimp_pixel_rgn_init(&pixel_rgn, drawable, 0, 0, drawable->width, drawable->height, TRUE, FALSE);
gimp_pixel_rgn_set_rect(&pixel_rgn, dest, 0, 0, drawable->width, drawable->height);
if ((!grey) && (bpp<24)) gimp_image_set_cmap(image, gimp_cmap, ncols);
1997-11-25 06:05:25 +08:00
gimp_drawable_flush(drawable);
gimp_drawable_detach(drawable);
g_free(dest);
return (image);
1997-11-25 06:05:25 +08:00
}