diff options
Diffstat (limited to 'plug-ins/file-bmp')
-rw-r--r-- | plug-ins/file-bmp/Makefile.am | 52 | ||||
-rw-r--r-- | plug-ins/file-bmp/Makefile.in | 1012 | ||||
-rw-r--r-- | plug-ins/file-bmp/bmp-load.c | 1026 | ||||
-rw-r--r-- | plug-ins/file-bmp/bmp-load.h | 27 | ||||
-rw-r--r-- | plug-ins/file-bmp/bmp-save.c | 1104 | ||||
-rw-r--r-- | plug-ins/file-bmp/bmp-save.h | 39 | ||||
-rw-r--r-- | plug-ins/file-bmp/bmp.c | 306 | ||||
-rw-r--r-- | plug-ins/file-bmp/bmp.h | 71 |
8 files changed, 3637 insertions, 0 deletions
diff --git a/plug-ins/file-bmp/Makefile.am b/plug-ins/file-bmp/Makefile.am new file mode 100644 index 0000000..4dc09ec --- /dev/null +++ b/plug-ins/file-bmp/Makefile.am @@ -0,0 +1,52 @@ +## Process this file with automake to produce Makefile.in + +libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la +libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la +libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la +libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la +libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la +libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la +libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la + +if OS_WIN32 +mwindows = -mwindows +endif + +if HAVE_WINDRES +include $(top_srcdir)/build/windows/gimprc-plug-ins.rule +file_bmp_RC = file-bmp.rc.o +endif + +AM_LDFLAGS = $(mwindows) + +libexecdir = $(gimpplugindir)/plug-ins/file-bmp + +libexec_PROGRAMS = file-bmp + +file_bmp_SOURCES = \ + bmp.c \ + bmp.h \ + bmp-load.c \ + bmp-load.h \ + bmp-save.c \ + bmp-save.h + +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + $(GTK_CFLAGS) \ + $(GEGL_CFLAGS) \ + -I$(includedir) + +LDADD = \ + $(libgimpui) \ + $(libgimpwidgets) \ + $(libgimpconfig) \ + $(libgimp) \ + $(libgimpcolor) \ + $(libgimpmath) \ + $(libgimpbase) \ + $(GTK_LIBS) \ + $(GEGL_LIBS) \ + $(RT_LIBS) \ + $(INTLLIBS) \ + $(file_bmp_RC) diff --git a/plug-ins/file-bmp/Makefile.in b/plug-ins/file-bmp/Makefile.in new file mode 100644 index 0000000..dfe3334 --- /dev/null +++ b/plug-ins/file-bmp/Makefile.in @@ -0,0 +1,1012 @@ +# Makefile.in generated by automake 1.16.3 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2020 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Version resources for Microsoft Windows + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +libexec_PROGRAMS = file-bmp$(EXEEXT) +subdir = plug-ins/file-bmp +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/m4macros/alsa.m4 \ + $(top_srcdir)/m4macros/ax_compare_version.m4 \ + $(top_srcdir)/m4macros/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4macros/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4macros/ax_prog_cc_for_build.m4 \ + $(top_srcdir)/m4macros/ax_prog_perl_version.m4 \ + $(top_srcdir)/m4macros/detectcflags.m4 \ + $(top_srcdir)/m4macros/pythondev.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(libexecdir)" +PROGRAMS = $(libexec_PROGRAMS) +am_file_bmp_OBJECTS = bmp.$(OBJEXT) bmp-load.$(OBJEXT) \ + bmp-save.$(OBJEXT) +file_bmp_OBJECTS = $(am_file_bmp_OBJECTS) +file_bmp_LDADD = $(LDADD) +am__DEPENDENCIES_1 = +file_bmp_DEPENDENCIES = $(libgimpui) $(libgimpwidgets) \ + $(libgimpconfig) $(libgimp) $(libgimpcolor) $(libgimpmath) \ + $(libgimpbase) $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(file_bmp_RC) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/bmp-load.Po ./$(DEPDIR)/bmp-save.Po \ + ./$(DEPDIR)/bmp.Po +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(file_bmp_SOURCES) +DIST_SOURCES = $(file_bmp_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(top_srcdir)/build/windows/gimprc-plug-ins.rule \ + $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +AA_LIBS = @AA_LIBS@ +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +ALL_LINGUAS = @ALL_LINGUAS@ +ALSA_CFLAGS = @ALSA_CFLAGS@ +ALSA_LIBS = @ALSA_LIBS@ +ALTIVEC_EXTRA_CFLAGS = @ALTIVEC_EXTRA_CFLAGS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +APPSTREAM_UTIL = @APPSTREAM_UTIL@ +AR = @AR@ +AS = @AS@ +ATK_CFLAGS = @ATK_CFLAGS@ +ATK_LIBS = @ATK_LIBS@ +ATK_REQUIRED_VERSION = @ATK_REQUIRED_VERSION@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BABL_CFLAGS = @BABL_CFLAGS@ +BABL_LIBS = @BABL_LIBS@ +BABL_REQUIRED_VERSION = @BABL_REQUIRED_VERSION@ +BUG_REPORT_URL = @BUG_REPORT_URL@ +BUILD_EXEEXT = @BUILD_EXEEXT@ +BUILD_OBJEXT = @BUILD_OBJEXT@ +BZIP2_LIBS = @BZIP2_LIBS@ +CAIRO_CFLAGS = @CAIRO_CFLAGS@ +CAIRO_LIBS = @CAIRO_LIBS@ +CAIRO_PDF_CFLAGS = @CAIRO_PDF_CFLAGS@ +CAIRO_PDF_LIBS = @CAIRO_PDF_LIBS@ +CAIRO_PDF_REQUIRED_VERSION = @CAIRO_PDF_REQUIRED_VERSION@ +CAIRO_REQUIRED_VERSION = @CAIRO_REQUIRED_VERSION@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CC_FOR_BUILD = @CC_FOR_BUILD@ +CC_VERSION = @CC_VERSION@ +CFLAGS = @CFLAGS@ +CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@ +CPP_FOR_BUILD = @CPP_FOR_BUILD@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DESKTOP_DATADIR = @DESKTOP_DATADIR@ +DESKTOP_FILE_VALIDATE = @DESKTOP_FILE_VALIDATE@ +DLLTOOL = @DLLTOOL@ +DOC_SHOOTER = @DOC_SHOOTER@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FILE_AA = @FILE_AA@ +FILE_EXR = @FILE_EXR@ +FILE_HEIF = @FILE_HEIF@ +FILE_JP2_LOAD = @FILE_JP2_LOAD@ +FILE_JPEGXL = @FILE_JPEGXL@ +FILE_MNG = @FILE_MNG@ +FILE_PDF_SAVE = @FILE_PDF_SAVE@ +FILE_PS = @FILE_PS@ +FILE_WMF = @FILE_WMF@ +FILE_XMC = @FILE_XMC@ +FILE_XPM = @FILE_XPM@ +FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@ +FONTCONFIG_LIBS = @FONTCONFIG_LIBS@ +FONTCONFIG_REQUIRED_VERSION = @FONTCONFIG_REQUIRED_VERSION@ +FREETYPE2_REQUIRED_VERSION = @FREETYPE2_REQUIRED_VERSION@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GDBUS_CODEGEN = @GDBUS_CODEGEN@ +GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@ +GDK_PIXBUF_CSOURCE = @GDK_PIXBUF_CSOURCE@ +GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@ +GDK_PIXBUF_REQUIRED_VERSION = @GDK_PIXBUF_REQUIRED_VERSION@ +GEGL = @GEGL@ +GEGL_CFLAGS = @GEGL_CFLAGS@ +GEGL_LIBS = @GEGL_LIBS@ +GEGL_MAJOR_MINOR_VERSION = @GEGL_MAJOR_MINOR_VERSION@ +GEGL_REQUIRED_VERSION = @GEGL_REQUIRED_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GEXIV2_CFLAGS = @GEXIV2_CFLAGS@ +GEXIV2_LIBS = @GEXIV2_LIBS@ +GEXIV2_REQUIRED_VERSION = @GEXIV2_REQUIRED_VERSION@ +GIMP_API_VERSION = @GIMP_API_VERSION@ +GIMP_APP_VERSION = @GIMP_APP_VERSION@ +GIMP_BINARY_AGE = @GIMP_BINARY_AGE@ +GIMP_COMMAND = @GIMP_COMMAND@ +GIMP_DATA_VERSION = @GIMP_DATA_VERSION@ +GIMP_FULL_NAME = @GIMP_FULL_NAME@ +GIMP_INTERFACE_AGE = @GIMP_INTERFACE_AGE@ +GIMP_MAJOR_VERSION = @GIMP_MAJOR_VERSION@ +GIMP_MICRO_VERSION = @GIMP_MICRO_VERSION@ +GIMP_MINOR_VERSION = @GIMP_MINOR_VERSION@ +GIMP_MKENUMS = @GIMP_MKENUMS@ +GIMP_MODULES = @GIMP_MODULES@ +GIMP_PACKAGE_REVISION = @GIMP_PACKAGE_REVISION@ +GIMP_PKGCONFIG_VERSION = @GIMP_PKGCONFIG_VERSION@ +GIMP_PLUGINS = @GIMP_PLUGINS@ +GIMP_PLUGIN_VERSION = @GIMP_PLUGIN_VERSION@ +GIMP_REAL_VERSION = @GIMP_REAL_VERSION@ +GIMP_RELEASE = @GIMP_RELEASE@ +GIMP_SYSCONF_VERSION = @GIMP_SYSCONF_VERSION@ +GIMP_TOOL_VERSION = @GIMP_TOOL_VERSION@ +GIMP_UNSTABLE = @GIMP_UNSTABLE@ +GIMP_USER_VERSION = @GIMP_USER_VERSION@ +GIMP_VERSION = @GIMP_VERSION@ +GIO_CFLAGS = @GIO_CFLAGS@ +GIO_LIBS = @GIO_LIBS@ +GIO_UNIX_CFLAGS = @GIO_UNIX_CFLAGS@ +GIO_UNIX_LIBS = @GIO_UNIX_LIBS@ +GIO_WINDOWS_CFLAGS = @GIO_WINDOWS_CFLAGS@ +GIO_WINDOWS_LIBS = @GIO_WINDOWS_LIBS@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_COMPILE_RESOURCES = @GLIB_COMPILE_RESOURCES@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GLIB_REQUIRED_VERSION = @GLIB_REQUIRED_VERSION@ +GMODULE_NO_EXPORT_CFLAGS = @GMODULE_NO_EXPORT_CFLAGS@ +GMODULE_NO_EXPORT_LIBS = @GMODULE_NO_EXPORT_LIBS@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GOBJECT_QUERY = @GOBJECT_QUERY@ +GREP = @GREP@ +GS_LIBS = @GS_LIBS@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GTK_CFLAGS = @GTK_CFLAGS@ +GTK_LIBS = @GTK_LIBS@ +GTK_MAC_INTEGRATION_CFLAGS = @GTK_MAC_INTEGRATION_CFLAGS@ +GTK_MAC_INTEGRATION_LIBS = @GTK_MAC_INTEGRATION_LIBS@ +GTK_REQUIRED_VERSION = @GTK_REQUIRED_VERSION@ +GTK_UPDATE_ICON_CACHE = @GTK_UPDATE_ICON_CACHE@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HARFBUZZ_CFLAGS = @HARFBUZZ_CFLAGS@ +HARFBUZZ_LIBS = @HARFBUZZ_LIBS@ +HARFBUZZ_REQUIRED_VERSION = @HARFBUZZ_REQUIRED_VERSION@ +HAVE_CXX14 = @HAVE_CXX14@ +HAVE_FINITE = @HAVE_FINITE@ +HAVE_ISFINITE = @HAVE_ISFINITE@ +HAVE_VFORK = @HAVE_VFORK@ +HOST_GLIB_COMPILE_RESOURCES = @HOST_GLIB_COMPILE_RESOURCES@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_REQUIRED_VERSION = @INTLTOOL_REQUIRED_VERSION@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ +INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ +INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ +INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +ISO_CODES_LOCALEDIR = @ISO_CODES_LOCALEDIR@ +ISO_CODES_LOCATION = @ISO_CODES_LOCATION@ +JPEG_LIBS = @JPEG_LIBS@ +JSON_GLIB_CFLAGS = @JSON_GLIB_CFLAGS@ +JSON_GLIB_LIBS = @JSON_GLIB_LIBS@ +JXL_CFLAGS = @JXL_CFLAGS@ +JXL_LIBS = @JXL_LIBS@ +JXL_THREADS_CFLAGS = @JXL_THREADS_CFLAGS@ +JXL_THREADS_LIBS = @JXL_THREADS_LIBS@ +LCMS_CFLAGS = @LCMS_CFLAGS@ +LCMS_LIBS = @LCMS_LIBS@ +LCMS_REQUIRED_VERSION = @LCMS_REQUIRED_VERSION@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ +LIBBACKTRACE_LIBS = @LIBBACKTRACE_LIBS@ +LIBHEIF_CFLAGS = @LIBHEIF_CFLAGS@ +LIBHEIF_LIBS = @LIBHEIF_LIBS@ +LIBHEIF_REQUIRED_VERSION = @LIBHEIF_REQUIRED_VERSION@ +LIBJXL_REQUIRED_VERSION = @LIBJXL_REQUIRED_VERSION@ +LIBLZMA_REQUIRED_VERSION = @LIBLZMA_REQUIRED_VERSION@ +LIBMYPAINT_CFLAGS = @LIBMYPAINT_CFLAGS@ +LIBMYPAINT_LIBS = @LIBMYPAINT_LIBS@ +LIBMYPAINT_REQUIRED_VERSION = @LIBMYPAINT_REQUIRED_VERSION@ +LIBOBJS = @LIBOBJS@ +LIBPNG_REQUIRED_VERSION = @LIBPNG_REQUIRED_VERSION@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUNWIND_CFLAGS = @LIBUNWIND_CFLAGS@ +LIBUNWIND_LIBS = @LIBUNWIND_LIBS@ +LIBUNWIND_REQUIRED_VERSION = @LIBUNWIND_REQUIRED_VERSION@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_CURRENT_MINUS_AGE = @LT_CURRENT_MINUS_AGE@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +LT_VERSION_INFO = @LT_VERSION_INFO@ +LZMA_CFLAGS = @LZMA_CFLAGS@ +LZMA_LIBS = @LZMA_LIBS@ +MAIL = @MAIL@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MIME_INFO_CFLAGS = @MIME_INFO_CFLAGS@ +MIME_INFO_LIBS = @MIME_INFO_LIBS@ +MIME_TYPES = @MIME_TYPES@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MMX_EXTRA_CFLAGS = @MMX_EXTRA_CFLAGS@ +MNG_CFLAGS = @MNG_CFLAGS@ +MNG_LIBS = @MNG_LIBS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +MYPAINT_BRUSHES_CFLAGS = @MYPAINT_BRUSHES_CFLAGS@ +MYPAINT_BRUSHES_LIBS = @MYPAINT_BRUSHES_LIBS@ +NATIVE_GLIB_CFLAGS = @NATIVE_GLIB_CFLAGS@ +NATIVE_GLIB_LIBS = @NATIVE_GLIB_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENEXR_CFLAGS = @OPENEXR_CFLAGS@ +OPENEXR_LIBS = @OPENEXR_LIBS@ +OPENEXR_REQUIRED_VERSION = @OPENEXR_REQUIRED_VERSION@ +OPENJPEG_CFLAGS = @OPENJPEG_CFLAGS@ +OPENJPEG_LIBS = @OPENJPEG_LIBS@ +OPENJPEG_REQUIRED_VERSION = @OPENJPEG_REQUIRED_VERSION@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PANGOCAIRO_CFLAGS = @PANGOCAIRO_CFLAGS@ +PANGOCAIRO_LIBS = @PANGOCAIRO_LIBS@ +PANGOCAIRO_REQUIRED_VERSION = @PANGOCAIRO_REQUIRED_VERSION@ +PATHSEP = @PATHSEP@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PERL_REQUIRED_VERSION = @PERL_REQUIRED_VERSION@ +PERL_VERSION = @PERL_VERSION@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PNG_CFLAGS = @PNG_CFLAGS@ +PNG_LIBS = @PNG_LIBS@ +POFILES = @POFILES@ +POPPLER_CFLAGS = @POPPLER_CFLAGS@ +POPPLER_DATA_CFLAGS = @POPPLER_DATA_CFLAGS@ +POPPLER_DATA_LIBS = @POPPLER_DATA_LIBS@ +POPPLER_DATA_REQUIRED_VERSION = @POPPLER_DATA_REQUIRED_VERSION@ +POPPLER_LIBS = @POPPLER_LIBS@ +POPPLER_REQUIRED_VERSION = @POPPLER_REQUIRED_VERSION@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +PYBIN_PATH = @PYBIN_PATH@ +PYCAIRO_CFLAGS = @PYCAIRO_CFLAGS@ +PYCAIRO_LIBS = @PYCAIRO_LIBS@ +PYGIMP_EXTRA_CFLAGS = @PYGIMP_EXTRA_CFLAGS@ +PYGTK_CFLAGS = @PYGTK_CFLAGS@ +PYGTK_CODEGEN = @PYGTK_CODEGEN@ +PYGTK_DEFSDIR = @PYGTK_DEFSDIR@ +PYGTK_LIBS = @PYGTK_LIBS@ +PYLINK_LIBS = @PYLINK_LIBS@ +PYTHON = @PYTHON@ +PYTHON2_REQUIRED_VERSION = @PYTHON2_REQUIRED_VERSION@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_INCLUDES = @PYTHON_INCLUDES@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +RSVG_REQUIRED_VERSION = @RSVG_REQUIRED_VERSION@ +RT_LIBS = @RT_LIBS@ +SCREENSHOT_LIBS = @SCREENSHOT_LIBS@ +SED = @SED@ +SENDMAIL = @SENDMAIL@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOCKET_LIBS = @SOCKET_LIBS@ +SSE2_EXTRA_CFLAGS = @SSE2_EXTRA_CFLAGS@ +SSE4_1_EXTRA_CFLAGS = @SSE4_1_EXTRA_CFLAGS@ +SSE_EXTRA_CFLAGS = @SSE_EXTRA_CFLAGS@ +STRIP = @STRIP@ +SVG_CFLAGS = @SVG_CFLAGS@ +SVG_LIBS = @SVG_LIBS@ +SYMPREFIX = @SYMPREFIX@ +TIFF_LIBS = @TIFF_LIBS@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WEBKIT_CFLAGS = @WEBKIT_CFLAGS@ +WEBKIT_LIBS = @WEBKIT_LIBS@ +WEBKIT_REQUIRED_VERSION = @WEBKIT_REQUIRED_VERSION@ +WEBPDEMUX_CFLAGS = @WEBPDEMUX_CFLAGS@ +WEBPDEMUX_LIBS = @WEBPDEMUX_LIBS@ +WEBPMUX_CFLAGS = @WEBPMUX_CFLAGS@ +WEBPMUX_LIBS = @WEBPMUX_LIBS@ +WEBP_CFLAGS = @WEBP_CFLAGS@ +WEBP_LIBS = @WEBP_LIBS@ +WEBP_REQUIRED_VERSION = @WEBP_REQUIRED_VERSION@ +WEB_PAGE = @WEB_PAGE@ +WIN32_LARGE_ADDRESS_AWARE = @WIN32_LARGE_ADDRESS_AWARE@ +WINDRES = @WINDRES@ +WMF_CFLAGS = @WMF_CFLAGS@ +WMF_CONFIG = @WMF_CONFIG@ +WMF_LIBS = @WMF_LIBS@ +WMF_REQUIRED_VERSION = @WMF_REQUIRED_VERSION@ +XDG_EMAIL = @XDG_EMAIL@ +XFIXES_CFLAGS = @XFIXES_CFLAGS@ +XFIXES_LIBS = @XFIXES_LIBS@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_REQUIRED_VERSION = @XGETTEXT_REQUIRED_VERSION@ +XMC_CFLAGS = @XMC_CFLAGS@ +XMC_LIBS = @XMC_LIBS@ +XMKMF = @XMKMF@ +XMLLINT = @XMLLINT@ +XMU_LIBS = @XMU_LIBS@ +XPM_LIBS = @XPM_LIBS@ +XSLTPROC = @XSLTPROC@ +XVFB_RUN = @XVFB_RUN@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +Z_LIBS = @Z_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +gimpdatadir = @gimpdatadir@ +gimpdir = @gimpdir@ +gimplocaledir = @gimplocaledir@ +gimpplugindir = @gimpplugindir@ +gimpsysconfdir = @gimpsysconfdir@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +intltool__v_merge_options_ = @intltool__v_merge_options_@ +intltool__v_merge_options_0 = @intltool__v_merge_options_0@ +libdir = @libdir@ +libexecdir = $(gimpplugindir)/plug-ins/file-bmp +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +manpage_gimpdir = @manpage_gimpdir@ +mkdir_p = @mkdir_p@ +ms_librarian = @ms_librarian@ +mypaint_brushes_dir = @mypaint_brushes_dir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la +libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la +libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la +libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la +libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la +libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la +libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la +@OS_WIN32_TRUE@mwindows = -mwindows +@HAVE_WINDRES_TRUE@GIMPPLUGINRC = $(top_builddir)/build/windows/gimp-plug-ins.rc +@HAVE_WINDRES_TRUE@file_bmp_RC = file-bmp.rc.o +AM_LDFLAGS = $(mwindows) +file_bmp_SOURCES = \ + bmp.c \ + bmp.h \ + bmp-load.c \ + bmp-load.h \ + bmp-save.c \ + bmp-save.h + +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + $(GTK_CFLAGS) \ + $(GEGL_CFLAGS) \ + -I$(includedir) + +LDADD = \ + $(libgimpui) \ + $(libgimpwidgets) \ + $(libgimpconfig) \ + $(libgimp) \ + $(libgimpcolor) \ + $(libgimpmath) \ + $(libgimpbase) \ + $(GTK_LIBS) \ + $(GEGL_LIBS) \ + $(RT_LIBS) \ + $(INTLLIBS) \ + $(file_bmp_RC) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/build/windows/gimprc-plug-ins.rule $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plug-ins/file-bmp/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu plug-ins/file-bmp/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; +$(top_srcdir)/build/windows/gimprc-plug-ins.rule $(am__empty): + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-libexecPROGRAMS: $(libexec_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(libexecdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libexecdir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-libexecPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(libexec_PROGRAMS)'; test -n "$(libexecdir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' \ + `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(libexecdir)" && rm -f $$files + +clean-libexecPROGRAMS: + @list='$(libexec_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +file-bmp$(EXEEXT): $(file_bmp_OBJECTS) $(file_bmp_DEPENDENCIES) $(EXTRA_file_bmp_DEPENDENCIES) + @rm -f file-bmp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(file_bmp_OBJECTS) $(file_bmp_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bmp-load.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bmp-save.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bmp.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(libexecdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libexecPROGRAMS clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -f ./$(DEPDIR)/bmp-load.Po + -rm -f ./$(DEPDIR)/bmp-save.Po + -rm -f ./$(DEPDIR)/bmp.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libexecPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ./$(DEPDIR)/bmp-load.Po + -rm -f ./$(DEPDIR)/bmp-save.Po + -rm -f ./$(DEPDIR)/bmp.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-libexecPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-libexecPROGRAMS clean-libtool \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-libexecPROGRAMS \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am uninstall-libexecPROGRAMS + +.PRECIOUS: Makefile + + +# `windres` seems a very stupid tool and it breaks with double shlashes +# in parameter paths. Strengthen the rule a little. +@HAVE_WINDRES_TRUE@%.rc.o: +@HAVE_WINDRES_TRUE@ $(WINDRES) --define ORIGINALFILENAME_STR="$*$(EXEEXT)" \ +@HAVE_WINDRES_TRUE@ --define INTERNALNAME_STR="$*" \ +@HAVE_WINDRES_TRUE@ --define TOP_SRCDIR="`echo $(top_srcdir) | sed 's*//*/*'`" \ +@HAVE_WINDRES_TRUE@ -I"`echo $(top_srcdir)/app | sed 's%/\+%/%'`" \ +@HAVE_WINDRES_TRUE@ -I"`echo $(top_builddir)/app | sed 's%/\+%/%'`"\ +@HAVE_WINDRES_TRUE@ -I"`echo $(top_builddir) | sed 's%/\+%/%'`"\ +@HAVE_WINDRES_TRUE@ $(GIMPPLUGINRC) $@ + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/plug-ins/file-bmp/bmp-load.c b/plug-ins/file-bmp/bmp-load.c new file mode 100644 index 0000000..e79b900 --- /dev/null +++ b/plug-ins/file-bmp/bmp-load.c @@ -0,0 +1,1026 @@ +/* bmpread.c reads any bitmap I could get for testing */ +/* Alexander.Schulz@stud.uni-karlsruhe.de */ + +/* + * GIMP - The GNU 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 3 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, see <https://www.gnu.org/licenses/>. + * ---------------------------------------------------------------------------- + */ + +#include "config.h" + +#include <errno.h> +#include <string.h> + +#include <glib/gstdio.h> + +#include <libgimp/gimp.h> + +#include "bmp.h" +#include "bmp-load.h" + +#include "libgimp/stdplugins-intl.h" + + +#if !defined(WIN32) || defined(__MINGW32__) +#define BI_RGB 0 +#define BI_RLE8 1 +#define BI_RLE4 2 +#define BI_BITFIELDS 3 +#define BI_ALPHABITFIELDS 4 +#endif + + +static gint32 ReadImage (FILE *fd, + const gchar *filename, + gint width, + gint height, + guchar cmap[256][3], + gint ncols, + gint bpp, + gint compression, + gint rowbytes, + gboolean gray, + const BitmapChannel *masks, + GError **error); + + +static void +setMasksDefault (gushort biBitCnt, + BitmapChannel *masks) +{ + switch (biBitCnt) + { + case 32: + masks[0].mask = 0x00ff0000; + masks[0].shiftin = 16; + masks[0].max_value = (gfloat)255.0; + masks[1].mask = 0x0000ff00; + masks[1].shiftin = 8; + masks[1].max_value = (gfloat)255.0; + masks[2].mask = 0x000000ff; + masks[2].shiftin = 0; + masks[2].max_value = (gfloat)255.0; + masks[3].mask = 0x00000000; + masks[3].shiftin = 0; + masks[3].max_value = (gfloat)0.0; + break; + + case 24: + masks[0].mask = 0xff0000; + masks[0].shiftin = 16; + masks[0].max_value = (gfloat)255.0; + masks[1].mask = 0x00ff00; + masks[1].shiftin = 8; + masks[1].max_value = (gfloat)255.0; + masks[2].mask = 0x0000ff; + masks[2].shiftin = 0; + masks[2].max_value = (gfloat)255.0; + masks[3].mask = 0x0; + masks[3].shiftin = 0; + masks[3].max_value = (gfloat)0.0; + break; + + case 16: + masks[0].mask = 0x7c00; + masks[0].shiftin = 10; + masks[0].max_value = (gfloat)31.0; + masks[1].mask = 0x03e0; + masks[1].shiftin = 5; + masks[1].max_value = (gfloat)31.0; + masks[2].mask = 0x001f; + masks[2].shiftin = 0; + masks[2].max_value = (gfloat)31.0; + masks[3].mask = 0x0; + masks[3].shiftin = 0; + masks[3].max_value = (gfloat)0.0; + break; + + default: + break; + } +} + +static gint32 +ToL (const guchar *buffer) +{ + return (buffer[0] | buffer[1] << 8 | buffer[2] << 16 | buffer[3] << 24); +} + +static gint16 +ToS (const guchar *buffer) +{ + return (buffer[0] | buffer[1] << 8); +} + +static gboolean +ReadColorMap (FILE *fd, + guchar buffer[256][3], + gint number, + gint size, + gboolean *gray) +{ + gint i; + + *gray = (number > 2); + + for (i = 0; i < number ; i++) + { + guchar rgb[4]; + + if (! ReadOK (fd, rgb, size)) + { + g_message (_("Bad colormap")); + 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]; + + *gray = ((*gray) && (rgb[0] == rgb[1]) && (rgb[1] == rgb[2])); + } + + return TRUE; +} + +static gboolean +ReadChannelMasks (guint32 *tmp, + BitmapChannel *masks, + guint channels) +{ + gint i; + + for (i = 0; i < channels; i++) + { + guint32 mask; + gint nbits, offset, bit; + + mask = tmp[i]; + masks[i].mask = mask; + nbits = 0; + offset = -1; + + for (bit = 0; bit < 32; bit++) + { + if (mask & 1) + { + nbits++; + if (offset == -1) + offset = bit; + } + + mask = mask >> 1; + } + + masks[i].shiftin = offset; + masks[i].max_value = (gfloat) ((1 << nbits) - 1); + +#ifdef DEBUG + g_print ("Channel %d mask %08x in %d max_val %d\n", + i, masks[i].mask, masks[i].shiftin, (gint)masks[i].max_value); +#endif + } + + return TRUE; +} + +gint32 +load_image (const gchar *filename, + GError **error) +{ + FILE *fd; + BitmapFileHead bitmap_file_head; + BitmapHead bitmap_head; + guchar buffer[124]; + gint ColormapSize, rowbytes, Maps; + gboolean gray = FALSE; + guchar ColorMap[256][3]; + gint32 image_ID = -1; + gchar magick[2]; + BitmapChannel masks[4]; + + gimp_progress_init_printf (_("Opening '%s'"), + gimp_filename_to_utf8 (filename)); + + fd = g_fopen (filename, "rb"); + + if (!fd) + { + g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), + _("Could not open '%s' for reading: %s"), + gimp_filename_to_utf8 (filename), g_strerror (errno)); + goto out; + } + + /* It is a File. Now is it a Bitmap? Read the shortest possible header */ + + if (! ReadOK (fd, magick, 2) || + ! (! strncmp (magick, "BA", 2) || + ! strncmp (magick, "BM", 2) || + ! strncmp (magick, "IC", 2) || + ! strncmp (magick, "PT", 2) || + ! strncmp (magick, "CI", 2) || + ! strncmp (magick, "CP", 2))) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("'%s' is not a valid BMP file"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + while (! strncmp (magick, "BA", 2)) + { + if (! ReadOK (fd, buffer, 12)) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("'%s' is not a valid BMP file"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + if (! ReadOK (fd, magick, 2)) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("'%s' is not a valid BMP file"), + gimp_filename_to_utf8 (filename)); + goto out; + } + } + + if (! ReadOK (fd, buffer, 12)) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("'%s' is not a valid BMP file"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + /* bring them to the right byteorder. Not too nice, but it should work */ + + bitmap_file_head.bfSize = ToL (&buffer[0x00]); + bitmap_file_head.zzHotX = ToS (&buffer[0x04]); + bitmap_file_head.zzHotY = ToS (&buffer[0x06]); + bitmap_file_head.bfOffs = ToL (&buffer[0x08]); + + if (! ReadOK (fd, buffer, 4)) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("'%s' is not a valid BMP file"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + bitmap_file_head.biSize = ToL (&buffer[0x00]); + + /* What kind of bitmap is it? */ + + if (bitmap_file_head.biSize == 12) /* OS/2 1.x ? */ + { + if (! ReadOK (fd, buffer, 8)) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("Error reading BMP file header from '%s'"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + bitmap_head.biWidth = ToS (&buffer[0x00]); /* 12 */ + bitmap_head.biHeight = ToS (&buffer[0x02]); /* 14 */ + bitmap_head.biPlanes = ToS (&buffer[0x04]); /* 16 */ + bitmap_head.biBitCnt = ToS (&buffer[0x06]); /* 18 */ + bitmap_head.biCompr = 0; + bitmap_head.biSizeIm = 0; + bitmap_head.biXPels = bitmap_head.biYPels = 0; + bitmap_head.biClrUsed = 0; + bitmap_head.biClrImp = 0; + bitmap_head.masks[0] = 0; + bitmap_head.masks[1] = 0; + bitmap_head.masks[2] = 0; + bitmap_head.masks[3] = 0; + + memset (masks, 0, sizeof (masks)); + Maps = 3; + } + else if (bitmap_file_head.biSize == 40) /* Windows 3.x */ + { + if (! ReadOK (fd, buffer, 36)) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("Error reading BMP file header from '%s'"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + bitmap_head.biWidth = ToL (&buffer[0x00]); /* 12 */ + bitmap_head.biHeight = ToL (&buffer[0x04]); /* 16 */ + bitmap_head.biPlanes = ToS (&buffer[0x08]); /* 1A */ + bitmap_head.biBitCnt = ToS (&buffer[0x0A]); /* 1C */ + bitmap_head.biCompr = ToL (&buffer[0x0C]); /* 1E */ + bitmap_head.biSizeIm = ToL (&buffer[0x10]); /* 22 */ + bitmap_head.biXPels = ToL (&buffer[0x14]); /* 26 */ + bitmap_head.biYPels = ToL (&buffer[0x18]); /* 2A */ + bitmap_head.biClrUsed = ToL (&buffer[0x1C]); /* 2E */ + bitmap_head.biClrImp = ToL (&buffer[0x20]); /* 32 */ + bitmap_head.masks[0] = 0; + bitmap_head.masks[1] = 0; + bitmap_head.masks[2] = 0; + bitmap_head.masks[3] = 0; + + Maps = 4; + memset (masks, 0, sizeof (masks)); + + if (bitmap_head.biCompr == BI_BITFIELDS) + { +#ifdef DEBUG + g_print ("Got BI_BITFIELDS compression\n"); +#endif + + if (! ReadOK (fd, buffer, 3 * sizeof (guint32))) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("Error reading BMP file header from '%s'"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + bitmap_head.masks[0] = ToL (&buffer[0x00]); + bitmap_head.masks[1] = ToL (&buffer[0x04]); + bitmap_head.masks[2] = ToL (&buffer[0x08]); + + ReadChannelMasks (&bitmap_head.masks[0], masks, 3); + } + else if (bitmap_head.biCompr == BI_RGB) + { +#ifdef DEBUG + g_print ("Got BI_RGB compression\n"); +#endif + + setMasksDefault (bitmap_head.biBitCnt, masks); + } + else if ((bitmap_head.biCompr != BI_RLE4) && + (bitmap_head.biCompr != BI_RLE8)) + { + /* BI_ALPHABITFIELDS, etc. */ + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("Unsupported compression (%u) in BMP file from '%s'"), + bitmap_head.biCompr, + gimp_filename_to_utf8 (filename)); + } + +#ifdef DEBUG + g_print ("Got BI_RLE4 or BI_RLE8 compression\n"); +#endif + } + else if (bitmap_file_head.biSize >= 56 && + bitmap_file_head.biSize <= 64) + { + /* enhanced Windows format with bit masks */ + + if (! ReadOK (fd, buffer, bitmap_file_head.biSize - 4)) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("Error reading BMP file header from '%s'"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + bitmap_head.biWidth = ToL (&buffer[0x00]); /* 12 */ + bitmap_head.biHeight = ToL (&buffer[0x04]); /* 16 */ + bitmap_head.biPlanes = ToS (&buffer[0x08]); /* 1A */ + bitmap_head.biBitCnt = ToS (&buffer[0x0A]); /* 1C */ + bitmap_head.biCompr = ToL (&buffer[0x0C]); /* 1E */ + bitmap_head.biSizeIm = ToL (&buffer[0x10]); /* 22 */ + bitmap_head.biXPels = ToL (&buffer[0x14]); /* 26 */ + bitmap_head.biYPels = ToL (&buffer[0x18]); /* 2A */ + bitmap_head.biClrUsed = ToL (&buffer[0x1C]); /* 2E */ + bitmap_head.biClrImp = ToL (&buffer[0x20]); /* 32 */ + bitmap_head.masks[0] = ToL (&buffer[0x24]); /* 36 */ + bitmap_head.masks[1] = ToL (&buffer[0x28]); /* 3A */ + bitmap_head.masks[2] = ToL (&buffer[0x2C]); /* 3E */ + bitmap_head.masks[3] = ToL (&buffer[0x30]); /* 42 */ + + Maps = 4; + ReadChannelMasks (&bitmap_head.masks[0], masks, 4); + } + else if (bitmap_file_head.biSize == 108 || + bitmap_file_head.biSize == 124) + { + /* BMP Version 4 or 5 */ + + if (! ReadOK (fd, buffer, bitmap_file_head.biSize - 4)) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("Error reading BMP file header from '%s'"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + bitmap_head.biWidth = ToL (&buffer[0x00]); + bitmap_head.biHeight = ToL (&buffer[0x04]); + bitmap_head.biPlanes = ToS (&buffer[0x08]); + bitmap_head.biBitCnt = ToS (&buffer[0x0A]); + bitmap_head.biCompr = ToL (&buffer[0x0C]); + bitmap_head.biSizeIm = ToL (&buffer[0x10]); + bitmap_head.biXPels = ToL (&buffer[0x14]); + bitmap_head.biYPels = ToL (&buffer[0x18]); + bitmap_head.biClrUsed = ToL (&buffer[0x1C]); + bitmap_head.biClrImp = ToL (&buffer[0x20]); + bitmap_head.masks[0] = ToL (&buffer[0x24]); + bitmap_head.masks[1] = ToL (&buffer[0x28]); + bitmap_head.masks[2] = ToL (&buffer[0x2C]); + bitmap_head.masks[3] = ToL (&buffer[0x30]); + + Maps = 4; + + if (bitmap_head.biCompr == BI_BITFIELDS) + { +#ifdef DEBUG + g_print ("Got BI_BITFIELDS compression\n"); +#endif + + ReadChannelMasks (&bitmap_head.masks[0], masks, 4); + } + else if (bitmap_head.biCompr == BI_RGB) + { +#ifdef DEBUG + g_print ("Got BI_RGB compression\n"); +#endif + + setMasksDefault (bitmap_head.biBitCnt, masks); + } + } + else + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("Error reading BMP file header from '%s'"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + /* Valid bit depth is 1, 4, 8, 16, 24, 32 */ + /* 16 is awful, we should probably shoot whoever invented it */ + + switch (bitmap_head.biBitCnt) + { + case 1: + case 2: + case 4: + case 8: + case 16: + case 24: + case 32: + break; + default: + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("'%s' is not a valid BMP file"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + /* 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 <= 8)) + { + ColormapSize = bitmap_head.biClrUsed = 1 << bitmap_head.biBitCnt; + } + + if (ColormapSize > 256) + ColormapSize = 256; + + /* Sanity checks */ + + if (bitmap_head.biHeight == 0 || + bitmap_head.biWidth == 0) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("'%s' is not a valid BMP file"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + /* biHeight may be negative, but G_MININT32 is dangerous because: + G_MININT32 == -(G_MININT32) */ + if (bitmap_head.biWidth < 0 || + bitmap_head.biHeight == G_MININT32) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("'%s' is not a valid BMP file"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + if (bitmap_head.biPlanes != 1) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("'%s' is not a valid BMP file"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + if (bitmap_head.biClrUsed > 256 && + bitmap_head.biBitCnt <= 8) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("'%s' is not a valid BMP file"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + /* protect against integer overflows caused by malicious BMPs */ + /* use divisions in comparisons to avoid type overflows */ + + if (((guint64) bitmap_head.biWidth) > G_MAXINT32 / bitmap_head.biBitCnt || + ((guint64) bitmap_head.biWidth) > (G_MAXINT32 / ABS (bitmap_head.biHeight)) / 4) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("'%s' is not a valid BMP file"), + gimp_filename_to_utf8 (filename)); + goto out; + } + + /* Windows and OS/2 declare filler so that rows are a multiple of + * word length (32 bits == 4 bytes) + */ + + rowbytes = ((bitmap_head.biWidth * bitmap_head.biBitCnt - 1) / 32) * 4 + 4; + +#ifdef DEBUG + printf ("\nSize: %lu, Colors: %lu, Bits: %hu, Width: %ld, Height: %ld, " + "Comp: %lu, Zeile: %d\n", + bitmap_file_head.bfSize, + bitmap_head.biClrUsed, + bitmap_head.biBitCnt, + bitmap_head.biWidth, + bitmap_head.biHeight, + bitmap_head.biCompr, + rowbytes); +#endif + + if (bitmap_head.biBitCnt <= 8) + { +#ifdef DEBUG + printf ("Colormap read\n"); +#endif + /* Get the Colormap */ + if (! ReadColorMap (fd, ColorMap, ColormapSize, Maps, &gray)) + goto out; + } + + fseek (fd, bitmap_file_head.bfOffs, SEEK_SET); + + /* Get the Image and return the ID or -1 on error*/ + image_ID = ReadImage (fd, + filename, + bitmap_head.biWidth, + ABS (bitmap_head.biHeight), + ColorMap, + bitmap_head.biClrUsed, + bitmap_head.biBitCnt, + bitmap_head.biCompr, + rowbytes, + gray, + masks, + error); + + if (image_ID < 0) + goto out; + + if (bitmap_head.biXPels > 0 && + bitmap_head.biYPels > 0) + { + /* Fixed up from scott@asofyet's changes last year, njl195 */ + gdouble xresolution; + gdouble yresolution; + + /* I don't agree with scott's feeling that Gimp should be trying + * to "fix" metric resolution translations, in the long term + * Gimp should be SI (metric) anyway, but we haven't told the + * Americans that yet + */ + + xresolution = bitmap_head.biXPels * 0.0254; + yresolution = bitmap_head.biYPels * 0.0254; + + gimp_image_set_resolution (image_ID, xresolution, yresolution); + } + + if (bitmap_head.biHeight < 0) + gimp_image_flip (image_ID, GIMP_ORIENTATION_VERTICAL); + +out: + if (fd) + fclose (fd); + + return image_ID; +} + +static gint32 +ReadImage (FILE *fd, + const gchar *filename, + gint width, + gint height, + guchar cmap[256][3], + gint ncols, + gint bpp, + gint compression, + gint rowbytes, + gboolean gray, + const BitmapChannel *masks, + GError **error) +{ + guchar v, n; + gint xpos = 0; + gint ypos = 0; + gint32 image; + gint32 layer; + GeglBuffer *buffer; + guchar *dest, *temp, *row_buf; + guchar gimp_cmap[768]; + gushort rgb; + glong rowstride, channels; + gint i, i_max, j, cur_progress, max_progress; + gint total_bytes_read; + GimpImageBaseType base_type; + GimpImageType image_type; + guint32 px32; + + if (! (compression == BI_RGB || compression == BI_BITFIELDS || + (bpp == 8 && compression == BI_RLE8) || + (bpp == 4 && compression == BI_RLE4))) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + "%s", + _("Unrecognized or invalid BMP compression format.")); + return -1; + } + + /* Make a new image in GIMP */ + + switch (bpp) + { + case 32: + case 24: + case 16: + base_type = GIMP_RGB; + if (masks[3].mask != 0) + { + image_type = GIMP_RGBA_IMAGE; + channels = 4; + } + else + { + image_type = GIMP_RGB_IMAGE; + channels = 3; + } + if (bpp == 24 && compression == BI_BITFIELDS) + g_printerr ("Loading BMP with invalid combination of 24 bpp and BI_BITFIELDS compression.\n"); + break; + + case 8: + case 4: + case 1: + if (gray) + { + base_type = GIMP_GRAY; + image_type = GIMP_GRAY_IMAGE; + } + else + { + base_type = GIMP_INDEXED; + image_type = GIMP_INDEXED_IMAGE; + } + if (compression == BI_BITFIELDS) + g_printerr ("Loading BMP with invalid combination of %d bpp and BI_BITFIELDS compression.\n", + bpp); + + channels = 1; + break; + + default: + g_message (_("Unsupported or invalid bitdepth.")); + return -1; + } + + if ((width < 0) || (width > GIMP_MAX_IMAGE_SIZE)) + { + g_message (_("Unsupported or invalid image width: %d"), width); + return -1; + } + + if ((height < 0) || (height > GIMP_MAX_IMAGE_SIZE)) + { + g_message (_("Unsupported or invalid image height: %d"), height); + return -1; + } + + image = gimp_image_new (width, height, base_type); + layer = gimp_layer_new (image, _("Background"), + width, height, + image_type, 100, + gimp_image_get_default_new_layer_mode (image)); + + gimp_image_set_filename (image, filename); + + gimp_image_insert_layer (image, layer, -1, 0); + + /* use g_malloc0 to initialize the dest buffer so that unspecified + pixels in RLE bitmaps show up as the zeroth element in the palette. + */ + dest = g_malloc0 (width * height * channels); + row_buf = g_malloc (rowbytes); + rowstride = width * channels; + + ypos = height - 1; /* Bitmaps begin in the lower left corner */ + cur_progress = 0; + max_progress = height; + + switch (bpp) + { + case 32: + { + while (ReadOK (fd, row_buf, rowbytes)) + { + temp = dest + (ypos * rowstride); + + for (xpos= 0; xpos < width; ++xpos) + { + px32 = ToL(&row_buf[xpos*4]); + *(temp++) = ((px32 & masks[0].mask) >> masks[0].shiftin) * 255.0 / masks[0].max_value + 0.5; + *(temp++) = ((px32 & masks[1].mask) >> masks[1].shiftin) * 255.0 / masks[1].max_value + 0.5; + *(temp++) = ((px32 & masks[2].mask) >> masks[2].shiftin) * 255.0 / masks[2].max_value + 0.5; + if (channels > 3) + *(temp++) = ((px32 & masks[3].mask) >> masks[3].shiftin) * 255.0 / masks[3].max_value + 0.5; + } + + if (ypos == 0) + break; + + --ypos; /* next line */ + + cur_progress++; + if ((cur_progress % 5) == 0) + gimp_progress_update ((gdouble) cur_progress / + (gdouble) max_progress); + } + } + break; + + case 24: + { + while (ReadOK (fd, row_buf, rowbytes)) + { + temp = dest + (ypos * rowstride); + + for (xpos= 0; xpos < width; ++xpos) + { + *(temp++) = row_buf[xpos * 3 + 2]; + *(temp++) = row_buf[xpos * 3 + 1]; + *(temp++) = row_buf[xpos * 3]; + } + + if (ypos == 0) + break; + + --ypos; /* next line */ + + cur_progress++; + if ((cur_progress % 5) == 0) + gimp_progress_update ((gdouble) cur_progress / + (gdouble) max_progress); + } + } + break; + + case 16: + { + while (ReadOK (fd, row_buf, rowbytes)) + { + temp = dest + (ypos * rowstride); + + for (xpos= 0; xpos < width; ++xpos) + { + rgb= ToS(&row_buf[xpos * 2]); + *(temp++) = ((rgb & masks[0].mask) >> masks[0].shiftin) * 255.0 / masks[0].max_value + 0.5; + *(temp++) = ((rgb & masks[1].mask) >> masks[1].shiftin) * 255.0 / masks[1].max_value + 0.5; + *(temp++) = ((rgb & masks[2].mask) >> masks[2].shiftin) * 255.0 / masks[2].max_value + 0.5; + if (channels > 3) + *(temp++) = ((rgb & masks[3].mask) >> masks[3].shiftin) * 255.0 / masks[3].max_value + 0.5; + } + + if (ypos == 0) + break; + + --ypos; /* next line */ + + cur_progress++; + if ((cur_progress % 5) == 0) + gimp_progress_update ((gdouble) cur_progress / + (gdouble) max_progress); + } + } + break; + + case 8: + case 4: + case 1: + { + if (compression == BI_RGB || compression == BI_BITFIELDS) + /* no compression */ + { + while (ReadOK (fd, &v, 1)) + { + for (i = 1; (i <= (8 / bpp)) && (xpos < width); i++, xpos++) + { + temp = dest + (ypos * rowstride) + (xpos * channels); + *temp=( v & ( ((1<<bpp)-1) << (8-(i*bpp)) ) ) >> (8-(i*bpp)); + if (gray) + *temp = cmap[*temp][0]; + } + + if (xpos == width) + { + fread (row_buf, rowbytes - 1 - (width * bpp - 1) / 8, 1, fd); + + if (ypos == 0) + break; + + ypos--; + xpos = 0; + + cur_progress++; + if ((cur_progress % 5) == 0) + gimp_progress_update ((gdouble) cur_progress / + (gdouble) max_progress); + } + + if (ypos < 0) + break; + } + break; + } + else + { + /* compressed image (either RLE8 or RLE4) */ + while (ypos >= 0 && xpos <= width) + { + if (! ReadOK (fd, row_buf, 2)) + { + g_message (_("The bitmap ends unexpectedly.")); + break; + } + + if (row_buf[0] != 0) + /* Count + Color - record */ + { + /* encoded mode run - + * row_buf[0] == run_length + * row_buf[1] == pixel data + */ + for (j = 0; + ((guchar) j < row_buf[0]) && (xpos < width);) + { +#ifdef DEBUG2 + printf("%u %u | ",xpos,width); +#endif + for (i = 1; + ((i <= (8 / bpp)) && + (xpos < width) && + ((guchar) j < row_buf[0])); + i++, xpos++, j++) + { + temp = dest + (ypos * rowstride) + (xpos * channels); + *temp = (row_buf[1] & + (((1<<bpp)-1) << (8 - (i * bpp)))) >> (8 - (i * bpp)); + if (gray) + *temp = cmap[*temp][0]; + } + } + } + + if ((row_buf[0] == 0) && (row_buf[1] > 2)) + /* uncompressed record */ + { + n = row_buf[1]; + total_bytes_read = 0; + + for (j = 0; j < n; j += (8 / bpp)) + { + /* read the next byte in the record */ + if (! ReadOK (fd, &v, 1)) + { + g_message (_("The bitmap ends unexpectedly.")); + break; + } + + total_bytes_read++; + + /* read all pixels from that byte */ + i_max = 8 / bpp; + if (n - j < i_max) + { + i_max = n - j; + } + + i = 1; + while ((i <= i_max) && (xpos < width)) + { + temp = + dest + (ypos * rowstride) + (xpos * channels); + *temp = (v >> (8-(i*bpp))) & ((1<<bpp)-1); + if (gray) + *temp = cmap[*temp][0]; + i++; + xpos++; + } + } + + /* absolute mode runs are padded to 16-bit alignment */ + if (total_bytes_read % 2) + fread (&v, 1, 1, fd); + } + + if ((row_buf[0] == 0) && (row_buf[1] == 0)) + /* Line end */ + { + ypos--; + xpos = 0; + + cur_progress++; + if ((cur_progress % 5) == 0) + gimp_progress_update ((gdouble) cur_progress / + (gdouble) max_progress); + } + + if ((row_buf[0] == 0) && (row_buf[1] == 1)) + /* Bitmap end */ + { + break; + } + + if ((row_buf[0] == 0) && (row_buf[1] == 2)) + /* Deltarecord */ + { + if (! ReadOK (fd, row_buf, 2)) + { + g_message (_("The bitmap ends unexpectedly.")); + break; + } + + xpos += row_buf[0]; + ypos -= row_buf[1]; + } + } + break; + } + } + break; + + default: + g_assert_not_reached (); + break; + } + + if (bpp <= 8) + 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]; + } + + buffer = gimp_drawable_get_buffer (layer); + + gegl_buffer_set (buffer, GEGL_RECTANGLE (0, 0, width, height), 0, + NULL, dest, GEGL_AUTO_ROWSTRIDE); + + g_object_unref (buffer); + + g_free (dest); + + if ((! gray) && (bpp <= 8)) + gimp_image_set_colormap (image, gimp_cmap, ncols); + + gimp_progress_update (1.0); + + return image; +} diff --git a/plug-ins/file-bmp/bmp-load.h b/plug-ins/file-bmp/bmp-load.h new file mode 100644 index 0000000..7d80abe --- /dev/null +++ b/plug-ins/file-bmp/bmp-load.h @@ -0,0 +1,27 @@ +/* + * GIMP - The GNU 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +#ifndef __BMP_LOAD_H__ +#define __BMP_LOAD_H__ + + +gint32 load_image (const gchar *filename, + GError **error); + + +#endif /* __BMP_LOAD_H__ */ diff --git a/plug-ins/file-bmp/bmp-save.c b/plug-ins/file-bmp/bmp-save.c new file mode 100644 index 0000000..6654f12 --- /dev/null +++ b/plug-ins/file-bmp/bmp-save.c @@ -0,0 +1,1104 @@ +/* bmpwrite.c Writes Bitmap files. Even RLE encoded ones. */ +/* (Windows (TM) doesn't read all of those, but who */ +/* cares? ;-) */ +/* I changed a few things over the time, so perhaps */ +/* it dos now, but now there's no Windows left on */ +/* my computer... */ + +/* Alexander.Schulz@stud.uni-karlsruhe.de */ + +/* + * GIMP - The GNU 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 3 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, see <https://www.gnu.org/licenses/>. + * ---------------------------------------------------------------------------- + */ + +#include "config.h" + +#include <errno.h> +#include <string.h> + +#include <glib/gstdio.h> + +#include <libgimp/gimp.h> +#include <libgimp/gimpui.h> + +#include "bmp.h" +#include "bmp-save.h" + +#include "libgimp/stdplugins-intl.h" + + +typedef enum +{ + RGB_565, + RGBA_5551, + RGB_555, + RGB_888, + RGBA_8888, + RGBX_8888 +} RGBMode; + + +static void write_image (FILE *f, + guchar *src, + gint width, + gint height, + gint use_run_length_encoding, + gint channels, + gint bpp, + gint spzeile, + gint MapSize, + RGBMode rgb_format, + gint mask_info_size, + gint color_space_size); + +static gboolean save_dialog (gint channels, + gint bpp); + + +static struct +{ + RGBMode rgb_format; + gint use_run_length_encoding; + + /* Whether or not to write BITMAPV5HEADER color space data */ + gint dont_write_color_space_data; + gboolean overwrite_RGB_format; +} BMPSaveData; + + +static void +write_color_map (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); + } +} + +static gboolean +warning_dialog (const gchar *primary, + const gchar *secondary) +{ + GtkWidget *dialog; + gboolean ok; + + dialog = gtk_message_dialog_new (NULL, 0, + GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, + "%s", primary); + + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + "%s", secondary); + + gimp_window_set_transient (GTK_WINDOW (dialog)); + + ok = (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK); + + gtk_widget_destroy (dialog); + + return ok; +} + +GimpPDBStatusType +save_image (const gchar *filename, + gint32 image, + gint32 drawable_ID, + GimpRunMode run_mode, + GError **error) +{ + FILE *outfile; + BitmapFileHead bitmap_file_head; + BitmapHead bitmap_head; + gint Red[MAXCOLORS]; + gint Green[MAXCOLORS]; + gint Blue[MAXCOLORS]; + guchar *cmap; + gint rows, cols, Spcols, channels, MapSize, SpZeile; + glong BitsPerPixel; + gint colors; + guchar *pixels; + GeglBuffer *buffer; + const Babl *format; + GimpImageType drawable_type; + gint drawable_width; + gint drawable_height; + gint i; + gint mask_info_size; + gint color_space_size; + guint32 Mask[4]; + + buffer = gimp_drawable_get_buffer (drawable_ID); + + drawable_type = gimp_drawable_type (drawable_ID); + drawable_width = gimp_drawable_width (drawable_ID); + drawable_height = gimp_drawable_height (drawable_ID); + + switch (drawable_type) + { + case GIMP_RGBA_IMAGE: + format = babl_format ("R'G'B'A u8"); + colors = 0; + BitsPerPixel = 32; + MapSize = 0; + channels = 4; + if (!BMPSaveData.overwrite_RGB_format) + BMPSaveData.rgb_format = RGBA_8888; + break; + + case GIMP_RGB_IMAGE: + format = babl_format ("R'G'B' u8"); + colors = 0; + BitsPerPixel = 24; + MapSize = 0; + channels = 3; + if (!BMPSaveData.overwrite_RGB_format) + BMPSaveData.rgb_format = RGB_888; + break; + + case GIMP_GRAYA_IMAGE: + if (run_mode == GIMP_RUN_INTERACTIVE && + ! warning_dialog (_("Cannot export indexed image with " + "transparency in BMP file format."), + _("Alpha channel will be ignored."))) + return GIMP_PDB_CANCEL; + + /* fallthrough */ + + case GIMP_GRAY_IMAGE: + colors = 256; + BitsPerPixel = 8; + MapSize = 1024; + + if (drawable_type == GIMP_GRAYA_IMAGE) + { + format = babl_format ("Y'A u8"); + channels = 2; + } + else + { + format = babl_format ("Y' u8"); + channels = 1; + } + + for (i = 0; i < colors; i++) + { + Red[i] = i; + Green[i] = i; + Blue[i] = i; + } + break; + + case GIMP_INDEXEDA_IMAGE: + if (run_mode == GIMP_RUN_INTERACTIVE && + ! warning_dialog (_("Cannot export indexed image with " + "transparency in BMP file format."), + _("Alpha channel will be ignored."))) + return GIMP_PDB_CANCEL; + + /* fallthrough */ + + case GIMP_INDEXED_IMAGE: + format = gimp_drawable_get_format (drawable_ID); + cmap = gimp_image_get_colormap (image, &colors); + MapSize = 4 * colors; + + if (drawable_type == GIMP_INDEXEDA_IMAGE) + channels = 2; + else + channels = 1; + + if (colors > 16) + BitsPerPixel = 8; + else if (colors > 2) + BitsPerPixel = 4; + else + BitsPerPixel = 1; + + for (i = 0; i < colors; i++) + { + Red[i] = *cmap++; + Green[i] = *cmap++; + Blue[i] = *cmap++; + } + break; + + default: + g_assert_not_reached (); + } + + /* Don't alter option data if already defined in non-interactive mode Script-fu */ + if (BMPSaveData.use_run_length_encoding != 1) + BMPSaveData.use_run_length_encoding = 0; + + if (BMPSaveData.dont_write_color_space_data != 1) + BMPSaveData.dont_write_color_space_data = 0; + mask_info_size = 0; + + if (run_mode != GIMP_RUN_NONINTERACTIVE) + { + gimp_get_data (SAVE_PROC, &BMPSaveData); + } + + if (run_mode == GIMP_RUN_INTERACTIVE && + (BitsPerPixel == 8 || + BitsPerPixel == 4 || + BitsPerPixel == 1)) + { + if (! save_dialog (1, BitsPerPixel)) + return GIMP_PDB_CANCEL; + } + else if (BitsPerPixel == 24 || + BitsPerPixel == 32) + { + if (run_mode == GIMP_RUN_INTERACTIVE) + { + if (! save_dialog (channels, BitsPerPixel)) + return GIMP_PDB_CANCEL; + } + + /* mask_info_size is only set to non-zero for 16- and 32-bpp */ + switch (BMPSaveData.rgb_format) + { + case RGB_888: + BitsPerPixel = 24; + break; + case RGBA_8888: + BitsPerPixel = 32; + mask_info_size = 16; + break; + case RGBX_8888: + BitsPerPixel = 32; + mask_info_size = 16; + break; + case RGB_565: + BitsPerPixel = 16; + mask_info_size = 16; + break; + case RGBA_5551: + BitsPerPixel = 16; + mask_info_size = 16; + break; + case RGB_555: + BitsPerPixel = 16; + mask_info_size = 16; + break; + default: + g_return_val_if_reached (GIMP_PDB_EXECUTION_ERROR); + } + } + + gimp_set_data (SAVE_PROC, &BMPSaveData, sizeof (BMPSaveData)); + + /* Let's begin the progress */ + gimp_progress_init_printf (_("Exporting '%s'"), + gimp_filename_to_utf8 (filename)); + + /* Let's take some file */ + outfile = g_fopen (filename, "wb"); + if (!outfile) + { + g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), + _("Could not open '%s' for writing: %s"), + gimp_filename_to_utf8 (filename), g_strerror (errno)); + return GIMP_PDB_EXECUTION_ERROR; + } + + /* fetch the image */ + pixels = g_new (guchar, drawable_width * drawable_height * channels); + + gegl_buffer_get (buffer, GEGL_RECTANGLE (0, 0, + drawable_width, drawable_height), 1.0, + format, pixels, + GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); + + g_object_unref (buffer); + + /* Now, we need some further information ... */ + cols = drawable_width; + rows = drawable_height; + + /* ... that we write to our headers. */ + if ((BitsPerPixel <= 8) && (cols % (8 / BitsPerPixel))) + Spcols = (((cols / (8 / BitsPerPixel)) + 1) * (8 / BitsPerPixel)); + else + Spcols = cols; + + if ((((Spcols * BitsPerPixel) / 8) % 4) == 0) + SpZeile = ((Spcols * BitsPerPixel) / 8); + else + SpZeile = ((gint) (((Spcols * BitsPerPixel) / 8) / 4) + 1) * 4; + + if (! BMPSaveData.dont_write_color_space_data) + { + /* Always include color mask for BITMAPV5HEADER, see #4155. */ + mask_info_size = 16; + color_space_size = 68; + } + else + { + color_space_size = 0; + } + + bitmap_file_head.bfSize = (0x36 + MapSize + (rows * SpZeile) + + mask_info_size + color_space_size); + bitmap_file_head.zzHotX = 0; + bitmap_file_head.zzHotY = 0; + bitmap_file_head.bfOffs = (0x36 + MapSize + + mask_info_size + color_space_size); + bitmap_file_head.biSize = 40 + mask_info_size + color_space_size; + + bitmap_head.biWidth = cols; + bitmap_head.biHeight = rows; + bitmap_head.biPlanes = 1; + bitmap_head.biBitCnt = BitsPerPixel; + + if (BMPSaveData.use_run_length_encoding == 0) + { + /* The Microsoft specification for BITMAPV5HEADER says that + * BI_BITFIELDS is valid for 16 and 32-bits per pixel, + * Since it doesn't mention 24 bpp or other numbers + * use BI_RGB for that. See issue #6114. */ + if (mask_info_size > 0 && (BitsPerPixel == 16 || BitsPerPixel == 32)) + bitmap_head.biCompr = 3; /* BI_BITFIELDS */ + else + bitmap_head.biCompr = 0; /* BI_RGB */ + } + else if (BitsPerPixel == 8) + { + bitmap_head.biCompr = 1; + } + else if (BitsPerPixel == 4) + { + bitmap_head.biCompr = 2; + } + else + { + bitmap_head.biCompr = 0; + } + + bitmap_head.biSizeIm = SpZeile * rows; + + { + gdouble xresolution; + gdouble yresolution; + gimp_image_get_resolution (image, &xresolution, &yresolution); + + if (xresolution > GIMP_MIN_RESOLUTION && + yresolution > GIMP_MIN_RESOLUTION) + { + /* + * 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"), + * so... + * n dots inch 100 cm m dots + * ------ * ------- * ------ = ------ + * inch 2.54 cm m inch + * + * We add 0.5 for proper rounding. + */ + bitmap_head.biXPels = (long int) (xresolution * 100.0 / 2.54 + 0.5); + bitmap_head.biYPels = (long int) (yresolution * 100.0 / 2.54 + 0.5); + } + } + + if (BitsPerPixel <= 8) + bitmap_head.biClrUsed = colors; + else + bitmap_head.biClrUsed = 0; + + bitmap_head.biClrImp = bitmap_head.biClrUsed; + +#ifdef DEBUG + printf ("\nSize: %u, Colors: %u, Bits: %u, Width: %u, Height: %u, Comp: %u, Zeile: %u\n", + (int)bitmap_file_head.bfSize, + (int)bitmap_head.biClrUsed, + bitmap_head.biBitCnt, + (int)bitmap_head.biWidth, + (int)bitmap_head.biHeight, + (int)bitmap_head.biCompr,SpZeile); +#endif + + /* And now write the header and the colormap (if any) to disk */ + + Write (outfile, "BM", 2); + + bitmap_file_head.bfSize = GUINT32_TO_LE (bitmap_file_head.bfSize); + bitmap_file_head.zzHotX = GUINT16_TO_LE (bitmap_file_head.zzHotX); + bitmap_file_head.zzHotY = GUINT16_TO_LE (bitmap_file_head.zzHotY); + bitmap_file_head.bfOffs = GUINT32_TO_LE (bitmap_file_head.bfOffs); + bitmap_file_head.biSize = GUINT32_TO_LE (bitmap_file_head.biSize); + + Write (outfile, &bitmap_file_head.bfSize, 16); + + bitmap_head.biWidth = GINT32_TO_LE (bitmap_head.biWidth); + bitmap_head.biHeight = GINT32_TO_LE (bitmap_head.biHeight); + bitmap_head.biPlanes = GUINT16_TO_LE (bitmap_head.biPlanes); + bitmap_head.biBitCnt = GUINT16_TO_LE (bitmap_head.biBitCnt); + bitmap_head.biCompr = GUINT32_TO_LE (bitmap_head.biCompr); + bitmap_head.biSizeIm = GUINT32_TO_LE (bitmap_head.biSizeIm); + bitmap_head.biXPels = GUINT32_TO_LE (bitmap_head.biXPels); + bitmap_head.biYPels = GUINT32_TO_LE (bitmap_head.biYPels); + bitmap_head.biClrUsed = GUINT32_TO_LE (bitmap_head.biClrUsed); + bitmap_head.biClrImp = GUINT32_TO_LE (bitmap_head.biClrImp); + + Write (outfile, &bitmap_head, 36); + + if (mask_info_size > 0) + { + switch (BMPSaveData.rgb_format) + { + default: + case RGB_888: + case RGBX_8888: + Mask[0] = 0x00ff0000; + Mask[1] = 0x0000ff00; + Mask[2] = 0x000000ff; + Mask[3] = 0x00000000; + break; + + case RGBA_8888: + Mask[0] = 0x00ff0000; + Mask[1] = 0x0000ff00; + Mask[2] = 0x000000ff; + Mask[3] = 0xff000000; + break; + + case RGB_565: + Mask[0] = 0xf800; + Mask[1] = 0x7e0; + Mask[2] = 0x1f; + Mask[3] = 0x0; + break; + + case RGBA_5551: + Mask[0] = 0x7c00; + Mask[1] = 0x3e0; + Mask[2] = 0x1f; + Mask[3] = 0x8000; + break; + + case RGB_555: + Mask[0] = 0x7c00; + Mask[1] = 0x3e0; + Mask[2] = 0x1f; + Mask[3] = 0x0; + break; + } + + Mask[0] = GUINT32_TO_LE (Mask[0]); + Mask[1] = GUINT32_TO_LE (Mask[1]); + Mask[2] = GUINT32_TO_LE (Mask[2]); + Mask[3] = GUINT32_TO_LE (Mask[3]); + + Write (outfile, &Mask, mask_info_size); + } + + if (! BMPSaveData.dont_write_color_space_data) + { + guint32 buf[0x11]; + + /* Write V5 color space fields */ + + /* bV5CSType = LCS_sRGB */ + buf[0x00] = GUINT32_TO_LE (0x73524742); + + /* bV5Endpoints is set to 0 (ignored) */ + for (i = 0; i < 0x09; i++) + buf[i + 1] = 0x00; + + /* bV5GammaRed is set to 0 (ignored) */ + buf[0x0a] = GUINT32_TO_LE (0x0); + + /* bV5GammaGreen is set to 0 (ignored) */ + buf[0x0b] = GUINT32_TO_LE (0x0); + + /* bV5GammaBlue is set to 0 (ignored) */ + buf[0x0c] = GUINT32_TO_LE (0x0); + + /* bV5Intent = LCS_GM_GRAPHICS */ + buf[0x0d] = GUINT32_TO_LE (0x00000002); + + /* bV5ProfileData is set to 0 (ignored) */ + buf[0x0e] = GUINT32_TO_LE (0x0); + + /* bV5ProfileSize is set to 0 (ignored) */ + buf[0x0f] = GUINT32_TO_LE (0x0); + + /* bV5Reserved = 0 */ + buf[0x10] = GUINT32_TO_LE (0x0); + + Write (outfile, buf, color_space_size); + } + + write_color_map (outfile, Red, Green, Blue, MapSize); + + /* After that is done, we write the image ... */ + + write_image (outfile, + pixels, cols, rows, + BMPSaveData.use_run_length_encoding, + channels, BitsPerPixel, SpZeile, + MapSize, BMPSaveData.rgb_format, + mask_info_size, color_space_size); + + /* ... and exit normally */ + + fclose (outfile); + g_free (pixels); + + return GIMP_PDB_SUCCESS; +} + +/* Entry point for file-bmp-save2 */ +GimpPDBStatusType +save_image2 (const gchar *filename, + gint32 image, + gint32 drawable_ID, + gint32 use_rle, + gint32 write_color_space, + gint32 rgb_format, + GimpRunMode run_mode, + GError **error) +{ + BMPSaveData.use_run_length_encoding = use_rle; + BMPSaveData.dont_write_color_space_data = write_color_space; + BMPSaveData.rgb_format = (RGBMode) rgb_format; + /* Prevents save_image () from overwriting user's RGB format */ + BMPSaveData.overwrite_RGB_format = TRUE; + + return save_image (filename, image, drawable_ID, + run_mode, error); +} + +static inline void +Make565 (guchar r, + guchar g, + guchar b, + guchar *buf) +{ + gint p; + + p = ((((gint) (r / 255.0 * 31.0 + 0.5)) << 11) | + (((gint) (g / 255.0 * 63.0 + 0.5)) << 5) | + (((gint) (b / 255.0 * 31.0 + 0.5)))); + + buf[0] = (guchar) (p & 0xff); + buf[1] = (guchar) (p >> 8); +} + +static inline void +Make5551 (guchar r, + guchar g, + guchar b, + guchar a, + guchar *buf) +{ + gint p; + + p = ((((gint) (r / 255.0 * 31.0 + 0.5)) << 10) | + (((gint) (g / 255.0 * 31.0 + 0.5)) << 5) | + (((gint) (b / 255.0 * 31.0 + 0.5))) | + (((gint) (a / 255.0 + 0.5) << 15))); + + buf[0] = (guchar) (p & 0xff); + buf[1] = (guchar) (p >> 8); +} + +static void +write_image (FILE *f, + guchar *src, + gint width, + gint height, + gint use_run_length_encoding, + gint channels, + gint bpp, + gint spzeile, + gint MapSize, + RGBMode rgb_format, + gint mask_info_size, + gint color_space_size) +{ + guchar buf[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0 }; + guint32 uint32buf; + guchar *temp, v; + guchar *row, *ketten; + gint xpos, ypos, i, j, rowstride, length, thiswidth; + gint breite, k; + guchar n, r, g, b, a; + gint cur_progress; + gint max_progress; + + xpos = 0; + rowstride = width * channels; + + cur_progress = 0; + max_progress = height; + + /* We'll begin with the 16/24/32 bit Bitmaps, they are easy :-) */ + + if (bpp > 8) + { + for (ypos = height - 1; ypos >= 0; ypos--) /* for each row */ + { + for (i = 0; i < width; i++) /* for each pixel */ + { + temp = src + (ypos * rowstride) + (xpos * channels); + switch (rgb_format) + { + default: + case RGB_888: + buf[2] = *temp++; + buf[1] = *temp++; + buf[0] = *temp++; + xpos++; + if (channels > 3 && (guchar) *temp == 0) + buf[0] = buf[1] = buf[2] = 0xff; + Write (f, buf, 3); + break; + case RGBX_8888: + buf[2] = *temp++; + buf[1] = *temp++; + buf[0] = *temp++; + buf[3] = 0; + xpos++; + if (channels > 3 && (guchar) *temp == 0) + buf[0] = buf[1] = buf[2] = 0xff; + Write (f, buf, 4); + break; + case RGBA_8888: + buf[2] = *temp++; + buf[1] = *temp++; + buf[0] = *temp++; + buf[3] = *temp; + xpos++; + Write (f, buf, 4); + break; + case RGB_565: + r = *temp++; + g = *temp++; + b = *temp++; + if (channels > 3 && (guchar) *temp == 0) + r = g = b = 0xff; + Make565 (r, g, b, buf); + xpos++; + Write (f, buf, 2); + break; + case RGB_555: + r = *temp++; + g = *temp++; + b = *temp++; + if (channels > 3 && (guchar) *temp == 0) + r = g = b = 0xff; + Make5551 (r, g, b, 0x0, buf); + xpos++; + Write (f, buf, 2); + break; + case RGBA_5551: + r = *temp++; + g = *temp++; + b = *temp++; + a = *temp; + Make5551 (r, g, b, a, buf); + xpos++; + Write (f, buf, 2); + break; + } + } + + Write (f, &buf[4], spzeile - (width * (bpp/8))); + + cur_progress++; + if ((cur_progress % 5) == 0) + gimp_progress_update ((gdouble) cur_progress / + (gdouble) max_progress); + + xpos = 0; + } + } + else + { + if (bpp == 1) + use_run_length_encoding = 0; + switch (use_run_length_encoding) /* now it gets more difficult */ + { /* uncompressed 1,4 and 8 bit */ + case 0: + { + thiswidth = (width / (8 / bpp)); + if (width % (8 / bpp)) + thiswidth++; + + for (ypos = height - 1; ypos >= 0; ypos--) /* for each row */ + { + for (xpos = 0; xpos < width;) /* for each _byte_ */ + { + v = 0; + for (i = 1; + (i <= (8 / bpp)) && (xpos < width); + i++, xpos++) /* for each pixel */ + { + temp = src + (ypos * rowstride) + (xpos * channels); + if (channels > 1 && *(temp+1) == 0) *temp = 0x0; + v=v | ((guchar) *temp << (8 - (i * bpp))); + } + Write (f, &v, 1); + } + Write (f, &buf[3], spzeile - thiswidth); + xpos = 0; + + cur_progress++; + if ((cur_progress % 5) == 0) + gimp_progress_update ((gdouble) cur_progress / + (gdouble) max_progress); + } + break; + } + default: + { /* Save RLE encoded file, quite difficult */ + length = 0; + buf[12] = 0; + buf[13] = 1; + buf[14] = 0; + buf[15] = 0; + row = g_new (guchar, width / (8 / bpp) + 10); + ketten = g_new (guchar, width / (8 / bpp) + 10); + for (ypos = height - 1; ypos >= 0; ypos--) + { /* each row separately */ + j = 0; + /* first copy the pixels to a buffer, + * making one byte from two 4bit pixels + */ + for (xpos = 0; xpos < width;) + { + v = 0; + for (i = 1; + (i <= (8 / bpp)) && (xpos < width); + i++, xpos++) + { /* for each pixel */ + temp = src + (ypos * rowstride) + (xpos * channels); + if (channels > 1 && *(temp+1) == 0) *temp = 0x0; + v = v | ((guchar) * temp << (8 - (i * bpp))); + } + row[j++] = v; + } + breite = width / (8 / bpp); + if (width % (8 / bpp)) + breite++; + + /* then check for strings of equal bytes */ + for (i = 0; i < breite; i += j) + { + j = 0; + while ((i + j < breite) && + (j < (255 / (8 / bpp))) && + (row[i + j] == row[i])) + j++; + + ketten[i] = j; + } + + /* then write the strings and the other pixels to the file */ + for (i = 0; i < breite;) + { + if (ketten[i] < 3) + /* strings of different pixels ... */ + { + j = 0; + while ((i + j < breite) && + (j < (255 / (8 / bpp))) && + (ketten[i + j] < 3)) + j += ketten[i + j]; + + /* this can only happen if j jumps over + * the end with a 2 in ketten[i+j] + */ + if (j > (255 / (8 / bpp))) + j -= 2; + /* 00 01 and 00 02 are reserved */ + if (j > 2) + { + Write (f, &buf[12], 1); + n = j * (8 / bpp); + if (n + i * (8 / bpp) > width) + n--; + Write (f, &n, 1); + length += 2; + Write (f, &row[i], j); + length += j; + if ((j) % 2) + { + Write (f, &buf[12], 1); + length++; + } + } + else + { + for (k = i; k < i + j; k++) + { + n = (8 / bpp); + if (n + i * (8 / bpp) > width) + n--; + Write (f, &n, 1); + Write (f, &row[k], 1); + /*printf("%i.#|",n); */ + length += 2; + } + } + i += j; + } + else + /* strings of equal pixels */ + { + n = ketten[i] * (8 / bpp); + if (n + i * (8 / bpp) > width) + n--; + Write (f, &n, 1); + Write (f, &row[i], 1); + i += ketten[i]; + length += 2; + } + } + + Write (f, &buf[14], 2); /* End of row */ + length += 2; + + cur_progress++; + if ((cur_progress % 5) == 0) + gimp_progress_update ((gdouble) cur_progress / + (gdouble) max_progress); + } + + fseek (f, -2, SEEK_CUR); /* Overwrite last End of row ... */ + Write (f, &buf[12], 2); /* ... with End of file */ + + fseek (f, 0x22, SEEK_SET); /* Write length of image */ + uint32buf = GUINT32_TO_LE (length); + Write (f, &uint32buf, 4); + + fseek (f, 0x02, SEEK_SET); /* Write length of file */ + length += (0x36 + MapSize + mask_info_size + color_space_size); + uint32buf = GUINT32_TO_LE (length); + Write (f, &uint32buf, 4); + + g_free (ketten); + g_free (row); + break; + } + } + } + + gimp_progress_update (1.0); +} + +static void +format_callback (GtkToggleButton *toggle, + gpointer data) +{ + if (gtk_toggle_button_get_active (toggle)) + BMPSaveData.rgb_format = GPOINTER_TO_INT (data); +} + +static gboolean +save_dialog (gint channels, gint bpp) +{ + GtkWidget *dialog; + GtkWidget *toggle; + GtkWidget *vbox_main; + GtkWidget *vbox; + GtkWidget *vbox2; + GtkWidget *expander; + GtkWidget *frame; + GSList *group; + gboolean run; + + /* Dialog init */ + dialog = gimp_export_dialog_new ("BMP", PLUG_IN_BINARY, SAVE_PROC); + + gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); + + vbox_main = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); + gtk_container_set_border_width (GTK_CONTAINER (vbox_main), 12); + gtk_box_pack_start (GTK_BOX (gimp_export_dialog_get_content_area (dialog)), + vbox_main, TRUE, TRUE, 0); + gtk_widget_show (vbox_main); + + /* Run-Length Encoded */ + toggle = gtk_check_button_new_with_mnemonic (_("_Run-Length Encoded")); + gtk_box_pack_start (GTK_BOX (vbox_main), toggle, FALSE, FALSE, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + BMPSaveData.use_run_length_encoding); + gtk_widget_show (toggle); + if (channels > 1 || bpp == 1) + gtk_widget_set_sensitive (toggle, FALSE); + + g_signal_connect (toggle, "toggled", + G_CALLBACK (gimp_toggle_button_update), + &BMPSaveData.use_run_length_encoding); + + /* Compatibility Options */ + expander = gtk_expander_new_with_mnemonic (_("Co_mpatibility Options")); + + gtk_box_pack_start (GTK_BOX (vbox_main), expander, TRUE, TRUE, 0); + gtk_widget_show (expander); + + vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); + gtk_container_set_border_width (GTK_CONTAINER (vbox2), 12); + gtk_container_add (GTK_CONTAINER (expander), vbox2); + gtk_widget_show (vbox2); + + toggle = gtk_check_button_new_with_mnemonic (_("_Do not write color space information")); + gimp_help_set_help_data (toggle, + _("Some applications can not read BMP images that " + "include color space information. GIMP writes " + "color space information by default. Enabling " + "this option will cause GIMP to not write color " + "space information to the file."), + NULL); + gtk_box_pack_start (GTK_BOX (vbox2), toggle, FALSE, FALSE, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + BMPSaveData.dont_write_color_space_data); + gtk_widget_show (toggle); + + g_signal_connect (toggle, "toggled", + G_CALLBACK (gimp_toggle_button_update), + &BMPSaveData.dont_write_color_space_data); + + /* Advanced Options */ + expander = gtk_expander_new_with_mnemonic (_("_Advanced Options")); + + gtk_box_pack_start (GTK_BOX (vbox_main), expander, TRUE, TRUE, 0); + gtk_widget_show (expander); + + if (channels < 3) + gtk_widget_set_sensitive (expander, FALSE); + + vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); + gtk_container_set_border_width (GTK_CONTAINER (vbox2), 12); + gtk_container_add (GTK_CONTAINER (expander), vbox2); + gtk_widget_show (vbox2); + + group = NULL; + + frame = gimp_frame_new (_("16 bits")); + gtk_box_pack_start (GTK_BOX (vbox2), frame, TRUE, TRUE, 0); + gtk_widget_show (frame); + + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_widget_show (vbox); + + toggle = gtk_radio_button_new_with_mnemonic (group, "_R5 G6 B5"); + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (toggle)); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_widget_show (toggle); + g_signal_connect (toggle, "toggled", + G_CALLBACK (format_callback), + GINT_TO_POINTER (RGB_565)); + + toggle = gtk_radio_button_new_with_mnemonic (group, "_A1 R5 G5 B5"); + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (toggle)); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + + if (channels < 4) + gtk_widget_set_sensitive (toggle, FALSE); + + gtk_widget_show (toggle); + + g_signal_connect (toggle, "toggled", + G_CALLBACK (format_callback), + GINT_TO_POINTER (RGBA_5551)); + toggle = gtk_radio_button_new_with_mnemonic (group, "_X1 R5 G5 B5"); + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (toggle)); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_widget_show (toggle); + g_signal_connect (toggle, "toggled", + G_CALLBACK (format_callback), + GINT_TO_POINTER (RGB_555)); + + frame = gimp_frame_new (_("24 bits")); + gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + toggle = gtk_radio_button_new_with_mnemonic (group, "R_8 G8 B8"); + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON(toggle)); + gtk_container_add (GTK_CONTAINER (frame), toggle); + gtk_widget_show (toggle); + g_signal_connect (toggle, "toggled", + G_CALLBACK (format_callback), + GINT_TO_POINTER (RGB_888)); + if (channels < 4) + { + BMPSaveData.rgb_format = RGB_888; + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), TRUE); + } + + frame = gimp_frame_new (_("32 bits")); + gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_widget_show (vbox); + + toggle = gtk_radio_button_new_with_mnemonic (group, "A8 R8 G8 _B8"); + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (toggle)); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_widget_show (toggle); + g_signal_connect (toggle, "toggled", + G_CALLBACK (format_callback), + GINT_TO_POINTER (RGBA_8888)); + + + if (channels < 4) + { + gtk_widget_set_sensitive (toggle, FALSE); + } + else + { + BMPSaveData.rgb_format = RGBA_8888; + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), TRUE); + } + + toggle = gtk_radio_button_new_with_mnemonic (group, "X8 R8 G8 _B8"); + group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (toggle)); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_widget_show (toggle); + g_signal_connect (toggle, "toggled", + G_CALLBACK (format_callback), + GINT_TO_POINTER (RGBX_8888)); + + /* Dialog show */ + gtk_widget_show (dialog); + + run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK); + + gtk_widget_destroy (dialog); + + return run; +} diff --git a/plug-ins/file-bmp/bmp-save.h b/plug-ins/file-bmp/bmp-save.h new file mode 100644 index 0000000..1483104 --- /dev/null +++ b/plug-ins/file-bmp/bmp-save.h @@ -0,0 +1,39 @@ +/* + * GIMP - The GNU 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +#ifndef __BMP_SAVE_H__ +#define __BMP_SAVE_H__ + + +GimpPDBStatusType save_image (const gchar *filename, + gint32 image, + gint32 drawable_ID, + GimpRunMode run_mode, + GError **error); + +GimpPDBStatusType save_image2 (const gchar *filename, + gint32 image, + gint32 drawable_ID, + gint32 use_rle, + gint32 write_color_space, + gint32 rgb_format, + GimpRunMode run_mode, + GError **error); + + +#endif /* __BMP_SAVE_H__ */ diff --git a/plug-ins/file-bmp/bmp.c b/plug-ins/file-bmp/bmp.c new file mode 100644 index 0000000..02d7aeb --- /dev/null +++ b/plug-ins/file-bmp/bmp.c @@ -0,0 +1,306 @@ +/* bmp.c */ +/* Version 0.52 */ +/* This is a File input and output filter for the */ +/* Gimp. It loads and saves images in windows(TM) */ +/* bitmap format. */ +/* Some Parts that deal with the interaction with */ +/* GIMP are taken from the GIF plugin by */ +/* Peter Mattis & Spencer Kimball and from the */ +/* PCX plugin by Francisco Bustamante. */ +/* */ +/* Alexander.Schulz@stud.uni-karlsruhe.de */ + +/* Changes: 28.11.1997 Noninteractive operation */ +/* 16.03.1998 Endian-independent!! */ +/* 21.03.1998 Little Bug-fix */ +/* 06.04.1998 Bugfix in Padding */ +/* 11.04.1998 Arch. cleanup (-Wall) */ +/* Parses gtkrc */ +/* 14.04.1998 Another Bug in Padding */ +/* 28.04.1998 RLE-Encoding rewritten */ +/* 29.10.1998 Changes by Tor Lillqvist */ +/* <tml@iki.fi> to support */ +/* 16 and 32 bit images */ +/* 28.11.1998 Bug in RLE-read-padding */ +/* fixed. */ +/* 19.12.1999 Resolution support added */ +/* 06.05.2000 Overhaul for 16&24-bit */ +/* plus better OS/2 code */ +/* by njl195@zepler.org.uk */ +/* 29.06.2006 Full support for 16/32 */ +/* bits bitmaps and support */ +/* for alpha channel */ +/* by p.filiciak@zax.pl */ + +/* + * GIMP - The GNU 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 3 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, see <https://www.gnu.org/licenses/>. + * ---------------------------------------------------------------------------- + */ + +#include "config.h" + +#include <stdlib.h> +#include <string.h> + +#include <libgimp/gimp.h> +#include <libgimp/gimpui.h> + +#include "bmp.h" +#include "bmp-load.h" +#include "bmp-save.h" + +#include "libgimp/stdplugins-intl.h" + + +/* Declare some local functions. + */ +static void query (void); +static void run (const gchar *name, + gint nparams, + const GimpParam *param, + gint *nreturn_vals, + GimpParam **return_vals); + + +const GimpPlugInInfo PLUG_IN_INFO = +{ + NULL, /* init_proc */ + NULL, /* quit_proc */ + query, /* query_proc */ + run, /* run_proc */ +}; + + +MAIN () + + +static void +query (void) +{ + static const GimpParamDef load_args[] = + { + { GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" }, + { GIMP_PDB_STRING, "filename", "The name of the file to load" }, + { GIMP_PDB_STRING, "raw-filename", "The name entered" }, + }; + static const GimpParamDef load_return_vals[] = + { + { GIMP_PDB_IMAGE, "image", "Output image" }, + }; + + static const GimpParamDef save_args[] = + { + { GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" }, + { GIMP_PDB_IMAGE, "image", "Input image" }, + { GIMP_PDB_DRAWABLE, "drawable", "Drawable to save" }, + { GIMP_PDB_STRING, "filename", "The name of the file to save the image in" }, + { GIMP_PDB_STRING, "raw-filename", "The name entered" }, + }; + + static const GimpParamDef save_args2[] = + { + { GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" }, + { GIMP_PDB_IMAGE, "image", "Input image" }, + { GIMP_PDB_DRAWABLE, "drawable", "Drawable to save" }, + { GIMP_PDB_STRING, "filename", "The name of the file to save the image in" }, + { GIMP_PDB_STRING, "raw-filename", "The name entered" }, + { GIMP_PDB_INT32, "use-rle", "Use run-length-encoding compression (only valid for 4 and 8-bit indexed images)" }, + { GIMP_PDB_INT32, "write-color-space", "Whether or not to write BITMAPV5HEADER color space data" }, + { GIMP_PDB_INT32, "rgb-format", "Export format for RGB images (0=RGB_565, 1=RGBA_5551, 2=RGB_555, 3=RGB_888, 4=RGBA_8888, 5=RGBX_8888)" }, + }; + + gimp_install_procedure (LOAD_PROC, + "Loads files of Windows BMP file format", + "Loads files of Windows BMP file format", + "Alexander Schulz", + "Alexander Schulz", + "1997", + N_("Windows BMP image"), + NULL, + GIMP_PLUGIN, + G_N_ELEMENTS (load_args), + G_N_ELEMENTS (load_return_vals), + load_args, load_return_vals); + + gimp_register_file_handler_mime (LOAD_PROC, "image/bmp"); + gimp_register_magic_load_handler (LOAD_PROC, + "bmp", + "", + "0,string,BM"); + + gimp_install_procedure (SAVE_PROC, + "Saves files in Windows BMP file format", + "Saves files in Windows BMP file format", + "Alexander Schulz", + "Alexander Schulz", + "1997", + N_("Windows BMP image"), + "INDEXED, GRAY, RGB*", + GIMP_PLUGIN, + G_N_ELEMENTS (save_args), 0, + save_args, NULL); + + gimp_register_file_handler_mime (SAVE_PROC, "image/bmp"); + gimp_register_save_handler (SAVE_PROC, "bmp", ""); + + gimp_install_procedure (SAVE_PROC2, + "Saves files in Windows BMP file format", + "Saves files in Windows BMP file format, " + "with RLE, color space information, and RGB format " + "options available non-interactively", + "Alexander Schulz", + "Alexander Schulz", + "1997", + N_("Windows BMP image"), + "INDEXED, GRAY, RGB*", + GIMP_PLUGIN, + G_N_ELEMENTS (save_args2), 0, + save_args2, NULL); + + gimp_register_file_handler_mime (SAVE_PROC2, "image/bmp"); + gimp_register_save_handler (SAVE_PROC2, "bmp", ""); +} + +static void +run (const gchar *name, + gint nparams, + const GimpParam *param, + gint *nreturn_vals, + GimpParam **return_vals) +{ + static GimpParam values[2]; + GimpRunMode run_mode; + GimpPDBStatusType status = GIMP_PDB_SUCCESS; + GError *error = NULL; + + INIT_I18N (); + gegl_init (NULL, NULL); + + run_mode = param[0].data.d_int32; + + *nreturn_vals = 1; + *return_vals = values; + + values[0].type = GIMP_PDB_STATUS; + values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR; + + if (strcmp (name, LOAD_PROC) == 0) + { + switch (run_mode) + { + case GIMP_RUN_INTERACTIVE: + break; + + case GIMP_RUN_NONINTERACTIVE: + /* Make sure all the arguments are there! */ + if (nparams != 3) + status = GIMP_PDB_CALLING_ERROR; + break; + + default: + break; + } + + if (status == GIMP_PDB_SUCCESS) + { + gint32 image_ID = load_image (param[1].data.d_string, + &error); + + if (image_ID != -1) + { + *nreturn_vals = 2; + values[1].type = GIMP_PDB_IMAGE; + values[1].data.d_image = image_ID; + } + else + { + status = GIMP_PDB_EXECUTION_ERROR; + } + } + } + else if (strcmp (name, SAVE_PROC) == 0 || + strcmp (name, SAVE_PROC2) == 0) + { + gint32 image_ID = param[1].data.d_int32; + gint32 drawable_ID = param[2].data.d_int32; + GimpExportReturn export = GIMP_EXPORT_CANCEL; + + /* eventually export the image */ + switch (run_mode) + { + case GIMP_RUN_INTERACTIVE: + case GIMP_RUN_WITH_LAST_VALS: + gimp_ui_init (PLUG_IN_BINARY, FALSE); + + export = gimp_export_image (&image_ID, &drawable_ID, "BMP", + GIMP_EXPORT_CAN_HANDLE_RGB | + GIMP_EXPORT_CAN_HANDLE_GRAY | + GIMP_EXPORT_CAN_HANDLE_ALPHA | + GIMP_EXPORT_CAN_HANDLE_INDEXED); + + if (export == GIMP_EXPORT_CANCEL) + { + values[0].data.d_status = GIMP_PDB_CANCEL; + return; + } + break; + + case GIMP_RUN_NONINTERACTIVE: + /* Make sure all the arguments are there! */ + if ((strcmp (name, SAVE_PROC) == 0 && nparams != 5) || + (strcmp (name, SAVE_PROC2) == 0 && nparams != 8)) + status = GIMP_PDB_CALLING_ERROR; + break; + + default: + break; + } + + if (status == GIMP_PDB_SUCCESS) + { + if (strcmp (name, SAVE_PROC) == 0) + status = save_image (param[3].data.d_string, + image_ID, drawable_ID, + run_mode, + &error); + else + status = save_image2 (param[3].data.d_string, + image_ID, drawable_ID, + param[5].data.d_int32, + param[6].data.d_int32, + param[7].data.d_int32, + run_mode, + &error); + } + + if (export == GIMP_EXPORT_EXPORT) + gimp_image_delete (image_ID); + } + else + { + status = GIMP_PDB_CALLING_ERROR; + } + + if (status != GIMP_PDB_SUCCESS && error) + { + *nreturn_vals = 2; + values[1].type = GIMP_PDB_STRING; + values[1].data.d_string = error->message; + } + + values[0].data.d_status = status; +} diff --git a/plug-ins/file-bmp/bmp.h b/plug-ins/file-bmp/bmp.h new file mode 100644 index 0000000..259b025 --- /dev/null +++ b/plug-ins/file-bmp/bmp.h @@ -0,0 +1,71 @@ +/* + * GIMP - The GNU 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 3 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, see <https://www.gnu.org/licenses/>. + */ + +#ifndef __BMP_H__ +#define __BMP_H__ + + +#define LOAD_PROC "file-bmp-load" +#define SAVE_PROC "file-bmp-save" +#define SAVE_PROC2 "file-bmp-save2" +#define PLUG_IN_BINARY "file-bmp" +#define PLUG_IN_ROLE "gimp-file-bmp" + +#define MAXCOLORS 256 + +#define BitSet(byte, bit) (((byte) & (bit)) == (bit)) + +#define ReadOK(file,buffer,len) (fread(buffer, len, 1, file) != 0) +#define Write(file,buffer,len) fwrite(buffer, len, 1, file) +#define WriteOK(file,buffer,len) (Write(buffer, len, file) != 0) + + +typedef struct +{ + gchar zzMagic[2]; /* 00 "BM" */ + guint32 bfSize; /* 02 */ + guint16 zzHotX; /* 06 */ + guint16 zzHotY; /* 08 */ + guint32 bfOffs; /* 0A */ + guint32 biSize; /* 0E */ +} BitmapFileHead; + +typedef struct +{ + gint32 biWidth; /* 12 */ + gint32 biHeight; /* 16 */ + guint16 biPlanes; /* 1A */ + guint16 biBitCnt; /* 1C */ + guint32 biCompr; /* 1E */ + guint32 biSizeIm; /* 22 */ + guint32 biXPels; /* 26 */ + guint32 biYPels; /* 2A */ + guint32 biClrUsed; /* 2E */ + guint32 biClrImp; /* 32 */ + guint32 masks[4]; /* 36 */ +} BitmapHead; + +typedef struct +{ + guint32 mask; + guint32 shiftin; + gfloat max_value; +} BitmapChannel; + + +#endif /* __BMP_H__ */ |