Browse Source

Imported Upstream version 0.4.0

tags/upstream/0.4.0^0
Bernd Zeimetz 10 years ago
parent
commit
a9be65c122
100 changed files with 35455 additions and 24679 deletions
  1. 59
    0
      ChangeLog
  2. 1
    0
      Makefile.am
  3. 15
    5
      Makefile.in
  4. 32
    0
      NEWS
  5. 16
    9
      README
  6. 53
    0
      README.Windows
  7. 7962
    17
      aclocal.m4
  8. 2
    2
      autogen.sh
  9. 19
    0
      config.h.in
  10. 13001
    7502
      configure
  11. 74
    19
      configure.ac
  12. 2
    0
      docs/Makefile
  13. 7114
    5461
      docs/liblqr_manual.docbook
  14. 5
    1
      examples/Makefile
  15. 170
    190
      examples/liquidrescale-basic.cpp
  16. 8
    4
      examples/liquidrescale-basic.h
  17. 874
    799
      examples/liquidrescale.cpp
  18. 23
    11
      examples/liquidrescale.h
  19. 14
    2
      lqr/Makefile.am
  20. 32
    9
      lqr/Makefile.in
  21. 4
    3
      lqr/lqr.h
  22. 4
    3
      lqr/lqr_all.h
  23. 64
    30
      lqr/lqr_base.h
  24. 1651
    1353
      lqr/lqr_carver.c
  25. 3
    2
      lqr/lqr_carver.h
  26. 141
    86
      lqr/lqr_carver_bias.c
  27. 2
    2
      lqr/lqr_carver_bias.h
  28. 2
    2
      lqr/lqr_carver_bias_priv.h
  29. 10
    7
      lqr/lqr_carver_bias_pub.h
  30. 59
    50
      lqr/lqr_carver_list.c
  31. 2
    4
      lqr/lqr_carver_list.h
  32. 7
    11
      lqr/lqr_carver_list_priv.h
  33. 11
    15
      lqr/lqr_carver_list_pub.h
  34. 133
    0
      lqr/lqr_carver_macros_priv.h
  35. 254
    169
      lqr/lqr_carver_priv.h
  36. 56
    34
      lqr/lqr_carver_pub.h
  37. 143
    94
      lqr/lqr_carver_rigmask.c
  38. 2
    2
      lqr/lqr_carver_rigmask.h
  39. 3
    4
      lqr/lqr_carver_rigmask_priv.h
  40. 10
    7
      lqr/lqr_carver_rigmask_pub.h
  41. 91
    102
      lqr/lqr_cursor.c
  42. 2
    2
      lqr/lqr_cursor.h
  43. 15
    16
      lqr/lqr_cursor_priv.h
  44. 3
    3
      lqr/lqr_cursor_pub.h
  45. 804
    0
      lqr/lqr_energy.c
  46. 29
    0
      lqr/lqr_energy.h
  47. 76
    0
      lqr/lqr_energy_priv.h
  48. 58
    0
      lqr/lqr_energy_pub.h
  49. 15
    30
      lqr/lqr_gradient.c
  50. 2
    3
      lqr/lqr_gradient.h
  51. 8
    9
      lqr/lqr_gradient_priv.h
  52. 9
    15
      lqr/lqr_gradient_pub.h
  53. 64
    72
      lqr/lqr_progress.c
  54. 2
    7
      lqr/lqr_progress.h
  55. 13
    20
      lqr/lqr_progress_priv.h
  56. 14
    15
      lqr/lqr_progress_pub.h
  57. 394
    0
      lqr/lqr_rwindow.c
  58. 29
    0
      lqr/lqr_rwindow.h
  59. 61
    0
      lqr/lqr_rwindow_priv.h
  60. 49
    0
      lqr/lqr_rwindow_pub.h
  61. 149
    173
      lqr/lqr_vmap.c
  62. 2
    3
      lqr/lqr_vmap.h
  63. 45
    50
      lqr/lqr_vmap_list.c
  64. 2
    4
      lqr/lqr_vmap_list.h
  65. 7
    11
      lqr/lqr_vmap_list_priv.h
  66. 6
    8
      lqr/lqr_vmap_list_pub.h
  67. 8
    10
      lqr/lqr_vmap_priv.h
  68. 12
    15
      lqr/lqr_vmap_pub.h
  69. 657
    125
      ltmain.sh
  70. 0
    7325
      m4/libtool.m4
  71. 0
    368
      m4/ltoptions.m4
  72. 0
    123
      m4/ltsugar.m4
  73. 0
    23
      m4/ltversion.m4
  74. 0
    92
      m4/lt~obsolete.m4
  75. 3
    3
      man/LqrColDepth.3
  76. 61
    0
      man/LqrImageType.3
  77. 9
    4
      man/LqrRetVal.3
  78. 21
    0
      man/Makefile.am
  79. 34
    4
      man/Makefile.in
  80. 4
    4
      man/lqr_carver_attach.3
  81. 1
    1
      man/lqr_carver_bias_add.3
  82. 1
    102
      man/lqr_carver_bias_add_area.3
  83. 1
    1
      man/lqr_carver_bias_add_rgb.3
  84. 1
    1
      man/lqr_carver_bias_add_rgb_area.3
  85. 125
    0
      man/lqr_carver_bias_add_xy.3
  86. 38
    0
      man/lqr_carver_bias_clear.3
  87. 160
    0
      man/lqr_carver_bias_set_energy_function.3
  88. 82
    0
      man/lqr_carver_bias_set_energy_function_builtin.3
  89. 58
    0
      man/lqr_carver_cancel.3
  90. 10
    5
      man/lqr_carver_destroy.3
  91. 6
    6
      man/lqr_carver_flatten.3
  92. 3
    3
      man/lqr_carver_get_channels.3
  93. 3
    3
      man/lqr_carver_get_col_depth.3
  94. 3
    3
      man/lqr_carver_get_depth.3
  95. 123
    0
      man/lqr_carver_get_energy.3
  96. 1
    0
      man/lqr_carver_get_energy_image.3
  97. 3
    3
      man/lqr_carver_get_enl_step.3
  98. 3
    3
      man/lqr_carver_get_height.3
  99. 38
    0
      man/lqr_carver_get_image_type.3
  100. 0
    0
      man/lqr_carver_get_orientation.3

+ 59
- 0
ChangeLog View File

@@ -1,3 +1,62 @@
2009-05-09 Carlo Baldassi <carlobaldassi@gmail.com>

* Changed lqr_carver_get_[true_]energy
* Added lqr_carver_get_energy_image

2009-05-05 Carlo Baldassi <carlobaldassi@gmail.com>

* Updated the example files with the new features

2009-05-04 Carlo Baldassi <carlobaldassi@gmail.com>

* Added lqr_carver_bias/rigmask_clear

2009-05-03 Carlo Baldassi <carlobaldassi@gmail.com>

* Changed CATCH* macros to LQR_CATCH*
* No alpha by default for LQR_CUSTOM_IMAGE
* Improved set alpha/black channel
* Bias activates energy (for using with
lqr_carver_get_energy)
* Fixes in lqr_carver_bias/rigmask_add_area
* Added lqr_carver_rigmask_add_xy
* Don't call transpose when adding rigmasks
* Rigmask init set to 0 instead of 1
* Removed energy previews
* Added lqr_carvre_get_true_energy

2009-04-28 Carlo Baldassi <carlobaldassi@gmail.com>

* Heavily optimised the update_mmap code
* Progress report spans whole sessions instead
of being divided into steps when enlagement
exceeds the enl_step

2009-04-27 Carlo Baldassi <carlobaldassi@gmail.com>

* New framework for energy definition,
including energy previews
* Added lqr_carver_bias_add_xy
* Better bias managment (saves memory if
bias is not used, no unnecessary
transpositions)

2009-04-16 Carlo Baldassi <carlobaldassi@gmail.com>

* Added cancel methods and structures
* Fixed recursiveness of some calls to
lqr_carver_list_foreach
* Fixed return value of lqr_carver_resize

2009-04-09 Carlo Baldassi <carlobaldassi@gmail.com>

* Added lqr_carver_set_preserve_input_image
* Version bump 0.4

2009-04-08 Carlo Baldassi <carlobaldassi@gmail.com>

* Fixed bug with 16-bit images

2009-01-26 Carlo Baldassi <carlobaldassi@gmail.com>

* Added readouts for current visiblity map

+ 1
- 0
Makefile.am View File

@@ -15,6 +15,7 @@ EXTRA_DIST = \
examples/Makefile \
examples/README \
BUGS \
README.Windows \
autogen.sh

DISTCLEANFILES = \

+ 15
- 5
Makefile.in View File

@@ -43,10 +43,7 @@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
config.sub depcomp install-sh ltmain.sh missing mkinstalldirs
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@@ -91,6 +88,7 @@ AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
API_VERSION = @API_VERSION@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
@@ -100,10 +98,15 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATADIR = @DATADIR@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -112,6 +115,7 @@ ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FVISIBILITY_FLAG = @FVISIBILITY_FLAG@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_DIR = @GLIB_DIR@
GLIB_LIBS = @GLIB_LIBS@
@@ -134,12 +138,14 @@ LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LTVERSION = @LTVERSION@
LT_NOUNDEF_FLAG = @LT_NOUNDEF_FLAG@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
@@ -158,9 +164,12 @@ SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -216,6 +225,7 @@ EXTRA_DIST = \
examples/Makefile \
examples/README \
BUGS \
README.Windows \
autogen.sh

DISTCLEANFILES = \
@@ -443,7 +453,7 @@ distclean-tags:
distdir: $(DISTFILES)
$(am__remove_distdir)
mkdir $(distdir)
$(mkdir_p) $(distdir)/. $(distdir)/docs $(distdir)/examples $(distdir)/m4
$(mkdir_p) $(distdir)/. $(distdir)/docs $(distdir)/examples
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \

+ 32
- 0
NEWS View File

@@ -1,3 +1,35 @@
Version 0.4:

* New features:
* Support for image types (color models):
GREY, GREYA, RGB, RGBA, CMY, CMYK, CMYKA
and custom
* Additional builtin energy functions based on
luma instead of brightness
* Support for custom energy functions
* Functions to read out the energy map
* Cancel function to interrupt computations
* Additional methods for bias and rigidity masks
* Use a single progress instead of several
ones when the update is performed in steps
* Can handle input buffers non-destructively

* Performace related:
* Faster rescaling thanks to optimisations in
the code
* Spare memory when not using features (e.g. the
bias)

* Configuration
* The default installation directory is now /usr
instead of /usr/local
* Compiling under MinGW now correctly produces a
DLL with the default settings
* Now it also compiles under MS Visual C++
* All public macro names start with LQR_* (old
versions are still available but can be disabled
at configure time)

Version 0.3:

* New features:

+ 16
- 9
README View File

@@ -1,5 +1,5 @@

LiquidRescale library 0.2.0
LiquidRescale library 0.4.0
===========================

Table of contents
@@ -29,6 +29,8 @@ Following is a list of features:

* Easy to use API
* Currently supports 8 bit to 64 bit per channel images
* Support for different color models: grayscale, RGB, CMY
and even custom ones
* Areas in the image can be marked for preservation or
discard, or for additional seam rigidity
* Once the image has been fully processed, the scaling can
@@ -39,13 +41,16 @@ Following is a list of features:
can also work in successive steps without wasting
computational time
* Possibility to tune the carving operation by letting the
seams be less connected, or more rigid, or both
seams be less connected, or more rigid, or both (the
rigidity can be also be modulated through a mask, to get
a differnet behaviour in different areas of the image)
* Can export and import the visibility map (the seams)
* Other images can be attached and undergo the same carving
process as the parent image
* The automatic feature detection algorithm can be tuned
by selecting among different energy gradient functions
* Reports progress through a customizable interface
by selecting among different energy gradient functions,
and even defining custom ones
* Reports progress through a customisable interface
* A signalling system permits to cleanly handle errors


@@ -62,15 +67,17 @@ The lqr library depends on the glib-2.0 libraries
The build package uses autotools and libtool, so the installation
commands on Unix systems are simply

./configure --prefix=/usr && make && sudo make install
./configure && make && sudo make install

The last step requires administrative privileges.
(If the dynamic linker path includes /usr/local/lib, the `--prefix'
option is not needed.)
(Note: the default installation path is /usr since version 0.4)

If you want to also install the man pages for the library functions,
add the option `--enable-install-man' in the call to ./configure.

If you wand to disable legacy macro names which do not begin with
LQR_ then add the option `--diable-legacy-macros'

See the INSTALL file for a full description.


@@ -89,7 +96,7 @@ the proper flags.

In the `examples' directory you can find a basic example program,
`liquidrescale-basic', and a full-featured demo program,
`liquidrescale', toghether with a simple Makefile. Both
`liquidrescale', together with a simple Makefile. Both
programs are fully commented.

The "basic" version demonstrates how to use the strictly-needed
@@ -122,5 +129,5 @@ http://www.faculty.idc.ac.il/arik/imret.pdf
+ Copyright
-----------

Copyright (C) 2007-2008 Carlo Baldassi <carlobaldassi@gmail.com>
Copyright (C) 2007-2009 Carlo Baldassi <carlobaldassi@gmail.com>


+ 53
- 0
README.Windows View File

@@ -0,0 +1,53 @@
Compiling the library in Windows
================================

DISCLAIMER: these notes are not very reliable, as they're
based on some very simple tests, without much knowledge of
the Windows operating system.

1) Using MinGW/MSYS

Everything goes as in standard *nix systems (you should
probably change the default installation location with the
--prefix option in `configure').
With the default options, the `configure' sctipt produces a
DLL. If you want to build a static library, you should pass the
options --disable-shared and --disable-declspec to
`configure', and make sure you define the preprocessor
LQR_DISABLE_DECLSPEC whenever you want to compile/link
against the static library.

2) Using MS Visual C++

The library compiles at least under `Microsoft Visual C++
2008 Express edition'. You can create an empty DLL project
with the default setup (choose Console Application then
Advanced Settings -> DLL + Empty Project), then put the
`lqr' directory in the project directory and add all of the
files within that dir to the project with `Add Exisitng
Item'. Then, you must modify the project properties like
this:

a) C/C++ -> General -> Additional Include Directories: add
the directory `lqr' and its parent, and also the directory
where all the necessary glib-2.0 headers are found.

b) C/C++ -> Preprocessor -> Preprocessor Definitions: add
LQR_EXPORT to the list

c) C/C++ -> Advanced -> Compile As: Compile as C Code (it
also works otherwise, but this option seems to make sense
given that the library is ANSI C)

d) Linker -> General -> Version: set version (don't know
if this is really needed or has any purpose at all though)

e) Linker -> Additional Library Directories: add the
directory where glib-2.0.lib is found

f) Linker -> Input -> Additional Dependencies: add
glib-2.0.lib

When you build the project, it should produce the library
liblqr-1-0.lib and liblqr-1-0.dll files (assuming your
project is called `liblqr-1-0').

+ 7962
- 17
aclocal.m4
File diff suppressed because it is too large
View File


+ 2
- 2
autogen.sh View File

@@ -115,7 +115,7 @@ test $TEST_TYPE $FILE || {
echo
echo "I am going to run ./configure with the following arguments:"
echo
echo " --enable-maintainer-mode --prefix=/usr --enable-install-man $AUTOGEN_CONFIGURE_ARGS $@"
echo " --enable-maintainer-mode --enable-install-man $AUTOGEN_CONFIGURE_ARGS $@"
echo

if test -z "$*"; then
@@ -164,7 +164,7 @@ libtoolize --force --copy --install || exit 1

cd $ORIGDIR

$srcdir/configure --enable-maintainer-mode --prefix=/usr --enable-install-man $AUTOGEN_CONFIGURE_ARGS "$@"
$srcdir/configure --enable-maintainer-mode --enable-install-man $AUTOGEN_CONFIGURE_ARGS "$@"
RC=$?
if test $RC -ne 0; then
echo

+ 19
- 0
config.h.in View File

@@ -36,6 +36,15 @@
/* Library name */
#undef LIBRARY_NAME

/* Disable __declspec directives */
#undef LQR_DISABLE_DECLSPEC

/* Disable legacy macros */
#undef LQR_DISABLE_LEGACY_MACROS

/* Flag for Windows DLL creation */
#undef LQR_EXPORTS

/* Library age */
#undef LTVERSION_AGE

@@ -81,3 +90,13 @@

/* Version number of package */
#undef VERSION

/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline
#endif

/* Define to empty if the keyword `volatile' does not work. Warning: valid
code using `volatile' can become incorrect without. Disable with care. */
#undef volatile

+ 13001
- 7502
configure
File diff suppressed because it is too large
View File


+ 74
- 19
configure.ac View File

@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.

AC_PREREQ(2.54)
AC_PREREQ(2.63)

dnl remember to edit the .pc file name
dnl and lqr/Makefile.am if you change these
@@ -14,18 +14,20 @@ m4_define([library_name], [liblqr-api_version])

dnl These three define the library version number
m4_define([package_major_version], [0])
m4_define([package_minor_version], [3])
m4_define([package_micro_version], [1])
m4_define([package_minor_version], [4])
m4_define([package_micro_version], [0])

m4_define([package_version],
[package_major_version.package_minor_version.package_micro_version])

m4_define([ltversion_current], [2])
m4_define([ltversion_revision], [1])
m4_define([ltversion_age], [2])
m4_define([ltversion_current], [3])
m4_define([ltversion_revision], [0])
m4_define([ltversion_age], [3])

AC_INIT([library_name], [package_version])

AC_PREFIX_DEFAULT([/usr])

AC_DEFINE(LIBRARY_NAME, PACKAGE_NAME, [Library name])

AC_DEFINE(PACKAGE_MAJOR_VERSION, package_major_version, [Package major version])
@@ -52,7 +54,7 @@ LTVERSION=ltversion_current:ltversion_revision:ltversion_age
AC_SUBST(LTVERSION)

AC_CONFIG_SRCDIR([lqr/lqr_carver.c])
AM_CONFIG_HEADER(config.h)
AC_CONFIG_HEADERS([config.h])

AC_CONFIG_MACRO_DIR([m4])

@@ -60,17 +62,24 @@ AM_INIT_AUTOMAKE([-Wall -Werror])

AC_ISC_POSIX
AC_PROG_CC
AC_PROG_CXX
AM_PROG_CC_STDC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_HEADER_STDC

AC_C_INLINE
AC_C_VOLATILE

AC_DISABLE_STATIC
AC_PROG_LIBTOOL
LT_INIT([win32-dll])

ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"

AM_MAINTAINER_MODE


dnl Use -Wall if we have gcc.
changequote(,)dnl
if test "x$GCC" = "xyes"; then
@@ -81,7 +90,6 @@ if test "x$GCC" = "xyes"; then
fi
changequote([,])dnl


GLIB_REQUIRED_VERSION=2.0.0

PKG_CHECK_MODULES(GLIB,
@@ -101,6 +109,62 @@ AC_CHECK_FUNCS(bind_textdomain_codeset)
DATADIR="${datadir}/library_name"
AC_SUBST(DATADIR)

AC_ARG_ENABLE([install-man],
[AS_HELP_STRING([--enable-install-man], [Install man pages])],
[AS_CASE(["${enableval}"],
[yes], [install_man=true],
[no], [install_man=false],
[AC_MSG_ERROR([bad value ${enableval} for --enable-install-man])]
)],
[install_man=false])
AM_CONDITIONAL([INSTMAN], [test x$install_man = xtrue])

AC_ARG_ENABLE([legacy-macros],
[AS_HELP_STRING([--disable-legacy-macros], [Disable legacy macros])],
[AS_CASE([["${enableval}"]],
[yes], [legacy_macros=true],
[no], [legacy_macros=false],
[AC_MSG_ERROR([bad value ${enableval} for --enable-legacy-macros])]
)],
[legacy_macros=true])
AS_IF([test "x$legacy_macros" = "xfalse"],
[AC_DEFINE([LQR_DISABLE_LEGACY_MACROS],[],[Disable legacy macros])],
[:]
)

AC_ARG_ENABLE([dllimport],
[AS_HELP_STRING([--disable-declspec], [Disable Win32 __declspec directives (only meaningful for building static library on MinGW)])],
[AS_CASE([["${enableval}"]],
[yes], [declspec=true],
[no], [declspec=false],
[AC_MSG_ERROR([bad value ${enableval} for --enable-declspec])]
)],
[declspec=true])
AS_IF([test "x$declspec" = "xfalse"],
[AC_DEFINE([LQR_DISABLE_DECLSPEC],[],[Disable __declspec directives])],
[:]
)


AC_MSG_CHECKING([[if we are on Win32]])
AC_LANG([C])
AC_PREPROC_IFELSE([[
#ifndef WIN32
#errrrrrrrrorrrrr
#endif
]],
[[is_win32=true]],
[[is_win32=false]]
)
AS_IF([test "x$is_win32" = "xtrue"],
[AC_MSG_RESULT([yes]); LT_NOUNDEF_FLAG="-no-undefined"; FVISIBILITY_FLAG=""],
[AC_MSG_RESULT([no]); LT_NOUNDEF_FLAG=""; FVISIBILITY_FLAG="-fvisibility=\"hidden\""],
)

AC_SUBST(LT_NOUNDEF_FLAG)
AC_SUBST(FVISIBILITY_FLAG)

AC_DEFINE([LQR_EXPORTS],[],[Flag for Windows DLL creation])

AC_CONFIG_FILES([
Makefile
@@ -109,14 +173,5 @@ man/Makefile
lqr-1.pc
])

AC_ARG_ENABLE([install-man],
[ --enable-install-man Install man pages],
[case "${enableval}" in
yes) install_man=true ;;
no) install_man=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-install-man]) ;;
esac],[install_man=false])
AM_CONDITIONAL([INSTMAN], [test x$install_man = xtrue])


AC_OUTPUT

+ 2
- 0
docs/Makefile View File

@@ -15,6 +15,8 @@ redir = redir-html

all: html

dist: html onepage dist-man

#sgml : $(dest)

#$(dest): $(source)

+ 7114
- 5461
docs/liblqr_manual.docbook
File diff suppressed because it is too large
View File


+ 5
- 1
examples/Makefile View File

@@ -34,6 +34,9 @@ PNGWRITER_CFLAGS = `freetype-config --cflags`

PNGWRITER_LIBS = -lpng -lpngwriter -lz -lfreetype

# collect flags for the compiler for glib thread support
GTHREAD_LIBS = `pkg-config --libs gthread-2.0`

# join the flags collected above
INCLUDES = \
$(LQR_CFLAGS) \
@@ -44,7 +47,8 @@ LIBDIRS = \

LIBS = \
$(LQR_LIBS) \
$(PNGWRITER_LIBS)
$(PNGWRITER_LIBS) \
$(GTHREAD_LIBS)

# define the flags to use in the various compilation steps
BASE_FLAGS = -Winline -O2 -Wall

+ 170
- 190
examples/liquidrescale-basic.cpp View File

@@ -29,258 +29,238 @@ gint new_height = 0;
gfloat rigidity = 0;
gint max_step = 1;


/*** MAIN ***/

int
main (int argc, char **argv)
main(int argc, char **argv)
{/*{{{*/

/*** read the command line ***/
TRAP (parse_command_line (argc, argv));
/*** read the command line ***/
TRAP(parse_command_line(argc, argv));

/*** open input and output files ***/
pngwriter png (1, 1, 0, outfile);
png.readfromfile (infile);
/*** open input and output files ***/
pngwriter png(1, 1, 0, outfile);
png.readfromfile(infile);

/*** old and new size ***/
gint old_width = png.getwidth ();
gint old_height = png.getheight ();
/*** old and new size ***/
gint old_width = png.getwidth();
gint old_height = png.getheight();

new_width = (new_width ? new_width : old_width);
new_height = (new_height ? new_height : old_height);
new_width = (new_width ? new_width : old_width);
new_height = (new_height ? new_height : old_height);

if (new_width < 2)
{
cerr << "The width should be greater than 2" << endl;
exit (1);
if (new_width < 2) {
cerr << "The width should be greater than 2" << endl;
exit(1);
}

if (new_height < 2)
{
cerr << "The height should be greater than 2" << endl;
exit (1);
if (new_height < 2) {
cerr << "The height should be greater than 2" << endl;
exit(1);
}

/*** print some information on screen ***/
cout << "resizing " << infile << " [" << old_width << "x" << old_height << "] into " <<
outfile << " [" << new_width << "x" << new_height << "]" << endl << flush;


/* convert the image into rgb buffers to use them with the library */

guchar *rgb_buffer;

TRAP_N (rgb_buffer = rgb_buffer_from_image (&png));
/*** print some information on screen ***/
cout << "resizing " << infile << " [" << old_width << "x" << old_height << "] into " <<
outfile << " [" << new_width << "x" << new_height << "]" << endl << flush;

/* convert the image into rgb buffers to use them with the library */

/**** (I) GENERATE THE MULTISIZE REPRESENTATION ****/
guchar *rgb_buffer;

/* (I.1) swallow the buffer in a (minimal) LqrCarver object
* (arguments are width, height and number of colour channels) */
LqrCarver *carver;
TRAP_N (carver = lqr_carver_new (rgb_buffer, old_width, old_height, 3));
TRAP_N(rgb_buffer = rgb_buffer_from_image(&png));

/* (I.2) initialize the carver (with default values),
* so that we can do the resizing */
TRAP (lqr_carver_init (carver, max_step, rigidity));
/**** (I) GENERATE THE MULTISIZE REPRESENTATION ****/

/* (I.1) swallow the buffer in a (minimal) LqrCarver object
* (arguments are width, height and number of colour channels) */
LqrCarver *carver;
TRAP_N(carver = lqr_carver_new(rgb_buffer, old_width, old_height, 3));

/**** (II) LIQUID RESCALE ****/
/* (I.2) initialize the carver (with default values),
* so that we can do the resizing */
TRAP(lqr_carver_init(carver, max_step, rigidity));

TRAP (lqr_carver_resize (carver, new_width, new_height));
/**** (II) LIQUID RESCALE ****/

TRAP(lqr_carver_resize(carver, new_width, new_height));

/**** (III) READOUT THE MULTISIZE IMAGE ****/
/**** (III) READOUT THE MULTISIZE IMAGE ****/

TRAP (write_carver_to_image (carver, &png));
TRAP(write_carver_to_image(carver, &png));

/**** (IV) DESTROY THE CARVER OBJECT ****/

lqr_carver_destroy(carver);

/*** close file (write the image on disk) ***/
/*** close file (write the image on disk) ***/

png.close ();
png.close();

return 0;
return 0;
}/*}}}*/

/*** PARSE COMMAND LINE ***/

LqrRetVal parse_command_line (int argc, char **argv)
LqrRetVal
parse_command_line(int argc, char **argv)
{/*{{{*/
int i;
int c;
struct option lopts[]= {
{"file", required_argument, NULL, 'f'},
{"out-file", required_argument, NULL, 'o'},
{"width", required_argument, NULL, 'w'},
{"height", required_argument, NULL, 'h'},
{"rigidity", required_argument, NULL, 'r'},
{"max-step", required_argument, NULL, 's'},
{"help", no_argument, NULL, '#'},
{NULL,0,NULL,0}
};



while ((c = getopt_long(argc, argv, "f:,o:,w:,h:,r:,s:", lopts, &i)) != EOF) {
switch (c)
{
case 'f':
infile = optarg;
break;
case 'o':
outfile = optarg;
break;
case 'w':
new_width = atoi(optarg);
break;
case 'h':
new_height = atoi(optarg);
break;
case 'r':
rigidity = atof(optarg);
break;
case 's':
max_step = atoi(optarg);
break;
case '#':
help(argv[0]);
exit (0);
default:
cerr << "Error parsing command line. Use " << argv[0] << " --help for usage instructions." << endl;
return LQR_ERROR;
int i;
int c;
struct option lopts[] = {
{"file", required_argument, NULL, 'f'},
{"out-file", required_argument, NULL, 'o'},
{"width", required_argument, NULL, 'w'},
{"height", required_argument, NULL, 'h'},
{"rigidity", required_argument, NULL, 'r'},
{"max-step", required_argument, NULL, 's'},
{"help", no_argument, NULL, '#'},
{NULL, 0, NULL, 0}
};

while ((c = getopt_long(argc, argv, "f:,o:,w:,h:,r:,s:", lopts, &i)) != EOF) {
switch (c) {
case 'f':
infile = optarg;
break;
case 'o':
outfile = optarg;
break;
case 'w':
new_width = atoi(optarg);
break;
case 'h':
new_height = atoi(optarg);
break;
case 'r':
rigidity = atof(optarg);
break;
case 's':
max_step = atoi(optarg);
break;
case '#':
help(argv[0]);
exit(0);
default:
cerr << "Error parsing command line. Use " << argv[0] << " --help for usage instructions." << endl;
return LQR_ERROR;
}
}
}

if (!infile)
{
cerr << "Input file missing." << endl;
return LQR_ERROR;
if (!infile) {
cerr << "Input file missing." << endl;
return LQR_ERROR;
}
if (!outfile)
{
cerr << "Output file missing." << endl;
return LQR_ERROR;
}

if (!new_width && !new_height)
{
cerr << "Either --width or --height has to be specified." << endl;
return LQR_ERROR;

if (!outfile) {
cerr << "Output file missing." << endl;
return LQR_ERROR;
}

if (rigidity < 0)
{
cerr << "Rigidity cannot be negative." << endl;
return LQR_ERROR;
if (!new_width && !new_height) {
cerr << "Either --width or --height has to be specified." << endl;
return LQR_ERROR;
}

if (max_step < 0)
{
cerr << "Max step cannot be negative." << endl;
return LQR_ERROR;
if (rigidity < 0) {
cerr << "Rigidity cannot be negative." << endl;
return LQR_ERROR;
}

if (max_step < 0) {
cerr << "Max step cannot be negative." << endl;
return LQR_ERROR;
}

return LQR_OK;
return LQR_OK;
}/*}}}*/

void help(char *command)
void
help(char *command)
{/*{{{*/
cout << "Usage: " << command << " -f <file> -o <out-file> [ -w <width> | -h <height> ] [ ... ]" << endl;
cout << " Options:" << endl;
cout << " -f <file> or --file <file>" << endl;
cout << " Specifies input file. Must be in PNG format, in RGB without alpha channel" << endl;
cout << " -o <out-file> or --out-file <out-file>" << endl;
cout << " Specifies the output file." << endl;
cout << " -w <width> or --width <width>" << endl;
cout << " The new width. It must be greater than 2." << endl;
cout << " If it is 0, or it is not given, the width is unchanged." << endl;
cout << " -h <height> or --height <height>" << endl;
cout << " Same as -w for the height." << endl;
cout << " -r <rigidity> or --rigidity < rigidity>" << endl;
cout << " Seams rigidity. Any non-negative value is allowed. Defaults to 0." << endl;
cout << " -s <max-step> or --max-step <max-step>" << endl;
cout << " Maximum seam transversal step. Default value is 1." << endl;
cout << " --help" << endl;
cout << " This help." << endl;
cout << "Usage: " << command << " -f <file> -o <out-file> [ -w <width> | -h <height> ] [ ... ]" << endl;
cout << " Options:" << endl;
cout << " -f <file> or --file <file>" << endl;
cout << " Specifies input file. Must be in PNG format, in RGB without alpha channel" << endl;
cout << " -o <out-file> or --out-file <out-file>" << endl;
cout << " Specifies the output file." << endl;
cout << " -w <width> or --width <width>" << endl;
cout << " The new width. It must be greater than 2." << endl;
cout << " If it is 0, or it is not given, the width is unchanged." << endl;
cout << " -h <height> or --height <height>" << endl;
cout << " Same as -w for the height." << endl;
cout << " -r <rigidity> or --rigidity < rigidity>" << endl;
cout << " Seams rigidity. Any non-negative value is allowed. Defaults to 0." << endl;
cout << " -s <max-step> or --max-step <max-step>" << endl;
cout << " Maximum seam transversal step. Default value is 1." << endl;
cout << " --help" << endl;
cout << " This help." << endl;
}/*}}}*/

/*** AUXILIARY I/O FUNCTIONS ***/

/* convert the image in the right format */
guchar *
rgb_buffer_from_image (pngwriter * png)
rgb_buffer_from_image(pngwriter *png)
{/*{{{*/
gint x, y, k, channels;
gint w, h;
guchar *buffer;

/* get info from the image */
w = png->getwidth ();
h = png->getheight ();
channels = 3; // we assume an RGB image here

/* allocate memory to store w * h * channels unsigned chars */
buffer = g_try_new (guchar, channels * w * h);
g_assert (buffer != NULL);

/* start iteration (always y first, then x, then colours) */
for (y = 0; y < h; y++)
{
for (x = 0; x < w; x++)
{
for (k = 0; k < channels; k++)
{
/* read the image channel k at position x,y */
buffer[(y * w + x) * channels + k] =
(guchar) (png->dread (x + 1, y + 1, k + 1) * 255);
/* note : the x+1,y+1,k+1 on the right side are
* specific the pngwriter library */
gint x, y, k, channels;
gint w, h;
guchar *buffer;

/* get info from the image */
w = png->getwidth();
h = png->getheight();
channels = 3; // we assume an RGB image here

/* allocate memory to store w * h * channels unsigned chars */
buffer = g_try_new(guchar, channels * w * h);
g_assert(buffer != NULL);

/* start iteration (always y first, then x, then colours) */
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
for (k = 0; k < channels; k++) {
/* read the image channel k at position x,y */
buffer[(y * w + x) * channels + k] = (guchar) (png->dread(x + 1, y + 1, k + 1) * 255);
/* note : the x+1,y+1,k+1 on the right side are
* specific the pngwriter library */
}
}
}

return buffer;
return buffer;
}/*}}}*/

/* readout the multizie image */
LqrRetVal
write_carver_to_image (LqrCarver * r, pngwriter * png)
write_carver_to_image(LqrCarver *r, pngwriter *png)
{/*{{{*/
gint x, y;
guchar * rgb;
gdouble red, green, blue;
gint w, h;

/* make sure the image is RGB */
CATCH_F (lqr_carver_get_channels(r) == 3);

/* resize the image canvas as needed to
* fit for the new size */
w = lqr_carver_get_width (r);
h = lqr_carver_get_height (r);
png->resize (w, h);

/* initialize image reading */
lqr_carver_scan_reset (r);

/* readout (no need to init rgb) */
while (lqr_carver_scan(r, &x, &y, &rgb))
{
/* convert the output into doubles */
red = (gdouble) rgb[0] / 255;
green = (gdouble) rgb[1] / 255;
blue = (gdouble) rgb[2] / 255;

/* plot (pngwriter's coordinates start from 1,1) */
png->plot (x + 1, y + 1, red, green, blue);
gint x, y;
guchar *rgb;
gdouble red, green, blue;
gint w, h;

/* make sure the image is RGB */
LQR_CATCH_F(lqr_carver_get_channels(r) == 3);

/* resize the image canvas as needed to
* fit for the new size */
w = lqr_carver_get_width(r);
h = lqr_carver_get_height(r);
png->resize(w, h);

/* initialize image reading */
lqr_carver_scan_reset(r);

/* readout (no need to init rgb) */
while (lqr_carver_scan(r, &x, &y, &rgb)) {
/* convert the output into doubles */
red = (gdouble) rgb[0] / 255;
green = (gdouble) rgb[1] / 255;
blue = (gdouble) rgb[2] / 255;

/* plot (pngwriter's coordinates start from 1,1) */
png->plot(x + 1, y + 1, red, green, blue);
}

return LQR_OK;
return LQR_OK;
}/*}}}*/


+ 8
- 4
examples/liquidrescale-basic.h View File

@@ -46,17 +46,21 @@
cerr << "Not enough memory, aborting." << endl; \
exit (1); \
break; \
case LQR_USRCANCEL: \
cerr << "Cancelled by user, aborting." << endl; \
exit (1); \
break; \
default: \
break; \
} \
}G_STMT_END
}G_STMT_END

/*** PARSE COMMAND LINE ***/
LqrRetVal parse_command_line (int argc, char **argv);
LqrRetVal parse_command_line(int argc, char **argv);
void help(char *command);

/*** RGB FILE I/O ***/
guchar *rgb_buffer_from_image (pngwriter * png);
LqrRetVal write_carver_to_image (LqrCarver * r, pngwriter * png);
guchar *rgb_buffer_from_image(pngwriter *png);
LqrRetVal write_carver_to_image(LqrCarver *r, pngwriter *png);

#endif /* __LIQUIDRESCALE_BASIC_H__ */

+ 874
- 799
examples/liquidrescale.cpp
File diff suppressed because it is too large
View File


+ 23
- 11
examples/liquidrescale.h View File

@@ -46,30 +46,42 @@
cerr << "Not enough memory, aborting." << endl; \
exit (1); \
break; \
case LQR_USRCANCEL: \
cerr << "Cancelled by user, aborting." << endl; \
exit (1); \
break; \
default: \
break; \
} \
}G_STMT_END
}G_STMT_END

/*** PARSE COMMAND LINE ***/
LqrRetVal parse_command_line (int argc, char **argv);
LqrRetVal parse_command_line(int argc, char **argv);
void help(char *command);

/*** RGB FILE I/O ***/
guchar *rgb_buffer_from_image (pngwriter * png);
LqrRetVal write_carver_to_image (LqrCarver * r, pngwriter * png);
guchar *rgb_buffer_from_image(pngwriter *png);
LqrRetVal write_carver_to_image(LqrCarver *r, pngwriter *png);

/*** VMAP FILES I/O ***/
LqrRetVal save_vmap_to_file (LqrVMap *vmap, gchar * name);
LqrVMap * load_vmap_from_file (gchar *name);
LqrRetVal save_vmap_to_file(LqrVMap *vmap, gchar *name);
LqrVMap *load_vmap_from_file(gchar *name);

/*** ENERGY FUNCTIONS ***/
gfloat sobelx(gint x, gint y, gint w, gint h, LqrReadingWindow *rw, gpointer extra_data);
gfloat sobel(gint x, gint y, gint w, gint h, LqrReadingWindow *rw, gpointer extra_data);
LqrRetVal set_energy(LqrCarver *carver, gchar *energy_function);
LqrRetVal write_energy(LqrCarver *carver, gchar *energy_outfile, gint orientation);

/*** PROGRESS REPORT FUNCTIONS ***/
LqrRetVal my_progress_init (const gchar * message);
LqrRetVal my_progress_update (gdouble percentage);
LqrRetVal my_progress_end (const gchar * message);
void init_progress (LqrProgress * progress);
LqrRetVal my_progress_init(const gchar *message);
LqrRetVal my_progress_update(gdouble percentage);
LqrRetVal my_progress_end(const gchar *message);
void init_progress(LqrProgress * progress);

/*** EXTRA ***/
void info_msg(const gchar * msg, const gchar *name);
void info_msg(const gchar *msg, const gchar *name);
gpointer cancel_thread(gpointer data);
void cancel_handler(int signum);

#endif /* __LIQUIDRESCALE_H__ */

+ 14
- 2
lqr/Makefile.am View File

@@ -12,6 +12,14 @@ liblqr_1_la_SOURCES = \
lqr_gradient.h \
lqr_gradient_pub.h \
lqr_gradient_priv.h \
lqr_rwindow.c \
lqr_rwindow.h \
lqr_rwindow_pub.h \
lqr_rwindow_priv.h \
lqr_energy.c \
lqr_energy.h \
lqr_energy_pub.h \
lqr_energy_priv.h \
lqr_cursor.c \
lqr_cursor.h \
lqr_cursor_pub.h \
@@ -20,6 +28,7 @@ liblqr_1_la_SOURCES = \
lqr_carver.h \
lqr_carver_pub.h \
lqr_carver_priv.h \
lqr_carver_macros_priv.h \
lqr_carver_list.c \
lqr_carver_list.h \
lqr_carver_list_pub.h \
@@ -45,7 +54,8 @@ liblqr_1_la_SOURCES = \
lqr_progress_pub.h \
lqr_progress_priv.h

liblqr_1_la_LDFLAGS = -version-info @LTVERSION@
liblqr_1_la_LDFLAGS = -version-info @LTVERSION@ @LT_NOUNDEF_FLAG@

liblqr_1_la_LIBADD = $(GLIB_LIBS) -lm

AM_CPPFLAGS = \
@@ -53,7 +63,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir) \
@GLIB_CFLAGS@ \
-I$(includedir) \
-fvisibility=hidden
@FVISIBILITY_FLAG@

lqr_include0_HEADERS = lqr.h

@@ -61,6 +71,8 @@ lqr_include0dir = $(includedir)/@LIBRARY_SNAME@

lqr_include_HEADERS = lqr_base.h \
lqr_gradient_pub.h \
lqr_rwindow_pub.h \
lqr_energy_pub.h \
lqr_cursor_pub.h \
lqr_carver_pub.h \
lqr_carver_list_pub.h \

+ 32
- 9
lqr/Makefile.in View File

@@ -41,10 +41,7 @@ subdir = lqr
DIST_COMMON = $(lqr_include0_HEADERS) $(lqr_include_HEADERS) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -62,9 +59,10 @@ lqrLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lqr_LTLIBRARIES)
am__DEPENDENCIES_1 =
liblqr_1_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am_liblqr_1_la_OBJECTS = lqr_gradient.lo lqr_cursor.lo lqr_carver.lo \
lqr_carver_list.lo lqr_carver_bias.lo lqr_carver_rigmask.lo \
lqr_vmap.lo lqr_vmap_list.lo lqr_progress.lo
am_liblqr_1_la_OBJECTS = lqr_gradient.lo lqr_rwindow.lo lqr_energy.lo \
lqr_cursor.lo lqr_carver.lo lqr_carver_list.lo \
lqr_carver_bias.lo lqr_carver_rigmask.lo lqr_vmap.lo \
lqr_vmap_list.lo lqr_progress.lo
liblqr_1_la_OBJECTS = $(am_liblqr_1_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -91,6 +89,7 @@ AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
API_VERSION = @API_VERSION@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
@@ -100,10 +99,15 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATADIR = @DATADIR@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -112,6 +116,7 @@ ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FVISIBILITY_FLAG = @FVISIBILITY_FLAG@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_DIR = @GLIB_DIR@
GLIB_LIBS = @GLIB_LIBS@
@@ -134,12 +139,14 @@ LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LTVERSION = @LTVERSION@
LT_NOUNDEF_FLAG = @LT_NOUNDEF_FLAG@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
@@ -158,9 +165,12 @@ SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -212,6 +222,14 @@ liblqr_1_la_SOURCES = \
lqr_gradient.h \
lqr_gradient_pub.h \
lqr_gradient_priv.h \
lqr_rwindow.c \
lqr_rwindow.h \
lqr_rwindow_pub.h \
lqr_rwindow_priv.h \
lqr_energy.c \
lqr_energy.h \
lqr_energy_pub.h \
lqr_energy_priv.h \
lqr_cursor.c \
lqr_cursor.h \
lqr_cursor_pub.h \
@@ -220,6 +238,7 @@ liblqr_1_la_SOURCES = \
lqr_carver.h \
lqr_carver_pub.h \
lqr_carver_priv.h \
lqr_carver_macros_priv.h \
lqr_carver_list.c \
lqr_carver_list.h \
lqr_carver_list_pub.h \
@@ -245,19 +264,21 @@ liblqr_1_la_SOURCES = \
lqr_progress_pub.h \
lqr_progress_priv.h

liblqr_1_la_LDFLAGS = -version-info @LTVERSION@
liblqr_1_la_LDFLAGS = -version-info @LTVERSION@ @LT_NOUNDEF_FLAG@
liblqr_1_la_LIBADD = $(GLIB_LIBS) -lm
AM_CPPFLAGS = \
-DDATADIR=\""$(DATADIR)"\" \
-I$(top_srcdir) \
@GLIB_CFLAGS@ \
-I$(includedir) \
-fvisibility=hidden
@FVISIBILITY_FLAG@

lqr_include0_HEADERS = lqr.h
lqr_include0dir = $(includedir)/@LIBRARY_SNAME@
lqr_include_HEADERS = lqr_base.h \
lqr_gradient_pub.h \
lqr_rwindow_pub.h \
lqr_energy_pub.h \
lqr_cursor_pub.h \
lqr_carver_pub.h \
lqr_carver_list_pub.h \
@@ -342,8 +363,10 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_carver_list.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_carver_rigmask.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_cursor.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_energy.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_gradient.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_progress.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_rwindow.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_vmap.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_vmap_list.Plo@am__quote@


+ 4
- 3
lqr/lqr.h View File

@@ -15,12 +15,11 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>
* along with this program; if not, see <http://www.gnu.org/licenses/>
*/


#ifndef __LQR_H__
#define __LQR_H__

@@ -30,6 +29,8 @@ G_BEGIN_DECLS

#include <lqr/lqr_base.h>
#include <lqr/lqr_gradient_pub.h>
#include <lqr/lqr_rwindow_pub.h>
#include <lqr/lqr_energy_pub.h>
#include <lqr/lqr_cursor_pub.h>
#include <lqr/lqr_progress_pub.h>
#include <lqr/lqr_vmap_pub.h>

+ 4
- 3
lqr/lqr_all.h View File

@@ -15,12 +15,11 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>
* along with this program; if not, see <http://www.gnu.org/licenses/>
*/


#ifndef __LQR_ALL_H__
#define __LQR_ALL_H__

@@ -30,6 +29,8 @@ G_BEGIN_DECLS

#include <lqr/lqr_base.h>
#include <lqr/lqr_gradient.h>
#include <lqr/lqr_rwindow.h>
#include <lqr/lqr_energy.h>
#include <lqr/lqr_cursor.h>
#include <lqr/lqr_progress.h>
#include <lqr/lqr_vmap.h>

+ 64
- 30
lqr/lqr_base.h View File

@@ -15,24 +15,34 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>
* along with this program; if not, see <http://www.gnu.org/licenses/>
*/


#ifndef __LQR_BASE_H__
#define __LQR_BASE_H__

#define LQR_MAX_NAME_LENGTH (1024)

#define LQR_PUBLIC __attribute__((visibility("default")))

#define TRY_N_N(assign) if ((assign) == NULL) { return NULL; }
//#define TRY_N_F(assign) if ((assign) == NULL) { return FALSE; }
//#define TRY_F_N(assign) if ((assign) == FALSE) { return NULL; }
//#define TRY_F_F(assign) if ((assign) == FALSE) { return FALSE; }

#if defined(G_OS_WIN32) && ! defined(LQR_DISABLE_DECLSPEC)
# ifdef LQR_EXPORTS
# define LQR_PUBLIC __declspec(dllexport)
# else
# define LQR_PUBLIC __declspec(dllimport)
# endif /* LQR_EXPORTS */
#elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# ifndef GCC_HASCLASSVISIBILITY
# define GCC_HASCLASSVISIBILITY
# endif /* !GCC_HASCLASSVISIBILITY */
# ifdef GCC_HASCLASSVISIBILITY
# define LQR_PUBLIC __attribute__((visibility("default")))
# else
# define LQR_PUBLIC
# endif /* GCC_HASCLASSVISIBILITY */
#else
# define LQR_PUBLIC
#endif /* G_OS_WIN32 */

#if 0
#define __LQR_DEBUG__
@@ -43,18 +53,24 @@
#endif

/**** RETURN VALUES (signals) ****/
enum _LqrRetVal
{
LQR_ERROR, /* generic error */
LQR_OK, /* ok */
LQR_NOMEM, /* not enough memory */
LQR_WARNING /* generic warning */
enum _LqrRetVal {
LQR_ERROR, /* generic error */
LQR_OK, /* ok */
LQR_NOMEM, /* not enough memory */
LQR_USRCANCEL /* action cancelled by user */
};

typedef enum _LqrRetVal LqrRetVal;

#define LQR_TRY_N_N(assign) if ((assign) == NULL) { return NULL; }
/*
#define LQR_TRY_F_N(assign) if ((assign) == FALSE) { return NULL; }
#define LQR_TRY_N_F(assign) if ((assign) == NULL) { return FALSE; }
#define LQR_TRY_F_F(assign) if ((assign) == FALSE) { return FALSE; }
*/

/* generic signal processing macros */
#define CATCH(expr) G_STMT_START { \
#define LQR_CATCH(expr) G_STMT_START { \
LqrRetVal ret_val; \
if ((ret_val = (expr)) != LQR_OK) \
{ \
@@ -63,7 +79,7 @@ typedef enum _LqrRetVal LqrRetVal;
} G_STMT_END

/* convert a NULL assignment to an error signal */
#define CATCH_MEM(expr) G_STMT_START { \
#define LQR_CATCH_MEM(expr) G_STMT_START { \
if ((expr) == NULL) \
{ \
return LQR_NOMEM; \
@@ -71,21 +87,26 @@ typedef enum _LqrRetVal LqrRetVal;
} G_STMT_END

/* convert a boolean value to an error signal */
#define CATCH_F(expr) G_STMT_START { \
#define LQR_CATCH_F(expr) G_STMT_START { \
if ((expr) == FALSE) \
{ \
return LQR_ERROR; \
} \
} G_STMT_END

/* legacy */
#ifndef LQR_DISABLE_LEGACY_MACROS
# define CATCH(expr) LQR_CATCH(expr)
# define CATCH_MEM(expr) LQR_CATCH_MEM(expr)
# define CATCH_F(expr) LQR_CATCH_F(expr)
#endif /* LQR_DISABLE_LEGACY_MACROS */

/**** IMAGE DEPTH ****/
enum _LqrColDepth
{
LQR_COLDEPTH_8I,
LQR_COLDEPTH_16I,
LQR_COLDEPTH_32F,
LQR_COLDEPTH_64F,
enum _LqrColDepth {
LQR_COLDEPTH_8I,
LQR_COLDEPTH_16I,
LQR_COLDEPTH_32F,
LQR_COLDEPTH_64F
};

typedef enum _LqrColDepth LqrColDepth;
@@ -97,17 +118,30 @@ typedef gfloat lqr_t_32f;
typedef gdouble lqr_t_64f;

/**** RESIZE ORDER ****/
enum _LqrResizeOrder
{
LQR_RES_ORDER_HOR,
LQR_RES_ORDER_VERT
enum _LqrResizeOrder {
LQR_RES_ORDER_HOR,
LQR_RES_ORDER_VERT
};

typedef enum _LqrResizeOrder LqrResizeOrder;

/**** IMAGE TYPE ****/
enum _LqrImageType {
LQR_RGB_IMAGE,
LQR_RGBA_IMAGE,
LQR_GREY_IMAGE,
LQR_GREYA_IMAGE,
LQR_CMY_IMAGE,
LQR_CMYK_IMAGE,
LQR_CMYKA_IMAGE,
LQR_CUSTOM_IMAGE
};

typedef enum _LqrImageType LqrImageType;

/**** CLASSES DECLARATIONS ****/

struct _LqrCarver; /* the multisize image carver */
struct _LqrCarver;

typedef struct _LqrCarver LqrCarver;


+ 1651
- 1353
lqr/lqr_carver.c
File diff suppressed because it is too large
View File


+ 3
- 2
lqr/lqr_carver.h View File

@@ -15,9 +15,9 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>
* along with this program; if not, see <http://www.gnu.org/licenses/>
*/

#ifndef __LQR_CARVER_H__
@@ -25,5 +25,6 @@

#include <lqr/lqr_carver_pub.h>
#include <lqr/lqr_carver_priv.h>
#include <lqr/lqr_carver_macros_priv.h>

#endif /* __LQR_CARVER_H__ */

+ 141
- 86
lqr/lqr_carver_bias.c View File

@@ -15,11 +15,15 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>
* along with this program; if not, see <http://www.gnu.org/licenses/>
*/

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <lqr/lqr_all.h>

#ifdef __LQR_DEBUG__
@@ -28,132 +32,183 @@

/**** LQR_CARVER_BIAS STRUCT FUNTIONS ****/

LQR_PUBLIC
/* LQR_PUBLIC */
void
lqr_carver_bias_clear(LqrCarver *r)
{
g_free(r->bias);
r->bias = NULL;
r->nrg_uptodate = FALSE;
}

/* LQR_PUBLIC */
LqrRetVal
lqr_carver_bias_add_area(LqrCarver *r, gdouble *buffer, gint bias_factor, gint width, gint height, gint x_off, gint y_off)
lqr_carver_bias_add_xy(LqrCarver *r, gdouble bias, gint x, gint y)
{
gint x, y;
gint x1, y1, x2, y2;
gfloat bias;
gint xt, yt;

if (bias == 0) {
return LQR_OK;
}

if (bias_factor == 0)
{
return LQR_OK;
LQR_CATCH_CANC(r);
if (r->nrg_active == FALSE) {
LQR_CATCH(lqr_carver_init_energy_related(r));
}

CATCH_F (r->active);
if ((r->w != r->w0) || (r->w_start != r->w0) ||
(r->h != r->h0) || (r->h_start != r->h0))
{
CATCH (lqr_carver_flatten(r));
if ((r->w != r->w0) || (r->w_start != r->w0) || (r->h != r->h0) || (r->h_start != r->h0)) {
LQR_CATCH(lqr_carver_flatten(r));
}
if (r->transposed)
{
CATCH (lqr_carver_transpose(r));
if (r->bias == NULL) {
LQR_CATCH_MEM(r->bias = g_try_new0(gfloat, r->w0 * r->h0));
}

x1 = MAX (0, x_off);
y1 = MAX (0, y_off);
x2 = MIN (r->w, width + x_off);
y2 = MIN (r->h, height + y_off);
xt = r->transposed ? y : x;
yt = r->transposed ? x : y;

for (y = 0; y < y2 - y1; y++)
{
for (x = 0; x < x2 - x1; x++)
{
bias = (gfloat) ((gdouble) bias_factor * buffer[y * width + x] / 2);
r->bias[yt * r->w0 + xt] += (gfloat) bias / 2;

r->bias[(y + y1) * r->w0 + (x + x1)] += bias;
r->nrg_uptodate = FALSE;

}
return LQR_OK;
}

/* LQR_PUBLIC */
LqrRetVal
lqr_carver_bias_add_area(LqrCarver *r, gdouble *buffer, gint bias_factor, gint width, gint height, gint x_off,
gint y_off)
{
gint x, y;
gint xt, yt;
gint wt, ht;
gint x0, y0, x1, y1, x2, y2;
gfloat bias;

LQR_CATCH_CANC(r);

if (bias_factor == 0) {
return LQR_OK;
}

return LQR_OK;
}
if ((r->w != r->w0) || (r->w_start != r->w0) || (r->h != r->h0) || (r->h_start != r->h0)) {
LQR_CATCH(lqr_carver_flatten(r));
}

if (r->nrg_active == FALSE) {
LQR_CATCH(lqr_carver_init_energy_related(r));
}

if (r->bias == NULL) {
LQR_CATCH_MEM(r->bias = g_try_new0(gfloat, r->w * r->h));
}

wt = r->transposed ? r->h : r->w;
ht = r->transposed ? r->w : r->h;

x0 = MIN(0, x_off);
y0 = MIN(0, y_off);
x1 = MAX(0, x_off);
y1 = MAX(0, y_off);
x2 = MIN(wt, width + x_off);
y2 = MIN(ht, height + y_off);

for (y = 0; y < y2 - y1; y++) {
for (x = 0; x < x2 - x1; x++) {
bias = (gfloat) ((gdouble) bias_factor * buffer[(y - y0) * width + (x - x0)] / 2);

xt = r->transposed ? y : x;
yt = r->transposed ? x : y;

r->bias[(yt + y1) * r->w0 + (xt + x1)] += bias;
}
}

r->nrg_uptodate = FALSE;

return LQR_OK;
}

LQR_PUBLIC
/* LQR_PUBLIC */
LqrRetVal
lqr_carver_bias_add(LqrCarver *r, gdouble *buffer, gint bias_factor)
{
return lqr_carver_bias_add_area(r, buffer, bias_factor, r->w0, r->h0, 0, 0);
return lqr_carver_bias_add_area(r, buffer, bias_factor, lqr_carver_get_width(r), lqr_carver_get_height(r), 0, 0);
}

LQR_PUBLIC
/* LQR_PUBLIC */
LqrRetVal
lqr_carver_bias_add_rgb_area(LqrCarver *r, guchar *rgb, gint bias_factor, gint channels, gint width, gint height, gint x_off, gint y_off)
lqr_carver_bias_add_rgb_area(LqrCarver *r, guchar *rgb, gint bias_factor, gint channels, gint width, gint height,
gint x_off, gint y_off)
{
gint x, y, k, c_channels;
gboolean has_alpha;
gint x0, y0, x1, y1, x2, y2;
gint transposed = 0;
gint sum;
gfloat bias;

if (bias_factor == 0)
{
return TRUE;
gint x, y, k, c_channels;
gboolean has_alpha;
gint xt, yt;
gint wt, ht;
gint x0, y0, x1, y1, x2, y2;
gint sum;
gdouble bias;

LQR_CATCH_CANC(r);

if ((r->w != r->w0) || (r->w_start != r->w0) || (r->h != r->h0) || (r->h_start != r->h0)) {
LQR_CATCH(lqr_carver_flatten(r));
}

CATCH_F (r->active);
if ((r->w != r->w0) || (r->w_start != r->w0) ||
(r->h != r->h0) || (r->h_start != r->h0))
{
CATCH (lqr_carver_flatten(r));
if (r->nrg_active == FALSE) {
LQR_CATCH(lqr_carver_init_energy_related(r));
}
if (r->transposed)
{
transposed = 1;
CATCH (lqr_carver_transpose(r));

if (bias_factor == 0) {
return LQR_OK;
}

if (r->bias == NULL) {
LQR_CATCH_MEM(r->bias = g_try_new0(gfloat, r->w * r->h));
}

has_alpha = (channels == 2 || channels >= 4);
c_channels = channels - (has_alpha ? 1 : 0);
x0 = MIN (0, x_off);
y0 = MIN (0, y_off);
x1 = MAX (0, x_off);
y1 = MAX (0, y_off);
x2 = MIN (r->w0, width + x_off);
y2 = MIN (r->h0, height + y_off);
for (y = 0; y < y2 - y1; y++)
{
for (x = 0; x < x2 - x1; x++)
{
sum = 0;
for (k = 0; k < c_channels; k++)
{
sum += rgb[((y - y0) * width + (x - x0)) * channels + k];
has_alpha = (channels == 2 || channels >= 4);
c_channels = channels - (has_alpha ? 1 : 0);
wt = r->transposed ? r->h : r->w;
ht = r->transposed ? r->w : r->h;
x0 = MIN(0, x_off);
y0 = MIN(0, y_off);
x1 = MAX(0, x_off);
y1 = MAX(0, y_off);
x2 = MIN(wt, width + x_off);
y2 = MIN(ht, height + y_off);
for (y = 0; y < y2 - y1; y++) {
for (x = 0; x < x2 - x1; x++) {
sum = 0;
for (k = 0; k < c_channels; k++) {
sum += rgb[((y - y0) * width + (x - x0)) * channels + k];
}

bias = (gfloat) ((gdouble) bias_factor * sum / (2 * 255 * c_channels));
if (has_alpha)
{
bias *= (gfloat) rgb[((y - y0) * width + (x - x0) + 1) * channels - 1] / 255;
bias = ((gdouble) bias_factor * sum / (2 * 255 * c_channels));
if (has_alpha) {
bias *= (gdouble) rgb[((y - y0) * width + (x - x0) + 1) * channels - 1] / 255;
}

r->bias[(y + y1) * r->w0 + (x + x1)] += bias;
xt = r->transposed ? y : x;
yt = r->transposed ? x : y;

r->bias[(yt + y1) * r->w0 + (xt + x1)] += (gfloat) bias;
}

}

if (transposed)
{
CATCH (lqr_carver_transpose(r));
}
r->nrg_uptodate = FALSE;

return LQR_OK;
return LQR_OK;
}

LQR_PUBLIC
/* LQR_PUBLIC */
LqrRetVal
lqr_carver_bias_add_rgb(LqrCarver *r, guchar *rgb, gint bias_factor, gint channels)
{
return lqr_carver_bias_add_rgb_area(r, rgb, bias_factor, channels, r->w0, r->h0, 0, 0);
return lqr_carver_bias_add_rgb_area(r, rgb, bias_factor, channels, lqr_carver_get_width(r),
lqr_carver_get_height(r), 0, 0);
}


/**** END OF LQR_CARVER_BIAS CLASS FUNCTIONS ****/

+ 2
- 2
lqr/lqr_carver_bias.h View File

@@ -15,9 +15,9 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>
* along with this program; if not, see <http://www.gnu.org/licenses/>
*/

#ifndef __LQR_CARVER_BIAS_H__

+ 2
- 2
lqr/lqr_carver_bias_priv.h View File

@@ -15,9 +15,9 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>
* along with this program; if not, see <http://www.gnu.org/licenses/>
*/

#ifndef __LQR_CARVER_BIAS_PRIV_H__

+ 10
- 7
lqr/lqr_carver_bias_pub.h View File

@@ -15,9 +15,9 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>
* along with this program; if not, see <http://www.gnu.org/licenses/>
*/

#ifndef __LQR_CARVER_BIAS_PUB_H__
@@ -29,10 +29,13 @@

/* PUBLIC BIAS-RELATED FUNCTIONS */

LqrRetVal lqr_carver_bias_add_rgb_area(LqrCarver *r, guchar *buffer, gint bias_factor, gint channels, gint width, gint height, gint x_off, gint y_off);
LqrRetVal lqr_carver_bias_add_rgb(LqrCarver *r, guchar *buffer, gint bias_factor, gint channels);
LqrRetVal lqr_carver_bias_add_area(LqrCarver *r, gdouble *buffer, gint bias_factor, gint width, gint height, gint x_off, gint y_off);
LqrRetVal lqr_carver_bias_add(LqrCarver *r, gdouble *buffer, gint bias_factor);

LQR_PUBLIC void lqr_carver_bias_clear(LqrCarver *r);
LQR_PUBLIC LqrRetVal lqr_carver_bias_add_xy(LqrCarver *r, gdouble bias, gint x, gint y);
LQR_PUBLIC LqrRetVal lqr_carver_bias_add_rgb_area(LqrCarver *r, guchar *buffer, gint bias_factor, gint channels,
gint width, gint height, gint x_off, gint y_off);
LQR_PUBLIC LqrRetVal lqr_carver_bias_add_rgb(LqrCarver *r, guchar *buffer, gint bias_factor, gint channels);
LQR_PUBLIC LqrRetVal lqr_carver_bias_add_area(LqrCarver *r, gdouble *buffer, gint bias_factor, gint width, gint height,
gint x_off, gint y_off);
LQR_PUBLIC LqrRetVal lqr_carver_bias_add(LqrCarver *r, gdouble *buffer, gint bias_factor);

#endif /* __LQR_CARVER_BIAS_PUB_H__ */

+ 59
- 50
lqr/lqr_carver_list.c View File

@@ -15,93 +15,102 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>
* along with this program; if not, see <http://www.gnu.org/licenses/>
*/

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <glib.h>

#include <lqr_all.h>
#include <lqr/lqr_all.h>

#ifdef __LQR_DEBUG__
#include <assert.h>
#endif /* __LQR_DEBUG__ */


/**** CARVER LIST FUNCTIONS ****/

LqrCarverList *
lqr_carver_list_append (LqrCarverList * list, LqrCarver * r)
LqrCarverList *
lqr_carver_list_append(LqrCarverList *list, LqrCarver *r)
{
LqrCarverList * prev = NULL;
LqrCarverList * now = list;
while (now != NULL)
{
prev = now;
now = now->next;
}
TRY_N_N (now = g_try_new(LqrCarverList, 1));
now->next = NULL;
now->current = r;
if (prev)
{
prev->next = now;
LqrCarverList *prev = NULL;
LqrCarverList *now = list;
while (now != NULL) {
prev = now;
now = now->next;
}
if (list == NULL)
{
return now;
LQR_TRY_N_N(now = g_try_new(LqrCarverList, 1));
now->next = NULL;
now->current = r;
if (prev) {
prev->next = now;
}
else
{
return list;
if (list == NULL) {
return now;
} else {
return list;
}
}

void
lqr_carver_list_destroy(LqrCarverList * list)
lqr_carver_list_destroy(LqrCarverList *list)
{
LqrCarverList * now = list;
if (now != NULL)
{
lqr_carver_list_destroy(now->next);
lqr_carver_destroy(now->current);
LqrCarverList *now = list;
if (now != NULL) {
lqr_carver_list_destroy(now->next);
lqr_carver_list_destroy(now->current->attached_list);
lqr_carver_destroy(now->current);
}
}

LQR_PUBLIC
/* LQR_PUBLIC */
LqrCarverList *
lqr_carver_list_start (LqrCarver *r)
lqr_carver_list_start(LqrCarver *r)
{
return r->attached_list;
return r->attached_list;
}

LQR_PUBLIC
/* LQR_PUBLIC */
LqrCarverList *
lqr_carver_list_next (LqrCarverList * list)
lqr_carver_list_next(LqrCarverList *list)
{
TRY_N_N (list);
return list->next;
LQR_TRY_N_N(list);
return list->next;
}

LQR_PUBLIC
/* LQR_PUBLIC */
LqrCarver *
lqr_carver_list_current (LqrCarverList * list)
lqr_carver_list_current(LqrCarverList *list)
{
TRY_N_N (list);
return list->current;
LQR_TRY_N_N(list);
return list->current;
}

LQR_PUBLIC
/* LQR_PUBLIC */
LqrRetVal
lqr_carver_list_foreach (LqrCarverList * list, LqrCarverFunc func, LqrDataTok data)
lqr_carver_list_foreach(LqrCarverList *list, LqrCarverFunc func, LqrDataTok data)
{
LqrCarverList * now = list;
if (now != NULL)
{
CATCH (func(now->current, data));
return lqr_carver_list_foreach (now->next, func, data);
LqrCarverList *now = list;
if (now != NULL) {
LQR_CATCH(func(now->current, data));
return lqr_carver_list_foreach(now->next, func, data);
}
return LQR_OK;
return LQR_OK;
}

/* LQR_PUBLIC */
LqrRetVal
lqr_carver_list_foreach_recursive(LqrCarverList *list, LqrCarverFunc func, LqrDataTok data)
{
LqrCarverList *now = list;
if (now != NULL) {
LQR_CATCH(func(now->current, data));
LQR_CATCH(lqr_carver_list_foreach(now->current->attached_list, func, data));
return lqr_carver_list_foreach(now->next, func, data);
}
return LQR_OK;
}

+ 2
- 4
lqr/lqr_carver_list.h View File

@@ -15,9 +15,9 @