diff options
Diffstat (limited to 'plug-ins/file-ico')
-rw-r--r-- | plug-ins/file-ico/Makefile.am | 57 | ||||
-rw-r--r-- | plug-ins/file-ico/Makefile.in | 1080 | ||||
-rw-r--r-- | plug-ins/file-ico/ico-dialog.c | 531 | ||||
-rw-r--r-- | plug-ins/file-ico/ico-dialog.h | 30 | ||||
-rw-r--r-- | plug-ins/file-ico/ico-load.c | 813 | ||||
-rw-r--r-- | plug-ins/file-ico/ico-load.h | 43 | ||||
-rw-r--r-- | plug-ins/file-ico/ico-save.c | 1176 | ||||
-rw-r--r-- | plug-ins/file-ico/ico-save.h | 34 | ||||
-rw-r--r-- | plug-ins/file-ico/ico.c | 344 | ||||
-rw-r--r-- | plug-ins/file-ico/ico.h | 110 |
10 files changed, 4218 insertions, 0 deletions
diff --git a/plug-ins/file-ico/Makefile.am b/plug-ins/file-ico/Makefile.am new file mode 100644 index 0000000..0bc5bbf --- /dev/null +++ b/plug-ins/file-ico/Makefile.am @@ -0,0 +1,57 @@ +## 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 +libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la +libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la + +if OS_WIN32 +mwindows = -mwindows +endif + +if HAVE_WINDRES +include $(top_srcdir)/build/windows/gimprc-plug-ins.rule +file_ico_RC = file-ico.rc.o +endif + +AM_LDFLAGS = $(mwindows) + +libexecdir = $(gimpplugindir)/plug-ins/file-ico + +libexec_PROGRAMS = file-ico + +file_ico_CFLAGS = $(PNG_CFLAGS) + +file_ico_SOURCES = \ + ico.c \ + ico.h \ + ico-dialog.c \ + ico-dialog.h \ + ico-load.c \ + ico-load.h \ + ico-save.c \ + ico-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) \ + $(PNG_LIBS) \ + $(RT_LIBS) \ + $(INTLLIBS) \ + $(file_ico_RC) diff --git a/plug-ins/file-ico/Makefile.in b/plug-ins/file-ico/Makefile.in new file mode 100644 index 0000000..a553db1 --- /dev/null +++ b/plug-ins/file-ico/Makefile.in @@ -0,0 +1,1080 @@ +# Makefile.in generated by automake 1.16.2 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-ico$(EXEEXT) +subdir = plug-ins/file-ico +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4macros/gtk-doc.m4 \ + $(top_srcdir)/m4macros/intltool.m4 \ + $(top_srcdir)/m4macros/libtool.m4 \ + $(top_srcdir)/m4macros/ltoptions.m4 \ + $(top_srcdir)/m4macros/ltsugar.m4 \ + $(top_srcdir)/m4macros/ltversion.m4 \ + $(top_srcdir)/m4macros/lt~obsolete.m4 \ + $(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_ico_OBJECTS = file_ico-ico.$(OBJEXT) \ + file_ico-ico-dialog.$(OBJEXT) file_ico-ico-load.$(OBJEXT) \ + file_ico-ico-save.$(OBJEXT) +file_ico_OBJECTS = $(am_file_ico_OBJECTS) +file_ico_LDADD = $(LDADD) +am__DEPENDENCIES_1 = +file_ico_DEPENDENCIES = $(libgimpui) $(libgimpwidgets) \ + $(libgimpconfig) $(libgimp) $(libgimpcolor) $(libgimpmath) \ + $(libgimpbase) $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(file_ico_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 = +file_ico_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(file_ico_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +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)/file_ico-ico-dialog.Po \ + ./$(DEPDIR)/file_ico-ico-load.Po \ + ./$(DEPDIR)/file_ico-ico-save.Po ./$(DEPDIR)/file_ico-ico.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_ico_SOURCES) +DIST_SOURCES = $(file_ico_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_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_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@ +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@ +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-ico +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 +libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la +libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(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_ico_RC = file-ico.rc.o +AM_LDFLAGS = $(mwindows) +file_ico_CFLAGS = $(PNG_CFLAGS) +file_ico_SOURCES = \ + ico.c \ + ico.h \ + ico-dialog.c \ + ico-dialog.h \ + ico-load.c \ + ico-load.h \ + ico-save.c \ + ico-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) \ + $(PNG_LIBS) \ + $(RT_LIBS) \ + $(INTLLIBS) \ + $(file_ico_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-ico/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu plug-ins/file-ico/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-ico$(EXEEXT): $(file_ico_OBJECTS) $(file_ico_DEPENDENCIES) $(EXTRA_file_ico_DEPENDENCIES) + @rm -f file-ico$(EXEEXT) + $(AM_V_CCLD)$(file_ico_LINK) $(file_ico_OBJECTS) $(file_ico_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_ico-ico-dialog.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_ico-ico-load.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_ico-ico-save.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_ico-ico.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 $@ $< + +file_ico-ico.o: ico.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -MT file_ico-ico.o -MD -MP -MF $(DEPDIR)/file_ico-ico.Tpo -c -o file_ico-ico.o `test -f 'ico.c' || echo '$(srcdir)/'`ico.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/file_ico-ico.Tpo $(DEPDIR)/file_ico-ico.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ico.c' object='file_ico-ico.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -c -o file_ico-ico.o `test -f 'ico.c' || echo '$(srcdir)/'`ico.c + +file_ico-ico.obj: ico.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -MT file_ico-ico.obj -MD -MP -MF $(DEPDIR)/file_ico-ico.Tpo -c -o file_ico-ico.obj `if test -f 'ico.c'; then $(CYGPATH_W) 'ico.c'; else $(CYGPATH_W) '$(srcdir)/ico.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/file_ico-ico.Tpo $(DEPDIR)/file_ico-ico.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ico.c' object='file_ico-ico.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -c -o file_ico-ico.obj `if test -f 'ico.c'; then $(CYGPATH_W) 'ico.c'; else $(CYGPATH_W) '$(srcdir)/ico.c'; fi` + +file_ico-ico-dialog.o: ico-dialog.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -MT file_ico-ico-dialog.o -MD -MP -MF $(DEPDIR)/file_ico-ico-dialog.Tpo -c -o file_ico-ico-dialog.o `test -f 'ico-dialog.c' || echo '$(srcdir)/'`ico-dialog.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/file_ico-ico-dialog.Tpo $(DEPDIR)/file_ico-ico-dialog.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ico-dialog.c' object='file_ico-ico-dialog.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -c -o file_ico-ico-dialog.o `test -f 'ico-dialog.c' || echo '$(srcdir)/'`ico-dialog.c + +file_ico-ico-dialog.obj: ico-dialog.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -MT file_ico-ico-dialog.obj -MD -MP -MF $(DEPDIR)/file_ico-ico-dialog.Tpo -c -o file_ico-ico-dialog.obj `if test -f 'ico-dialog.c'; then $(CYGPATH_W) 'ico-dialog.c'; else $(CYGPATH_W) '$(srcdir)/ico-dialog.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/file_ico-ico-dialog.Tpo $(DEPDIR)/file_ico-ico-dialog.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ico-dialog.c' object='file_ico-ico-dialog.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -c -o file_ico-ico-dialog.obj `if test -f 'ico-dialog.c'; then $(CYGPATH_W) 'ico-dialog.c'; else $(CYGPATH_W) '$(srcdir)/ico-dialog.c'; fi` + +file_ico-ico-load.o: ico-load.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -MT file_ico-ico-load.o -MD -MP -MF $(DEPDIR)/file_ico-ico-load.Tpo -c -o file_ico-ico-load.o `test -f 'ico-load.c' || echo '$(srcdir)/'`ico-load.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/file_ico-ico-load.Tpo $(DEPDIR)/file_ico-ico-load.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ico-load.c' object='file_ico-ico-load.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -c -o file_ico-ico-load.o `test -f 'ico-load.c' || echo '$(srcdir)/'`ico-load.c + +file_ico-ico-load.obj: ico-load.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -MT file_ico-ico-load.obj -MD -MP -MF $(DEPDIR)/file_ico-ico-load.Tpo -c -o file_ico-ico-load.obj `if test -f 'ico-load.c'; then $(CYGPATH_W) 'ico-load.c'; else $(CYGPATH_W) '$(srcdir)/ico-load.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/file_ico-ico-load.Tpo $(DEPDIR)/file_ico-ico-load.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ico-load.c' object='file_ico-ico-load.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -c -o file_ico-ico-load.obj `if test -f 'ico-load.c'; then $(CYGPATH_W) 'ico-load.c'; else $(CYGPATH_W) '$(srcdir)/ico-load.c'; fi` + +file_ico-ico-save.o: ico-save.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -MT file_ico-ico-save.o -MD -MP -MF $(DEPDIR)/file_ico-ico-save.Tpo -c -o file_ico-ico-save.o `test -f 'ico-save.c' || echo '$(srcdir)/'`ico-save.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/file_ico-ico-save.Tpo $(DEPDIR)/file_ico-ico-save.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ico-save.c' object='file_ico-ico-save.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -c -o file_ico-ico-save.o `test -f 'ico-save.c' || echo '$(srcdir)/'`ico-save.c + +file_ico-ico-save.obj: ico-save.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -MT file_ico-ico-save.obj -MD -MP -MF $(DEPDIR)/file_ico-ico-save.Tpo -c -o file_ico-ico-save.obj `if test -f 'ico-save.c'; then $(CYGPATH_W) 'ico-save.c'; else $(CYGPATH_W) '$(srcdir)/ico-save.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/file_ico-ico-save.Tpo $(DEPDIR)/file_ico-ico-save.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ico-save.c' object='file_ico-ico-save.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(file_ico_CFLAGS) $(CFLAGS) -c -o file_ico-ico-save.obj `if test -f 'ico-save.c'; then $(CYGPATH_W) 'ico-save.c'; else $(CYGPATH_W) '$(srcdir)/ico-save.c'; fi` + +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)/file_ico-ico-dialog.Po + -rm -f ./$(DEPDIR)/file_ico-ico-load.Po + -rm -f ./$(DEPDIR)/file_ico-ico-save.Po + -rm -f ./$(DEPDIR)/file_ico-ico.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)/file_ico-ico-dialog.Po + -rm -f ./$(DEPDIR)/file_ico-ico-load.Po + -rm -f ./$(DEPDIR)/file_ico-ico-save.Po + -rm -f ./$(DEPDIR)/file_ico-ico.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-ico/ico-dialog.c b/plug-ins/file-ico/ico-dialog.c new file mode 100644 index 0000000..84e9909 --- /dev/null +++ b/plug-ins/file-ico/ico-dialog.c @@ -0,0 +1,531 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis + * + * GIMP Plug-in for Windows Icon files. + * Copyright (C) 2002 Christian Kreibich <christian@whoop.org>. + * + * 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 <libgimp/gimp.h> +#include <libgimp/gimpui.h> + +/* #define ICO_DBG */ + +#include "ico.h" +#include "ico-dialog.h" +#include "ico-save.h" + +#include "libgimp/stdplugins-intl.h" + +static void ico_dialog_bpp_changed (GtkWidget *combo, + GObject *hbox); +static void ico_dialog_toggle_compress (GtkWidget *checkbox, + GObject *hbox); +static void ico_dialog_check_compat (GtkWidget *dialog, + IcoSaveInfo *info); + + +GtkWidget * +ico_dialog_new (IcoSaveInfo *info) +{ + GtkWidget *dialog; + GtkWidget *main_vbox; + GtkWidget *vbox; + GtkWidget *frame; + GtkWidget *scrolled_window; + GtkWidget *viewport; + GtkWidget *warning; + + dialog = gimp_export_dialog_new (_("Windows Icon"), + PLUG_IN_BINARY, + "plug-in-winicon"); + + /* We store an array that holds each icon's requested bit depth + with the dialog. It's queried when the dialog is closed so the + save routine knows what colormaps etc to generate in the saved + file. We store twice the number necessary because in the second + set, the color depths that are automatically suggested are stored + for later comparison. + */ + + g_object_set_data (G_OBJECT (dialog), "save_info", info); + + main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); + gtk_box_pack_start (GTK_BOX (gimp_export_dialog_get_content_area (dialog)), + main_vbox, TRUE, TRUE, 0); + gtk_widget_show (main_vbox); + + frame = gimp_frame_new (_("Icon Details")); + gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0); + gtk_widget_show (frame); + + scrolled_window = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + gtk_container_add (GTK_CONTAINER (frame), scrolled_window); + gtk_widget_show (scrolled_window); + + viewport = gtk_viewport_new (NULL, NULL); + gtk_container_add (GTK_CONTAINER (scrolled_window), viewport); + gtk_widget_show (viewport); + + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); + g_object_set_data (G_OBJECT (dialog), "icons_vbox", vbox); + gtk_container_add (GTK_CONTAINER (viewport), vbox); + gtk_widget_show (vbox); + + warning = g_object_new (GIMP_TYPE_HINT_BOX, + "icon-name", GIMP_ICON_DIALOG_WARNING, + "hint", + _("Large icons and compression are not supported " + "by all programs. Older applications may not " + "open this file correctly."), + NULL); + gtk_box_pack_end (GTK_BOX (main_vbox), warning, FALSE, FALSE, 0); + /* don't show the warning here */ + + g_object_set_data (G_OBJECT (dialog), "warning", warning); + + return dialog; +} + +static GtkWidget * +ico_preview_new (gint32 layer) +{ + GtkWidget *image; + GdkPixbuf *pixbuf; + gint width = gimp_drawable_width (layer); + gint height = gimp_drawable_height (layer); + + pixbuf = gimp_drawable_get_thumbnail (layer, + MIN (width, 128), MIN (height, 128), + GIMP_PIXBUF_SMALL_CHECKS); + image = gtk_image_new_from_pixbuf (pixbuf); + g_object_unref (pixbuf); + + return image; +} + +/* This function creates and returns an hbox for an icon, + which then gets added to the dialog's main vbox. */ +static GtkWidget * +ico_create_icon_hbox (GtkWidget *icon_preview, + gint32 layer, + gint layer_num, + IcoSaveInfo *info) +{ + static GtkSizeGroup *size = NULL; + + GtkWidget *hbox; + GtkWidget *vbox; + GtkWidget *alignment; + GtkWidget *combo; + GtkWidget *checkbox; + + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); + + alignment = gtk_alignment_new (1.0, 0.5, 0, 0); + gtk_box_pack_start (GTK_BOX (hbox), alignment, FALSE, FALSE, 0); + gtk_widget_show (alignment); + + /* To make life easier for the callbacks, we store the + layer's ID and stacking number with the hbox. */ + + g_object_set_data (G_OBJECT (hbox), + "icon_layer", GINT_TO_POINTER (layer)); + g_object_set_data (G_OBJECT (hbox), + "icon_layer_num", GINT_TO_POINTER (layer_num)); + + g_object_set_data (G_OBJECT (hbox), "icon_preview", icon_preview); + gtk_container_add (GTK_CONTAINER (alignment), icon_preview); + gtk_widget_show (icon_preview); + + if (! size) + size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + + gtk_size_group_add_widget (size, alignment); + + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); + gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); + gtk_widget_show (vbox); + + combo = gimp_int_combo_box_new (_("1 bpp, 1-bit alpha, 2-slot palette"), 1, + _("4 bpp, 1-bit alpha, 16-slot palette"), 4, + _("8 bpp, 1-bit alpha, 256-slot palette"), 8, + _("24 bpp, 1-bit alpha, no palette"), 24, + _("32 bpp, 8-bit alpha, no palette"), 32, + NULL); + gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), + info->depths[layer_num]); + + g_signal_connect (combo, "changed", + G_CALLBACK (ico_dialog_bpp_changed), + hbox); + + g_object_set_data (G_OBJECT (hbox), "icon_menu", combo); + + gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0); + gtk_widget_show (combo); + + checkbox = gtk_check_button_new_with_label (_("Compressed (PNG)")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), + info->compress[layer_num]); + g_signal_connect (checkbox, "toggled", + G_CALLBACK (ico_dialog_toggle_compress), hbox); + gtk_box_pack_start (GTK_BOX (vbox), checkbox, FALSE, FALSE, 0); + gtk_widget_show (checkbox); + + return hbox; +} + +static GtkWidget * +ico_dialog_get_layer_preview (GtkWidget *dialog, + gint32 layer) +{ + GtkWidget *preview; + GtkWidget *icon_hbox; + gchar key[ICO_MAXBUF]; + + g_snprintf (key, sizeof (key), "layer_%i_hbox", layer); + icon_hbox = g_object_get_data (G_OBJECT (dialog), key); + + if (!icon_hbox) + { + D(("Something's wrong -- couldn't look up hbox by layer ID\n")); + return NULL; + } + + preview = g_object_get_data (G_OBJECT (icon_hbox), "icon_preview"); + + if (!icon_hbox) + { + D(("Something's wrong -- couldn't look up preview from hbox\n")); + return NULL; + } + + return preview; +} + +static void +ico_dialog_update_icon_preview (GtkWidget *dialog, + gint32 layer, + gint bpp) +{ + GtkWidget *preview = ico_dialog_get_layer_preview (dialog, layer); + GdkPixbuf *pixbuf; + const Babl *format; + gint w = gimp_drawable_width (layer); + gint h = gimp_drawable_height (layer); + + if (! preview) + return; + + switch (gimp_drawable_type (layer)) + { + case GIMP_RGB_IMAGE: + format = babl_format ("R'G'B' u8"); + break; + + case GIMP_RGBA_IMAGE: + format = babl_format ("R'G'B'A u8"); + break; + + case GIMP_GRAY_IMAGE: + format = babl_format ("Y' u8"); + break; + + case GIMP_GRAYA_IMAGE: + format = babl_format ("Y'A u8"); + break; + + case GIMP_INDEXED_IMAGE: + case GIMP_INDEXEDA_IMAGE: + format = gimp_drawable_get_format (layer); + break; + + default: + g_return_if_reached (); + } + + if (bpp <= 8) + { + GeglBuffer *buffer; + GeglBuffer *tmp; + gint32 image; + gint32 tmp_image; + gint32 tmp_layer; + guchar *buf; + guchar *cmap; + gint num_colors; + + image = gimp_item_get_image (layer); + + tmp_image = gimp_image_new (w, h, gimp_image_base_type (image)); + gimp_image_undo_disable (tmp_image); + + if (gimp_drawable_is_indexed (layer)) + { + cmap = gimp_image_get_colormap (image, &num_colors); + gimp_image_set_colormap (tmp_image, cmap, num_colors); + g_free (cmap); + } + + tmp_layer = gimp_layer_new (tmp_image, "temporary", w, h, + gimp_drawable_type (layer), + 100, + gimp_image_get_default_new_layer_mode (tmp_image)); + gimp_image_insert_layer (tmp_image, tmp_layer, -1, 0); + + buffer = gimp_drawable_get_buffer (layer); + tmp = gimp_drawable_get_buffer (tmp_layer); + + buf = g_malloc (w * h * 4); + + gegl_buffer_get (buffer, GEGL_RECTANGLE (0, 0, w, h), 1.0, + format, buf, + GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); + + gegl_buffer_copy (buffer, NULL, GEGL_ABYSS_NONE, tmp, NULL); + + g_object_unref (tmp); + g_object_unref (buffer); + + if (gimp_drawable_is_indexed (layer)) + gimp_image_convert_rgb (tmp_image); + + gimp_image_convert_indexed (tmp_image, + GIMP_CONVERT_DITHER_FS, + GIMP_CONVERT_PALETTE_GENERATE, + 1 << bpp, TRUE, FALSE, "dummy"); + + cmap = gimp_image_get_colormap (tmp_image, &num_colors); + + if (num_colors == (1 << bpp) && + ! ico_cmap_contains_black (cmap, num_colors)) + { + /* Windows icons with color maps need the color black. + * We need to eliminate one more color to make room for black. + */ + if (gimp_drawable_is_indexed (layer)) + { + g_free (cmap); + cmap = gimp_image_get_colormap (image, &num_colors); + gimp_image_set_colormap (tmp_image, cmap, num_colors); + } + else if (gimp_drawable_is_gray (layer)) + { + gimp_image_convert_grayscale (tmp_image); + } + else + { + gimp_image_convert_rgb (tmp_image); + } + + tmp = gimp_drawable_get_buffer (tmp_layer); + + gegl_buffer_set (tmp, GEGL_RECTANGLE (0, 0, w, h), 0, + format, buf, GEGL_AUTO_ROWSTRIDE); + + g_object_unref (tmp); + + if (!gimp_drawable_is_rgb (layer)) + gimp_image_convert_rgb (tmp_image); + + gimp_image_convert_indexed (tmp_image, + GIMP_CONVERT_DITHER_FS, + GIMP_CONVERT_PALETTE_GENERATE, + (1 << bpp) - 1, TRUE, FALSE, "dummy"); + } + + g_free (cmap); + g_free (buf); + + pixbuf = gimp_drawable_get_thumbnail (tmp_layer, + MIN (w, 128), MIN (h, 128), + GIMP_PIXBUF_SMALL_CHECKS); + + gimp_image_delete (tmp_image); + } + else if (bpp == 24) + { + GeglBuffer *buffer; + GeglBuffer *tmp; + gint32 image; + gint32 tmp_image; + gint32 tmp_layer; + GimpParam *return_vals; + gint n_return_vals; + + image = gimp_item_get_image (layer); + + tmp_image = gimp_image_new (w, h, gimp_image_base_type (image)); + gimp_image_undo_disable (tmp_image); + + if (gimp_drawable_is_indexed (layer)) + { + guchar *cmap; + gint num_colors; + + cmap = gimp_image_get_colormap (image, &num_colors); + gimp_image_set_colormap (tmp_image, cmap, num_colors); + g_free (cmap); + } + + tmp_layer = gimp_layer_new (tmp_image, "temporary", w, h, + gimp_drawable_type (layer), + 100, + gimp_image_get_default_new_layer_mode (tmp_image)); + gimp_image_insert_layer (tmp_image, tmp_layer, -1, 0); + + buffer = gimp_drawable_get_buffer (layer); + tmp = gimp_drawable_get_buffer (tmp_layer); + + gegl_buffer_copy (buffer, NULL, GEGL_ABYSS_NONE, tmp, NULL); + + g_object_unref (tmp); + g_object_unref (buffer); + + if (gimp_drawable_is_indexed (layer)) + gimp_image_convert_rgb (tmp_image); + + return_vals = + gimp_run_procedure ("plug-in-threshold-alpha", &n_return_vals, + GIMP_PDB_INT32, GIMP_RUN_NONINTERACTIVE, + GIMP_PDB_IMAGE, tmp_image, + GIMP_PDB_DRAWABLE, tmp_layer, + GIMP_PDB_INT32, ICO_ALPHA_THRESHOLD, + GIMP_PDB_END); + gimp_destroy_params (return_vals, n_return_vals); + + pixbuf = gimp_drawable_get_thumbnail (tmp_layer, + MIN (w, 128), MIN (h, 128), + GIMP_PIXBUF_SMALL_CHECKS); + + gimp_image_delete (tmp_image); + } + else + { + pixbuf = gimp_drawable_get_thumbnail (layer, + MIN (w, 128), MIN (h, 128), + GIMP_PIXBUF_SMALL_CHECKS); + } + + gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf); + g_object_unref (pixbuf); +} + +void +ico_dialog_add_icon (GtkWidget *dialog, + gint32 layer, + gint layer_num) +{ + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *preview; + gchar key[ICO_MAXBUF]; + IcoSaveInfo *info; + + vbox = g_object_get_data (G_OBJECT (dialog), "icons_vbox"); + info = g_object_get_data (G_OBJECT (dialog), "save_info"); + + preview = ico_preview_new (layer); + hbox = ico_create_icon_hbox (preview, layer, layer_num, info); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); + + /* Let's make the hbox accessible through the layer ID */ + g_snprintf (key, sizeof (key), "layer_%i_hbox", layer); + g_object_set_data (G_OBJECT (dialog), key, hbox); + + ico_dialog_update_icon_preview (dialog, layer, info->depths[layer_num]); + + ico_dialog_check_compat (dialog, info); +} + +static void +ico_dialog_bpp_changed (GtkWidget *combo, + GObject *hbox) +{ + GtkWidget *dialog; + gint32 layer; + gint layer_num; + gint bpp; + IcoSaveInfo *info; + + dialog = gtk_widget_get_toplevel (combo); + + gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (combo), &bpp); + + info = g_object_get_data (G_OBJECT (dialog), "save_info"); + g_assert (info); + + layer = GPOINTER_TO_INT (g_object_get_data (hbox, "icon_layer")); + layer_num = GPOINTER_TO_INT (g_object_get_data (hbox, "icon_layer_num")); + + /* Update vector entry for later when we're actually saving, + and update the preview right away ... */ + info->depths[layer_num] = bpp; + ico_dialog_update_icon_preview (dialog, layer, bpp); +} + +static void +ico_dialog_toggle_compress (GtkWidget *checkbox, + GObject *hbox) +{ + GtkWidget *dialog; + gint layer_num; + IcoSaveInfo *info; + + dialog = gtk_widget_get_toplevel (checkbox); + + info = g_object_get_data (G_OBJECT (dialog), "save_info"); + g_assert (info); + layer_num = GPOINTER_TO_INT (g_object_get_data (hbox, "icon_layer_num")); + + /* Update vector entry for later when we're actually saving */ + info->compress[layer_num] = + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)); + + ico_dialog_check_compat (dialog, info); +} + +static void +ico_dialog_check_compat (GtkWidget *dialog, + IcoSaveInfo *info) +{ + GtkWidget *warning; + gboolean warn = FALSE; + gint i; + + for (i = 0; i < info->num_icons; i++) + { + if (gimp_drawable_width (info->layers[i]) > 255 || + gimp_drawable_height (info->layers[i]) > 255 || + info->compress[i]) + { + warn = TRUE; + break; + } + } + + warning = g_object_get_data (G_OBJECT (dialog), "warning"); + + gtk_widget_set_visible (warning, warn); +} diff --git a/plug-ins/file-ico/ico-dialog.h b/plug-ins/file-ico/ico-dialog.h new file mode 100644 index 0000000..19ddee4 --- /dev/null +++ b/plug-ins/file-ico/ico-dialog.h @@ -0,0 +1,30 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis + * + * GIMP Plug-in for Windows Icon files. + * Copyright (C) 2002 Christian Kreibich <christian@whoop.org>. + * + * 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 __ICO_DIALOG_H__ +#define __ICO_DIALOG_H__ + + +GtkWidget * ico_dialog_new (IcoSaveInfo *info); +void ico_dialog_add_icon (GtkWidget *dialog, + gint32 layer, + gint layer_num); + +#endif /* __ICO_DIALOG_H__ */ diff --git a/plug-ins/file-ico/ico-load.c b/plug-ins/file-ico/ico-load.c new file mode 100644 index 0000000..f44b805 --- /dev/null +++ b/plug-ins/file-ico/ico-load.c @@ -0,0 +1,813 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis + * + * GIMP Plug-in for Windows Icon files. + * Copyright (C) 2002 Christian Kreibich <christian@whoop.org>. + * + * 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 <png.h> + +/* #define ICO_DBG */ + +#include "ico.h" +#include "ico-load.h" + +#include "libgimp/stdplugins-intl.h" + + +#define A_VAL(p) ((guchar *)(p))[3] +#define R_VAL(p) ((guchar *)(p))[2] +#define G_VAL(p) ((guchar *)(p))[1] +#define B_VAL(p) ((guchar *)(p))[0] + +#define A_VAL_GIMP(p) ((guchar *)(p))[3] +#define R_VAL_GIMP(p) ((guchar *)(p))[0] +#define G_VAL_GIMP(p) ((guchar *)(p))[1] +#define B_VAL_GIMP(p) ((guchar *)(p))[2] + + +static gint ico_read_int8 (FILE *fp, + guint8 *data, + gint count); +static gint ico_read_int16 (FILE *fp, + guint16 *data, + gint count); +static gint ico_read_int32 (FILE *fp, + guint32 *data, + gint count); + +static gint +ico_read_int32 (FILE *fp, + guint32 *data, + gint count) +{ + gint i, total; + + total = count; + if (count > 0) + { + ico_read_int8 (fp, (guint8 *) data, count * 4); + for (i = 0; i < count; i++) + data[i] = GUINT32_FROM_LE (data[i]); + } + + return total * 4; +} + + +static gint +ico_read_int16 (FILE *fp, + guint16 *data, + gint count) +{ + gint i, total; + + total = count; + if (count > 0) + { + ico_read_int8 (fp, (guint8 *) data, count * 2); + for (i = 0; i < count; i++) + data[i] = GUINT16_FROM_LE (data[i]); + } + + return total * 2; +} + + +static gint +ico_read_int8 (FILE *fp, + guint8 *data, + gint count) +{ + gint total; + gint bytes; + + total = count; + while (count > 0) + { + bytes = fread ((gchar *) data, sizeof (gchar), count, fp); + if (bytes <= 0) /* something bad happened */ + break; + + count -= bytes; + data += bytes; + } + + return total; +} + + +static guint32 +ico_read_init (FILE *fp) +{ + IcoFileHeader header; + + /* read and check file header */ + if (! ico_read_int16 (fp, &header.reserved, 1) || + ! ico_read_int16 (fp, &header.resource_type, 1) || + ! ico_read_int16 (fp, &header.icon_count, 1) || + header.reserved != 0 || + header.resource_type != 1) + { + return 0; + } + + return header.icon_count; +} + + +static gboolean +ico_read_size (FILE *fp, + IcoLoadInfo *info) +{ + png_structp png_ptr; + png_infop info_ptr; + png_uint_32 w, h; + gint32 bpp; + gint32 color_type; + guint32 magic; + + if (fseek (fp, info->offset, SEEK_SET) < 0) + return FALSE; + + ico_read_int32 (fp, &magic, 1); + + if (magic == ICO_PNG_MAGIC) + { + png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, + NULL); + if (! png_ptr) + return FALSE; + + info_ptr = png_create_info_struct (png_ptr); + if (! info_ptr) + { + png_destroy_read_struct (&png_ptr, NULL, NULL); + return FALSE; + } + + if (setjmp (png_jmpbuf (png_ptr))) + { + png_destroy_read_struct (&png_ptr, NULL, NULL); + return FALSE; + } + png_init_io (png_ptr, fp); + png_set_sig_bytes (png_ptr, 4); + png_read_info (png_ptr, info_ptr); + png_get_IHDR (png_ptr, info_ptr, &w, &h, &bpp, &color_type, + NULL, NULL, NULL); + png_destroy_read_struct (&png_ptr, &info_ptr, NULL); + info->width = w; + info->height = h; + D(("ico_read_size: PNG: %ix%i\n", info->width, info->height)); + return TRUE; + } + else if (magic == 40) + { + if (ico_read_int32 (fp, &info->width, 1) && + ico_read_int32 (fp, &info->height, 1)) + { + info->height /= 2; + D(("ico_read_size: ICO: %ix%i\n", info->width, info->height)); + return TRUE; + } + else + { + info->width = 0; + info->height = 0; + return FALSE; + } + } + return FALSE; +} + +static IcoLoadInfo* +ico_read_info (FILE *fp, + gint icon_count, + GError **error) +{ + gint i; + IcoFileEntry *entries; + IcoLoadInfo *info; + + /* read icon entries */ + entries = g_new (IcoFileEntry, icon_count); + if (fread (entries, sizeof (IcoFileEntry), icon_count, fp) <= 0) + { + g_set_error (error, G_FILE_ERROR, 0, + _("Could not read '%lu' bytes"), + sizeof (IcoFileEntry)); + g_free (entries); + return NULL; + } + + info = g_new (IcoLoadInfo, icon_count); + for (i = 0; i < icon_count; i++) + { + info[i].width = entries[i].width; + info[i].height = entries[i].height; + info[i].bpp = GUINT16_FROM_LE (entries[i].bpp); + info[i].size = GUINT32_FROM_LE (entries[i].size); + info[i].offset = GUINT32_FROM_LE (entries[i].offset); + + if (info[i].width == 0 || info[i].height == 0) + { + ico_read_size (fp, info + i); + } + + D(("ico_read_info: %ix%i (%i bits, size: %i, offset: %i)\n", + info[i].width, info[i].height, info[i].bpp, + info[i].size, info[i].offset)); + + if (info[i].width == 0 || info[i].height == 0) + { + g_set_error (error, G_FILE_ERROR, 0, + _("Icon #%d has zero width or height"), i); + g_free (info); + g_free (entries); + return NULL; + } + } + + g_free (entries); + + return info; +} + +static gboolean +ico_read_png (FILE *fp, + guint32 header, + guchar *buf, + gint maxsize, + gint *width, + gint *height) +{ + png_structp png_ptr; + png_infop info; + png_uint_32 w; + png_uint_32 h; + gint32 bit_depth; + gint32 color_type; + guint32 **rows; + gint i; + + png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (! png_ptr) + return FALSE; + info = png_create_info_struct (png_ptr); + if (! info) + { + png_destroy_read_struct (&png_ptr, NULL, NULL); + return FALSE; + } + + if (setjmp (png_jmpbuf (png_ptr))) + { + png_destroy_read_struct (&png_ptr, &info, NULL); + return FALSE; + } + + png_init_io (png_ptr, fp); + png_set_sig_bytes (png_ptr, 4); + png_read_info (png_ptr, info); + png_get_IHDR (png_ptr, info, &w, &h, &bit_depth, &color_type, + NULL, NULL, NULL); + if (w*h*4 > maxsize) + { + png_destroy_read_struct (&png_ptr, &info, NULL); + return FALSE; + } + D(("ico_read_png: %ix%i, %i bits, %i type\n", (gint)w, (gint)h, + bit_depth, color_type)); + switch (color_type) + { + case PNG_COLOR_TYPE_GRAY: + png_set_expand_gray_1_2_4_to_8 (png_ptr); + if (bit_depth == 16) + png_set_strip_16 (png_ptr); + png_set_gray_to_rgb (png_ptr); + png_set_add_alpha (png_ptr, 0xff, PNG_FILLER_AFTER); + break; + case PNG_COLOR_TYPE_GRAY_ALPHA: + png_set_expand_gray_1_2_4_to_8 (png_ptr); + if (bit_depth == 16) + png_set_strip_16 (png_ptr); + png_set_gray_to_rgb (png_ptr); + break; + case PNG_COLOR_TYPE_PALETTE: + png_set_palette_to_rgb (png_ptr); + if (png_get_valid (png_ptr, info, PNG_INFO_tRNS)) + png_set_tRNS_to_alpha (png_ptr); + else + png_set_add_alpha (png_ptr, 0xff, PNG_FILLER_AFTER); + break; + case PNG_COLOR_TYPE_RGB: + if (bit_depth == 16) + png_set_strip_16 (png_ptr); + png_set_add_alpha (png_ptr, 0xff, PNG_FILLER_AFTER); + break; + case PNG_COLOR_TYPE_RGB_ALPHA: + if (bit_depth == 16) + png_set_strip_16 (png_ptr); + break; + } + + *width = w; + *height = h; + rows = g_new (guint32*, h); + rows[0] = (guint32*) buf; + for (i = 1; i < h; i++) + rows[i] = rows[i-1] + w; + png_read_image (png_ptr, (png_bytepp) rows); + png_destroy_read_struct (&png_ptr, &info, NULL); + g_free (rows); + return TRUE; +} + +gint +ico_get_bit_from_data (const guint8 *data, + gint line_width, + gint bit) +{ + gint line; + gint width32; + gint offset; + gint result; + + /* width per line in multiples of 32 bits */ + width32 = (line_width % 32 == 0 ? line_width/32 : line_width/32 + 1); + line = bit / line_width; + offset = bit % line_width; + + result = (data[line * width32 * 4 + offset/8] & (1 << (7 - (offset % 8)))); + + return (result ? 1 : 0); +} + + +gint +ico_get_nibble_from_data (const guint8 *data, + gint line_width, + gint nibble) +{ + gint line; + gint width32; + gint offset; + gint result; + + /* width per line in multiples of 32 bits */ + width32 = (line_width % 8 == 0 ? line_width/8 : line_width/8 + 1); + line = nibble / line_width; + offset = nibble % line_width; + + result = + (data[line * width32 * 4 + offset/2] & (0x0F << (4 * (1 - offset % 2)))); + + if (offset % 2 == 0) + result = result >> 4; + + return result; +} + +gint +ico_get_byte_from_data (const guint8 *data, + gint line_width, + gint byte) +{ + gint line; + gint width32; + gint offset; + + /* width per line in multiples of 32 bits */ + width32 = (line_width % 4 == 0 ? line_width / 4 : line_width / 4 + 1); + line = byte / line_width; + offset = byte % line_width; + + return data[line * width32 * 4 + offset]; +} + +static gboolean +ico_read_icon (FILE *fp, + guint32 header_size, + guchar *buf, + gint maxsize, + gint *width, + gint *height) +{ + IcoFileDataHeader data; + gint length; + gint x, y, w, h; + guchar *xor_map, *and_map; + guint32 *palette; + guint32 *dest_vec; + guchar *row; + gint rowstride; + + palette = NULL; + + data.header_size = header_size; + ico_read_int32 (fp, &data.width, 1); + ico_read_int32 (fp, &data.height, 1); + ico_read_int16 (fp, &data.planes, 1); + ico_read_int16 (fp, &data.bpp, 1); + ico_read_int32 (fp, &data.compression, 1); + ico_read_int32 (fp, &data.image_size, 1); + ico_read_int32 (fp, &data.x_res, 1); + ico_read_int32 (fp, &data.y_res, 1); + ico_read_int32 (fp, &data.used_clrs, 1); + ico_read_int32 (fp, &data.important_clrs, 1); + + D((" header size %i, " + "w %i, h %i, planes %i, size %i, bpp %i, used %i, imp %i.\n", + data.header_size, data.width, data.height, + data.planes, data.image_size, data.bpp, + data.used_clrs, data.important_clrs)); + + if (data.planes != 1 || + data.compression != 0) + { + D(("skipping image: invalid header\n")); + return FALSE; + } + + if (data.bpp != 1 && + data.bpp != 4 && + data.bpp != 8 && + data.bpp != 24 && + data.bpp != 32) + { + D(("skipping image: invalid depth: %i\n", data.bpp)); + return FALSE; + } + + if (data.width * data.height * 2 > maxsize) + { + D(("skipping image: too large\n")); + return FALSE; + } + + w = data.width; + h = data.height / 2; + + if (data.bpp <= 8) + { + if (data.used_clrs == 0) + data.used_clrs = (1 << data.bpp); + + D((" allocating a %i-slot palette for %i bpp.\n", + data.used_clrs, data.bpp)); + + palette = g_new0 (guint32, data.used_clrs); + ico_read_int8 (fp, (guint8 *) palette, data.used_clrs * 4); + } + + xor_map = ico_alloc_map (w, h, data.bpp, &length); + ico_read_int8 (fp, xor_map, length); + D((" length of xor_map: %i\n", length)); + + /* Read in and_map. It's padded out to 32 bits per line: */ + and_map = ico_alloc_map (w, h, 1, &length); + ico_read_int8 (fp, and_map, length); + D((" length of and_map: %i\n", length)); + + dest_vec = (guint32 *) buf; + switch (data.bpp) + { + case 1: + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) + { + guint32 color = palette[ico_get_bit_from_data (xor_map, + w, y * w + x)]; + guint32 *dest = dest_vec + (h - 1 - y) * w + x; + + R_VAL_GIMP (dest) = R_VAL (&color); + G_VAL_GIMP (dest) = G_VAL (&color); + B_VAL_GIMP (dest) = B_VAL (&color); + + if (ico_get_bit_from_data (and_map, w, y * w + x)) + A_VAL_GIMP (dest) = 0; + else + A_VAL_GIMP (dest) = 255; + } + break; + + case 4: + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) + { + guint32 color = palette[ico_get_nibble_from_data (xor_map, + w, y * w + x)]; + guint32 *dest = dest_vec + (h - 1 - y) * w + x; + + R_VAL_GIMP (dest) = R_VAL (&color); + G_VAL_GIMP (dest) = G_VAL (&color); + B_VAL_GIMP (dest) = B_VAL (&color); + + if (ico_get_bit_from_data (and_map, w, y * w + x)) + A_VAL_GIMP (dest) = 0; + else + A_VAL_GIMP (dest) = 255; + } + break; + + case 8: + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) + { + guint32 color = palette[ico_get_byte_from_data (xor_map, + w, y * w + x)]; + guint32 *dest = dest_vec + (h - 1 - y) * w + x; + + R_VAL_GIMP (dest) = R_VAL (&color); + G_VAL_GIMP (dest) = G_VAL (&color); + B_VAL_GIMP (dest) = B_VAL (&color); + + if (ico_get_bit_from_data (and_map, w, y * w + x)) + A_VAL_GIMP (dest) = 0; + else + A_VAL_GIMP (dest) = 255; + } + break; + + default: + { + gint bytespp = data.bpp / 8; + + rowstride = ico_rowstride (w, data.bpp); + + for (y = 0; y < h; y++) + { + row = xor_map + rowstride * y; + + for (x = 0; x < w; x++) + { + guint32 *dest = dest_vec + (h - 1 - y) * w + x; + + B_VAL_GIMP (dest) = row[0]; + G_VAL_GIMP (dest) = row[1]; + R_VAL_GIMP (dest) = row[2]; + + if (data.bpp < 32) + { + if (ico_get_bit_from_data (and_map, w, y * w + x)) + A_VAL_GIMP (dest) = 0; + else + A_VAL_GIMP (dest) = 255; + } + else + { + A_VAL_GIMP (dest) = row[3]; + } + + row += bytespp; + } + } + } + } + if (palette) + g_free (palette); + g_free (xor_map); + g_free (and_map); + *width = w; + *height = h; + return TRUE; +} + +static gint32 +ico_load_layer (FILE *fp, + gint32 image, + gint32 icon_num, + guchar *buf, + gint maxsize, + IcoLoadInfo *info) +{ + gint width, height; + gint32 layer; + guint32 first_bytes; + GeglBuffer *buffer; + gchar name[ICO_MAXBUF]; + + if (fseek (fp, info->offset, SEEK_SET) < 0 || + ! ico_read_int32 (fp, &first_bytes, 1)) + return -1; + + if (first_bytes == ICO_PNG_MAGIC) + { + if (!ico_read_png (fp, first_bytes, buf, maxsize, &width, &height)) + return -1; + } + else if (first_bytes == 40) + { + if (!ico_read_icon (fp, first_bytes, buf, maxsize, &width, &height)) + return -1; + } + else + { + return -1; + } + + /* read successfully. add to image */ + g_snprintf (name, sizeof (name), _("Icon #%i"), icon_num+1); + layer = gimp_layer_new (image, name, width, height, + GIMP_RGBA_IMAGE, + 100, + gimp_image_get_default_new_layer_mode (image)); + gimp_image_insert_layer (image, layer, -1, icon_num); + + buffer = gimp_drawable_get_buffer (layer); + + gegl_buffer_set (buffer, GEGL_RECTANGLE (0, 0, width, height), 0, + NULL, buf, GEGL_AUTO_ROWSTRIDE); + + g_object_unref (buffer); + + return layer; +} + + +gint32 +ico_load_image (const gchar *filename, + GError **error) +{ + FILE *fp; + IcoLoadInfo *info; + gint max_width, max_height; + gint i; + gint32 image; + guchar *buf; + guint icon_count; + gint maxsize; + + gimp_progress_init_printf (_("Opening '%s'"), + gimp_filename_to_utf8 (filename)); + + fp = g_fopen (filename, "rb"); + if (! fp) + { + 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)); + return -1; + } + + icon_count = ico_read_init (fp); + if (!icon_count) + { + fclose (fp); + return -1; + } + + info = ico_read_info (fp, icon_count, error); + if (! info) + { + fclose (fp); + return -1; + } + + /* find width and height of image */ + max_width = 0; + max_height = 0; + for (i = 0; i < icon_count; i++) + { + if (info[i].width > max_width) + max_width = info[i].width; + if (info[i].height > max_height) + max_height = info[i].height; + } + if (max_width <= 0 || max_height <= 0) + { + g_free (info); + fclose (fp); + return -1; + } + D(("image size: %ix%i\n", max_width, max_height)); + + image = gimp_image_new (max_width, max_height, GIMP_RGB); + gimp_image_set_filename (image, filename); + + maxsize = max_width * max_height * 4; + buf = g_new (guchar, max_width * max_height * 4); + for (i = 0; i < icon_count; i++) + { + ico_load_layer (fp, image, i, buf, maxsize, info+i); + } + g_free (buf); + g_free (info); + fclose (fp); + + gimp_progress_update (1.0); + + return image; +} + +gint32 +ico_load_thumbnail_image (const gchar *filename, + gint *width, + gint *height, + GError **error) +{ + FILE *fp; + IcoLoadInfo *info; + gint32 image; + gint w = 0; + gint h = 0; + gint bpp = 0; + gint match = 0; + gint i, icon_count; + guchar *buf; + + gimp_progress_init_printf (_("Opening thumbnail for '%s'"), + gimp_filename_to_utf8 (filename)); + + fp = g_fopen (filename, "rb"); + if (! fp) + { + 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)); + return -1; + } + + icon_count = ico_read_init (fp); + if (! icon_count) + { + fclose (fp); + return -1; + } + + D(("*** %s: Microsoft icon file, containing %i icon(s)\n", + filename, icon_count)); + + info = ico_read_info (fp, icon_count, error); + if (! info) + { + fclose (fp); + return -1; + } + + /* Do a quick scan of the icons in the file to find the best match */ + for (i = 0; i < icon_count; i++) + { + if ((info[i].width > w && w < *width) || + (info[i].height > h && h < *height)) + { + w = info[i].width; + h = info[i].height; + bpp = info[i].bpp; + + match = i; + } + else if (w == info[i].width && + h == info[i].height && + info[i].bpp > bpp) + { + /* better quality */ + bpp = info[i].bpp; + match = i; + } + } + + if (w <= 0 || h <= 0) + return -1; + + image = gimp_image_new (w, h, GIMP_RGB); + buf = g_new (guchar, w*h*4); + ico_load_layer (fp, image, match, buf, w*h*4, info+match); + g_free (buf); + + *width = w; + *height = h; + + D(("*** thumbnail successfully loaded.\n\n")); + + gimp_progress_update (1.0); + + g_free (info); + fclose (fp); + + return image; +} diff --git a/plug-ins/file-ico/ico-load.h b/plug-ins/file-ico/ico-load.h new file mode 100644 index 0000000..8749fd9 --- /dev/null +++ b/plug-ins/file-ico/ico-load.h @@ -0,0 +1,43 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis + * + * GIMP Plug-in for Windows Icon files. + * Copyright (C) 2002 Christian Kreibich <christian@whoop.org>. + * + * 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 __ICO_LOAD_H__ +#define __ICO_LOAD_H__ + + +gint32 ico_load_image (const gchar *filename, + GError **error); +gint32 ico_load_thumbnail_image (const gchar *filename, + gint *width, + gint *height, + GError **error); + +gint ico_get_bit_from_data (const guint8 *data, + gint line_width, + gint bit); +gint ico_get_nibble_from_data (const guint8 *data, + gint line_width, + gint nibble); +gint ico_get_byte_from_data (const guint8 *data, + gint line_width, + gint byte); + + +#endif /* __ICO_LOAD_H__ */ diff --git a/plug-ins/file-ico/ico-save.c b/plug-ins/file-ico/ico-save.c new file mode 100644 index 0000000..f8ce431 --- /dev/null +++ b/plug-ins/file-ico/ico-save.c @@ -0,0 +1,1176 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis + * + * GIMP Plug-in for Windows Icon files. + * Copyright (C) 2002 Christian Kreibich <christian@whoop.org>. + * + * 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 <png.h> + +/* #define ICO_DBG */ + +#include "ico.h" +#include "ico-load.h" +#include "ico-save.h" +#include "ico-dialog.h" + +#include "libgimp/stdplugins-intl.h" + + +static gint ico_write_int8 (FILE *fp, + guint8 *data, + gint count); +static gint ico_write_int16 (FILE *fp, + guint16 *data, + gint count); +static gint ico_write_int32 (FILE *fp, + guint32 *data, + gint count); + +/* Helpers to set bits in a *cleared* data chunk */ +static void ico_set_bit_in_data (guint8 *data, + gint line_width, + gint bit_num, + gint bit_val); +static void ico_set_nibble_in_data (guint8 *data, + gint line_width, + gint nibble_num, + gint nibble_val); +static void ico_set_byte_in_data (guint8 *data, + gint line_width, + gint byte_num, + gint byte_val); + +static gint ico_get_layer_num_colors (gint32 layer, + gboolean *uses_alpha_levels); +static void ico_image_get_reduced_buf (guint32 layer, + gint bpp, + gint *num_colors, + guchar **cmap_out, + guchar **buf_out); + + +static gint +ico_write_int32 (FILE *fp, + guint32 *data, + gint count) +{ + gint total; + + total = count; + if (count > 0) + { +#if (G_BYTE_ORDER == G_BIG_ENDIAN) + gint i; + + for (i = 0; i < count; i++) + data[i] = GUINT32_FROM_LE (data[i]); +#endif + + ico_write_int8 (fp, (guint8 *) data, count * 4); + +#if (G_BYTE_ORDER == G_BIG_ENDIAN) + /* Put it back like we found it */ + for (i = 0; i < count; i++) + data[i] = GUINT32_FROM_LE (data[i]); +#endif + } + + return total * 4; +} + + +static gint +ico_write_int16 (FILE *fp, + guint16 *data, + gint count) +{ + gint total; + + total = count; + if (count > 0) + { +#if (G_BYTE_ORDER == G_BIG_ENDIAN) + gint i; + + for (i = 0; i < count; i++) + data[i] = GUINT16_FROM_LE (data[i]); +#endif + + ico_write_int8 (fp, (guint8 *) data, count * 2); + +#if (G_BYTE_ORDER == G_BIG_ENDIAN) + /* Put it back like we found it */ + for (i = 0; i < count; i++) + data[i] = GUINT16_FROM_LE (data[i]); +#endif + } + + return total * 2; +} + + +static gint +ico_write_int8 (FILE *fp, + guint8 *data, + gint count) +{ + gint total; + gint bytes; + + total = count; + while (count > 0) + { + bytes = fwrite ((gchar *) data, sizeof (gchar), count, fp); + if (bytes <= 0) /* something bad happened */ + break; + count -= bytes; + data += bytes; + } + + return total; +} + + +static void +ico_save_init (gint32 image_ID, + IcoSaveInfo *info) +{ + gint *layers; + gint i, num_colors; + gboolean uses_alpha_values = FALSE; + + layers = gimp_image_get_layers (image_ID, &info->num_icons); + info->layers = layers; + info->depths = g_new (gint, info->num_icons); + info->default_depths = g_new (gint, info->num_icons); + info->compress = g_new (gboolean, info->num_icons); + + /* Limit the color depths to values that don't cause any color loss -- + the user should pick these anyway, so we can save her some time. + If the user wants to lose some colors, the settings can always be changed + in the dialog: */ + for (i = 0; i < info->num_icons; i++) + { + num_colors = ico_get_layer_num_colors (layers[i], &uses_alpha_values); + + if (!uses_alpha_values) + { + if (num_colors <= 2) + { + /* Let's suggest monochrome */ + info->default_depths [i] = 1; + } + else if (num_colors <= 16) + { + /* Let's suggest 4bpp */ + info->default_depths [i] = 4; + } + else if (num_colors <= 256) + { + /* Let's suggest 8bpp */ + info->default_depths [i] = 8; + } + else + { + /* Let's suggest 24bpp */ + info->default_depths [i] = 24; + } + } + else + { + /* Otherwise, or if real alpha levels are used, stick with 32bpp */ + info->default_depths [i] = 32; + } + + /* vista icons */ + if (gimp_drawable_width (layers[i]) > 255 + || gimp_drawable_height (layers[i]) > 255 ) + { + info->compress[i] = TRUE; + } + else + { + info->compress[i] = FALSE; + } + } + + /* set with default values */ + memcpy (info->depths, info->default_depths, + sizeof (gint) * info->num_icons); +} + + + +static gboolean +ico_save_dialog (gint32 image_ID, + IcoSaveInfo *info) +{ + GtkWidget *dialog; + gint i; + gint response; + + gimp_ui_init (PLUG_IN_BINARY, TRUE); + + dialog = ico_dialog_new (info); + for (i = 0; i < info->num_icons; i++) + { + /* if (gimp_layer_get_visible(layers[i])) */ + ico_dialog_add_icon (dialog, info->layers[i], i); + } + + /* Scale the thing to approximately fit its content, but not too large ... */ + gtk_window_set_default_size (GTK_WINDOW (dialog), + -1, + 200 + (info->num_icons > 4 ? + 500 : info->num_icons * 120)); + + gtk_widget_show (dialog); + + response = gimp_dialog_run (GIMP_DIALOG (dialog)); + + gtk_widget_destroy (dialog); + + return (response == GTK_RESPONSE_OK); +} + +static void +ico_set_bit_in_data (guint8 *data, + gint line_width, + gint bit_num, + gint bit_val) +{ + gint line; + gint width32; + gint offset; + + /* width per line in multiples of 32 bits */ + width32 = (line_width % 32 == 0 ? line_width/32 : line_width/32 + 1); + + line = bit_num / line_width; + offset = bit_num % line_width; + bit_val = bit_val & 0x00000001; + + data[line * width32 * 4 + offset/8] |= (bit_val << (7 - (offset % 8))); +} + + +static void +ico_set_nibble_in_data (guint8 *data, + gint line_width, + gint nibble_num, + gint nibble_val) +{ + gint line; + gint width8; + gint offset; + + /* width per line in multiples of 32 bits */ + width8 = (line_width % 8 == 0 ? line_width/8 : line_width/8 + 1); + + line = nibble_num / line_width; + offset = nibble_num % line_width; + nibble_val = nibble_val & 0x0000000F; + + data[line * width8 * 4 + offset/2] |= + (nibble_val << (4 * (1 - (offset % 2)))); +} + + +static void +ico_set_byte_in_data (guint8 *data, + gint line_width, + gint byte_num, + gint byte_val) +{ + gint line; + gint width4; + gint offset; + gint byte; + + /* width per line in multiples of 32 bits */ + width4 = (line_width % 4 == 0 ? line_width/4 : line_width/4 + 1); + + line = byte_num / line_width; + offset = byte_num % line_width; + byte = byte_val & 0x000000FF; + + data[line * width4 * 4 + offset] = byte; +} + + +/* Create a colormap from the given buffer data */ +static guint32 * +ico_create_palette (const guchar *cmap, + gint num_colors, + gint num_colors_used, + gint *black_slot) +{ + guchar *palette; + gint i; + + g_return_val_if_fail (cmap != NULL || num_colors_used == 0, NULL); + g_return_val_if_fail (num_colors_used <= num_colors, NULL); + + palette = g_new0 (guchar, num_colors * 4); + *black_slot = -1; + + for (i = 0; i < num_colors_used; i++) + { + palette[i * 4 + 2] = cmap[i * 3]; + palette[i * 4 + 1] = cmap[i * 3 + 1]; + palette[i * 4] = cmap[i * 3 + 2]; + + if ((cmap[i*3] == 0) && + (cmap[i*3 + 1] == 0) && + (cmap[i*3 + 2] == 0)) + { + *black_slot = i; + } + } + + if (*black_slot == -1) + { + if (num_colors_used == num_colors) + { + D(("WARNING -- no room for black, this shouldn't happen.\n")); + *black_slot = num_colors - 1; + + palette[(num_colors-1) * 4] = 0; + palette[(num_colors-1) * 4 + 1] = 0; + palette[(num_colors-1) * 4 + 2] = 0; + } + else + { + *black_slot = num_colors_used; + } + } + + return (guint32 *) palette; +} + + +static GHashTable * +ico_create_color_to_palette_map (const guint32 *palette, + gint num_colors) +{ + GHashTable *hash; + gint i; + + hash = g_hash_table_new_full (g_int_hash, g_int_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) g_free); + + for (i = 0; i < num_colors; i++) + { + const guint8 *pixel = (const guint8 *) &palette[i]; + gint *color; + gint *slot; + + color = g_new (gint, 1); + slot = g_new (gint, 1); + + *color = (pixel[2] << 16 | pixel[1] << 8 | pixel[0]); + *slot = i; + + g_hash_table_insert (hash, color, slot); + } + + return hash; +} + +static gint +ico_get_palette_index (GHashTable *hash, + gint red, + gint green, + gint blue) +{ + gint color = 0; + gint *slot; + + color = (red << 16 | green << 8 | blue); + slot = g_hash_table_lookup (hash, &color); + + if (!slot) + { + return 0; + } + + return *slot; +} + +static gint +ico_get_layer_num_colors (gint32 layer, + gboolean *uses_alpha_levels) +{ + gint w, h; + gint bpp; + gint num_colors = 0; + guint num_pixels; + guchar *buf; + guchar *src; + guint32 *colors; + guint32 *c; + GHashTable *hash; + GeglBuffer *buffer = gimp_drawable_get_buffer (layer); + const Babl *format; + + w = gegl_buffer_get_width (buffer); + h = gegl_buffer_get_height (buffer); + + num_pixels = w * h; + + switch (gimp_drawable_type (layer)) + { + case GIMP_RGB_IMAGE: + format = babl_format ("R'G'B' u8"); + break; + + case GIMP_RGBA_IMAGE: + format = babl_format ("R'G'B'A u8"); + break; + + case GIMP_GRAY_IMAGE: + format = babl_format ("Y' u8"); + break; + + case GIMP_GRAYA_IMAGE: + format = babl_format ("Y'A u8"); + break; + + case GIMP_INDEXED_IMAGE: + case GIMP_INDEXEDA_IMAGE: + format = gegl_buffer_get_format (buffer); + /* It is possible to count the colors of indexed image more easily + * with gimp_image_get_colormap(), but counting only the colors + * actually used will allow more efficient bpp if possible. */ + break; + + default: + g_return_val_if_reached (0); + } + + bpp = babl_format_get_bytes_per_pixel (format); + + buf = src = g_new (guchar, num_pixels * bpp); + + gegl_buffer_get (buffer, GEGL_RECTANGLE (0, 0, w, h), 1.0, + format, buf, + GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); + + g_object_unref (buffer); + + hash = g_hash_table_new (g_int_hash, g_int_equal); + *uses_alpha_levels = FALSE; + + colors = c = g_new (guint32, num_pixels); + + switch (bpp) + { + case 1: + while (num_pixels--) + { + *c = *src; + g_hash_table_insert (hash, c, c); + src++; + c++; + } + break; + + case 2: + while (num_pixels--) + { + *c = (src[1] << 8) | src[0]; + if (src[1] != 0 && src[1] != 255) + *uses_alpha_levels = TRUE; + g_hash_table_insert (hash, c, c); + src += 2; + c++; + } + break; + + case 3: + while (num_pixels--) + { + *c = (src[2] << 16) | (src[1] << 8) | src[0]; + g_hash_table_insert (hash, c, c); + src += 3; + c++; + } + break; + + case 4: + while (num_pixels--) + { + *c = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + if (src[3] != 0 && src[3] != 255) + *uses_alpha_levels = TRUE; + g_hash_table_insert (hash, c, c); + src += 4; + c++; + } + break; + } + + num_colors = g_hash_table_size (hash); + + g_hash_table_destroy (hash); + + g_free (colors); + g_free (buf); + + return num_colors; +} + +gboolean +ico_cmap_contains_black (const guchar *cmap, + gint num_colors) +{ + gint i; + + for (i = 0; i < num_colors; i++) + { + if ((cmap[3 * i ] == 0) && + (cmap[3 * i + 1] == 0) && + (cmap[3 * i + 2] == 0)) + { + return TRUE; + } + } + + return FALSE; +} + +static void +ico_image_get_reduced_buf (guint32 layer, + gint bpp, + gint *num_colors, + guchar **cmap_out, + guchar **buf_out) +{ + gint32 tmp_image; + gint32 tmp_layer; + gint w, h; + guchar *buf; + guchar *cmap = NULL; + GeglBuffer *buffer = gimp_drawable_get_buffer (layer); + const Babl *format; + + w = gegl_buffer_get_width (buffer); + h = gegl_buffer_get_height (buffer); + + switch (gimp_drawable_type (layer)) + { + case GIMP_RGB_IMAGE: + format = babl_format ("R'G'B' u8"); + break; + + case GIMP_RGBA_IMAGE: + format = babl_format ("R'G'B'A u8"); + break; + + case GIMP_GRAY_IMAGE: + format = babl_format ("Y' u8"); + break; + + case GIMP_GRAYA_IMAGE: + format = babl_format ("Y'A u8"); + break; + + case GIMP_INDEXED_IMAGE: + case GIMP_INDEXEDA_IMAGE: + format = gegl_buffer_get_format (buffer); + break; + + default: + g_return_if_reached (); + } + + *num_colors = 0; + + buf = g_new (guchar, w * h * 4); + + if (bpp <= 8 || bpp == 24 || babl_format_get_bytes_per_pixel (format) != 4) + { + gint32 image = gimp_item_get_image (layer); + GeglBuffer *tmp; + + tmp_image = gimp_image_new (w, h, gimp_image_base_type (image)); + gimp_image_undo_disable (tmp_image); + + if (gimp_drawable_is_indexed (layer)) + { + guchar *cmap; + gint num_colors; + + cmap = gimp_image_get_colormap (image, &num_colors); + gimp_image_set_colormap (tmp_image, cmap, num_colors); + g_free (cmap); + } + + tmp_layer = gimp_layer_new (tmp_image, "tmp", w, h, + gimp_drawable_type (layer), + 100, + gimp_image_get_default_new_layer_mode (tmp_image)); + gimp_image_insert_layer (tmp_image, tmp_layer, -1, 0); + + tmp = gimp_drawable_get_buffer (tmp_layer); + + gegl_buffer_get (buffer, GEGL_RECTANGLE (0, 0, w, h), 1.0, + format, buf, + GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); + + gegl_buffer_copy (buffer, NULL, GEGL_ABYSS_NONE, tmp, NULL); + + g_object_unref (tmp); + + if (! gimp_drawable_is_rgb (tmp_layer)) + gimp_image_convert_rgb (tmp_image); + + if (bpp <= 8) + { + gimp_image_convert_indexed (tmp_image, + GIMP_CONVERT_DITHER_FS, + GIMP_CONVERT_PALETTE_GENERATE, + 1 << bpp, TRUE, FALSE, "dummy"); + + cmap = gimp_image_get_colormap (tmp_image, num_colors); + + if (*num_colors == (1 << bpp) && + ! ico_cmap_contains_black (cmap, *num_colors)) + { + /* Windows icons with color maps need the color black. + * We need to eliminate one more color to make room for black. + */ + + if (gimp_drawable_is_indexed (layer)) + { + g_free (cmap); + cmap = gimp_image_get_colormap (image, num_colors); + gimp_image_set_colormap (tmp_image, cmap, *num_colors); + } + else if (gimp_drawable_is_gray (layer)) + { + gimp_image_convert_grayscale (tmp_image); + } + else + { + gimp_image_convert_rgb (tmp_image); + } + + tmp = gimp_drawable_get_buffer (tmp_layer); + + gegl_buffer_set (tmp, GEGL_RECTANGLE (0, 0, w, h), 0, + format, buf, GEGL_AUTO_ROWSTRIDE); + + g_object_unref (tmp); + + if (! gimp_drawable_is_rgb (layer)) + gimp_image_convert_rgb (tmp_image); + + gimp_image_convert_indexed (tmp_image, + GIMP_CONVERT_DITHER_FS, + GIMP_CONVERT_PALETTE_GENERATE, + (1<<bpp) - 1, TRUE, FALSE, "dummy"); + g_free (cmap); + cmap = gimp_image_get_colormap (tmp_image, num_colors); + } + + gimp_image_convert_rgb (tmp_image); + } + else if (bpp == 24) + { + GimpParam *return_vals; + gint n_return_vals; + + return_vals = + gimp_run_procedure ("plug-in-threshold-alpha", &n_return_vals, + GIMP_PDB_INT32, GIMP_RUN_NONINTERACTIVE, + GIMP_PDB_IMAGE, tmp_image, + GIMP_PDB_DRAWABLE, tmp_layer, + GIMP_PDB_INT32, ICO_ALPHA_THRESHOLD, + GIMP_PDB_END); + gimp_destroy_params (return_vals, n_return_vals); + } + + gimp_layer_add_alpha (tmp_layer); + + tmp = gimp_drawable_get_buffer (tmp_layer); + + gegl_buffer_get (tmp, GEGL_RECTANGLE (0, 0, w, h), 1.0, + NULL, buf, + GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); + + g_object_unref (tmp); + + gimp_image_delete (tmp_image); + } + else + { + gegl_buffer_get (buffer, GEGL_RECTANGLE (0, 0, w, h), 1.0, + format, buf, + GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); + } + + g_object_unref (buffer); + + *cmap_out = cmap; + *buf_out = buf; +} + +static gboolean +ico_write_png (FILE *fp, + gint32 layer, + gint32 depth) +{ + png_structp png_ptr; + png_infop info_ptr; + png_byte **row_pointers; + gint i, rowstride; + gint width, height; + gint num_colors_used; + guchar *palette; + guchar *buf; + + row_pointers = NULL; + palette = NULL; + buf = NULL; + + width = gimp_drawable_width (layer); + height = gimp_drawable_height (layer); + + png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if ( !png_ptr ) + return FALSE; + + info_ptr = png_create_info_struct (png_ptr); + if ( !info_ptr ) + { + png_destroy_write_struct (&png_ptr, NULL); + return FALSE; + } + + if (setjmp (png_jmpbuf (png_ptr))) + { + png_destroy_write_struct (&png_ptr, &info_ptr); + if ( row_pointers ) + g_free (row_pointers); + if (palette) + g_free (palette); + if (buf) + g_free (buf); + return FALSE; + } + + ico_image_get_reduced_buf (layer, depth, &num_colors_used, + &palette, &buf); + + png_init_io (png_ptr, fp); + png_set_IHDR (png_ptr, info_ptr, width, height, + 8, + PNG_COLOR_TYPE_RGBA, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + png_write_info (png_ptr, info_ptr); + + rowstride = ico_rowstride (width, 32); + row_pointers = g_new (png_byte*, height); + for (i = 0; i < height; i++) + { + row_pointers[i] = buf + rowstride * i; + } + png_write_image (png_ptr, row_pointers); + + row_pointers = NULL; + + png_write_end (png_ptr, info_ptr); + png_destroy_write_struct (&png_ptr, &info_ptr); + + g_free (row_pointers); + g_free (palette); + g_free (buf); + return TRUE; +} + +static gboolean +ico_write_icon (FILE *fp, + gint32 layer, + gint32 depth) +{ + IcoFileDataHeader header; + gint and_len, xor_len, palette_index, x, y; + gint num_colors = 0, num_colors_used = 0, black_index = 0; + gint width, height; + guchar *buf = NULL, *pixel; + guint32 *buf32; + guchar *palette; + GHashTable *color_to_slot = NULL; + guchar *xor_map, *and_map; + + guint32 *palette32 = NULL; + gint palette_len = 0; + + guint8 alpha_threshold; + + D(("Creating data structures for icon %i ------------------------\n", + num_icon)); + + width = gimp_drawable_width (layer); + height = gimp_drawable_height (layer); + + header.header_size = 40; + header.width = width; + header.height = 2 * height; + header.planes = 1; + header.bpp = depth; + header.compression = 0; + header.image_size = 0; + header.x_res = 0; + header.y_res = 0; + header.used_clrs = 0; + header.important_clrs = 0; + + num_colors = (1L << header.bpp); + + D((" header size %i, w %i, h %i, planes %i, bpp %i\n", + header.header_size, header.width, header.height, header.planes, + header.bpp)); + + /* Reduce colors in copy of image */ + ico_image_get_reduced_buf (layer, header.bpp, &num_colors_used, + &palette, &buf); + buf32 = (guint32 *) buf; + + /* Set up colormap and and_map when necessary: */ + if (header.bpp <= 8) + { + /* Create a colormap */ + palette32 = ico_create_palette (palette, + num_colors, num_colors_used, + &black_index); + palette_len = num_colors * 4; + + color_to_slot = ico_create_color_to_palette_map (palette32, + num_colors_used); + D((" created %i-slot colormap with %i colors, black at slot %i\n", + num_colors, num_colors_used, black_index)); + } + + /* Create and_map. It's padded out to 32 bits per line: */ + and_map = ico_alloc_map (width, height, 1, &and_len); + + /* 32-bit bitmaps have an alpha channel as well as a mask. Any partially or + * fully opaque pixel should have an opaque mask (some ICO code in Windows + * draws pixels as black if they have a transparent mask but a non-transparent + * alpha value). + * + * For bitmaps without an alpha channel, we use the normal threshold to build + * the mask, so that the mask is as close as possible to the original alpha + * channel. + */ + alpha_threshold = header.bpp < 32 ? ICO_ALPHA_THRESHOLD : 0; + + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) + { + pixel = (guint8 *) &buf32[y * width + x]; + + ico_set_bit_in_data (and_map, width, + (height - y -1) * width + x, + (pixel[3] > alpha_threshold ? 0 : 1)); + } + + xor_map = ico_alloc_map (width, height, header.bpp, &xor_len); + + /* Now fill in the xor map */ + switch (header.bpp) + { + case 1: + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) + { + pixel = (guint8 *) &buf32[y * width + x]; + palette_index = ico_get_palette_index (color_to_slot, pixel[0], + pixel[1], pixel[2]); + + if (ico_get_bit_from_data (and_map, width, + (height - y - 1) * width + x)) + { + ico_set_bit_in_data (xor_map, width, + (height - y -1) * width + x, + black_index); + } + else + { + ico_set_bit_in_data (xor_map, width, + (height - y -1) * width + x, + palette_index); + } + } + break; + + case 4: + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) + { + pixel = (guint8 *) &buf32[y * width + x]; + palette_index = ico_get_palette_index(color_to_slot, pixel[0], + pixel[1], pixel[2]); + + if (ico_get_bit_from_data (and_map, width, + (height - y - 1) * width + x)) + { + ico_set_nibble_in_data (xor_map, width, + (height - y -1) * width + x, + black_index); + } + else + { + ico_set_nibble_in_data (xor_map, width, + (height - y - 1) * width + x, + palette_index); + } + } + break; + + case 8: + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) + { + pixel = (guint8 *) &buf32[y * width + x]; + palette_index = ico_get_palette_index (color_to_slot, + pixel[0], + pixel[1], + pixel[2]); + + if (ico_get_bit_from_data (and_map, width, + (height - y - 1) * width + x)) + { + ico_set_byte_in_data (xor_map, width, + (height - y - 1) * width + x, + black_index); + } + else + { + ico_set_byte_in_data (xor_map, width, + (height - y - 1) * width + x, + palette_index); + } + + } + break; + + case 24: + for (y = 0; y < height; y++) + { + guchar *row = xor_map + (xor_len * (height - y - 1) / height); + + for (x = 0; x < width; x++) + { + pixel = (guint8 *) &buf32[y * width + x]; + + row[0] = pixel[2]; + row[1] = pixel[1]; + row[2] = pixel[0]; + + row += 3; + } + } + break; + + default: + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) + { + pixel = (guint8 *) &buf32[y * width + x]; + + ((guint32 *) xor_map)[(height - y -1) * width + x] = + GUINT32_TO_LE ((pixel[0] << 16) | + (pixel[1] << 8) | + (pixel[2]) | + (pixel[3] << 24)); + } + } + + D((" filled and_map of length %i, xor_map of length %i\n", + and_len, xor_len)); + + if (color_to_slot) + g_hash_table_destroy (color_to_slot); + + g_free (palette); + g_free (buf); + + ico_write_int32 (fp, (guint32*) &header, 3); + ico_write_int16 (fp, &header.planes, 2); + ico_write_int32 (fp, &header.compression, 6); + + if (palette_len) + ico_write_int8 (fp, (guint8 *) palette32, palette_len); + + ico_write_int8 (fp, xor_map, xor_len); + ico_write_int8 (fp, and_map, and_len); + + g_free (palette32); + g_free (xor_map); + g_free (and_map); + + return TRUE; +} + +static void +ico_save_info_free (IcoSaveInfo *info) +{ + g_free (info->depths); + g_free (info->default_depths); + g_free (info->compress); + g_free (info->layers); + memset (info, 0, sizeof (IcoSaveInfo)); +} + +GimpPDBStatusType +ico_save_image (const gchar *filename, + gint32 image, + gint32 run_mode, + GError **error) +{ + FILE *fp; + + gint i; + gint width, height; + IcoSaveInfo info; + IcoFileHeader header; + IcoFileEntry *entries; + gboolean saved; + + D(("*** Exporting Microsoft icon file %s\n", filename)); + + ico_save_init (image, &info); + + if (run_mode == GIMP_RUN_INTERACTIVE) + { + /* Allow user to override default values */ + if ( !ico_save_dialog (image, &info)) + return GIMP_PDB_CANCEL; + } + + gimp_progress_init_printf (_("Exporting '%s'"), + gimp_filename_to_utf8 (filename)); + + if (! (fp = g_fopen (filename, "wb"))) + { + 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; + } + + header.reserved = 0; + header.resource_type = 1; + header.icon_count = info.num_icons; + if ( !ico_write_int16 (fp, &header.reserved, 1) + || !ico_write_int16 (fp, &header.resource_type, 1) + || !ico_write_int16 (fp, &header.icon_count, 1) ) + { + ico_save_info_free (&info); + fclose (fp); + return GIMP_PDB_EXECUTION_ERROR; + } + + entries = g_new0 (IcoFileEntry, info.num_icons); + if (fwrite (entries, sizeof (IcoFileEntry), info.num_icons, fp) <= 0) + { + ico_save_info_free (&info); + g_free (entries); + fclose (fp); + return GIMP_PDB_EXECUTION_ERROR; + } + + for (i = 0; i < info.num_icons; i++) + { + gimp_progress_update ((gdouble)i / (gdouble)info.num_icons); + + width = gimp_drawable_width (info.layers[i]); + height = gimp_drawable_height (info.layers[i]); + if (width <= 255 && height <= 255) + { + entries[i].width = width; + entries[i].height = height; + } + else + { + entries[i].width = 0; + entries[i].height = 0; + } + if ( info.depths[i] <= 8 ) + entries[i].num_colors = 1 << info.depths[i]; + else + entries[i].num_colors = 0; + entries[i].reserved = 0; + entries[i].planes = 1; + entries[i].bpp = info.depths[i]; + entries[i].offset = ftell (fp); + + if (info.compress[i]) + saved = ico_write_png (fp, info.layers[i], info.depths[i]); + else + saved = ico_write_icon (fp, info.layers[i], info.depths[i]); + + if (!saved) + { + ico_save_info_free (&info); + fclose (fp); + return GIMP_PDB_EXECUTION_ERROR; + } + + entries[i].size = ftell (fp) - entries[i].offset; + } + + for (i = 0; i < info.num_icons; i++) + { + entries[i].planes = GUINT16_TO_LE (entries[i].planes); + entries[i].bpp = GUINT16_TO_LE (entries[i].bpp); + entries[i].size = GUINT32_TO_LE (entries[i].size); + entries[i].offset = GUINT32_TO_LE (entries[i].offset); + } + + if (fseek (fp, sizeof(IcoFileHeader), SEEK_SET) < 0 + || fwrite (entries, sizeof (IcoFileEntry), info.num_icons, fp) <= 0) + { + ico_save_info_free (&info); + fclose (fp); + return GIMP_PDB_EXECUTION_ERROR; + } + + gimp_progress_update (1.0); + + ico_save_info_free (&info); + fclose (fp); + g_free (entries); + + return GIMP_PDB_SUCCESS; +} diff --git a/plug-ins/file-ico/ico-save.h b/plug-ins/file-ico/ico-save.h new file mode 100644 index 0000000..46d6ff5 --- /dev/null +++ b/plug-ins/file-ico/ico-save.h @@ -0,0 +1,34 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis + * + * GIMP Plug-in for Windows Icon files. + * Copyright (C) 2002 Christian Kreibich <christian@whoop.org>. + * + * 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 __ICO_SAVE_H__ +#define __ICO_SAVE_H__ + + +GimpPDBStatusType ico_save_image (const gchar *file_name, + gint32 image_ID, + gint32 run_mode, + GError **error); + +gboolean ico_cmap_contains_black (const guchar *cmap, + gint num_colors); + + +#endif /* __ICO_SAVE_H__ */ diff --git a/plug-ins/file-ico/ico.c b/plug-ins/file-ico/ico.c new file mode 100644 index 0000000..c74aecd --- /dev/null +++ b/plug-ins/file-ico/ico.c @@ -0,0 +1,344 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis + * + * GIMP Plug-in for Windows Icon files. + * Copyright (C) 2002 Christian Kreibich <christian@whoop.org>. + * + * 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 <string.h> + +#include <libgimp/gimp.h> +#include <libgimp/gimpui.h> + +/* #define ICO_DBG */ + +#include "ico.h" +#include "ico-load.h" +#include "ico-save.h" + +#include "libgimp/stdplugins-intl.h" + +#define LOAD_PROC "file-ico-load" +#define LOAD_THUMB_PROC "file-ico-load-thumb" +#define SAVE_PROC "file-ico-save" + + +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 thumb_args[] = + { + { GIMP_PDB_STRING, "filename", "The name of the file to load" }, + { GIMP_PDB_INT32, "thumb-size", "Preferred thumbnail size" } + }; + static const GimpParamDef thumb_return_vals[] = + { + { GIMP_PDB_IMAGE, "image", "Thumbnail image" }, + { GIMP_PDB_INT32, "image-width", "Width of full-sized image" }, + { GIMP_PDB_INT32, "image-height", "Height of full-sized 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" }, + }; + + gimp_install_procedure (LOAD_PROC, + "Loads files of Windows ICO file format", + "Loads files of Windows ICO file format", + "Christian Kreibich <christian@whoop.org>", + "Christian Kreibich <christian@whoop.org>", + "2002", + N_("Microsoft Windows icon"), + 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/x-ico"); + gimp_register_magic_load_handler (LOAD_PROC, + "ico", + "", + "0,string,\\000\\001\\000\\000,0,string,\\000\\002\\000\\000"); + + gimp_install_procedure (LOAD_THUMB_PROC, + "Loads a preview from an Windows ICO file", + "", + "Dom Lachowicz, Sven Neumann", + "Sven Neumann <sven@gimp.org>", + "2005", + NULL, + NULL, + GIMP_PLUGIN, + G_N_ELEMENTS (thumb_args), + G_N_ELEMENTS (thumb_return_vals), + thumb_args, thumb_return_vals); + + gimp_register_thumbnail_loader (LOAD_PROC, LOAD_THUMB_PROC); + + gimp_install_procedure (SAVE_PROC, + "Saves files in Windows ICO file format", + "Saves files in Windows ICO file format", + "Christian Kreibich <christian@whoop.org>", + "Christian Kreibich <christian@whoop.org>", + "2002", + N_("Microsoft Windows icon"), + "*", + GIMP_PLUGIN, + G_N_ELEMENTS (save_args), 0, + save_args, NULL); + + gimp_register_file_handler_mime (SAVE_PROC, "image/x-ico"); + gimp_register_save_handler (SAVE_PROC, "ico", ""); +} + +static void +run (const gchar *name, + gint nparams, + const GimpParam *param, + gint *nreturn_vals, + GimpParam **return_vals) +{ + static GimpParam values[4]; + GimpRunMode run_mode; + GimpPDBStatusType status = GIMP_PDB_SUCCESS; + GimpExportReturn export = GIMP_EXPORT_CANCEL; + 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: + if (nparams != 3) + status = GIMP_PDB_CALLING_ERROR; + break; + + default: + break; + } + + if (status == GIMP_PDB_SUCCESS) + { + gint32 image_ID; + + image_ID = ico_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, LOAD_THUMB_PROC) == 0) + { + if (nparams < 2) + { + status = GIMP_PDB_CALLING_ERROR; + } + else + { + const gchar *filename = param[0].data.d_string; + gint width = param[1].data.d_int32; + gint height = param[1].data.d_int32; + gint32 image_ID; + + image_ID = ico_load_thumbnail_image (filename, + &width, &height, &error); + + if (image_ID != -1) + { + *nreturn_vals = 4; + + values[1].type = GIMP_PDB_IMAGE; + values[1].data.d_image = image_ID; + values[2].type = GIMP_PDB_INT32; + values[2].data.d_int32 = width; + values[3].type = GIMP_PDB_INT32; + values[3].data.d_int32 = height; + } + else + { + status = GIMP_PDB_EXECUTION_ERROR; + } + } + } + else if (strcmp (name, SAVE_PROC) == 0) + { + gchar *file_name; + gint32 image_ID; + + image_ID = param[1].data.d_int32; + file_name = param[3].data.d_string; + + switch (run_mode) + { + case GIMP_RUN_INTERACTIVE: + break; + + case GIMP_RUN_NONINTERACTIVE: + /* Make sure all the arguments are there! */ + if (nparams < 5) + status = GIMP_PDB_CALLING_ERROR; + break; + + case GIMP_RUN_WITH_LAST_VALS: + break; + + default: + break; + } + + if (status == GIMP_PDB_SUCCESS) + { + status = ico_save_image (file_name, image_ID, 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; +} + + +gint +ico_rowstride (gint width, + gint bpp) +{ + switch (bpp) + { + case 1: + if ((width % 32) == 0) + return width / 8; + else + return 4 * (width/32 + 1); + break; + + case 4: + if ((width % 8) == 0) + return width / 2; + else + return 4 * (width/8 + 1); + break; + + case 8: + if ((width % 4) == 0) + return width; + else + return 4 * (width/4 + 1); + break; + + case 24: + if (((width*3) % 4) == 0) + return width * 3; + else + return 4 * (width*3/4+1); + + case 32: + return width * 4; + + default: + g_warning ("invalid bitrate: %d\n", bpp); + g_assert_not_reached (); + return width * (bpp/8); + } +} + +guint8 * +ico_alloc_map (gint width, + gint height, + gint bpp, + gint *length) +{ + gint len = 0; + guint8 *map = NULL; + + len = ico_rowstride (width, bpp) * height; + + *length = len; + map = g_new0 (guint8, len); + + return map; +} diff --git a/plug-ins/file-ico/ico.h b/plug-ins/file-ico/ico.h new file mode 100644 index 0000000..65a217c --- /dev/null +++ b/plug-ins/file-ico/ico.h @@ -0,0 +1,110 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis + * + * GIMP Plug-in for Windows Icon files. + * Copyright (C) 2002 Christian Kreibich <christian@whoop.org>. + * + * 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 __ICO_H__ +#define __ICO_H__ + + +#ifdef ICO_DBG +#define D(x) \ +{ \ + printf("ICO plugin: "); \ + printf x; \ +} +#else +#define D(x) +#endif + +#define PLUG_IN_BINARY "file-ico" +#define PLUG_IN_ROLE "gimp-file-ico" + +#define ICO_PNG_MAGIC 0x474e5089 +#define ICO_ALPHA_THRESHOLD 127 +#define ICO_MAXBUF 4096 + + +typedef struct _IcoFileHeader +{ + guint16 reserved; + guint16 resource_type; + guint16 icon_count; +} IcoFileHeader; + +typedef struct _IcoFileEntry +{ + guint8 width; /* Width of icon in pixels */ + guint8 height; /* Height of icon in pixels */ + guint8 num_colors; /* Number of colors of paletted image */ + guint8 reserved; /* Must be 0 */ + guint16 planes; /* Must be 1 */ + guint16 bpp; /* 1, 4, 8, 24 or 32 bits per pixel */ + guint32 size; /* Size of icon (including data header) */ + guint32 offset; /* Absolute offset of data in a file */ + } IcoFileEntry; + +typedef struct _IcoFileDataHeader +{ + guint32 header_size; /* 40 bytes */ + guint32 width; /* Width of image in pixels */ + guint32 height; /* Height of image in pixels */ + guint16 planes; /* Must be 1 */ + guint16 bpp; + guint32 compression; /* Not used for icons */ + guint32 image_size; /* Size of image (without this header) */ + guint32 x_res; + guint32 y_res; + guint32 used_clrs; + guint32 important_clrs; +} IcoFileDataHeader; + + +typedef struct _IcoLoadInfo +{ + guint width; + guint height; + gint bpp; + gint offset; + gint size; +} IcoLoadInfo; + +typedef struct _IcoSaveInfo +{ + gint *depths; + gint *default_depths; + gboolean *compress; + gint *layers; + gint num_icons; +} IcoSaveInfo; + + +/* Miscellaneous helper functions below: */ + +gint ico_rowstride (gint width, + gint bpp); + +/* Allocates a 32-bit padded bitmap for various color depths. + Returns the allocated array directly, and the length of the + array in the len pointer */ +guint8 * ico_alloc_map (gint width, + gint height, + gint bpp, + gint *len); + +#endif /* __ICO_H__ */ |