mirror of https://github.com/GNOME/gimp.git
OS/2 reading fix
This commit is contained in:
parent
0309fec9f1
commit
9f716ba7e5
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2000-03-24 Asbjorn Pettersen <asbjornP@dualog.no>
|
||||
|
||||
* plug-ins/bmp/Makefile.am : add bmpos2.c and bmpos2.h
|
||||
|
||||
* plug-ins/bmp/bmpread.c (ReadBMP): Add support for
|
||||
reading old OS/2 bitmaps.
|
||||
|
||||
* plug-ins/bmp/bmpos2.h (read_os2_head1):
|
||||
* plug-ins/bmp/bmpos2.c : New file for OS/2 bitmap reading.
|
||||
|
||||
Fri Mar 24 17:13:41 CET 2000 Sven Neumann <sven@gimp.org>
|
||||
|
||||
plug-ins/common/mapcolor.c: applied gimp-kirchgessner-000320-0.
|
||||
|
|
|
@ -7,6 +7,8 @@ libexec_PROGRAMS = bmp
|
|||
bmp_SOURCES = \
|
||||
bmp.c \
|
||||
bmp.h \
|
||||
bmpos2.c \
|
||||
bmpos2.h \
|
||||
bmpread.c \
|
||||
bmpwrite.c
|
||||
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/* bmpos2.c */
|
||||
/* */
|
||||
/* asbjorn.pettersen@dualog.no */
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "bmp.h"
|
||||
|
||||
static void dump_file_head (struct Bitmap_File_Head_Struct *p)
|
||||
{
|
||||
printf("bfSize=%ld\n",p->bfSize);
|
||||
printf("bfoffs=%ld\n",p->bfOffs);
|
||||
printf("biSize=%ld\n",p->biSize);
|
||||
}
|
||||
|
||||
static void dump_os2_head (struct Bitmap_OS2_Head_Struct *p)
|
||||
{
|
||||
printf("bcWidth =%4d ",p->bcWidth);
|
||||
printf("bcHeigth=%4d\n",p->bcHeight);
|
||||
printf("bcPlanes=%4d ",p->bcPlanes);
|
||||
printf("bcBitCnt=%4d\n",p->bcBitCnt);
|
||||
}
|
||||
|
||||
int read_os2_head1 (FILE *fd, int headsz, struct Bitmap_Head_Struct *p)
|
||||
{
|
||||
guchar puffer[150];
|
||||
|
||||
if (!ReadOK (fd, puffer, headsz))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
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]);
|
||||
#if 0
|
||||
dump_os2_head (&Bitmap_OS2_Head);
|
||||
#endif
|
||||
p->biHeight = Bitmap_OS2_Head.bcHeight;
|
||||
p->biWidth = Bitmap_OS2_Head.bcWidth;
|
||||
p->biPlanes = Bitmap_OS2_Head.bcPlanes;
|
||||
p->biBitCnt = Bitmap_OS2_Head.bcBitCnt;
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
extern int read_os2_head1 (FILE *fd, int headsz,
|
||||
struct Bitmap_Head_Struct *p);
|
|
@ -33,6 +33,7 @@
|
|||
#include <libgimp/gimp.h>
|
||||
|
||||
#include "bmp.h"
|
||||
#include "bmpos2.h"
|
||||
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
|
@ -91,7 +92,16 @@ ReadBMP (gchar *name)
|
|||
|
||||
/* Is it a Windows (R) Bitmap or not */
|
||||
|
||||
if (Bitmap_File_Head.biSize != 40)
|
||||
if (Bitmap_File_Head.biSize == 12) /* OS/2 */
|
||||
{
|
||||
if (!read_os2_head1 (fd, Bitmap_File_Head.biSize - 4, &Bitmap_Head))
|
||||
{
|
||||
g_message (_("%s: error reading BMP file header\n"), prog_name);
|
||||
return -1;
|
||||
}
|
||||
Maps = 3;
|
||||
}
|
||||
else if (Bitmap_File_Head.biSize != 40)
|
||||
{
|
||||
g_warning ("OS/2 unsupported!\n");
|
||||
if (!ReadOK (fd, puffer, Bitmap_File_Head.biSize))
|
||||
|
@ -246,10 +256,10 @@ ReadColorMap (FILE *fd,
|
|||
}
|
||||
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];
|
||||
/* this one is for old os2 Bitmaps */
|
||||
buffer[i][0] = rgb[2];
|
||||
buffer[i][1] = rgb[1];
|
||||
buffer[i][2] = rgb[0];
|
||||
}
|
||||
*grey = ((*grey) && (rgb[0]==rgb[1]) && (rgb[1]==rgb[2]));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue