Bill Skaggs <weskaggs@primate.ucdavis.edu>

* plug-ins/common/png.c
	* po/Makefile.in.in: revert changes inintentionally included
	in previous commit.
This commit is contained in:
William Skaggs 2006-06-08 22:24:43 +00:00
parent 9dbc0ee193
commit c61eddd5c6
3 changed files with 74 additions and 313 deletions

View File

@ -1,3 +1,9 @@
2006-06-08 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* plug-ins/common/png.c
* po/Makefile.in.in: revert changes inintentionally included
in previous commit.
2006-06-08 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/core/core-enums.[ch]: add GIMP_ARRANGE_FOO values

View File

@ -149,11 +149,6 @@ static gint find_unused_ia_color (const guchar *pixels,
static gboolean load_defaults (void);
static void save_defaults (void);
static void load_gui_defaults (PngSaveGui *pg);
static guchar *fill_bit2byte (void);
static void byte2bit (const guchar *byteline,
gint width,
guchar *bitline,
gboolean invert);
/*
* Globals...
@ -677,16 +672,8 @@ load_image (const gchar *filename,
GimpPixelRgn pixel_rgn; /* Pixel region for layer */
png_structp pp; /* PNG read pointer */
png_infop info; /* PNG info pointers */
gboolean is_bw = FALSE;
guchar **pixels = NULL; /* Pixel rows */
guchar *pixel = NULL; /* Pixel data */
/* b&w needs this for bits*/
guchar *bits = NULL; /* rows of bits */
guchar **bit_line = NULL; /* pointers to BOR */
gint bit_line_len = 0; /* number of bytes to keep the bits */
guchar *bit2byte = NULL;
guchar **pixels, /* Pixel rows */
*pixel; /* Pixel data */
guchar alpha[256], /* Index -> Alpha */
*alpha_ptr; /* Temporary pointer */
@ -698,20 +685,6 @@ load_image (const gchar *filename,
if (setjmp (pp->jmpbuf))
{
/* this is a (maybe useless) attempt to recover cleanly from errors. */
#if PNG_LIBPNG_VER > 88
png_destroy_read_struct(&pp, &info, (png_infopp) NULL);
#endif
g_free (pixel);
g_free (pixels);
if (is_bw)
{
g_free (bit2byte);
g_free (bits);
g_free (bit_line);
};
g_message (_("Error while reading '%s'. File corrupted?"),
gimp_filename_to_utf8 (filename));
return image;
@ -771,19 +744,8 @@ load_image (const gchar *filename,
if (info->color_type != PNG_COLOR_TYPE_PALETTE &&
(info->valid & PNG_INFO_tRNS))
{
if (info->bit_depth == 1)
{
/* b&w, load this as an indexed image */
is_bw = TRUE;
bits = NULL;
bit_line = NULL;
bit2byte = NULL;
}
else
{
png_set_expand (pp);
}
}
png_set_expand (pp);
}
/*
* Turn on interlace handling... libpng returns just 1 (ie single pass)
@ -819,7 +781,6 @@ load_image (const gchar *filename,
png_read_update_info (pp, info);
/* mmc: this means, that png_set_expand & png_set_packing may change info->color_type? */
switch (info->color_type)
{
case PNG_COLOR_TYPE_RGB: /* RGB */
@ -835,22 +796,9 @@ load_image (const gchar *filename,
break;
case PNG_COLOR_TYPE_GRAY: /* Grayscale */
/* g_print("opening a grayscale png. bit depth: %d\n", info->bit_depth); */
if (is_bw)
{
/* Have to construct the white&black palette, see below. */
image_type = GIMP_INDEXED;
layer_type = GIMP_INDEXED_IMAGE;
bpp = 1; /* This is fake, we disable the expansion (by libpng)!
* But, after our conversion the rows will indeed be 1 byte-per-pixel. */
bit2byte = fill_bit2byte ();
}
else
{
bpp = 1;
image_type = GIMP_GRAY;
layer_type = GIMP_GRAY_IMAGE;
}
bpp = 1;
image_type = GIMP_GRAY;
layer_type = GIMP_GRAY_IMAGE;
break;
case PNG_COLOR_TYPE_GRAY_ALPHA: /* Grayscale + alpha */
@ -990,12 +938,6 @@ load_image (const gchar *filename,
info->num_palette);
}
}
else if (is_bw)
{
/* we are converting grayscale image to a b&w palette: this is the palette then: */
guchar bw_map[] = { 0, 0, 0, 255, 255, 255 };
gimp_image_set_colormap (image, bw_map,2);
}
/*
* Get the drawable and set the pixel region for our load...
@ -1014,21 +956,6 @@ load_image (const gchar *filename,
pixel = g_new (guchar, tile_height * info->width * bpp);
pixels = g_new (guchar *, tile_height);
if (is_bw)
{
bit_line_len = ((info->width +7 ) / 8);
/* >> 3 */
/* bits_per_byte! */
bits = g_new (guchar, tile_height * bit_line_len);
bit_line = g_new (guchar *, tile_height);
for (i = 0; i < tile_height; i++)
bit_line[i] = bits + bit_line_len * i;
/* g_print("bit_line_len =%d\n", bit_line_len); */
}
for (i = 0; i < tile_height; i++)
pixels[i] = pixel + info->width * info->channels * i;
@ -1050,49 +977,7 @@ load_image (const gchar *filename,
gimp_pixel_rgn_get_rect (&pixel_rgn, pixel, 0, begin,
drawable->width, num);
/* mmc: interlacing not handled now? */
/* if we used the libpng builtin expansion, we would have to
* convert values 255 (black) into 1 (palette index)
* I think this approach is faster:
*/
if (is_bw)
{
int i, j;
guchar *source, *dest;
png_read_rows (pp, bit_line, NULL, num);
/* FIXME: we must not memcpy after the boundary!
* So, if the line is not a multiple of 8 (bits per byte),
* we should do it out of the cycle!*/
#define BITS_PER_BYTE 8
for (j=0; j< tile_height; j++)
{
dest = pixels[j];
source = bit_line[j];
for (i=0; i < (info->width / BITS_PER_BYTE) ; i++)
{
memcpy (dest,
bit2byte + *source * BITS_PER_BYTE,
BITS_PER_BYTE);
dest += BITS_PER_BYTE;
source++;
}
if (info->width / BITS_PER_BYTE < bit_line_len)
{
memcpy (dest,
bit2byte + *source * BITS_PER_BYTE,
info->width % BITS_PER_BYTE);
}
}
}
else
{
png_read_rows (pp, pixels, NULL, num);
}
png_read_rows (pp, pixels, NULL, num);
gimp_pixel_rgn_set_rect (&pixel_rgn, pixel, 0, begin,
drawable->width, num);
@ -1234,23 +1119,7 @@ load_image (const gchar *filename,
}
static guchar *
fill_bit2byte (void)
{
guchar *bit2byte = g_new (guchar, 256 * 8);
guchar *dest;
gint i, j;
dest = bit2byte;
for (j = 0; j < 256; j++)
for (i = 7; i >= 0; i--)
*(dest++) = ((j & (1 << i)) != 0);
return bit2byte;
}
/*
/*
* 'save_image ()' - Save the specified image to a PNG file.
*/
@ -1269,16 +1138,16 @@ save_image (const gchar *filename,
begin, /* Beginning tile row */
end, /* Ending tile row */
num; /* Number of rows to load */
FILE *fp = NULL; /* File pointer */
FILE *fp; /* File pointer */
GimpDrawable *drawable; /* Drawable for layer */
GimpPixelRgn pixel_rgn; /* Pixel region for layer */
png_structp pp; /* PNG read pointer */
png_infop info; /* PNG info pointer */
gint num_colors; /* Number of colors in colormap */
gint offx, offy; /* Drawable offsets from origin */
guchar **pixels = NULL; /* Pixel rows */
guchar *fixed = NULL; /* Fixed-up pixel data */
guchar *pixel = NULL; /* Pixel data */
guchar **pixels, /* Pixel rows */
*fixed, /* Fixed-up pixel data */
*pixel; /* Pixel data */
gdouble xres, yres; /* GIMP resolution (dpi) */
png_color_16 background; /* Background color */
png_time mod_time; /* Modification time (ie NOW) */
@ -1288,10 +1157,7 @@ save_image (const gchar *filename,
guchar remap[256]; /* Re-mapping for the palette */
/* indexed b/w -> save as 1bit grayscale to save space! */
gboolean is_bw = FALSE, invert = FALSE;
png_textp text = NULL;
png_textp text = NULL;
if (pngvals.comment)
{
@ -1337,18 +1203,7 @@ save_image (const gchar *filename,
if (setjmp (pp->jmpbuf))
{
/* mmc: fixme: neo says, on failure a saving process exits, so this might be done implicitely
* I do it explicitely for case someone reuses the code. */
#if PNG_LIBPNG_VER > 88
png_destroy_write_struct(&pp, &info);
#endif
if (fp)
fclose (fp);
g_free (pixels);
g_free (pixel);
g_message (_("Error while saving '%s'. Could not save image."),
g_message (_("Error while saving '%s'. Could not save image."),
gimp_filename_to_utf8 (filename));
return FALSE;
}
@ -1424,42 +1279,12 @@ save_image (const gchar *filename,
break;
case GIMP_INDEXED_IMAGE:
{
/* copied from tiff.c ! */
guchar *cmap = gimp_image_get_colormap (image_ID, &num_colors);
if (num_colors == 2)
{
const guchar bw_map[] = { 0, 0, 0, 255, 255, 255 };
const guchar wb_map[] = { 255, 255, 255, 0, 0, 0 };
is_bw = (memcmp (cmap, bw_map, 6) == 0);
if (!is_bw)
{
is_bw = (memcmp (cmap, wb_map, 6) == 0);
if (is_bw)
invert = TRUE;
}
}
if (is_bw)
{
bpp = 1;
info->color_type = PNG_COLOR_TYPE_GRAY;
info->bit_depth = 1;
g_free (cmap);
}
else
{
bpp = 1;
info->color_type = PNG_COLOR_TYPE_PALETTE;
info->valid |= PNG_INFO_PLTE;
info->palette = (png_colorp) cmap;
info->num_palette = num_colors;
}
}
bpp = 1;
info->color_type = PNG_COLOR_TYPE_PALETTE;
info->valid |= PNG_INFO_PLTE;
info->palette =
(png_colorp) gimp_image_get_colormap (image_ID, &num_colors);
info->num_palette = num_colors;
break;
case GIMP_INDEXEDA_IMAGE:
@ -1681,17 +1506,6 @@ save_image (const gchar *filename,
}
}
}
else if (is_bw)
{
/* indexed b/w -> 1-grayscale: at this stage, */
/* we have to convert the 0/1 indexes(bytes) into 0/1 bits */
/* pixel is the array of several lines of the image: indexes
* pixels is an array of pointers at the beginnings of the lines */
for (i = 0; i < num; ++i)
{
byte2bit (pixels[i], info->width, pixels[i], invert);
}
}
png_write_rows (pp, pixels, num);
@ -1725,53 +1539,6 @@ save_image (const gchar *filename,
return TRUE;
}
/* Convert n bytes of 0/1 to a line of bits */
static void
byte2bit (const guchar *byteline,
gint width,
guchar *bitline,
gboolean invert)
{
guchar bitval;
guchar rest[8];
while (width >= 8)
{
bitval = 0;
if (*(byteline++)) bitval |= 0x80;
if (*(byteline++)) bitval |= 0x40;
if (*(byteline++)) bitval |= 0x20;
if (*(byteline++)) bitval |= 0x10;
if (*(byteline++)) bitval |= 0x08;
if (*(byteline++)) bitval |= 0x04;
if (*(byteline++)) bitval |= 0x02;
if (*(byteline++)) bitval |= 0x01;
*(bitline++) = invert ? ~bitval : bitval;
width -= 8;
}
if (width > 0)
{
memset (rest, 0, 8);
memcpy (rest, byteline, width);
bitval = 0;
byteline = rest;
if (*(byteline++)) bitval |= 0x80;
if (*(byteline++)) bitval |= 0x40;
if (*(byteline++)) bitval |= 0x20;
if (*(byteline++)) bitval |= 0x10;
if (*(byteline++)) bitval |= 0x08;
if (*(byteline++)) bitval |= 0x04;
if (*(byteline++)) bitval |= 0x02;
*bitline = invert ? ~bitval & (0xff << (8 - width)) : bitval;
}
}
static gboolean
ia_has_transparent_pixels (const guchar *pixels,
gint numpixels)

View File

@ -11,6 +11,11 @@
#
# - Modified by jacob berkman <jacob@ximian.com> to install
# Makefile.in.in and po2tbl.sed.in for use with glib-gettextize
#
# - Modified by Rodney Dawes <dobey@novell.com> for use with intltool
#
# We have the following line for use by intltoolize:
# INTLTOOL_MAKEFILE
GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
PACKAGE = @PACKAGE@
@ -27,20 +32,21 @@ VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
datadir = @datadir@
datarootdir = @datarootdir@
libdir = @libdir@
localedir = $(libdir)/locale
gnulocaledir = $(datadir)/locale
gettextsrcdir = $(datadir)/glib-2.0/gettext/po
subdir = po
install_sh = @install_sh@
mkdir_p = @mkdir_p@
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
# Automake >= 1.8 provides @mkdir_p@.
# Until it can be supposed, use the safe fallback:
mkdir_p = $(install_sh) -d
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
CC = @CC@
GENCAT = @GENCAT@
GMSGFMT = @GMSGFMT@
MSGFMT = @MSGFMT@
XGETTEXT = @XGETTEXT@
@ -61,13 +67,13 @@ SOURCES =
POFILES = @POFILES@
GMOFILES = @GMOFILES@
DISTFILES = ChangeLog Makefile.in.in POTFILES.in \
$(POFILES) $(GMOFILES) $(SOURCES)
$(POFILES) $(SOURCES)
EXTRA_DISTFILES = POTFILES.skip Makevars LINGUAS
POTFILES = \
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
INSTOBJEXT = @INSTOBJEXT@
.SUFFIXES:
.SUFFIXES: .c .o .po .pox .gmo .mo .msg .cat
@ -77,7 +83,7 @@ INSTOBJEXT = @INSTOBJEXT@
.po.pox:
$(MAKE) $(GETTEXT_PACKAGE).pot
$(MSGMERGE) $< $(top_builddir)/po/$(GETTEXT_PACKAGE).pot -o $*pox
$(MSGMERGE) $< $(GETTEXT_PACKAGE).pot -o $*.pox
.po.mo:
$(MSGFMT) -o $@ $<
@ -88,7 +94,7 @@ INSTOBJEXT = @INSTOBJEXT@
.po.cat:
sed -f ../intl/po2msg.sed < $< > $*.msg \
&& rm -f $@ && $(GENCAT) $@ $*.msg
&& rm -f $@ && gencat $@ $*.msg
all: all-@USE_NLS@
@ -104,11 +110,7 @@ install-exec:
install-data: install-data-@USE_NLS@
install-data-no: all
install-data-yes: all
if test -n "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $(DESTDIR)$(datadir); \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(datadir); \
fi
$(mkdir_p) $(DESTDIR)$(datadir)
@catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
@ -118,39 +120,31 @@ install-data-yes: all
esac; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
dir=$(DESTDIR)$$destdir/$$lang/LC_MESSAGES; \
if test -n "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $$dir; \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $$dir; \
fi; \
$(mkdir_p) $$dir; \
if test -r $$cat; then \
$(INSTALL_DATA) $$cat $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
echo "installing $$cat as $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT)"; \
$(INSTALL_DATA) $$cat $$dir/$(GETTEXT_PACKAGE).mo; \
echo "installing $$cat as $$dir/$(GETTEXT_PACKAGE).mo"; \
else \
$(INSTALL_DATA) $(srcdir)/$$cat $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
$(INSTALL_DATA) $(srcdir)/$$cat $$dir/$(GETTEXT_PACKAGE).mo; \
echo "installing $(srcdir)/$$cat as" \
"$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT)"; \
"$$dir/$(GETTEXT_PACKAGE).mo"; \
fi; \
if test -r $$cat.m; then \
$(INSTALL_DATA) $$cat.m $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
echo "installing $$cat.m as $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m"; \
$(INSTALL_DATA) $$cat.m $$dir/$(GETTEXT_PACKAGE).mo.m; \
echo "installing $$cat.m as $$dir/$(GETTEXT_PACKAGE).mo.m"; \
else \
if test -r $(srcdir)/$$cat.m ; then \
$(INSTALL_DATA) $(srcdir)/$$cat.m \
$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
$$dir/$(GETTEXT_PACKAGE).mo.m; \
echo "installing $(srcdir)/$$cat as" \
"$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m"; \
"$$dir/$(GETTEXT_PACKAGE).mo.m"; \
else \
true; \
fi; \
fi; \
done
if test "$(PACKAGE)" = "glib"; then \
if test -n "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $(DESTDIR)$(gettextsrcdir); \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(gettextsrcdir); \
fi; \
$(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
$(INSTALL_DATA) $(srcdir)/Makefile.in.in \
$(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
else \
@ -165,16 +159,16 @@ uninstall:
for cat in $$catalogs; do \
cat=`basename $$cat`; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \
rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \
done
if test "$(PACKAGE)" = "glib"; then \
rm -f $(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
fi
check: all
check: all $(GETTEXT_PACKAGE).pot
dvi info tags TAGS ID:
@ -186,19 +180,25 @@ mostlyclean:
clean: mostlyclean
distclean: clean
rm -f Makefile Makefile.in POTFILES *.mo *.msg *.cat *.cat.m
rm -f Makefile Makefile.in POTFILES stamp-it
rm -f *.mo *.msg *.cat *.cat.m *.gmo
maintainer-clean: distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
rm -f $(GMOFILES)
rm -f Makefile.in.in
distdir = ../$(GETTEXT_PACKAGE)-$(VERSION)/$(subdir)
dist distdir: $(DISTFILES) $(GETTEXT_PACKAGE).pot
dist distdir: $(DISTFILES)
dists="$(DISTFILES)"; \
extra_dists="$(EXTRA_DISTFILES)"; \
for file in $$extra_dists; do \
test -f $(srcdir)/$$file && dists="$$dists $(srcdir)/$$file"; \
done; \
for file in $$dists; do \
ln $(srcdir)/$$file $(distdir) 2> /dev/null \
|| cp -p $(srcdir)/$$file $(distdir); \
test -f $$file || file="$(srcdir)/$$file"; \
ln $$file $(distdir) 2> /dev/null \
|| cp -p $$file $(distdir); \
done
update-po: Makefile
@ -228,27 +228,15 @@ update-po: Makefile
fi; \
done
# POTFILES is created from POTFILES.in by stripping comments, empty lines
# and Intltool tags (enclosed in square brackets), and appending a full
# relative path to them
POTFILES: POTFILES.in
( if test 'x$(srcdir)' != 'x.'; then \
posrcprefix='$(top_srcdir)/'; \
else \
posrcprefix="../"; \
fi; \
rm -f $@-t $@ \
&& (sed -e '/^#/d' \
-e "s/^\[.*\] +//" \
-e '/^[ ]*$$/d' \
-e "s@.*@ $$posrcprefix& \\\\@" < $(srcdir)/$@.in \
| sed -e '$$s/\\$$//') > $@-t \
&& chmod a-w $@-t \
&& mv $@-t $@ )
Makefile POTFILES: stamp-it
@if test ! -f $@; then \
rm -f stamp-it; \
$(MAKE) stamp-it; \
fi
Makefile: Makefile.in.in ../config.status POTFILES
stamp-it: Makefile.in.in ../config.status POTFILES.in
cd .. \
&& CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
&& CONFIG_FILES=$(subdir)/Makefile.in CONFIG_HEADERS= CONFIG_LINKS= \
$(SHELL) ./config.status
# Tell versions [3.59,3.63) of GNU make not to export all variables.