Browse Source

Imported Upstream version 0.4.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 @@
1
+2009-05-09  Carlo Baldassi  <carlobaldassi@gmail.com>
2
+
3
+	* Changed lqr_carver_get_[true_]energy
4
+	* Added lqr_carver_get_energy_image
5
+
6
+2009-05-05  Carlo Baldassi  <carlobaldassi@gmail.com>
7
+
8
+	* Updated the example files with the new features
9
+
10
+2009-05-04  Carlo Baldassi  <carlobaldassi@gmail.com>
11
+
12
+	* Added lqr_carver_bias/rigmask_clear
13
+
14
+2009-05-03  Carlo Baldassi  <carlobaldassi@gmail.com>
15
+
16
+	* Changed CATCH* macros to LQR_CATCH*
17
+	* No alpha by default for LQR_CUSTOM_IMAGE
18
+	* Improved set alpha/black channel
19
+	* Bias activates energy (for using with
20
+	  lqr_carver_get_energy)
21
+	* Fixes in lqr_carver_bias/rigmask_add_area
22
+	* Added lqr_carver_rigmask_add_xy
23
+	* Don't call transpose when adding rigmasks
24
+	* Rigmask init set to 0 instead of 1
25
+	* Removed energy previews
26
+	* Added lqr_carvre_get_true_energy
27
+
28
+2009-04-28  Carlo Baldassi  <carlobaldassi@gmail.com>
29
+
30
+	* Heavily optimised the update_mmap code
31
+	* Progress report spans whole sessions instead
32
+	  of being divided into steps when enlagement
33
+	  exceeds the enl_step
34
+
35
+2009-04-27  Carlo Baldassi  <carlobaldassi@gmail.com>
36
+
37
+	* New framework for energy definition, 
38
+	  including energy previews
39
+	* Added lqr_carver_bias_add_xy
40
+	* Better bias managment (saves memory if
41
+	  bias is not used, no unnecessary
42
+	  transpositions)
43
+
44
+2009-04-16  Carlo Baldassi  <carlobaldassi@gmail.com>
45
+
46
+	* Added cancel methods and structures
47
+	* Fixed recursiveness of some calls to
48
+	  lqr_carver_list_foreach
49
+	* Fixed return value of lqr_carver_resize
50
+
51
+2009-04-09  Carlo Baldassi  <carlobaldassi@gmail.com>
52
+
53
+	* Added lqr_carver_set_preserve_input_image
54
+	* Version bump 0.4
55
+
56
+2009-04-08  Carlo Baldassi  <carlobaldassi@gmail.com>
57
+
58
+	* Fixed bug with 16-bit images
59
+
1 60
 2009-01-26  Carlo Baldassi  <carlobaldassi@gmail.com>
2 61
 
3 62
 	* Added readouts for current visiblity map

+ 1
- 0
Makefile.am View File

@@ -15,6 +15,7 @@ EXTRA_DIST = \
15 15
 	examples/Makefile \
16 16
 	examples/README \
17 17
 	BUGS		\
18
+	README.Windows	\
18 19
 	autogen.sh	
19 20
 
20 21
 DISTCLEANFILES = \

+ 15
- 5
Makefile.in View File

@@ -43,10 +43,7 @@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
43 43
 	config.sub depcomp install-sh ltmain.sh missing mkinstalldirs
44 44
 subdir = .
45 45
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
46
-am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
47
-	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
48
-	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
49
-	$(top_srcdir)/configure.ac
46
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
50 47
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
51 48
 	$(ACLOCAL_M4)
52 49
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@@ -91,6 +88,7 @@ AMDEP_TRUE = @AMDEP_TRUE@
91 88
 AMTAR = @AMTAR@
92 89
 API_VERSION = @API_VERSION@
93 90
 AR = @AR@
91
+AS = @AS@
94 92
 AUTOCONF = @AUTOCONF@
95 93
 AUTOHEADER = @AUTOHEADER@
96 94
 AUTOMAKE = @AUTOMAKE@
@@ -100,10 +98,15 @@ CCDEPMODE = @CCDEPMODE@
100 98
 CFLAGS = @CFLAGS@
101 99
 CPP = @CPP@
102 100
 CPPFLAGS = @CPPFLAGS@
101
+CXX = @CXX@
102
+CXXCPP = @CXXCPP@
103
+CXXDEPMODE = @CXXDEPMODE@
104
+CXXFLAGS = @CXXFLAGS@
103 105
 CYGPATH_W = @CYGPATH_W@
104 106
 DATADIR = @DATADIR@
105 107
 DEFS = @DEFS@
106 108
 DEPDIR = @DEPDIR@
109
+DLLTOOL = @DLLTOOL@
107 110
 DSYMUTIL = @DSYMUTIL@
108 111
 DUMPBIN = @DUMPBIN@
109 112
 ECHO_C = @ECHO_C@
@@ -112,6 +115,7 @@ ECHO_T = @ECHO_T@
112 115
 EGREP = @EGREP@
113 116
 EXEEXT = @EXEEXT@
114 117
 FGREP = @FGREP@
118
+FVISIBILITY_FLAG = @FVISIBILITY_FLAG@
115 119
 GLIB_CFLAGS = @GLIB_CFLAGS@
116 120
 GLIB_DIR = @GLIB_DIR@
117 121
 GLIB_LIBS = @GLIB_LIBS@
@@ -134,12 +138,14 @@ LIPO = @LIPO@
134 138
 LN_S = @LN_S@
135 139
 LTLIBOBJS = @LTLIBOBJS@
136 140
 LTVERSION = @LTVERSION@
141
+LT_NOUNDEF_FLAG = @LT_NOUNDEF_FLAG@
137 142
 MAINT = @MAINT@
138 143
 MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
139 144
 MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
140 145
 MAKEINFO = @MAKEINFO@
141 146
 NM = @NM@
142 147
 NMEDIT = @NMEDIT@
148
+OBJDUMP = @OBJDUMP@
143 149
 OBJEXT = @OBJEXT@
144 150
 OTOOL = @OTOOL@
145 151
 OTOOL64 = @OTOOL64@
@@ -158,9 +164,12 @@ SHELL = @SHELL@
158 164
 STRIP = @STRIP@
159 165
 VERSION = @VERSION@
160 166
 ac_ct_CC = @ac_ct_CC@
167
+ac_ct_CXX = @ac_ct_CXX@
161 168
 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
162 169
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
163 170
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
171
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
172
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
164 173
 am__include = @am__include@
165 174
 am__leading_dot = @am__leading_dot@
166 175
 am__quote = @am__quote@
@@ -216,6 +225,7 @@ EXTRA_DIST = \
216 225
 	examples/Makefile \
217 226
 	examples/README \
218 227
 	BUGS		\
228
+	README.Windows	\
219 229
 	autogen.sh	
220 230
 
221 231
 DISTCLEANFILES = \
@@ -443,7 +453,7 @@ distclean-tags:
443 453
 distdir: $(DISTFILES)
444 454
 	$(am__remove_distdir)
445 455
 	mkdir $(distdir)
446
-	$(mkdir_p) $(distdir)/. $(distdir)/docs $(distdir)/examples $(distdir)/m4
456
+	$(mkdir_p) $(distdir)/. $(distdir)/docs $(distdir)/examples
447 457
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
448 458
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
449 459
 	list='$(DISTFILES)'; for file in $$list; do \

+ 32
- 0
NEWS View File

@@ -1,3 +1,35 @@
1
+Version 0.4:
2
+
3
+* New features:
4
+  * Support for image types (color models):
5
+    GREY, GREYA, RGB, RGBA, CMY, CMYK, CMYKA
6
+    and custom
7
+  * Additional builtin energy functions based on
8
+    luma instead of brightness
9
+  * Support for custom energy functions
10
+  * Functions to read out the energy map
11
+  * Cancel function to interrupt computations
12
+  * Additional methods for bias and rigidity masks
13
+  * Use a single progress instead of several
14
+    ones when the update is performed in steps
15
+  * Can handle input buffers non-destructively
16
+
17
+* Performace related:
18
+  * Faster rescaling thanks to optimisations in
19
+    the code
20
+  * Spare memory when not using features (e.g. the
21
+    bias)
22
+
23
+* Configuration
24
+  * The default installation directory is now /usr
25
+    instead of /usr/local
26
+  * Compiling under MinGW now correctly produces a
27
+    DLL with the default settings
28
+  * Now it also compiles under MS Visual C++
29
+  * All public macro names start with LQR_* (old
30
+    versions are still available but can be disabled
31
+    at configure time)
32
+
1 33
 Version 0.3:
2 34
 
3 35
 * New features:

+ 16
- 9
README View File

@@ -1,5 +1,5 @@
1 1
 
2
-LiquidRescale library 0.2.0
2
+LiquidRescale library 0.4.0
3 3
 ===========================
4 4
 
5 5
 Table of contents
@@ -29,6 +29,8 @@ Following is a list of features:
29 29
 
30 30
   * Easy to use API
31 31
   * Currently supports 8 bit to 64 bit per channel images
32
+  * Support for different color models: grayscale, RGB, CMY
33
+    and even custom ones
32 34
   * Areas in the image can be marked for preservation or
33 35
     discard, or for additional seam rigidity
34 36
   * Once the image has been fully processed, the scaling can
@@ -39,13 +41,16 @@ Following is a list of features:
39 41
     can also work in successive steps without wasting
40 42
     computational time
41 43
   * Possibility to tune the carving operation by letting the
42
-    seams be less connected, or more rigid, or both 
44
+    seams be less connected, or more rigid, or both (the
45
+    rigidity can be also be modulated through a mask, to get
46
+    a differnet behaviour in different areas of the image)
43 47
   * Can export and import the visibility map (the seams)
44 48
   * Other images can be attached and undergo the same carving
45 49
     process as the parent image 
46 50
   * The automatic feature detection algorithm can be tuned
47
-    by selecting among different energy gradient functions
48
-  * Reports progress through a customizable interface
51
+    by selecting among different energy gradient functions,
52
+    and even defining custom ones
53
+  * Reports progress through a customisable interface
49 54
   * A signalling system permits to cleanly handle errors
50 55
 
51 56
 
@@ -62,15 +67,17 @@ The lqr library depends on the glib-2.0 libraries
62 67
 The build package uses autotools and libtool, so the installation
63 68
 commands on Unix systems are simply
64 69
 
65
-./configure --prefix=/usr && make && sudo make install
70
+./configure && make && sudo make install
66 71
 
67 72
 The last step requires administrative privileges.
68
-(If the dynamic linker path includes /usr/local/lib, the `--prefix'
69
-option is not needed.)
73
+(Note: the default installation path is /usr since version 0.4)
70 74
 
71 75
 If you want to also install the man pages for the library functions,
72 76
 add the option `--enable-install-man' in the call to ./configure.
73 77
 
78
+If you wand to disable legacy macro names which do not begin with
79
+LQR_ then add the option `--diable-legacy-macros'
80
+
74 81
 See the INSTALL file for a full description.
75 82
 
76 83
 
@@ -89,7 +96,7 @@ the proper flags.
89 96
 
90 97
 In the `examples' directory you can find a basic example program,
91 98
 `liquidrescale-basic', and a full-featured demo program,
92
-`liquidrescale', toghether with a simple Makefile. Both
99
+`liquidrescale', together with a simple Makefile. Both
93 100
 programs are fully commented.
94 101
 
95 102
 The "basic" version demonstrates how to use the strictly-needed 
@@ -122,5 +129,5 @@ http://www.faculty.idc.ac.il/arik/imret.pdf
122 129
 + Copyright
123 130
 -----------
124 131
 
125
-Copyright (C) 2007-2008 Carlo Baldassi <carlobaldassi@gmail.com>
132
+Copyright (C) 2007-2009 Carlo Baldassi <carlobaldassi@gmail.com>
126 133
 

+ 53
- 0
README.Windows View File

@@ -0,0 +1,53 @@
1
+Compiling the library in Windows
2
+================================
3
+
4
+DISCLAIMER: these notes are not very reliable, as they're
5
+based on some very simple tests, without much knowledge of
6
+the Windows operating system.
7
+
8
+1) Using MinGW/MSYS
9
+
10
+Everything goes as in standard *nix systems (you should
11
+probably change the default installation location with the
12
+--prefix option in `configure').
13
+With the default options, the `configure' sctipt produces a
14
+DLL.  If you want to build a static library, you should pass the
15
+options --disable-shared and --disable-declspec to
16
+`configure', and make sure you define the preprocessor
17
+LQR_DISABLE_DECLSPEC whenever you want to compile/link
18
+against the static library.
19
+
20
+2) Using MS Visual C++
21
+
22
+The library compiles at least under `Microsoft Visual C++
23
+2008 Express edition'. You can create an empty DLL project
24
+with the default setup (choose Console Application then
25
+Advanced Settings -> DLL + Empty Project), then put the
26
+`lqr' directory in the project directory and add all of the
27
+files within that dir to the project with `Add Exisitng
28
+Item'.  Then, you must modify the project properties like
29
+this:
30
+
31
+  a) C/C++ -> General -> Additional Include Directories: add
32
+  the directory `lqr' and its parent, and also the directory
33
+  where all the necessary glib-2.0 headers are found.
34
+
35
+  b) C/C++ -> Preprocessor -> Preprocessor Definitions: add
36
+  LQR_EXPORT to the list
37
+
38
+  c) C/C++ -> Advanced -> Compile As: Compile as C Code (it
39
+  also works otherwise, but this option seems to make sense
40
+  given that the library is ANSI C)
41
+
42
+  d) Linker -> General -> Version: set version (don't know
43
+  if this is really needed or has any purpose at all though)
44
+
45
+  e) Linker -> Additional Library Directories: add the
46
+  directory where glib-2.0.lib is found
47
+
48
+  f) Linker -> Input -> Additional Dependencies: add
49
+  glib-2.0.lib
50
+
51
+When you build the project, it should produce the library
52
+liblqr-1-0.lib and liblqr-1-0.dll files (assuming your
53
+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 || {
115 115
 echo
116 116
 echo "I am going to run ./configure with the following arguments:"
117 117
 echo
118
-echo "  --enable-maintainer-mode --prefix=/usr --enable-install-man $AUTOGEN_CONFIGURE_ARGS $@"
118
+echo "  --enable-maintainer-mode --enable-install-man $AUTOGEN_CONFIGURE_ARGS $@"
119 119
 echo
120 120
 
121 121
 if test -z "$*"; then
@@ -164,7 +164,7 @@ libtoolize --force --copy --install || exit 1
164 164
 
165 165
 cd $ORIGDIR
166 166
 
167
-$srcdir/configure --enable-maintainer-mode --prefix=/usr --enable-install-man $AUTOGEN_CONFIGURE_ARGS "$@"
167
+$srcdir/configure --enable-maintainer-mode --enable-install-man $AUTOGEN_CONFIGURE_ARGS "$@"
168 168
 RC=$?
169 169
 if test $RC -ne 0; then
170 170
   echo

+ 19
- 0
config.h.in View File

@@ -36,6 +36,15 @@
36 36
 /* Library name */
37 37
 #undef LIBRARY_NAME
38 38
 
39
+/* Disable __declspec directives */
40
+#undef LQR_DISABLE_DECLSPEC
41
+
42
+/* Disable legacy macros */
43
+#undef LQR_DISABLE_LEGACY_MACROS
44
+
45
+/* Flag for Windows DLL creation */
46
+#undef LQR_EXPORTS
47
+
39 48
 /* Library age */
40 49
 #undef LTVERSION_AGE
41 50
 
@@ -81,3 +90,13 @@
81 90
 
82 91
 /* Version number of package */
83 92
 #undef VERSION
93
+
94
+/* Define to `__inline__' or `__inline' if that's what the C compiler
95
+   calls it, or to nothing if 'inline' is not supported under any name.  */
96
+#ifndef __cplusplus
97
+#undef inline
98
+#endif
99
+
100
+/* Define to empty if the keyword `volatile' does not work. Warning: valid
101
+   code using `volatile' can become incorrect without. Disable with care. */
102
+#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 @@
1 1
 dnl Process this file with autoconf to produce a configure script.
2 2
 
3
-AC_PREREQ(2.54)
3
+AC_PREREQ(2.63)
4 4
 
5 5
 dnl remember to edit the .pc file name
6 6
 dnl and lqr/Makefile.am if you change these 
@@ -14,18 +14,20 @@ m4_define([library_name], [liblqr-api_version])
14 14
 
15 15
 dnl These three define the library version number
16 16
 m4_define([package_major_version], [0])
17
-m4_define([package_minor_version], [3])
18
-m4_define([package_micro_version], [1])
17
+m4_define([package_minor_version], [4])
18
+m4_define([package_micro_version], [0])
19 19
 
20 20
 m4_define([package_version],
21 21
           [package_major_version.package_minor_version.package_micro_version])
22 22
 
23
-m4_define([ltversion_current], [2])
24
-m4_define([ltversion_revision], [1])
25
-m4_define([ltversion_age], [2])
23
+m4_define([ltversion_current], [3])
24
+m4_define([ltversion_revision], [0])
25
+m4_define([ltversion_age], [3])
26 26
 
27 27
 AC_INIT([library_name], [package_version])
28 28
 
29
+AC_PREFIX_DEFAULT([/usr])
30
+
29 31
 AC_DEFINE(LIBRARY_NAME, PACKAGE_NAME, [Library name])
30 32
 
31 33
 AC_DEFINE(PACKAGE_MAJOR_VERSION, package_major_version, [Package major version])
@@ -52,7 +54,7 @@ LTVERSION=ltversion_current:ltversion_revision:ltversion_age
52 54
 AC_SUBST(LTVERSION)
53 55
 
54 56
 AC_CONFIG_SRCDIR([lqr/lqr_carver.c])
55
-AM_CONFIG_HEADER(config.h)
57
+AC_CONFIG_HEADERS([config.h])
56 58
 
57 59
 AC_CONFIG_MACRO_DIR([m4])
58 60
 
@@ -60,17 +62,24 @@ AM_INIT_AUTOMAKE([-Wall -Werror])
60 62
 
61 63
 AC_ISC_POSIX
62 64
 AC_PROG_CC
65
+AC_PROG_CXX
63 66
 AM_PROG_CC_STDC
67
+AC_PROG_INSTALL
68
+AC_PROG_LN_S
69
+AC_PROG_MAKE_SET
70
+AC_PROG_RANLIB
64 71
 AC_HEADER_STDC
65 72
 
73
+AC_C_INLINE
74
+AC_C_VOLATILE
75
+
66 76
 AC_DISABLE_STATIC
67
-AC_PROG_LIBTOOL
77
+LT_INIT([win32-dll])
68 78
 
69 79
 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
70 80
 
71 81
 AM_MAINTAINER_MODE
72 82
 
73
-
74 83
 dnl Use -Wall if we have gcc.
75 84
 changequote(,)dnl
76 85
 if test "x$GCC" = "xyes"; then
@@ -81,7 +90,6 @@ if test "x$GCC" = "xyes"; then
81 90
 fi
82 91
 changequote([,])dnl
83 92
 
84
-
85 93
 GLIB_REQUIRED_VERSION=2.0.0
86 94
 
87 95
 PKG_CHECK_MODULES(GLIB,
@@ -101,6 +109,62 @@ AC_CHECK_FUNCS(bind_textdomain_codeset)
101 109
 DATADIR="${datadir}/library_name"
102 110
 AC_SUBST(DATADIR)
103 111
 
112
+AC_ARG_ENABLE([install-man],
113
+     [AS_HELP_STRING([--enable-install-man], [Install man pages])],
114
+     [AS_CASE(["${enableval}"],
115
+	  [yes], [install_man=true],
116
+	  [no], [install_man=false],
117
+	  [AC_MSG_ERROR([bad value ${enableval} for --enable-install-man])]
118
+	  )],
119
+     [install_man=false])
120
+AM_CONDITIONAL([INSTMAN], [test x$install_man = xtrue])
121
+
122
+AC_ARG_ENABLE([legacy-macros],
123
+     [AS_HELP_STRING([--disable-legacy-macros], [Disable legacy macros])],
124
+     [AS_CASE([["${enableval}"]],
125
+	  [yes], [legacy_macros=true],
126
+	  [no], [legacy_macros=false],
127
+	  [AC_MSG_ERROR([bad value ${enableval} for --enable-legacy-macros])]
128
+	  )],
129
+     [legacy_macros=true])
130
+AS_IF([test "x$legacy_macros" = "xfalse"],
131
+      [AC_DEFINE([LQR_DISABLE_LEGACY_MACROS],[],[Disable legacy macros])],
132
+      [:]
133
+      )
134
+
135
+AC_ARG_ENABLE([dllimport],
136
+     [AS_HELP_STRING([--disable-declspec], [Disable Win32 __declspec directives (only meaningful for building static library on MinGW)])],
137
+     [AS_CASE([["${enableval}"]],
138
+	  [yes], [declspec=true],
139
+	  [no], [declspec=false],
140
+	  [AC_MSG_ERROR([bad value ${enableval} for --enable-declspec])]
141
+	  )],
142
+     [declspec=true])
143
+AS_IF([test "x$declspec" = "xfalse"],
144
+      [AC_DEFINE([LQR_DISABLE_DECLSPEC],[],[Disable __declspec directives])],
145
+      [:]
146
+      )
147
+
148
+
149
+AC_MSG_CHECKING([[if we are on Win32]])
150
+AC_LANG([C])
151
+AC_PREPROC_IFELSE([[
152
+		   #ifndef WIN32
153
+		   #errrrrrrrrorrrrr
154
+		   #endif
155
+		   ]],
156
+		   [[is_win32=true]],
157
+		   [[is_win32=false]]
158
+		   )
159
+AS_IF([test "x$is_win32" = "xtrue"],
160
+      [AC_MSG_RESULT([yes]); LT_NOUNDEF_FLAG="-no-undefined"; FVISIBILITY_FLAG=""],
161
+      [AC_MSG_RESULT([no]); LT_NOUNDEF_FLAG=""; FVISIBILITY_FLAG="-fvisibility=\"hidden\""],
162
+      )
163
+
164
+AC_SUBST(LT_NOUNDEF_FLAG)
165
+AC_SUBST(FVISIBILITY_FLAG)
166
+
167
+AC_DEFINE([LQR_EXPORTS],[],[Flag for Windows DLL creation])
104 168
 
105 169
 AC_CONFIG_FILES([
106 170
 Makefile
@@ -109,14 +173,5 @@ man/Makefile
109 173
 lqr-1.pc
110 174
 ])
111 175
 
112
-AC_ARG_ENABLE([install-man],
113
-     [  --enable-install-man    Install man pages],
114
-     [case "${enableval}" in
115
-       yes) install_man=true ;;
116
-       no)  install_man=false ;;
117
-       *) AC_MSG_ERROR([bad value ${enableval} for --enable-install-man]) ;;
118
-     esac],[install_man=false])
119
-AM_CONDITIONAL([INSTMAN], [test x$install_man = xtrue])
120
-
121 176
 
122 177
 AC_OUTPUT

+ 2
- 0
docs/Makefile View File

@@ -15,6 +15,8 @@ redir = redir-html
15 15
 
16 16
 all: html
17 17
 
18
+dist: html onepage dist-man
19
+
18 20
 #sgml : $(dest)
19 21
 
20 22
 #$(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`
34 34
 
35 35
 PNGWRITER_LIBS = -lpng -lpngwriter -lz -lfreetype 
36 36
 
37
+# collect flags for the compiler for glib thread support
38
+GTHREAD_LIBS = `pkg-config --libs gthread-2.0`
39
+
37 40
 # join the flags collected above
38 41
 INCLUDES = \
39 42
 	$(LQR_CFLAGS) \
@@ -44,7 +47,8 @@ LIBDIRS = \
44 47
 
45 48
 LIBS = \
46 49
        $(LQR_LIBS) \
47
-       $(PNGWRITER_LIBS)
50
+       $(PNGWRITER_LIBS) \
51
+       $(GTHREAD_LIBS)
48 52
 
49 53
 # define the flags to use in the various compilation steps
50 54
 BASE_FLAGS = -Winline -O2 -Wall

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

@@ -29,258 +29,238 @@ gint new_height = 0;
29 29
 gfloat rigidity = 0;
30 30
 gint max_step = 1;
31 31
 
32
-
33 32
 /*** MAIN ***/
34 33
 
35 34
 int
36
-main (int argc, char **argv)
35
+main(int argc, char **argv)
37 36
 {/*{{{*/
38 37
 
39
-  /*** read the command line ***/
40
-  TRAP (parse_command_line (argc, argv));
38
+    /*** read the command line ***/
39
+    TRAP(parse_command_line(argc, argv));
41 40
 
42
-  /*** open input and output files ***/
43
-  pngwriter png (1, 1, 0, outfile);
44
-  png.readfromfile (infile);
41
+    /*** open input and output files ***/
42
+    pngwriter png(1, 1, 0, outfile);
43
+    png.readfromfile(infile);
45 44
 
46
-  /*** old and new size ***/
47
-  gint old_width = png.getwidth ();
48
-  gint old_height = png.getheight ();
45
+    /*** old and new size ***/
46
+    gint old_width = png.getwidth();
47
+    gint old_height = png.getheight();
49 48
 
50
-  new_width = (new_width ? new_width : old_width);
51
-  new_height = (new_height ? new_height : old_height);
49
+    new_width = (new_width ? new_width : old_width);
50
+    new_height = (new_height ? new_height : old_height);
52 51
 
53
-  if (new_width < 2)
54
-    {
55
-      cerr << "The width should be greater than 2" << endl;
56
-      exit (1);
52
+    if (new_width < 2) {
53
+        cerr << "The width should be greater than 2" << endl;
54
+        exit(1);
57 55
     }
58 56
 
59
-  if (new_height < 2)
60
-    {
61
-      cerr << "The height should be greater than 2" << endl;
62
-      exit (1);
57
+    if (new_height < 2) {
58
+        cerr << "The height should be greater than 2" << endl;
59
+        exit(1);
63 60
     }
64 61
 
65
-  /*** print some information on screen ***/
66
-  cout << "resizing " << infile << " [" << old_width << "x" << old_height << "] into " <<
67
-    outfile << " [" << new_width << "x" << new_height << "]" << endl << flush;
68
-
69
-
70
-  /* convert the image into rgb buffers to use them with the library */
71
-
72
-  guchar *rgb_buffer;
73
-
74
-  TRAP_N (rgb_buffer = rgb_buffer_from_image (&png));
62
+    /*** print some information on screen ***/
63
+    cout << "resizing " << infile << " [" << old_width << "x" << old_height << "] into " <<
64
+        outfile << " [" << new_width << "x" << new_height << "]" << endl << flush;
75 65
 
76
-  
66
+    /* convert the image into rgb buffers to use them with the library */
77 67
 
78
-  /**** (I) GENERATE THE MULTISIZE REPRESENTATION ****/
68
+    guchar *rgb_buffer;
79 69
 
80
-  /* (I.1) swallow the buffer in a (minimal) LqrCarver object 
81
-   *       (arguments are width, height and number of colour channels) */
82
-  LqrCarver *carver;
83
-  TRAP_N (carver = lqr_carver_new (rgb_buffer, old_width, old_height, 3));
70
+    TRAP_N(rgb_buffer = rgb_buffer_from_image(&png));
84 71
 
85
-  /* (I.2) initialize the carver (with default values),
86
-   *          so that we can do the resizing */
87
-  TRAP (lqr_carver_init (carver, max_step, rigidity));
72
+    /**** (I) GENERATE THE MULTISIZE REPRESENTATION ****/
88 73
 
74
+    /* (I.1) swallow the buffer in a (minimal) LqrCarver object 
75
+     *       (arguments are width, height and number of colour channels) */
76
+    LqrCarver *carver;
77
+    TRAP_N(carver = lqr_carver_new(rgb_buffer, old_width, old_height, 3));
89 78
 
90
-  /**** (II) LIQUID RESCALE ****/
79
+    /* (I.2) initialize the carver (with default values),
80
+     *          so that we can do the resizing */
81
+    TRAP(lqr_carver_init(carver, max_step, rigidity));
91 82
 
92
-  TRAP (lqr_carver_resize (carver, new_width, new_height));
83
+    /**** (II) LIQUID RESCALE ****/
93 84
 
85
+    TRAP(lqr_carver_resize(carver, new_width, new_height));
94 86
 
95
-  /**** (III) READOUT THE MULTISIZE IMAGE ****/
87
+    /**** (III) READOUT THE MULTISIZE IMAGE ****/
96 88
 
97
-  TRAP (write_carver_to_image (carver, &png));
89
+    TRAP(write_carver_to_image(carver, &png));
98 90
 
91
+    /**** (IV) DESTROY THE CARVER OBJECT ****/
99 92
 
93
+    lqr_carver_destroy(carver);
100 94
 
101
-  /*** close file (write the image on disk) ***/
95
+    /*** close file (write the image on disk) ***/
102 96
 
103
-  png.close ();
97
+    png.close();
104 98
 
105
-  return 0;
99
+    return 0;
106 100
 }/*}}}*/
107 101
 
108 102
 /*** PARSE COMMAND LINE ***/
109 103
 
110
-LqrRetVal parse_command_line (int argc, char **argv)
104
+LqrRetVal
105
+parse_command_line(int argc, char **argv)
111 106
 {/*{{{*/
112
-  int i;
113
-  int c;
114
-  struct option lopts[]= {
115
-    {"file", required_argument, NULL, 'f'},
116
-    {"out-file", required_argument, NULL, 'o'},
117
-    {"width", required_argument, NULL, 'w'},
118
-    {"height", required_argument, NULL, 'h'},
119
-    {"rigidity", required_argument, NULL, 'r'},
120
-    {"max-step", required_argument, NULL, 's'},
121
-    {"help", no_argument, NULL, '#'},
122
-    {NULL,0,NULL,0}
123
-  };
124
-
125
-
126
-
127
-  while ((c = getopt_long(argc, argv, "f:,o:,w:,h:,r:,s:", lopts, &i)) != EOF) {
128
-    switch (c)
129
-    {
130
-      case 'f':
131
-	infile = optarg;
132
-	break;
133
-      case 'o':
134
-	outfile = optarg;
135
-	break;
136
-      case 'w':
137
-	new_width = atoi(optarg);
138
-	break;
139
-      case 'h':
140
-	new_height = atoi(optarg);
141
-	break;
142
-      case 'r':
143
-	rigidity = atof(optarg);
144
-	break;
145
-      case 's':
146
-	max_step = atoi(optarg);
147
-	break;
148
-      case '#':
149
-	help(argv[0]);
150
-	exit (0);
151
-      default:
152
-	cerr << "Error parsing command line. Use " << argv[0] << " --help for usage instructions." << endl;
153
-	return LQR_ERROR;
107
+    int i;
108
+    int c;
109
+    struct option lopts[] = {
110
+        {"file", required_argument, NULL, 'f'},
111
+        {"out-file", required_argument, NULL, 'o'},
112
+        {"width", required_argument, NULL, 'w'},
113
+        {"height", required_argument, NULL, 'h'},
114
+        {"rigidity", required_argument, NULL, 'r'},
115
+        {"max-step", required_argument, NULL, 's'},
116
+        {"help", no_argument, NULL, '#'},
117
+        {NULL, 0, NULL, 0}
118
+    };
119
+
120
+    while ((c = getopt_long(argc, argv, "f:,o:,w:,h:,r:,s:", lopts, &i)) != EOF) {
121
+        switch (c) {
122
+            case 'f':
123
+                infile = optarg;
124
+                break;
125
+            case 'o':
126
+                outfile = optarg;
127
+                break;
128
+            case 'w':
129
+                new_width = atoi(optarg);
130
+                break;
131
+            case 'h':
132
+                new_height = atoi(optarg);
133
+                break;
134
+            case 'r':
135
+                rigidity = atof(optarg);
136
+                break;
137
+            case 's':
138
+                max_step = atoi(optarg);
139
+                break;
140
+            case '#':
141
+                help(argv[0]);
142
+                exit(0);
143
+            default:
144
+                cerr << "Error parsing command line. Use " << argv[0] << " --help for usage instructions." << endl;
145
+                return LQR_ERROR;
146
+        }
154 147
     }
155
-  }
156 148
 
157
-  if (!infile)
158
-    {
159
-     cerr << "Input file missing." << endl;
160
-     return LQR_ERROR;
149
+    if (!infile) {
150
+        cerr << "Input file missing." << endl;
151
+        return LQR_ERROR;
161 152
     }
162
-  
163
-  if (!outfile)
164
-    {
165
-     cerr << "Output file missing." << endl;
166
-     return LQR_ERROR;
167
-    } 
168
-
169
-  if (!new_width && !new_height)
170
-    {
171
-      cerr << "Either --width or --height has to be specified." << endl;
172
-      return LQR_ERROR;
153
+
154
+    if (!outfile) {
155
+        cerr << "Output file missing." << endl;
156
+        return LQR_ERROR;
173 157
     }
174 158
 
175
-  if (rigidity < 0)
176
-    {
177
-      cerr << "Rigidity cannot be negative." << endl;
178
-      return LQR_ERROR;
159
+    if (!new_width && !new_height) {
160
+        cerr << "Either --width or --height has to be specified." << endl;
161
+        return LQR_ERROR;
179 162
     }
180 163
 
181
-  if (max_step < 0)
182
-    {
183
-      cerr << "Max step cannot be negative." << endl;
184
-      return LQR_ERROR;
164
+    if (rigidity < 0) {
165
+        cerr << "Rigidity cannot be negative." << endl;
166
+        return LQR_ERROR;
185 167
     }
186 168
 
169
+    if (max_step < 0) {
170
+        cerr << "Max step cannot be negative." << endl;
171
+        return LQR_ERROR;
172
+    }
187 173
 
188
-  return LQR_OK;
174
+    return LQR_OK;
189 175
 }/*}}}*/
190 176
 
191
-void help(char *command)
177
+void
178
+help(char *command)
192 179
 {/*{{{*/
193
-  cout << "Usage: " << command << " -f <file> -o <out-file> [ -w <width> | -h <height> ] [ ... ]" << endl;
194
-  cout << "  Options:" << endl;
195
-  cout << "    -f <file> or --file <file>" << endl;
196
-  cout << "        Specifies input file. Must be in PNG format, in RGB without alpha channel" << endl;
197
-  cout << "    -o <out-file> or --out-file <out-file>" << endl;
198
-  cout << "        Specifies the output file." << endl;
199
-  cout << "    -w <width> or --width <width>" << endl;
200
-  cout << "        The new width. It must be greater than 2." << endl;
201
-  cout << "        If it is 0, or it is not given, the width is unchanged." << endl;
202
-  cout << "    -h <height> or --height <height>" << endl;
203
-  cout << "        Same as -w for the height." << endl;
204
-  cout << "    -r <rigidity> or --rigidity < rigidity>" << endl;
205
-  cout << "        Seams rigidity. Any non-negative value is allowed. Defaults to 0." << endl;
206
-  cout << "    -s <max-step> or --max-step <max-step>" << endl;
207
-  cout << "        Maximum seam transversal step. Default value is 1." << endl;
208
-  cout << "    --help" << endl;
209
-  cout << "        This help." << endl;
180
+    cout << "Usage: " << command << " -f <file> -o <out-file> [ -w <width> | -h <height> ] [ ... ]" << endl;
181
+    cout << "  Options:" << endl;
182
+    cout << "    -f <file> or --file <file>" << endl;
183
+    cout << "        Specifies input file. Must be in PNG format, in RGB without alpha channel" << endl;
184
+    cout << "    -o <out-file> or --out-file <out-file>" << endl;
185
+    cout << "        Specifies the output file." << endl;
186
+    cout << "    -w <width> or --width <width>" << endl;
187
+    cout << "        The new width. It must be greater than 2." << endl;
188
+    cout << "        If it is 0, or it is not given, the width is unchanged." << endl;
189
+    cout << "    -h <height> or --height <height>" << endl;
190
+    cout << "        Same as -w for the height." << endl;
191
+    cout << "    -r <rigidity> or --rigidity < rigidity>" << endl;
192
+    cout << "        Seams rigidity. Any non-negative value is allowed. Defaults to 0." << endl;
193
+    cout << "    -s <max-step> or --max-step <max-step>" << endl;
194
+    cout << "        Maximum seam transversal step. Default value is 1." << endl;
195
+    cout << "    --help" << endl;
196
+    cout << "        This help." << endl;
210 197
 }/*}}}*/
211
-  
212 198
 
213 199
 /*** AUXILIARY I/O FUNCTIONS ***/
214 200
 
215 201
 /* convert the image in the right format */
216 202
 guchar *
217
-rgb_buffer_from_image (pngwriter * png)
203
+rgb_buffer_from_image(pngwriter *png)
218 204
 {/*{{{*/
219
-  gint x, y, k, channels;
220
-  gint w, h;
221
-  guchar *buffer;
222
-
223
-  /* get info from the image */
224
-  w = png->getwidth ();
225
-  h = png->getheight ();
226
-  channels = 3;                      // we assume an RGB image here 
227
-
228
-  /* allocate memory to store w * h * channels unsigned chars */
229
-  buffer = g_try_new (guchar, channels * w * h);
230
-  g_assert (buffer != NULL);
231
-
232
-  /* start iteration (always y first, then x, then colours) */
233
-  for (y = 0; y < h; y++)
234
-    {
235
-      for (x = 0; x < w; x++)
236
-        {
237
-          for (k = 0; k < channels; k++)
238
-            {
239
-              /* read the image channel k at position x,y */
240
-              buffer[(y * w + x) * channels + k] =
241
-                (guchar) (png->dread (x + 1, y + 1, k + 1) * 255);
242
-              /* note : the x+1,y+1,k+1 on the right side are
243
-               *        specific the pngwriter library */
205
+    gint x, y, k, channels;
206
+    gint w, h;
207
+    guchar *buffer;
208
+
209
+    /* get info from the image */
210
+    w = png->getwidth();
211
+    h = png->getheight();
212
+    channels = 3;                       // we assume an RGB image here 
213
+
214
+    /* allocate memory to store w * h * channels unsigned chars */
215
+    buffer = g_try_new(guchar, channels * w * h);
216
+    g_assert(buffer != NULL);
217
+
218
+    /* start iteration (always y first, then x, then colours) */
219
+    for (y = 0; y < h; y++) {
220
+        for (x = 0; x < w; x++) {
221
+            for (k = 0; k < channels; k++) {
222
+                /* read the image channel k at position x,y */
223
+                buffer[(y * w + x) * channels + k] = (guchar) (png->dread(x + 1, y + 1, k + 1) * 255);
224
+                /* note : the x+1,y+1,k+1 on the right side are
225
+                 *        specific the pngwriter library */
244 226
             }
245 227
         }
246 228
     }
247 229
 
248
-  return buffer;
230
+    return buffer;
249 231
 }/*}}}*/
250 232
 
251 233
 /* readout the multizie image */
252 234
 LqrRetVal
253
-write_carver_to_image (LqrCarver * r, pngwriter * png)
235
+write_carver_to_image(LqrCarver *r, pngwriter *png)
254 236
 {/*{{{*/
255
-  gint x, y;
256
-  guchar * rgb;
257
-  gdouble red, green, blue;
258
-  gint w, h;
259
-
260
-  /* make sure the image is RGB */
261
-  CATCH_F (lqr_carver_get_channels(r) == 3);
262
-
263
-  /* resize the image canvas as needed to
264
-   * fit for the new size */
265
-  w = lqr_carver_get_width (r);
266
-  h = lqr_carver_get_height (r);
267
-  png->resize (w, h);
268
-
269
-  /* initialize image reading */
270
-  lqr_carver_scan_reset (r);
271
-
272
-  /* readout (no need to init rgb) */
273
-  while (lqr_carver_scan(r, &x, &y, &rgb))
274
-    {
275
-      /* convert the output into doubles */
276
-      red = (gdouble) rgb[0] / 255;
277
-      green = (gdouble) rgb[1] / 255;
278
-      blue = (gdouble) rgb[2] / 255;
279
-
280
-      /* plot (pngwriter's coordinates start from 1,1) */
281
-      png->plot (x + 1, y + 1, red, green, blue);
237
+    gint x, y;
238
+    guchar *rgb;
239
+    gdouble red, green, blue;
240
+    gint w, h;
241
+
242
+    /* make sure the image is RGB */
243
+    LQR_CATCH_F(lqr_carver_get_channels(r) == 3);
244
+
245
+    /* resize the image canvas as needed to
246
+     * fit for the new size */
247
+    w = lqr_carver_get_width(r);
248
+    h = lqr_carver_get_height(r);
249
+    png->resize(w, h);
250
+
251
+    /* initialize image reading */
252
+    lqr_carver_scan_reset(r);
253
+
254
+    /* readout (no need to init rgb) */
255
+    while (lqr_carver_scan(r, &x, &y, &rgb)) {
256
+        /* convert the output into doubles */
257
+        red = (gdouble) rgb[0] / 255;
258
+        green = (gdouble) rgb[1] / 255;
259
+        blue = (gdouble) rgb[2] / 255;
260
+
261
+        /* plot (pngwriter's coordinates start from 1,1) */
262
+        png->plot(x + 1, y + 1, red, green, blue);
282 263
     }
283 264
 
284
-  return LQR_OK;
265
+    return LQR_OK;
285 266
 }/*}}}*/
286
-

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

@@ -46,17 +46,21 @@
46 46
 	cerr << "Not enough memory, aborting." << endl; \
47 47
 	exit (1); \
48 48
 	break; \
49
+      case LQR_USRCANCEL: \
50
+	cerr << "Cancelled by user, aborting." << endl; \
51
+	exit (1); \
52
+	break; \
49 53
       default: \
50 54
 	break; \
51 55
     } \
52
-}G_STMT_END 
56
+}G_STMT_END
53 57
 
54 58
 /*** PARSE COMMAND LINE ***/
55
-LqrRetVal parse_command_line (int argc, char **argv);
59
+LqrRetVal parse_command_line(int argc, char **argv);
56 60
 void help(char *command);
57 61
 
58 62
 /*** RGB FILE I/O ***/
59
-guchar *rgb_buffer_from_image (pngwriter * png);
60
-LqrRetVal write_carver_to_image (LqrCarver * r, pngwriter * png);
63
+guchar *rgb_buffer_from_image(pngwriter *png);
64
+LqrRetVal write_carver_to_image(LqrCarver *r, pngwriter *png);
61 65
 
62 66
 #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 @@
46 46
 	cerr << "Not enough memory, aborting." << endl; \
47 47
 	exit (1); \
48 48
 	break; \
49
+      case LQR_USRCANCEL: \
50
+	cerr << "Cancelled by user, aborting." << endl; \
51
+	exit (1); \
52
+	break; \
49 53
       default: \
50 54
 	break; \
51 55
     } \
52
-}G_STMT_END 
56
+}G_STMT_END
53 57
 
54 58
 /*** PARSE COMMAND LINE ***/
55
-LqrRetVal parse_command_line (int argc, char **argv);
59
+LqrRetVal parse_command_line(int argc, char **argv);
56 60
 void help(char *command);
57 61
 
58 62
 /*** RGB FILE I/O ***/
59
-guchar *rgb_buffer_from_image (pngwriter * png);
60
-LqrRetVal write_carver_to_image (LqrCarver * r, pngwriter * png);
63
+guchar *rgb_buffer_from_image(pngwriter *png);
64
+LqrRetVal write_carver_to_image(LqrCarver *r, pngwriter *png);
61 65
 
62 66
 /*** VMAP FILES I/O ***/
63
-LqrRetVal save_vmap_to_file (LqrVMap *vmap, gchar * name);
64
-LqrVMap * load_vmap_from_file (gchar *name);
67
+LqrRetVal save_vmap_to_file(LqrVMap *vmap, gchar *name);
68
+LqrVMap *load_vmap_from_file(gchar *name);
69
+
70
+/*** ENERGY FUNCTIONS ***/
71
+gfloat sobelx(gint x, gint y, gint w, gint h, LqrReadingWindow *rw, gpointer extra_data);
72
+gfloat sobel(gint x, gint y, gint w, gint h, LqrReadingWindow *rw, gpointer extra_data);
73
+LqrRetVal set_energy(LqrCarver *carver, gchar *energy_function);
74
+LqrRetVal write_energy(LqrCarver *carver, gchar *energy_outfile, gint orientation);
65 75
 
66 76
 /*** PROGRESS REPORT FUNCTIONS ***/
67
-LqrRetVal my_progress_init (const gchar * message);
68
-LqrRetVal my_progress_update (gdouble percentage);
69
-LqrRetVal my_progress_end (const gchar * message);
70
-void init_progress (LqrProgress * progress);
77
+LqrRetVal my_progress_init(const gchar *message);
78
+LqrRetVal my_progress_update(gdouble percentage);
79
+LqrRetVal my_progress_end(const gchar *message);
80
+void init_progress(LqrProgress * progress);
71 81
 
72 82
 /*** EXTRA ***/
73
-void info_msg(const gchar * msg, const gchar *name);
83
+void info_msg(const gchar *msg, const gchar *name);
84
+gpointer cancel_thread(gpointer data);
85
+void cancel_handler(int signum);
74 86
 
75 87
 #endif /* __LIQUIDRESCALE_H__ */

+ 14
- 2
lqr/Makefile.am View File

@@ -12,6 +12,14 @@ liblqr_1_la_SOURCES = \
12 12
 	lqr_gradient.h  \
13 13
 	lqr_gradient_pub.h  \
14 14
 	lqr_gradient_priv.h  \
15
+	lqr_rwindow.c  \
16
+	lqr_rwindow.h  \
17
+	lqr_rwindow_pub.h  \
18
+	lqr_rwindow_priv.h  \
19
+	lqr_energy.c  \
20
+	lqr_energy.h  \
21
+	lqr_energy_pub.h  \
22
+	lqr_energy_priv.h  \
15 23
 	lqr_cursor.c    \
16 24
 	lqr_cursor.h    \
17 25
 	lqr_cursor_pub.h    \
@@ -20,6 +28,7 @@ liblqr_1_la_SOURCES = \
20 28
 	lqr_carver.h    \
21 29
 	lqr_carver_pub.h    \
22 30
 	lqr_carver_priv.h    \
31
+	lqr_carver_macros_priv.h    \
23 32
 	lqr_carver_list.c    \
24 33
 	lqr_carver_list.h    \
25 34
 	lqr_carver_list_pub.h    \
@@ -45,7 +54,8 @@ liblqr_1_la_SOURCES = \
45 54
 	lqr_progress_pub.h  \
46 55
 	lqr_progress_priv.h
47 56
 
48
-liblqr_1_la_LDFLAGS = -version-info @LTVERSION@
57
+liblqr_1_la_LDFLAGS = -version-info @LTVERSION@ @LT_NOUNDEF_FLAG@
58
+
49 59
 liblqr_1_la_LIBADD = $(GLIB_LIBS) -lm
50 60
 
51 61
 AM_CPPFLAGS = \
@@ -53,7 +63,7 @@ AM_CPPFLAGS = \
53 63
 	-I$(top_srcdir)		\
54 64
 	@GLIB_CFLAGS@		\
55 65
 	-I$(includedir)		\
56
-	-fvisibility=hidden
66
+	@FVISIBILITY_FLAG@
57 67
 
58 68
 lqr_include0_HEADERS = lqr.h
59 69
 
@@ -61,6 +71,8 @@ lqr_include0dir = $(includedir)/@LIBRARY_SNAME@
61 71
 
62 72
 lqr_include_HEADERS = lqr_base.h \
63 73
 		      lqr_gradient_pub.h \
74
+		      lqr_rwindow_pub.h \
75
+		      lqr_energy_pub.h \
64 76
 		      lqr_cursor_pub.h \
65 77
 		      lqr_carver_pub.h \
66 78
 		      lqr_carver_list_pub.h \

+ 32
- 9
lqr/Makefile.in View File

@@ -41,10 +41,7 @@ subdir = lqr
41 41
 DIST_COMMON = $(lqr_include0_HEADERS) $(lqr_include_HEADERS) \
42 42
 	$(srcdir)/Makefile.am $(srcdir)/Makefile.in
43 43
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
44
-am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
45
-	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
46
-	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
47
-	$(top_srcdir)/configure.ac
44
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
48 45
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
49 46
 	$(ACLOCAL_M4)
50 47
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -62,9 +59,10 @@ lqrLTLIBRARIES_INSTALL = $(INSTALL)
62 59
 LTLIBRARIES = $(lqr_LTLIBRARIES)
63 60
 am__DEPENDENCIES_1 =
64 61
 liblqr_1_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
65
-am_liblqr_1_la_OBJECTS = lqr_gradient.lo lqr_cursor.lo lqr_carver.lo \
66
-	lqr_carver_list.lo lqr_carver_bias.lo lqr_carver_rigmask.lo \
67
-	lqr_vmap.lo lqr_vmap_list.lo lqr_progress.lo
62
+am_liblqr_1_la_OBJECTS = lqr_gradient.lo lqr_rwindow.lo lqr_energy.lo \
63
+	lqr_cursor.lo lqr_carver.lo lqr_carver_list.lo \
64
+	lqr_carver_bias.lo lqr_carver_rigmask.lo lqr_vmap.lo \
65
+	lqr_vmap_list.lo lqr_progress.lo
68 66
 liblqr_1_la_OBJECTS = $(am_liblqr_1_la_OBJECTS)
69 67
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
70 68
 depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -91,6 +89,7 @@ AMDEP_TRUE = @AMDEP_TRUE@
91 89
 AMTAR = @AMTAR@
92 90
 API_VERSION = @API_VERSION@
93 91
 AR = @AR@
92
+AS = @AS@
94 93
 AUTOCONF = @AUTOCONF@
95 94
 AUTOHEADER = @AUTOHEADER@
96 95
 AUTOMAKE = @AUTOMAKE@
@@ -100,10 +99,15 @@ CCDEPMODE = @CCDEPMODE@
100 99
 CFLAGS = @CFLAGS@
101 100
 CPP = @CPP@
102 101
 CPPFLAGS = @CPPFLAGS@
102
+CXX = @CXX@
103
+CXXCPP = @CXXCPP@
104
+CXXDEPMODE = @CXXDEPMODE@
105
+CXXFLAGS = @CXXFLAGS@
103 106
 CYGPATH_W = @CYGPATH_W@
104 107
 DATADIR = @DATADIR@
105 108
 DEFS = @DEFS@
106 109
 DEPDIR = @DEPDIR@
110
+DLLTOOL = @DLLTOOL@
107 111
 DSYMUTIL = @DSYMUTIL@
108 112
 DUMPBIN = @DUMPBIN@
109 113
 ECHO_C = @ECHO_C@
@@ -112,6 +116,7 @@ ECHO_T = @ECHO_T@
112 116
 EGREP = @EGREP@
113 117
 EXEEXT = @EXEEXT@
114 118
 FGREP = @FGREP@
119
+FVISIBILITY_FLAG = @FVISIBILITY_FLAG@
115 120
 GLIB_CFLAGS = @GLIB_CFLAGS@
116 121
 GLIB_DIR = @GLIB_DIR@
117 122
 GLIB_LIBS = @GLIB_LIBS@
@@ -134,12 +139,14 @@ LIPO = @LIPO@
134 139
 LN_S = @LN_S@
135 140
 LTLIBOBJS = @LTLIBOBJS@
136 141
 LTVERSION = @LTVERSION@
142
+LT_NOUNDEF_FLAG = @LT_NOUNDEF_FLAG@
137 143
 MAINT = @MAINT@
138 144
 MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
139 145
 MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
140 146
 MAKEINFO = @MAKEINFO@
141 147
 NM = @NM@
142 148
 NMEDIT = @NMEDIT@
149
+OBJDUMP = @OBJDUMP@
143 150
 OBJEXT = @OBJEXT@
144 151
 OTOOL = @OTOOL@
145 152
 OTOOL64 = @OTOOL64@
@@ -158,9 +165,12 @@ SHELL = @SHELL@
158 165
 STRIP = @STRIP@
159 166
 VERSION = @VERSION@
160 167
 ac_ct_CC = @ac_ct_CC@
168
+ac_ct_CXX = @ac_ct_CXX@
161 169
 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
162 170
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
163 171
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
172
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
173
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
164 174
 am__include = @am__include@
165 175
 am__leading_dot = @am__leading_dot@
166 176
 am__quote = @am__quote@
@@ -212,6 +222,14 @@ liblqr_1_la_SOURCES = \
212 222
 	lqr_gradient.h  \
213 223
 	lqr_gradient_pub.h  \
214 224
 	lqr_gradient_priv.h  \
225
+	lqr_rwindow.c  \
226
+	lqr_rwindow.h  \
227
+	lqr_rwindow_pub.h  \
228
+	lqr_rwindow_priv.h  \
229
+	lqr_energy.c  \
230
+	lqr_energy.h  \
231
+	lqr_energy_pub.h  \
232
+	lqr_energy_priv.h  \
215 233
 	lqr_cursor.c    \
216 234
 	lqr_cursor.h    \
217 235
 	lqr_cursor_pub.h    \
@@ -220,6 +238,7 @@ liblqr_1_la_SOURCES = \
220 238
 	lqr_carver.h    \
221 239
 	lqr_carver_pub.h    \
222 240
 	lqr_carver_priv.h    \
241
+	lqr_carver_macros_priv.h    \
223 242
 	lqr_carver_list.c    \
224 243
 	lqr_carver_list.h    \
225 244
 	lqr_carver_list_pub.h    \
@@ -245,19 +264,21 @@ liblqr_1_la_SOURCES = \
245 264
 	lqr_progress_pub.h  \
246 265
 	lqr_progress_priv.h
247 266
 
248
-liblqr_1_la_LDFLAGS = -version-info @LTVERSION@
267
+liblqr_1_la_LDFLAGS = -version-info @LTVERSION@ @LT_NOUNDEF_FLAG@
249 268
 liblqr_1_la_LIBADD = $(GLIB_LIBS) -lm
250 269
 AM_CPPFLAGS = \
251 270
 	-DDATADIR=\""$(DATADIR)"\"		\
252 271
 	-I$(top_srcdir)		\
253 272
 	@GLIB_CFLAGS@		\
254 273
 	-I$(includedir)		\
255
-	-fvisibility=hidden
274
+	@FVISIBILITY_FLAG@
256 275
 
257 276
 lqr_include0_HEADERS = lqr.h
258 277
 lqr_include0dir = $(includedir)/@LIBRARY_SNAME@
259 278
 lqr_include_HEADERS = lqr_base.h \
260 279
 		      lqr_gradient_pub.h \
280
+		      lqr_rwindow_pub.h \
281
+		      lqr_energy_pub.h \
261 282
 		      lqr_cursor_pub.h \
262 283
 		      lqr_carver_pub.h \
263 284
 		      lqr_carver_list_pub.h \
@@ -342,8 +363,10 @@ distclean-compile:
342 363
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_carver_list.Plo@am__quote@
343 364
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_carver_rigmask.Plo@am__quote@
344 365
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_cursor.Plo@am__quote@
366
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_energy.Plo@am__quote@
345 367
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_gradient.Plo@am__quote@
346 368
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_progress.Plo@am__quote@
369
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_rwindow.Plo@am__quote@
347 370
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_vmap.Plo@am__quote@
348 371
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lqr_vmap_list.Plo@am__quote@
349 372
 

+ 4
- 3
lqr/lqr.h View File

@@ -15,12 +15,11 @@
15 15
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 17
  * GNU Lesser General Public License for more details.
18
- 
18
+
19 19
  * You should have received a copy of the GNU Lesser General Public License
20
- * along with this program; if not, see <http://www.gnu.org/licenses/> 
20
+ * along with this program; if not, see <http://www.gnu.org/licenses/>
21 21
  */
22 22
 
23
-
24 23
 #ifndef __LQR_H__
25 24
 #define __LQR_H__
26 25
 
@@ -30,6 +29,8 @@ G_BEGIN_DECLS
30 29
 
31 30
 #include <lqr/lqr_base.h>
32 31
 #include <lqr/lqr_gradient_pub.h>
32
+#include <lqr/lqr_rwindow_pub.h>
33
+#include <lqr/lqr_energy_pub.h>
33 34
 #include <lqr/lqr_cursor_pub.h>
34 35
 #include <lqr/lqr_progress_pub.h>
35 36
 #include <lqr/lqr_vmap_pub.h>

+ 4
- 3
lqr/lqr_all.h View File

@@ -15,12 +15,11 @@
15 15
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 17
  * GNU Lesser General Public License for more details.
18
- 
18
+
19 19
  * You should have received a copy of the GNU Lesser General Public License
20
- * along with this program; if not, see <http://www.gnu.org/licenses/> 
20
+ * along with this program; if not, see <http://www.gnu.org/licenses/>
21 21
  */
22 22
 
23
-
24 23
 #ifndef __LQR_ALL_H__
25 24
 #define __LQR_ALL_H__
26 25
 
@@ -30,6 +29,8 @@ G_BEGIN_DECLS
30 29
 
31 30
 #include <lqr/lqr_base.h>
32 31
 #include <lqr/lqr_gradient.h>
32
+#include <lqr/lqr_rwindow.h>
33
+#include <lqr/lqr_energy.h>
33 34
 #include <lqr/lqr_cursor.h>
34 35
 #include <lqr/lqr_progress.h>
35 36
 #include <lqr/lqr_vmap.h>

+ 64
- 30
lqr/lqr_base.h View File

@@ -15,24 +15,34 @@
15 15
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 17
  * GNU Lesser General Public License for more details.
18
- 
18
+
19 19
  * You should have received a copy of the GNU Lesser General Public License
20
- * along with this program; if not, see <http://www.gnu.org/licenses/> 
20
+ * along with this program; if not, see <http://www.gnu.org/licenses/>
21 21
  */
22 22
 
23
-
24 23
 #ifndef __LQR_BASE_H__
25 24
 #define __LQR_BASE_H__
26 25
 
27 26
 #define LQR_MAX_NAME_LENGTH (1024)
28 27
 
29
-#define LQR_PUBLIC __attribute__((visibility("default")))
30
-
31
-#define TRY_N_N(assign) if ((assign) == NULL) { return NULL; }
32
-//#define TRY_N_F(assign) if ((assign) == NULL) { return FALSE; }
33
-//#define TRY_F_N(assign) if ((assign) == FALSE) { return NULL; }
34
-//#define TRY_F_F(assign) if ((assign) == FALSE) { return FALSE; }
35
-
28
+#if defined(G_OS_WIN32) && ! defined(LQR_DISABLE_DECLSPEC)
29
+#  ifdef LQR_EXPORTS
30
+#    define LQR_PUBLIC __declspec(dllexport)
31
+#  else
32
+#    define LQR_PUBLIC __declspec(dllimport)
33
+#  endif /* LQR_EXPORTS */
34
+#elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
35
+#  ifndef GCC_HASCLASSVISIBILITY
36
+#    define GCC_HASCLASSVISIBILITY
37
+#  endif /* !GCC_HASCLASSVISIBILITY */
38
+#  ifdef GCC_HASCLASSVISIBILITY
39
+#    define LQR_PUBLIC __attribute__((visibility("default")))
40
+#  else
41
+#    define LQR_PUBLIC
42
+#  endif /* GCC_HASCLASSVISIBILITY */
43
+#else
44
+#  define LQR_PUBLIC
45
+#endif /* G_OS_WIN32 */
36 46
 
37 47
 #if 0
38 48
 #define __LQR_DEBUG__
@@ -43,18 +53,24 @@
43 53
 #endif
44 54
 
45 55
 /**** RETURN VALUES (signals) ****/
46
-enum _LqrRetVal
47
-{
48
-  LQR_ERROR,		/* generic error */
49
-  LQR_OK,		/* ok */ 
50
-  LQR_NOMEM,		/* not enough memory */
51
-  LQR_WARNING		/* generic warning */
56
+enum _LqrRetVal {
57
+    LQR_ERROR,                          /* generic error */
58
+    LQR_OK,                             /* ok */
59
+    LQR_NOMEM,                          /* not enough memory */
60
+    LQR_USRCANCEL                       /* action cancelled by user */
52 61
 };
53 62
 
54 63
 typedef enum _LqrRetVal LqrRetVal;
55 64
 
65
+#define LQR_TRY_N_N(assign) if ((assign) == NULL) { return NULL; }
66
+/*
67
+#define LQR_TRY_F_N(assign) if ((assign) == FALSE) { return NULL; }
68
+#define LQR_TRY_N_F(assign) if ((assign) == NULL) { return FALSE; }
69
+#define LQR_TRY_F_F(assign) if ((assign) == FALSE) { return FALSE; }
70
+*/
71
+
56 72
 /* generic signal processing macros */
57
-#define CATCH(expr) G_STMT_START { \
73
+#define LQR_CATCH(expr) G_STMT_START { \
58 74
   LqrRetVal ret_val; \
59 75
   if ((ret_val = (expr)) != LQR_OK) \
60 76
     { \
@@ -63,7 +79,7 @@ typedef enum _LqrRetVal LqrRetVal;
63 79
 } G_STMT_END
64 80
 
65 81
 /* convert a NULL assignment to an error signal */
66
-#define CATCH_MEM(expr) G_STMT_START { \
82
+#define LQR_CATCH_MEM(expr) G_STMT_START { \
67 83
   if ((expr) == NULL) \
68 84
     { \
69 85
       return LQR_NOMEM; \
@@ -71,21 +87,26 @@ typedef enum _LqrRetVal LqrRetVal;
71 87
 } G_STMT_END
72 88
 
73 89
 /* convert a boolean value to an error signal */
74
-#define CATCH_F(expr) G_STMT_START { \
90
+#define LQR_CATCH_F(expr) G_STMT_START { \
75 91
   if ((expr) == FALSE) \
76 92
     { \
77 93
       return LQR_ERROR; \
78 94
     } \
79 95
 } G_STMT_END
80 96
 
97
+/* legacy */
98
+#ifndef LQR_DISABLE_LEGACY_MACROS
99
+#  define CATCH(expr) LQR_CATCH(expr)
100
+#  define CATCH_MEM(expr) LQR_CATCH_MEM(expr)
101
+#  define CATCH_F(expr) LQR_CATCH_F(expr)
102
+#endif /* LQR_DISABLE_LEGACY_MACROS */
81 103
 
82 104
 /**** IMAGE DEPTH ****/
83
-enum _LqrColDepth
84
-{
85
-  LQR_COLDEPTH_8I,
86
-  LQR_COLDEPTH_16I,
87
-  LQR_COLDEPTH_32F,
88
-  LQR_COLDEPTH_64F,
105
+enum _LqrColDepth {
106
+    LQR_COLDEPTH_8I,
107
+    LQR_COLDEPTH_16I,
108
+    LQR_COLDEPTH_32F,
109
+    LQR_COLDEPTH_64F
89 110
 };
90 111
 
91 112
 typedef enum _LqrColDepth LqrColDepth;
@@ -97,17 +118,30 @@ typedef gfloat lqr_t_32f;
97 118
 typedef gdouble lqr_t_64f;
98 119
 
99 120
 /**** RESIZE ORDER ****/
100
-enum _LqrResizeOrder
101
-{
102
-  LQR_RES_ORDER_HOR,
103
-  LQR_RES_ORDER_VERT
121
+enum _LqrResizeOrder {
122
+    LQR_RES_ORDER_HOR,
123
+    LQR_RES_ORDER_VERT
104 124
 };
105 125
 
106 126
 typedef enum _LqrResizeOrder LqrResizeOrder;
107 127
 
128
+/**** IMAGE TYPE ****/
129
+enum _LqrImageType {
130
+    LQR_RGB_IMAGE,
131
+    LQR_RGBA_IMAGE,
132
+    LQR_GREY_IMAGE,
133
+    LQR_GREYA_IMAGE,
134
+    LQR_CMY_IMAGE,
135
+    LQR_CMYK_IMAGE,
136
+    LQR_CMYKA_IMAGE,
137
+    LQR_CUSTOM_IMAGE
138
+};
139
+
140
+typedef enum _LqrImageType LqrImageType;
141
+
108 142
 /**** CLASSES DECLARATIONS ****/
109 143
 
110
-struct _LqrCarver;              /* the multisize image carver */
144
+struct _LqrCarver;
111 145
 
112 146
 typedef struct _LqrCarver LqrCarver;
113 147
 

+ 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 @@
15 15
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 17
  * GNU Lesser General Public License for more details.
18
- 
18
+
19 19
  * You should have received a copy of the GNU Lesser General Public License
20
- * along with this program; if not, see <http://www.gnu.org/licenses/> 
20
+ * along with this program; if not, see <http://www.gnu.org/licenses/>
21 21
  */
22 22
 
23 23
 #ifndef __LQR_CARVER_H__
@@ -25,5 +25,6 @@
25 25
 
26 26
 #include <lqr/lqr_carver_pub.h>
27 27
 #include <lqr/lqr_carver_priv.h>
28
+#include <lqr/lqr_carver_macros_priv.h>
28 29
 
29 30
 #endif /* __LQR_CARVER_H__ */

+ 141
- 86
lqr/lqr_carver_bias.c View File

@@ -15,11 +15,15 @@
15 15
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 17
  * GNU Lesser General Public License for more details.
18
- 
18
+
19 19
  * You should have received a copy of the GNU Lesser General Public License
20
- * along with this program; if not, see <http://www.gnu.org/licenses/> 
20
+ * along with this program; if not, see <http://www.gnu.org/licenses/>
21 21
  */
22 22
 
23
+#ifdef HAVE_CONFIG_H
24
+#  include <config.h>
25
+#endif
26
+
23 27
 #include <lqr/lqr_all.h>
24 28
 
25 29
 #ifdef __LQR_DEBUG__
@@ -28,132 +32,183 @@
28 32
 
29 33
 /**** LQR_CARVER_BIAS STRUCT FUNTIONS ****/
30 34
 
31
-LQR_PUBLIC
35
+/* LQR_PUBLIC */
36
+void
37
+lqr_carver_bias_clear(LqrCarver *r)
38
+{
39
+    g_free(r->bias);
40
+    r->bias = NULL;
41
+    r->nrg_uptodate = FALSE;
42
+}
43
+
44
+/* LQR_PUBLIC */
32 45
 LqrRetVal
33
-lqr_carver_bias_add_area(LqrCarver *r, gdouble *buffer, gint bias_factor, gint width, gint height, gint x_off, gint y_off)
46
+lqr_carver_bias_add_xy(LqrCarver *r, gdouble bias, gint x, gint y)
34 47
 {
35
-  gint x, y;
36
-  gint x1, y1, x2, y2;
37
-  gfloat bias;
48
+    gint xt, yt;
49
+
50
+    if (bias == 0) {
51
+        return LQR_OK;
52
+    }
38 53
 
39
-  if (bias_factor == 0)
40
-    {
41
-      return LQR_OK;
54
+    LQR_CATCH_CANC(r);
55
+    if (r->nrg_active == FALSE) {
56
+        LQR_CATCH(lqr_carver_init_energy_related(r));
42 57
     }
43 58
 
44
-  CATCH_F (r->active);
45
-  if ((r->w != r->w0) || (r->w_start != r->w0) ||
46
-      (r->h != r->h0) || (r->h_start != r->h0))
47
-    {
48
-      CATCH (lqr_carver_flatten(r));
59
+    if ((r->w != r->w0) || (r->w_start != r->w0) || (r->h != r->h0) || (r->h_start != r->h0)) {
60
+        LQR_CATCH(lqr_carver_flatten(r));
49 61
     }
50
-  if (r->transposed)
51
-    {
52
-      CATCH (lqr_carver_transpose(r));
62
+    if (r->bias == NULL) {
63
+        LQR_CATCH_MEM(r->bias = g_try_new0(gfloat, r->w0 * r->h0));
53 64
     }
54 65
 
55
-  x1 = MAX (0, x_off);
56
-  y1 = MAX (0, y_off);
57
-  x2 = MIN (r->w, width + x_off);
58
-  y2 = MIN (r->h, height + y_off);
66
+    xt = r->transposed ? y : x;
67
+    yt = r->transposed ? x : y;
59 68
 
60
-  for (y = 0; y < y2 - y1; y++)
61
-    {
62
-      for (x = 0; x < x2 - x1; x++)
63
-        {
64
-          bias = (gfloat) ((gdouble) bias_factor * buffer[y * width + x] / 2);
69
+    r->bias[yt * r->w0 + xt] += (gfloat) bias / 2;
65 70
 
66
-          r->bias[(y + y1) * r->w0 + (x + x1)] += bias;
71
+    r->nrg_uptodate = FALSE;
67 72
 
68
-        }
73
+    return LQR_OK;
74
+}
69 75
 
76
+/* LQR_PUBLIC */
77
+LqrRetVal
78
+lqr_carver_bias_add_area(LqrCarver *r, gdouble *buffer, gint bias_factor, gint width, gint height, gint x_off,
79
+                         gint y_off)
80
+{
81
+    gint x, y;
82
+    gint xt, yt;
83
+    gint wt, ht;
84
+    gint x0, y0, x1, y1, x2, y2;
85
+    gfloat bias;
86
+
87
+    LQR_CATCH_CANC(r);
88
+
89
+    if (bias_factor == 0) {
90
+        return LQR_OK;
70 91
     }
71 92
 
72
-  return LQR_OK;
73
-}
93
+    if ((r->w != r->w0) || (r->w_start != r->w0) || (r->h != r->h0) || (r->h_start != r->h0)) {
94
+        LQR_CATCH(lqr_carver_flatten(r));
95
+    }
96
+
97
+    if (r->nrg_active == FALSE) {
98
+        LQR_CATCH(lqr_carver_init_energy_related(r));
99
+    }
100
+
101
+    if (r->bias == NULL) {
102
+        LQR_CATCH_MEM(r->bias = g_try_new0(gfloat, r->w * r->h));
103
+    }
104
+
105
+    wt = r->transposed ? r->h : r->w;
106
+    ht = r->transposed ? r->w : r->h;
107
+
108
+    x0 = MIN(0, x_off);
109
+    y0 = MIN(0, y_off);
110
+    x1 = MAX(0, x_off);
111
+    y1 = MAX(0, y_off);
112
+    x2 = MIN(wt, width + x_off);
113
+    y2 = MIN(ht, height + y_off);
114
+
115
+    for (y = 0; y < y2 - y1; y++) {
116
+        for (x = 0; x < x2 - x1; x++) {
117
+            bias = (gfloat) ((gdouble) bias_factor * buffer[(y - y0) * width + (x - x0)] / 2);
118
+
119
+            xt = r->transposed ? y : x;
120
+            yt = r->transposed ? x : y;
74 121
 
122
+            r->bias[(yt + y1) * r->w0 + (xt + x1)] += bias;
123
+        }
124
+    }
125
+
126
+    r->nrg_uptodate = FALSE;
127
+
128
+    return LQR_OK;
129
+}
75 130
 
76
-LQR_PUBLIC
131
+/* LQR_PUBLIC */
77 132
 LqrRetVal
78 133
 lqr_carver_bias_add(LqrCarver *r, gdouble *buffer, gint bias_factor)
79 134
 {
80
-  return lqr_carver_bias_add_area(r, buffer, bias_factor, r->w0, r->h0, 0, 0);
135
+    return lqr_carver_bias_add_area(r, buffer, bias_factor, lqr_carver_get_width(r), lqr_carver_get_height(r), 0, 0);
81 136
 }
82 137
 
83
-LQR_PUBLIC
138
+/* LQR_PUBLIC */
84 139
 LqrRetVal
85
-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)
140
+lqr_carver_bias_add_rgb_area(LqrCarver *r, guchar *rgb, gint bias_factor, gint channels, gint width, gint height,
141
+                             gint x_off, gint y_off)
86 142
 {
87
-  gint x, y, k, c_channels;
88
-  gboolean has_alpha;
89
-  gint x0, y0, x1, y1, x2, y2;
90
-  gint transposed = 0;
91
-  gint sum;
92
-  gfloat bias;
93
-
94
-  if (bias_factor == 0)
95
-    {
96
-      return TRUE;
143
+    gint x, y, k, c_channels;
144
+    gboolean has_alpha;
145
+    gint xt, yt;
146
+    gint wt, ht;
147
+    gint x0, y0, x1, y1, x2, y2;
148
+    gint sum;
149
+    gdouble bias;
150
+
151
+    LQR_CATCH_CANC(r);
152
+
153
+    if ((r->w != r->w0) || (r->w_start != r->w0) || (r->h != r->h0) || (r->h_start != r->h0)) {
154
+        LQR_CATCH(lqr_carver_flatten(r));
97 155
     }
98 156
 
99
-  CATCH_F (r->active);
100
-  if ((r->w != r->w0) || (r->w_start != r->w0) ||
101
-      (r->h != r->h0) || (r->h_start != r->h0))
102
-    {
103
-      CATCH (lqr_carver_flatten(r));
157
+    if (r->nrg_active == FALSE) {
158
+        LQR_CATCH(lqr_carver_init_energy_related(r));
104 159
     }
105
-  if (r->transposed)
106
-    {
107
-      transposed = 1;
108
-      CATCH (lqr_carver_transpose(r));
160
+
161
+    if (bias_factor == 0) {
162
+        return LQR_OK;
163
+    }
164
+
165
+    if (r->bias == NULL) {
166
+        LQR_CATCH_MEM(r->bias = g_try_new0(gfloat, r->w * r->h));
109 167
     }
110 168
 
111
-  has_alpha = (channels == 2 || channels >= 4);
112
-  c_channels = channels - (has_alpha ? 1 : 0);
113
-
114
-  x0 = MIN (0, x_off);
115
-  y0 = MIN (0, y_off);
116
-  x1 = MAX (0, x_off);
117
-  y1 = MAX (0, y_off);
118
-  x2 = MIN (r->w0, width + x_off);
119
-  y2 = MIN (r->h0, height + y_off);
120
-
121
-  for (y = 0; y < y2 - y1; y++)
122
-    {
123
-      for (x = 0; x < x2 - x1; x++)
124
-        {
125
-          sum = 0;
126
-          for (k = 0; k < c_channels; k++)
127
-            {
128
-              sum += rgb[((y - y0) * width + (x - x0)) * channels + k];
169
+    has_alpha = (channels == 2 || channels >= 4);
170
+    c_channels = channels - (has_alpha ? 1 : 0);
171
+
172
+    wt = r->transposed ? r->h : r->w;
173
+    ht = r->transposed ? r->w : r->h;
174
+
175
+    x0 = MIN(0, x_off);
176
+    y0 = MIN(0, y_off);
177
+    x1 = MAX(0, x_off);
178
+    y1 = MAX(0, y_off);
179
+    x2 = MIN(wt, width + x_off);
180
+    y2 = MIN(ht, height + y_off);
181
+
182
+    for (y = 0; y < y2 - y1; y++) {
183
+        for (x = 0; x < x2 - x1; x++) {
184
+            sum = 0;
185
+            for (k = 0; k < c_channels; k++) {
186
+                sum += rgb[((y - y0) * width + (x - x0)) * channels + k];
129 187
             }
130 188
 
131
-          bias = (gfloat) ((gdouble) bias_factor * sum / (2 * 255 * c_channels));
132
-          if (has_alpha)
133
-            {
134
-	      bias *= (gfloat) rgb[((y - y0) * width + (x - x0) + 1) * channels - 1] / 255;
189
+            bias = ((gdouble) bias_factor * sum / (2 * 255 * c_channels));
190
+            if (has_alpha) {
191
+                bias *= (gdouble) rgb[((y - y0) * width + (x - x0) + 1) * channels - 1] / 255;
135 192
             }
136 193
 
137
-          r->bias[(y + y1) * r->w0 + (x + x1)] += bias;
194
+            xt = r->transposed ? y : x;
195
+            yt = r->transposed ? x : y;
138 196
 
197
+            r->bias[(yt + y1) * r->w0 + (xt + x1)] += (gfloat) bias;
139 198
         }
140
-
141 199
     }
142 200
 
143
-  if (transposed)
144
-    {
145
-      CATCH (lqr_carver_transpose(r));
146
-    }
201
+    r->nrg_uptodate = FALSE;
147 202
 
148
-  return LQR_OK;
203
+    return LQR_OK;
149 204
 }
150 205
 
151
-LQR_PUBLIC
206
+/* LQR_PUBLIC */
152 207
 LqrRetVal
153 208
 lqr_carver_bias_add_rgb(LqrCarver *r, guchar *rgb, gint bias_factor, gint channels)
154 209
 {
155
-  return lqr_carver_bias_add_rgb_area(r, rgb, bias_factor, channels, r->w0, r->h0, 0, 0);
210
+    return lqr_carver_bias_add_rgb_area(r, rgb, bias_factor, channels, lqr_carver_get_width(r),
211
+                                        lqr_carver_get_height(r), 0, 0);
156 212
 }
157 213
 
158
-
159 214
 /**** END OF LQR_CARVER_BIAS CLASS FUNCTIONS ****/

+ 2
- 2
lqr/lqr_carver_bias.h View File

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

+ 2
- 2
lqr/lqr_carver_bias_priv.h View File

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

+ 10
- 7
lqr/lqr_carver_bias_pub.h View File

@@ -15,9 +15,9 @@
15 15
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 17
  * GNU Lesser General Public License for more details.
18
- 
18
+
19 19
  * You should have received a copy of the GNU Lesser General Public License
20
- * along with this program; if not, see <http://www.gnu.org/licenses/> 
20
+ * along with this program; if not, see <http://www.gnu.org/licenses/>
21 21
  */
22 22
 
23 23
 #ifndef __LQR_CARVER_BIAS_PUB_H__
@@ -29,10 +29,13 @@
29 29
 
30 30
 /* PUBLIC BIAS-RELATED FUNCTIONS */
31 31
 
32
-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);
33
-LqrRetVal lqr_carver_bias_add_rgb(LqrCarver *r, guchar *buffer, gint bias_factor, gint channels);
34
-LqrRetVal lqr_carver_bias_add_area(LqrCarver *r, gdouble *buffer, gint bias_factor, gint width, gint height, gint x_off, gint y_off);
35
-LqrRetVal lqr_carver_bias_add(LqrCarver *r, gdouble *buffer, gint bias_factor);
36
-
32
+LQR_PUBLIC void lqr_carver_bias_clear(LqrCarver *r);
33
+LQR_PUBLIC LqrRetVal lqr_carver_bias_add_xy(LqrCarver *r, gdouble bias, gint x, gint y);
34
+LQR_PUBLIC LqrRetVal lqr_carver_bias_add_rgb_area(LqrCarver *r, guchar *buffer, gint bias_factor, gint channels,
35
+                                                  gint width, gint height, gint x_off, gint y_off);
36
+LQR_PUBLIC LqrRetVal lqr_carver_bias_add_rgb(LqrCarver *r, guchar *buffer, gint bias_factor, gint channels);
37
+LQR_PUBLIC LqrRetVal lqr_carver_bias_add_area(LqrCarver *r, gdouble *buffer, gint bias_factor, gint width, gint height,
38
+                                              gint x_off, gint y_off);
39
+LQR_PUBLIC LqrRetVal lqr_carver_bias_add(LqrCarver *r, gdouble *buffer, gint bias_factor);
37 40
 
38 41
 #endif /* __LQR_CARVER_BIAS_PUB_H__ */

+ 59
- 50
lqr/lqr_carver_list.c View File

@@ -15,93 +15,102 @@
15 15
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 17
  * GNU Lesser General Public License for more details.
18
- 
18
+
19 19
  * You should have received a copy of the GNU Lesser General Public License
20
- * along with this program; if not, see <http://www.gnu.org/licenses/> 
20
+ * along with this program; if not, see <http://www.gnu.org/licenses/>
21 21
  */
22 22
 
23
+#ifdef HAVE_CONFIG_H
24
+#  include <config.h>
25
+#endif
26
+
23 27
 #include <glib.h>
24 28
 
25
-#include <lqr_all.h>
29
+#include <lqr/lqr_all.h>
26 30
 
27 31
 #ifdef __LQR_DEBUG__
28 32
 #include <assert.h>
29 33
 #endif /* __LQR_DEBUG__ */
30 34
 
31
-
32 35
 /**** CARVER LIST FUNCTIONS ****/
33 36
 
34
-LqrCarverList * 
35
-lqr_carver_list_append (LqrCarverList * list, LqrCarver * r)
37
+LqrCarverList *
38
+lqr_carver_list_append(LqrCarverList *list, LqrCarver *r)
36 39
 {
37
-  LqrCarverList * prev = NULL;
38
-  LqrCarverList * now = list;
39
-  while (now != NULL)
40
-    {
41
-      prev = now;
42
-      now = now->next;
43
-    }
44
-  TRY_N_N (now = g_try_new(LqrCarverList, 1));
45
-  now->next = NULL;
46
-  now->current = r;
47
-  if (prev)
48
-    {
49
-      prev->next = now;
40
+    LqrCarverList *prev = NULL;
41
+    LqrCarverList *now = list;
42
+    while (now != NULL) {
43
+        prev = now;
44
+        now = now->next;
50 45
     }
51
-  if (list == NULL)
52
-    {
53
-      return now;
46
+    LQR_TRY_N_N(now = g_try_new(LqrCarverList, 1));
47
+    now->next = NULL;
48
+    now->current = r;
49
+    if (prev) {
50
+        prev->next = now;
54 51
     }
55
-  else
56
-    {
57
-      return list;
52
+    if (list == NULL) {
53
+        return now;
54
+    } else {
55
+        return list;
58 56
     }
59 57
 }
60 58
 
61 59
 void
62
-lqr_carver_list_destroy(LqrCarverList * list)
60
+lqr_carver_list_destroy(LqrCarverList *list)
63 61
 {
64
-  LqrCarverList * now = list;
65
-  if (now != NULL)
66
-    {
67
-      lqr_carver_list_destroy(now->next);
68
-      lqr_carver_destroy(now->current);
62
+    LqrCarverList *now = list;
63
+    if (now != NULL) {
64
+        lqr_carver_list_destroy(now->next);
65
+        lqr_carver_list_destroy(now->current->attached_list);
66
+        lqr_carver_destroy(now->current);
69 67
     }
70 68
 }
71 69
 
72
-LQR_PUBLIC
70
+/* LQR_PUBLIC */
73 71
 LqrCarverList *
74
-lqr_carver_list_start (LqrCarver *r)
72
+lqr_carver_list_start(LqrCarver *r)
75 73
 {
76
-  return r->attached_list;
74
+    return r->attached_list;
77 75
 }
78 76
 
79
-LQR_PUBLIC
77
+/* LQR_PUBLIC */
80 78
 LqrCarverList *
81
-lqr_carver_list_next (LqrCarverList * list)
79
+lqr_carver_list_next(LqrCarverList *list)
82 80
 {
83
-  TRY_N_N (list);
84
-  return list->next;
81
+    LQR_TRY_N_N(list);
82
+    return list->next;
85 83
 }
86 84
 
87
-LQR_PUBLIC
85
+/* LQR_PUBLIC */
88 86
 LqrCarver *
89
-lqr_carver_list_current (LqrCarverList * list)
87
+lqr_carver_list_current(LqrCarverList *list)
90 88
 {
91
-  TRY_N_N (list);
92
-  return list->current;
89
+    LQR_TRY_N_N(list);
90
+    return list->current;
93 91
 }
94 92
 
95
-LQR_PUBLIC
93
+/* LQR_PUBLIC */
96 94
 LqrRetVal
97
-lqr_carver_list_foreach (LqrCarverList * list, LqrCarverFunc func, LqrDataTok data)
95
+lqr_carver_list_foreach(LqrCarverList *list, LqrCarverFunc func, LqrDataTok data)
98 96
 {
99
-  LqrCarverList * now = list;
100
-  if (now != NULL)
101
-    {
102
-      CATCH (func(now->current, data));
103
-      return lqr_carver_list_foreach (now->next, func, data);
97
+    LqrCarverList *now = list;
98
+    if (now != NULL) {
99
+        LQR_CATCH(func(now->current, data));
100
+        return lqr_carver_list_foreach(now->next, func, data);
104 101
     }
105
-  return LQR_OK;
102
+    return LQR_OK;
106 103
 }
107 104
 
105
+/* LQR_PUBLIC */
106
+LqrRetVal
107
+lqr_carver_list_foreach_recursive(LqrCarverList *list, LqrCarverFunc func, LqrDataTok data)
108
+{
109
+    LqrCarverList *now = list;
110
+    if (now != NULL) {
111
+        LQR_CATCH(func(now->current, data));
112
+        LQR_CATCH(lqr_carver_list_foreach(now->current->attached_list, func, data));
113
+        return lqr_carver_list_foreach(now->next, func, data);
114
+    }
115
+    return LQR_OK;
116
+}

+ 2
- 4
lqr/lqr_carver_list.h View File

@@ -15,9 +15,9 @@
15 15
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 17
  * GNU Lesser General Public License for more details.
18
- 
18
+
19 19
  * You should have received a copy of the GNU Lesser General Public License
20
- * along with this program; if not, see <http://www.gnu.org/licenses/> 
20
+ * along with this program; if not, see <http://www.gnu.org/licenses/>
21 21
  */
22 22
 
23 23
 #ifndef __LQR_CARVER_LIST_H__
@@ -27,5 +27,3 @@
27 27
 #include <lqr/lqr_carver_list_priv.h>
28 28
 
29 29
 #endif /* __LQR_CARVER_LIST_H__ */
30
-
31
-

+ 7
- 11
lqr/lqr_carver_list_priv.h View File

@@ -15,9 +15,9 @@
15 15
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 17
  * GNU Lesser General Public License for more details.
18
- 
18
+
19 19
  * You should have received a copy of the GNU Lesser General Public License
20
- * along with this program; if not, see <http://www.gnu.org/licenses/> 
20
+ * along with this program; if not, see <http://www.gnu.org/licenses/>
21 21
  */
22 22
 
23 23
 #ifndef __LQR_CARVER_LIST_PRIV_H__
@@ -29,18 +29,14 @@
29 29
 
30 30
 /**** LQR_CARVER_LIST CLASS DEFINITION ****/
31 31
 
32
-struct _LqrCarverList
33
-{
34
-  LqrCarver * current;
35
-  LqrCarverList * next;
32
+struct _LqrCarverList {
33
+    LqrCarver *current;
34
+    LqrCarverList *next;
36 35
 };
37 36
 
38 37
 /* LQR_CARVER_LIST PRIVATE FUNCTIONS */
39 38
 
40
-LqrCarverList * lqr_carver_list_append (LqrCarverList * list, LqrCarver * buffer);
41
-void lqr_carver_list_destroy (LqrCarverList * list);
42
-
39
+LqrCarverList *lqr_carver_list_append(LqrCarverList *list, LqrCarver *buffer);
40
+void lqr_carver_list_destroy(LqrCarverList *list);
43 41
 
44 42
 #endif /* __LQR_CARVER_LIST_PRIV_H__ */
45
-
46
-

+ 11
- 15
lqr/lqr_carver_list_pub.h View File

@@ -15,9 +15,9 @@
15 15
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 17
  * GNU Lesser General Public License for more details.
18
- 
18
+
19 19
  * You should have received a copy of the GNU Lesser General Public License
20
- * along with this program; if not, see <http://www.gnu.org/licenses/> 
20
+ * along with this program; if not, see <http://www.gnu.org/licenses/>
21 21
  */
22 22
 
23 23
 #ifndef __LQR_CARVER_LIST_PUB_H__
@@ -27,21 +27,18 @@
27 27
 #error "lqr_base.h must be included prior to lqr_carver_list_pub.h"
28 28
 #endif /* __LQR_BASE_H__ */
29 29
 
30
-
31 30
 /**** LQR_DATA_TOK STRUCT DEFINITION ****/
32 31
 union _LqrDataTok;
33 32
 typedef union _LqrDataTok LqrDataTok;
34 33
 
35
-union _LqrDataTok
36
-{
37
-  LqrCarver *carver;
38
-  gint integer;
39
-  gpointer data;
34
+union _LqrDataTok {
35
+    LqrCarver *carver;
36
+    gint integer;
37
+    gpointer data;
40 38
 };
41 39
 
42 40
 typedef LqrRetVal (*LqrCarverFunc) (LqrCarver *carver, LqrDataTok data);
43 41
 
44
-
45 42
 /**** LQR_CARVER_LIST CLASS DECLARATION ****/
46 43
 struct _LqrCarverList;
47 44
 
@@ -49,11 +46,10 @@ typedef struct _LqrCarverList LqrCarverList;
49 46
 
50 47
 /* LQR_CARVER_LIST PUBLIC FUNCTIONS */
51 48
 
52
-LqrCarverList * lqr_carver_list_start (LqrCarver *r);
53
-LqrCarver * lqr_carver_list_current (LqrCarverList *list);
54
-LqrCarverList * lqr_carver_list_next (LqrCarverList * list);
55
-LqrRetVal lqr_carver_list_foreach (LqrCarverList * list, LqrCarverFunc func, LqrDataTok data);
49
+LQR_PUBLIC LqrCarverList *lqr_carver_list_start(LqrCarver *r);
50
+LQR_PUBLIC LqrCarver *lqr_carver_list_current(LqrCarverList *list);
51
+LQR_PUBLIC LqrCarverList *lqr_carver_list_next(LqrCarverList *list);
52
+LQR_PUBLIC LqrRetVal lqr_carver_list_foreach(LqrCarverList *list, LqrCarverFunc func, LqrDataTok data);
53
+LQR_PUBLIC LqrRetVal lqr_carver_list_foreach_recursive(LqrCarverList *list, LqrCarverFunc func, LqrDataTok data);
56 54
 
57 55
 #endif /* __LQR_CARVER_LIST_PUB_H__ */
58
-
59
-

+ 133
- 0
lqr/lqr_carver_macros_priv.h View File

@@ -0,0 +1,133 @@
1
+/* LiquidRescaling Library
2
+ * Copyright (C) 2007-2009 Carlo Baldassi (the "Author") <carlobaldassi@gmail.com>.
3
+ * All Rights Reserved.
4
+ *
5
+ * This library implements the algorithm described in the paper
6
+ * "Seam Carving for Content-Aware Image Resizing"
7
+ * by Shai Avidan and Ariel Shamir
8
+ * which can be found at http://www.faculty.idc.ac.il/arik/imret.pdf
9
+ *
10
+ * This file was automatically generated.
11
+ *
12
+ * This program is free software; you can redistribute it and/or modify
13
+ * it under the terms of the GNU Lesser General Public License as published by
14
+ * the Free Software Foundation; version 3 dated June, 2007.
15
+
16
+ * This program is distributed in the hope that it will be useful,
17
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
+ * GNU Lesser General Public License for more details.
20
+
21
+ * You should have received a copy of the GNU Lesser General Public License
22
+ * along with this program; if not, see <http://www.gnu.org/licenses/>
23
+ */
24
+
25
+/* Macros for update_mmap speedup : without rigidity */
26
+
27
+#define DATADOWN(y, x) (r->raw[(y) - 1][(x)])
28
+#define MDOWN(y, x) (r->m[DATADOWN((y), (x))])
29
+
30
+#define MMIN01G(y, x) (least = DATADOWN((y), (x)), MDOWN((y), (x)))
31
+#define MMINTESTL(y, x1, x2) (MDOWN((y), (x1)) <= MDOWN((y), (x2)))
32
+#define MMINTESTR(y, x1, x2) (MDOWN((y), (x1)) <  MDOWN((y), (x2)))
33
+
34
+#define MMINL01G(y, x01)                     MMIN01G((y), (x01))
35
+#define MMINL02G(y, x01, x02)                MMINTESTL((y), (x01), (x02)) ? MMINL01G((y), (x01)) : MMINL01G((y), (x02))
36
+#define MMINL03G(y, x01, x02, x03)           MMINTESTL((y), (x01), (x02)) ? MMINL02G((y), (x01), (x03)) : MMINL02G((y), (x02), (x03))
37
+#define MMINL04G(y, x01, x02, x03, x04)      MMINTESTL((y), (x01), (x02)) ? MMINL03G((y), (x01), (x03), (x04)) : MMINL03G((y), (x02), (x03), (x04))
38
+#define MMINL05G(y, x01, x02, x03, x04, x05) MMINTESTL((y), (x01), (x02)) ? MMINL04G((y), (x01), (x03), (x04), (x05)) : MMINL04G((y), (x02), (x03), (x04), (x05))
39
+
40
+#define MMINR01G(y, x01)                     MMIN01G((y), (x01))
41
+#define MMINR02G(y, x01, x02)                MMINTESTR((y), (x01), (x02)) ? MMINR01G((y), (x01)) : MMINR01G((y), (x02))
42
+#define MMINR03G(y, x01, x02, x03)           MMINTESTR((y), (x01), (x02)) ? MMINR02G((y), (x01), (x03)) : MMINR02G((y), (x02), (x03))
43
+#define MMINR04G(y, x01, x02, x03, x04)      MMINTESTR((y), (x01), (x02)) ? MMINR03G((y), (x01), (x03), (x04)) : MMINR03G((y), (x02), (x03), (x04))
44
+#define MMINR05G(y, x01, x02, x03, x04, x05) MMINTESTR((y), (x01), (x02)) ? MMINR04G((y), (x01), (x03), (x04), (x05)) : MMINR04G((y), (x02), (x03), (x04), (x05))
45
+
46
+#define MMINL01(y, x) MMINL01G((y), (x))
47
+#define MMINL02(y, x) MMINL02G((y), (x), (x) + 1)
48
+#define MMINL03(y, x) MMINL03G((y), (x), (x) + 1, (x) + 2)
49
+#define MMINL04(y, x) MMINL04G((y), (x), (x) + 1, (x) + 2, (x) + 3)
50
+#define MMINL05(y, x) MMINL05G((y), (x), (x) + 1, (x) + 2, (x) + 3, (x) + 4)
51
+
52
+#define MMINR01(y, x) MMINR01G((y), (x))
53
+#define MMINR02(y, x) MMINR02G((y), (x), (x) + 1)
54
+#define MMINR03(y, x) MMINR03G((y), (x), (x) + 1, (x) + 2)
55
+#define MMINR04(y, x) MMINR04G((y), (x), (x) + 1, (x) + 2, (x) + 3)
56
+#define MMINR05(y, x) MMINR05G((y), (x), (x) + 1, (x) + 2, (x) + 3, (x) + 4)
57
+
58
+/* Macros for update_mmap speedup : with rigidity */
59
+
60
+#define MRDOWN(y, x, dx) (r->m[DATADOWN((y), (x))] + r_fact * r->rigidity_map[(dx)])
61
+
62
+#define MRSET01(y, x, dx) (mc[(dx)] = MRDOWN((y), (x), (dx)))
63
+#define MRSET02(y, x, dx) (MRSET01((y), (x), (dx)), MRSET01((y), (x) + 1, (dx) + 1))
64
+#define MRSET03(y, x, dx) (MRSET02((y), (x), (dx)), MRSET01((y), (x) + 2, (dx) + 2))
65
+#define MRSET04(y, x, dx) (MRSET03((y), (x), (dx)), MRSET01((y), (x) + 3, (dx) + 3))
66
+#define MRSET05(y, x, dx) (MRSET04((y), (x), (dx)), MRSET01((y), (x) + 4, (dx) + 4))
67
+
68
+#define MRMIN01G(y, x, dx) (least = DATADOWN((y), (x)), mc[(dx)])
69
+#define MRMINTESTL(dx1, dx2) (mc[(dx1)] <= mc[(dx2)])
70
+#define MRMINTESTR(dx1, dx2) (mc[(dx1)] < mc[(dx2)])
71
+
72
+#define MRMINL01G(y, x01, dx01)                                             MRMIN01G((y), (x01), (dx01))
73
+#define MRMINL02G(y, x01, dx01, x02, dx02)                                  MRMINTESTL((dx01), (dx02)) ? MRMINL01G((y), (x01), (dx01)) : MRMINL01G((y), (x02), (dx02))
74
+#define MRMINL03G(y, x01, dx01, x02, dx02, x03, dx03)                       MRMINTESTL((dx01), (dx02)) ? MRMINL02G((y), (x01), (dx01), (x03), (dx03)) : MRMINL02G((y), (x02), (dx02), (x03), (dx03))
75
+#define MRMINL04G(y, x01, dx01, x02, dx02, x03, dx03, x04, dx04)            MRMINTESTL((dx01), (dx02)) ? MRMINL03G((y), (x01), (dx01), (x03), (dx03), (x04), (dx04)) : MRMINL03G((y), (x02), (dx02), (x03), (dx03), (x04), (dx04))
76
+#define MRMINL05G(y, x01, dx01, x02, dx02, x03, dx03, x04, dx04, x05, dx05) MRMINTESTL((dx01), (dx02)) ? MRMINL04G((y), (x01), (dx01), (x03), (dx03), (x04), (dx04), (x05), (dx05)) : MRMINL04G((y), (x02), (dx02), (x03), (dx03), (x04), (dx04), (x05), (dx05))
77
+
78
+#define MRMINR01G(y, x01, dx01)                                             MRMIN01G((y), (x01), (dx01))
79
+#define MRMINR02G(y, x01, dx01, x02, dx02)                                  MRMINTESTR((dx01), (dx02)) ? MRMINR01G((y), (x01), (dx01)) : MRMINR01G((y), (x02), (dx02))
80
+#define MRMINR03G(y, x01, dx01, x02, dx02, x03, dx03)                       MRMINTESTR((dx01), (dx02)) ? MRMINR02G((y), (x01), (dx01), (x03), (dx03)) : MRMINR02G((y), (x02), (dx02), (x03), (dx03))
81
+#define MRMINR04G(y, x01, dx01, x02, dx02, x03, dx03, x04, dx04)            MRMINTESTR((dx01), (dx02)) ? MRMINR03G((y), (x01), (dx01), (x03), (dx03), (x04), (dx04)) : MRMINR03G((y), (x02), (dx02), (x03), (dx03), (x04), (dx04))
82
+#define MRMINR05G(y, x01, dx01, x02, dx02, x03, dx03, x04, dx04, x05, dx05) MRMINTESTR((dx01), (dx02)) ? MRMINR04G((y), (x01), (dx01), (x03), (dx03), (x04), (dx04), (x05), (dx05)) : MRMINR04G((y), (x02), (dx02), (x03), (dx03), (x04), (dx04), (x05), (dx05))
83
+
84
+#define MRMINL01(y, x, dx) MRMINL01G((y), (x), (dx))
85
+#define MRMINL02(y, x, dx) MRMINL02G((y), (x), (dx), (x) + 1, (dx) + 1)
86
+#define MRMINL03(y, x, dx) MRMINL03G((y), (x), (dx), (x) + 1, (dx) + 1, (x) + 2, (dx) + 2)
87
+#define MRMINL04(y, x, dx) MRMINL04G((y), (x), (dx), (x) + 1, (dx) + 1, (x) + 2, (dx) + 2, (x) + 3, (dx) + 3)
88
+#define MRMINL05(y, x, dx) MRMINL05G((y), (x), (dx), (x) + 1, (dx) + 1, (x) + 2, (dx) + 2, (x) + 3, (dx) + 3, (x) + 4, (dx) + 4)
89
+
90
+#define MRMINR01(y, x, dx) MRMINR01G((y), (x), (dx))
91
+#define MRMINR02(y, x, dx) MRMINR02G((y), (x), (dx), (x) + 1, (dx) + 1)
92
+#define MRMINR03(y, x, dx) MRMINR03G((y), (x), (dx), (x) + 1, (dx) + 1, (x) + 2, (dx) + 2)
93
+#define MRMINR04(y, x, dx) MRMINR04G((y), (x), (dx), (x) + 1, (dx) + 1, (x) + 2, (dx) + 2, (x) + 3, (dx) + 3)
94
+#define MRMINR05(y, x, dx) MRMINR05G((y), (x), (dx), (x) + 1, (dx) + 1, (x) + 2, (dx) + 2, (x) + 3, (dx) + 3, (x) + 4, (dx) + 4)
95
+
96
+#define UPDATE_MMAP_OPTIMISED_CASES \
97
+     case 1: \
98
+       m = r->leftright ? MMINR01(y, x1_min) : MMINL01(y, x1_min); \
99
+       break; \
100
+     case 2: \
101
+       m = r->leftright ? MMINR02(y, x1_min) : MMINL02(y, x1_min); \
102
+       break; \
103
+     case 3: \
104
+       m = r->leftright ? MMINR03(y, x1_min) : MMINL03(y, x1_min); \
105
+       break; \
106
+     case 4: \
107
+       m = r->leftright ? MMINR04(y, x1_min) : MMINL04(y, x1_min); \
108
+       break; \
109
+     case 5: \
110
+       m = r->leftright ? MMINR05(y, x1_min) : MMINL05(y, x1_min); \
111
+       break;
112
+
113
+#define UPDATE_MMAP_OPTIMISED_CASES_RIG \
114
+     case 1: \
115
+       MRSET01(y, x1_min, dx); \
116
+       m = r->leftright ? MRMINR01(y, x1_min, dx) : MRMINL01(y, x1_min, dx); \
117
+       break; \
118
+     case 2: \
119
+       MRSET02(y, x1_min, dx); \
120
+       m = r->leftright ? MRMINR02(y, x1_min, dx) : MRMINL02(y, x1_min, dx); \
121
+       break; \
122
+     case 3: \
123
+       MRSET03(y, x1_min, dx); \
124
+       m = r->leftright ? MRMINR03(y, x1_min, dx) : MRMINL03(y, x1_min, dx); \
125
+       break; \
126
+     case 4: \
127
+       MRSET04(y, x1_min, dx); \
128
+       m = r->leftright ? MRMINR04(y, x1_min, dx) : MRMINL04(y, x1_min, dx); \
129
+       break; \
130
+     case 5: \
131
+       MRSET05(y, x1_min, dx); \
132
+       m = r->leftright ? MRMINR05(y, x1_min, dx) : MRMINL05(y, x1_min, dx); \
133
+       break;

+ 254
- 169
lqr/lqr_carver_priv.h View File

@@ -15,9 +15,9 @@
15 15
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 17
  * GNU Lesser General Public License for more details.
18
- 
18
+
19 19
  * You should have received a copy of the GNU Lesser General Public License
20
- * along with this program; if not, see <http://www.gnu.org/licenses/> 
20
+ * along with this program; if not, see <http://www.gnu.org/licenses/>
21 21
  */
22 22
 
23 23
 #ifndef __LQR_CARVER_PRIV_H__
@@ -31,6 +31,14 @@
31 31
 #error "lqr_gradient.h must be included prior to lqr_carver_priv.h"
32 32
 #endif /* __LQR_GRADIENT_H__ */
33 33
 
34
+#ifndef __LQR_READER_WINDOW_PUB_H__
35
+#error "lqr_rwindow_pub.h must be included prior to lqr_carver_priv.h"
36
+#endif /* __LQR_READER_WINDOW_PUB_H__ */
37
+
38
+#ifndef __LQR_ENERGY_H__
39
+#error "lqr_energy.h must be included prior to lqr_carver_priv.h"
40
+#endif /* __LQR_ENERGY_H__ */
41
+
34 42
 #ifndef __LQR_CARVER_LIST_H__
35 43
 #error "lqr_carver_list.h must be included prior to lqr_carver_priv.h"
36 44
 #endif /* __LQR_CARVER_LIST_H__ */
@@ -45,194 +53,271 @@
45 53
 
46 54
 /* Macros for internal use */
47 55
 
48
-#define AS_8I(x) ((lqr_t_8i*)x)
49
-#define AS_16I(x) ((lqr_t_16i*)x)
50
-#define AS_32F(x) ((lqr_t_32f*)x)
51
-#define AS_64F(x) ((lqr_t_64f*)x)
52
-
53
-#define AS2_8I(x) ((lqr_t_8i**)x)
54
-#define AS2_16I(x) ((lqr_t_16i**)x)
55
-#define AS2_32F(x) ((lqr_t_32f**)x)
56
-#define AS2_64F(x) ((lqr_t_64f**)x)
57
-
58
-#define PXL_COPY(dest, dest_ind, src, src_ind, col_depth) \
59
-	do { \
60
-          switch (col_depth) \
61
-            { \
62
-              case LQR_COLDEPTH_8I: \
63
-                AS_8I(dest)[dest_ind] = AS_8I(src)[src_ind]; \
64
-                break; \
65
-              case LQR_COLDEPTH_16I: \
66
-                AS_16I(dest)[dest_ind] = AS_16I(src)[src_ind]; \
67
-                break; \
68
-              case LQR_COLDEPTH_32F: \
69
-                AS_32F(dest)[dest_ind] = AS_32F(src)[src_ind]; \
70
-                break; \
71
-              case LQR_COLDEPTH_64F: \
72
-                AS_64F(dest)[dest_ind] = AS_64F(src)[src_ind]; \
73
-                break; \
74
-            } \
75
-	} while (0)
76
-
77
-#define BUF_POINTER_COPY(dest, src, col_depth) \
78
-	do { \
79
-          switch (col_depth) \
80
-            { \
81
-              case LQR_COLDEPTH_8I: \
82
-                *AS2_8I(dest) = AS_8I(src); \
83
-                break; \
84
-              case LQR_COLDEPTH_16I: \
85
-                *AS2_16I(dest) = AS_16I(src); \
86
-                break; \
87
-              case LQR_COLDEPTH_32F: \
88
-                *AS2_32F(dest) = AS_32F(src); \
89
-                break; \
90
-              case LQR_COLDEPTH_64F: \
91
-                *AS2_64F(dest) = AS_64F(src); \
92
-                break; \
93
-            } \
94
-	} while (0)
95
-
96
-#define BUF_TRY_NEW_RET_POINTER(dest, size, col_depth) \
97
-	do { \
98
-          switch (col_depth) \
99
-            { \
100
-              case LQR_COLDEPTH_8I: \
101
-                TRY_N_N (dest = g_try_new (lqr_t_8i, size)); \
102
-                break; \
103
-              case LQR_COLDEPTH_16I: \
104
-                TRY_N_N (dest = g_try_new (lqr_t_16i, size)); \
105
-                break; \
106
-              case LQR_COLDEPTH_32F: \
107
-                TRY_N_N (dest = g_try_new (lqr_t_32f, size)); \
108
-                break; \
109
-              case LQR_COLDEPTH_64F: \
110
-                TRY_N_N (dest = g_try_new (lqr_t_64f, size)); \
111
-                break; \
112
-            } \
113
-        } while (0)
114
-
115
-#define BUF_TRY_NEW0_RET_LQR(dest, size, col_depth) \
116
-	do { \
117
-          switch (col_depth) \
118
-            { \
119
-              case LQR_COLDEPTH_8I: \
120
-                CATCH_MEM (dest = g_try_new0 (lqr_t_8i, size)); \
121
-                break; \
122
-              case LQR_COLDEPTH_16I: \
123
-                CATCH_MEM (dest = g_try_new0 (lqr_t_16i, size)); \
124
-                break; \
125
-              case LQR_COLDEPTH_32F: \
126
-                CATCH_MEM (dest = g_try_new0 (lqr_t_32f, size)); \
127
-                break; \
128
-              case LQR_COLDEPTH_64F: \
129
-                CATCH_MEM (dest = g_try_new0 (lqr_t_64f, size)); \
130
-                break; \
131
-            } \
132
-        } while (0)
56
+#define AS0_8I(x) ((lqr_t_8i)(x))
57
+#define AS0_16I(x) ((lqr_t_16i)(x))
58
+#define AS0_32F(x) ((lqr_t_32f)(x))
59
+#define AS0_64F(x) ((lqr_t_64f)(x))
60
+
61
+#define AS_8I(x) ((lqr_t_8i*)(x))
62
+#define AS_16I(x) ((lqr_t_16i*)(x))
63
+#define AS_32F(x) ((lqr_t_32f*)(x))
64
+#define AS_64F(x) ((lqr_t_64f*)(x))
65
+
66
+#define AS2_8I(x) ((lqr_t_8i**)(x))
67
+#define AS2_16I(x) ((lqr_t_16i**)(x))
68
+#define AS2_32F(x) ((lqr_t_32f**)(x))
69
+#define AS2_64F(x) ((lqr_t_64f**)(x))
70
+
71
+#define PXL_COPY(dest, dest_ind, src, src_ind, col_depth) G_STMT_START { \
72
+  switch (col_depth) \
73
+    { \
74
+      case LQR_COLDEPTH_8I: \
75
+        AS_8I((dest))[(dest_ind)] = AS_8I((src))[(src_ind)]; \
76
+        break; \
77
+      case LQR_COLDEPTH_16I: \
78
+        AS_16I((dest))[(dest_ind)] = AS_16I((src))[(src_ind)]; \
79
+        break; \
80
+      case LQR_COLDEPTH_32F: \
81
+        AS_32F((dest))[(dest_ind)] = AS_32F((src))[(src_ind)]; \
82
+        break; \
83
+      case LQR_COLDEPTH_64F: \
84
+        AS_64F((dest))[(dest_ind)] = AS_64F((src))[(src_ind)]; \
85
+        break; \
86
+    } \
87
+} G_STMT_END
88
+
89
+#define BUF_POINTER_COPY(dest, src, col_depth) G_STMT_START {