mirror of https://github.com/GNOME/gimp.git
Fix for #102562 + minor clean-up of bmp plug-in
This commit is contained in:
parent
50c8c56fe0
commit
0eccb0fec1
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,9 @@
|
|||
2003-01-05 Maurits Rijk <lpeek.mrijk@consunet.nl>
|
||||
|
||||
* libgimp/gimpmisc.c (gimp_pixel_fetcher_get_pixel2): x and y
|
||||
coordinates have to be clamped on image width/height - 1. Fixes
|
||||
#102562
|
||||
|
||||
2003-01-05 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpwidgets/gimpchainbutton.[ch]
|
||||
|
@ -63,6 +69,13 @@
|
|||
return the offset. Finally allows to handle swap files larger than
|
||||
2 GB (fixes bug #74478).
|
||||
|
||||
2003-01-03 Maurits Rijk <lpeek.mrijk@consunet.nl>
|
||||
|
||||
* plug-ins/bmp/bmpread.c
|
||||
* plug-ins/bmp/bmpwrite.c
|
||||
* plug-ins/bmp/bmp.[ch]: added mnemonics to save dialog. Minor code
|
||||
clean-up.
|
||||
|
||||
2003-01-03 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* configure.in: bumped the version number to 1.3.12.
|
||||
|
|
|
@ -197,8 +197,8 @@ gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
|||
}
|
||||
break;
|
||||
case PIXEL_SMEAR:
|
||||
x = CLAMP (x, 0, pf->img_width);
|
||||
y = CLAMP (y, 0, pf->img_height);
|
||||
x = CLAMP (x, 0, pf->img_width - 1);
|
||||
y = CLAMP (y, 0, pf->img_height - 1);
|
||||
break;
|
||||
case PIXEL_BLACK:
|
||||
if (x < 0 || x >= pf->img_width ||
|
||||
|
|
|
@ -197,8 +197,8 @@ gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
|||
}
|
||||
break;
|
||||
case PIXEL_SMEAR:
|
||||
x = CLAMP (x, 0, pf->img_width);
|
||||
y = CLAMP (y, 0, pf->img_height);
|
||||
x = CLAMP (x, 0, pf->img_width - 1);
|
||||
y = CLAMP (y, 0, pf->img_height - 1);
|
||||
break;
|
||||
case PIXEL_BLACK:
|
||||
if (x < 0 || x >= pf->img_width ||
|
||||
|
|
|
@ -197,8 +197,8 @@ gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
|||
}
|
||||
break;
|
||||
case PIXEL_SMEAR:
|
||||
x = CLAMP (x, 0, pf->img_width);
|
||||
y = CLAMP (y, 0, pf->img_height);
|
||||
x = CLAMP (x, 0, pf->img_width - 1);
|
||||
y = CLAMP (y, 0, pf->img_height - 1);
|
||||
break;
|
||||
case PIXEL_BLACK:
|
||||
if (x < 0 || x >= pf->img_width ||
|
||||
|
|
|
@ -63,10 +63,9 @@
|
|||
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
FILE *errorfile;
|
||||
gchar *prog_name = "bmp";
|
||||
gchar *filename;
|
||||
gint interactive_bmp;
|
||||
gboolean interactive_bmp;
|
||||
|
||||
struct Bitmap_File_Head_Struct Bitmap_File_Head;
|
||||
struct Bitmap_Head_Struct Bitmap_Head;
|
||||
|
@ -271,32 +270,3 @@ run (gchar *name,
|
|||
values[0].data.d_status = status;
|
||||
}
|
||||
|
||||
gint32
|
||||
ToL (guchar *puffer)
|
||||
{
|
||||
return (puffer[0] | puffer[1]<<8 | puffer[2]<<16 | puffer[3]<<24);
|
||||
}
|
||||
|
||||
gint16
|
||||
ToS (guchar *puffer)
|
||||
{
|
||||
return (puffer[0] | puffer[1]<<8);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void
|
||||
FromS (gint16 wert,
|
||||
guchar *bopuffer)
|
||||
{
|
||||
bopuffer[0] = (wert & 0x00ff)>>0x00;
|
||||
bopuffer[1] = (wert & 0xff00)>>0x08;
|
||||
}
|
||||
|
|
|
@ -9,21 +9,10 @@
|
|||
#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 (gchar *);
|
||||
extern GimpPDBStatusType WriteBMP (gchar *,
|
||||
gint32,
|
||||
gint32);
|
||||
extern gint ReadColorMap (FILE *,
|
||||
guchar[256][3],
|
||||
gint,
|
||||
gint,
|
||||
gint *);
|
||||
extern Image ReadImage (FILE *,
|
||||
gint,
|
||||
gint,
|
||||
|
@ -33,11 +22,6 @@ extern Image ReadImage (FILE *,
|
|||
gint,
|
||||
gint,
|
||||
gint);
|
||||
extern void WriteColorMap (FILE *,
|
||||
gint *,
|
||||
gint *,
|
||||
gint *,
|
||||
gint);
|
||||
extern void WriteImage (FILE *,
|
||||
guchar *,
|
||||
gint,
|
||||
|
@ -48,10 +32,9 @@ extern void WriteImage (FILE *,
|
|||
gint,
|
||||
gint);
|
||||
|
||||
extern gint interactive_bmp;
|
||||
extern gboolean interactive_bmp;
|
||||
extern gchar *prog_name;
|
||||
extern gchar *filename;
|
||||
extern FILE *errorfile;
|
||||
|
||||
extern struct Bitmap_File_Head_Struct
|
||||
{
|
||||
|
|
|
@ -36,6 +36,47 @@
|
|||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
|
||||
static gint32
|
||||
ToL (guchar *puffer)
|
||||
{
|
||||
return (puffer[0] | puffer[1]<<8 | puffer[2]<<16 | puffer[3]<<24);
|
||||
}
|
||||
|
||||
static gint16
|
||||
ToS (guchar *puffer)
|
||||
{
|
||||
return (puffer[0] | puffer[1]<<8);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ReadColorMap (FILE *fd,
|
||||
guchar buffer[256][3],
|
||||
gint number,
|
||||
gint size,
|
||||
gint *grey)
|
||||
{
|
||||
gint i;
|
||||
guchar rgb[4];
|
||||
|
||||
*grey=(number>2);
|
||||
for (i = 0; i < number ; i++)
|
||||
{
|
||||
if (!ReadOK (fd, rgb, size))
|
||||
{
|
||||
g_message (_("%s: bad colormap"), prog_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Bitmap save the colors in another order! But change only once! */
|
||||
|
||||
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]));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gint32
|
||||
ReadBMP (gchar *name)
|
||||
{
|
||||
|
@ -219,7 +260,7 @@ ReadBMP (gchar *name)
|
|||
|
||||
/* Get the Colormap */
|
||||
|
||||
if (ReadColorMap (fd, ColorMap, ColormapSize, Maps, &Grey) == -1)
|
||||
if (!ReadColorMap (fd, ColorMap, ColormapSize, Maps, &Grey))
|
||||
return -1;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -259,35 +300,6 @@ ReadBMP (gchar *name)
|
|||
return (image_ID);
|
||||
}
|
||||
|
||||
gint
|
||||
ReadColorMap (FILE *fd,
|
||||
guchar buffer[256][3],
|
||||
gint number,
|
||||
gint size,
|
||||
gint *grey)
|
||||
{
|
||||
gint i;
|
||||
guchar rgb[4];
|
||||
|
||||
*grey=(number>2);
|
||||
for (i = 0; i < number ; i++)
|
||||
{
|
||||
if (!ReadOK (fd, rgb, size))
|
||||
{
|
||||
g_message (_("%s: bad colormap"), prog_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Bitmap save the colors in another order! But change only once! */
|
||||
|
||||
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]));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Image
|
||||
ReadImage (FILE *fd,
|
||||
gint width,
|
||||
|
|
|
@ -45,10 +45,8 @@
|
|||
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
guchar *pixels;
|
||||
gint cur_progress;
|
||||
|
||||
gint max_progress;
|
||||
static gint cur_progress;
|
||||
static gint max_progress;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -60,13 +58,52 @@ static BMPSaveInterface gsint =
|
|||
FALSE /* run */
|
||||
};
|
||||
|
||||
gint encoded = 0;
|
||||
static gint encoded = 0;
|
||||
|
||||
|
||||
static gint save_dialog (void);
|
||||
static void save_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static 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;
|
||||
}
|
||||
|
||||
static void
|
||||
FromS (gint16 wert,
|
||||
guchar *bopuffer)
|
||||
{
|
||||
bopuffer[0] = (wert & 0x00ff)>>0x00;
|
||||
bopuffer[1] = (wert & 0xff00)>>0x08;
|
||||
}
|
||||
|
||||
static void
|
||||
WriteColorMap (FILE *f,
|
||||
gint red[MAXCOLORS],
|
||||
gint green[MAXCOLORS],
|
||||
gint blue[MAXCOLORS],
|
||||
gint size)
|
||||
{
|
||||
gchar trgb[4];
|
||||
gint i;
|
||||
|
||||
size /= 4;
|
||||
trgb[3] = 0;
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
trgb[0] = (guchar) blue[i];
|
||||
trgb[1] = (guchar) green[i];
|
||||
trgb[2] = (guchar) red[i];
|
||||
Write (f, trgb, 4);
|
||||
}
|
||||
}
|
||||
|
||||
GimpPDBStatusType
|
||||
WriteBMP (gchar *filename,
|
||||
gint32 image,
|
||||
|
@ -94,16 +131,10 @@ WriteBMP (gchar *filename,
|
|||
drawable_type = gimp_drawable_type(drawable_ID);
|
||||
gimp_pixel_rgn_init (&pixel_rgn, drawable,
|
||||
0, 0, drawable->width, drawable->height, FALSE, FALSE);
|
||||
switch (drawable_type)
|
||||
if (gimp_drawable_has_alpha(drawable_ID))
|
||||
{
|
||||
case GIMP_RGB_IMAGE:
|
||||
case GIMP_GRAY_IMAGE:
|
||||
case GIMP_INDEXED_IMAGE:
|
||||
break;
|
||||
default:
|
||||
g_message(_("BMP: cannot operate on unknown image types or alpha images"));
|
||||
return GIMP_PDB_EXECUTION_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
/* We can save it. So what colors do we use? */
|
||||
|
@ -297,28 +328,7 @@ WriteBMP (gchar *filename,
|
|||
return GIMP_PDB_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
WriteColorMap (FILE *f,
|
||||
gint red[MAXCOLORS],
|
||||
gint green[MAXCOLORS],
|
||||
gint blue[MAXCOLORS],
|
||||
gint size)
|
||||
{
|
||||
gchar trgb[4];
|
||||
gint i;
|
||||
|
||||
size /= 4;
|
||||
trgb[3] = 0;
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
trgb[0] = (guchar) blue[i];
|
||||
trgb[1] = (guchar) green[i];
|
||||
trgb[2] = (guchar) red[i];
|
||||
Write (f, trgb, 4);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
WriteImage (FILE *f,
|
||||
guchar *src,
|
||||
gint width,
|
||||
|
@ -413,7 +423,6 @@ WriteImage (FILE *f,
|
|||
ketten = (guchar *) g_malloc (width / (8 / bpp) + 10);
|
||||
for (ypos = height - 1; ypos >= 0; ypos--)
|
||||
{ /* each row separately */
|
||||
/*printf("Line: %i\n",ypos); */
|
||||
j = 0;
|
||||
/* first copy the pixels to a buffer,
|
||||
* making one byte from two 4bit pixels
|
||||
|
@ -443,10 +452,8 @@ WriteImage (FILE *f,
|
|||
j++;
|
||||
|
||||
ketten[i] = j;
|
||||
/*printf("%i:",ketten[i]); */
|
||||
i += j;
|
||||
}
|
||||
/*printf("\n"); */
|
||||
|
||||
/* then write the strings and the other pixels to the file */
|
||||
for (i = 0; i < breite;)
|
||||
|
@ -475,16 +482,12 @@ WriteImage (FILE *f,
|
|||
Write (f, &n, 1);
|
||||
laenge += 2;
|
||||
Write (f, &Zeile[i], j);
|
||||
/*printf("0.%i.",n); */
|
||||
/*for (k=j;k;k--) printf("#"); */
|
||||
laenge += j;
|
||||
if ((j) % 2)
|
||||
{
|
||||
Write (f, &buf[12], 1);
|
||||
laenge++;
|
||||
/*printf("0"); */
|
||||
}
|
||||
/*printf("|"); */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -509,12 +512,10 @@ WriteImage (FILE *f,
|
|||
n--;
|
||||
Write (f, &n, 1);
|
||||
Write (f, &Zeile[i], 1);
|
||||
/*printf("%i.#|",n); */
|
||||
i += ketten[i];
|
||||
laenge += 2;
|
||||
}
|
||||
}
|
||||
/*printf("\n"); */
|
||||
Write (f, &buf[14], 2); /* End of row */
|
||||
laenge += 2;
|
||||
|
||||
|
@ -578,7 +579,7 @@ save_dialog (void)
|
|||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
|
||||
toggle = gtk_check_button_new_with_label (_("RLE encoded"));
|
||||
toggle = gtk_check_button_new_with_mnemonic (_("_RLE encoded"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), encoded);
|
||||
gtk_widget_show (toggle);
|
||||
|
|
|
@ -27,7 +27,8 @@ VPATH = @srcdir@
|
|||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
datadir = @datadir@
|
||||
localedir = $(datadir)/locale
|
||||
libdir = @libdir@
|
||||
localedir = $(libdir)/locale
|
||||
gnulocaledir = $(datadir)/locale
|
||||
gettextsrcdir = $(datadir)/glib-2.0/gettext/po
|
||||
subdir = po
|
||||
|
@ -38,13 +39,10 @@ MKINSTALLDIRS = $(top_srcdir)/@MKINSTALLDIRS@
|
|||
|
||||
CC = @CC@
|
||||
GENCAT = @GENCAT@
|
||||
GMSGFMT = PATH=../src:$$PATH @GMSGFMT@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
MSGFMT = @MSGFMT@
|
||||
XGETTEXT = PATH=../src:$$PATH @XGETTEXT@
|
||||
INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
|
||||
INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
|
||||
MSGMERGE = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist
|
||||
GENPOT = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --pot
|
||||
XGETTEXT = @XGETTEXT@
|
||||
MSGMERGE = msgmerge
|
||||
|
||||
DEFS = @DEFS@
|
||||
CFLAGS = @CFLAGS@
|
||||
|
@ -197,7 +195,6 @@ dist distdir: update-po $(DISTFILES)
|
|||
|
||||
update-po: Makefile
|
||||
$(MAKE) $(GETTEXT_PACKAGE).pot
|
||||
PATH=`pwd`/../src:$$PATH; \
|
||||
cd $(srcdir); \
|
||||
catalogs='$(CATALOGS)'; \
|
||||
for cat in $$catalogs; do \
|
||||
|
|
Loading…
Reference in New Issue