* mln/io/magick/internal/init_magick.hh: New.
* mln/io/magick/load.hh,
* mln/io/magick/save.hh: Use init_magick struct and update doc.
* tests/io/magick/load.cc,
* tests/io/magick/save.cc: Remove references to InitializeMagick.
---
milena/ChangeLog | 12 +++++
.../{abort.hh => magick/internal/init_magick.hh} | 43 ++++++++++---------
milena/mln/io/magick/load.hh | 31 +++-----------
milena/mln/io/magick/save.hh | 32 +++-----------
milena/tests/io/magick/load.cc | 18 +-------
milena/tests/io/magick/save.cc | 19 +--------
6 files changed, 53 insertions(+), 102 deletions(-)
copy milena/mln/io/{abort.hh => magick/internal/init_magick.hh} (71%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 277a65d..92f8ad0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,15 @@
+2013-03-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Automatically initialize GraphicsMagick.
+
+ * mln/io/magick/internal/init_magick.hh: New.
+
+ * mln/io/magick/load.hh,
+ * mln/io/magick/save.hh: Use init_magick struct and update doc.
+
+ * tests/io/magick/load.cc,
+ * tests/io/magick/save.cc: Remove references to InitializeMagick.
+
2013-03-08 Guillaume Lazzara <z(a)lrde.epita.fr>
* doc/img/2dgrid.png: New. Add missing file.
diff --git a/milena/mln/io/abort.hh b/milena/mln/io/magick/internal/init_magick.hh
similarity index 71%
copy from milena/mln/io/abort.hh
copy to milena/mln/io/magick/internal/init_magick.hh
index 9d06e7b..35a64a2 100644
--- a/milena/mln/io/abort.hh
+++ b/milena/mln/io/magick/internal/init_magick.hh
@@ -1,5 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2013 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -24,16 +23,14 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_IO_ABORT_HH
-# define MLN_IO_ABORT_HH
+#ifndef MLN_IO_MAGICK_INTERNAL_INIT_MAGICK_HH
+# define MLN_IO_MAGICK_INTERNAL_INIT_MAGICK_HH
/// \file
+///
+/// \brief Initialize GraphicsMagick library.
-/// Define a function which aborts a process in io module.
-
-# include <cstdlib>
-# include <iostream>
-
+# include <Magick++.h>
namespace mln
{
@@ -41,27 +38,33 @@ namespace mln
namespace io
{
- namespace internal
+ namespace magick
{
- /// The way to abort when an error occur in io processing.
- void abort();
+ namespace internal
+ {
+
+ struct init_magick
+ {
+ init_magick();
+ };
# ifndef MLN_INCLUDE_ONLY
- inline
- void abort()
- {
- std::cerr << "I/O error, aborting." << std::endl;
- std::abort();
- }
+ init_magick::init_magick()
+ {
+ Magick::InitializeMagick(0);
+ }
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::io::internal
+ } // end of namespace mln::io::magick::internal
+
+ } // end of namespace mln::io::magick
} // end of namespace mln::io
} // end of namespace mln
-#endif // ! MLN_IO_ABORT_HH
+
+#endif // ! MLN_IO_MAGICK_INTERNAL_INIT_MAGICK_HH
diff --git a/milena/mln/io/magick/load.hh b/milena/mln/io/magick/load.hh
index 3065db0..e3c07bd 100644
--- a/milena/mln/io/magick/load.hh
+++ b/milena/mln/io/magick/load.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009, 2010, 2012 EPITA Research and Development
+// Copyright (C) 2009, 2010, 2012, 2013 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -30,11 +30,6 @@
/// \file
///
/// \brief Image intput routines based on Magick++.
-///
-/// Do not forget to call Magick::InitializeMagick(*argv)
-/// <em>before</em> using any of these functions, as advised by the
-/// GraphicsMagick documentation
-/// (http://www.graphicsmagick.org/Magick++/Image.html).
# include <cstdlib>
@@ -45,6 +40,8 @@
# include <mln/value/int_u8.hh>
# include <mln/value/rgb8.hh>
+# include <mln/io/magick/internal/init_magick.hh>
+
namespace mln
{
@@ -146,6 +143,10 @@ namespace mln
I& ima = exact(ima_);
+ // Initialize GraphicsMagick only once.
+ static internal::init_magick init;
+ (void) init;
+
// FIXME: Handle Magick++'s exceptions (see either
// ImageMagick++'s or GraphicsMagick++'s documentation).
Magick::Image magick_ima(filename);
@@ -203,24 +204,6 @@ namespace mln
}
- // FIXME: Unfinished?
-#if 0
- template<typename T>
- inline
- void
- load(Image<tiled2d<T> >& ima_, const std::string& filename)
- {
- trace::entering("mln::io::magick::load");
-
- tiled2d<T>& ima = exact(ima_);
-
- tiled2d<T> result(filename);
-
- ima = result;
- trace::exiting("mln::io::magick::load");
- }
-#endif
-
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/io/magick/save.hh b/milena/mln/io/magick/save.hh
index 0ed869b..4c10703 100644
--- a/milena/mln/io/magick/save.hh
+++ b/milena/mln/io/magick/save.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2010, 2011, 2012 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2009, 2010, 2011, 2012, 2013 EPITA Research and
+// Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -30,11 +30,6 @@
/// \file
///
/// \brief Image output routines based on Magick++.
-///
-/// Do not forget to call Magick::InitializeMagick(*argv)
-/// <em>before</em> using any of these functions, as advised by the
-/// GraphicsMagick documentation
-/// (http://www.graphicsmagick.org/Magick++/Image.html).
# include <cstdlib>
@@ -52,6 +47,7 @@
# include <mln/geom/nrows.hh>
# include <mln/geom/ncols.hh>
+# include <mln/io/magick/internal/init_magick.hh>
namespace mln
{
@@ -500,6 +496,10 @@ namespace mln
const I& ima = exact(ima_);
const J& opacity_mask = exact(opacity_mask_);
+ // Initialize GraphicsMagick only once.
+ static internal::init_magick init;
+ (void) init;
+
def::coord
ncols = geom::ncols(ima),
nrows = geom::nrows(ima);
@@ -542,24 +542,6 @@ namespace mln
save(ima, opacity_mask, filename);
}
-
- // FIXME: Unfinished?
-#if 0
- template <typename T>
- void
- save(const Image< tiled2d<T> >& ima_, const std::string& filename)
- {
- trace::entering("mln::io::magick::save");
-
- tiled2d<T>& ima = exact(ima_);
-
- ima.buffer().write(filename);
-
- trace::exiting("mln::io::magick::save");
- }
-#endif
-
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::io::magick
diff --git a/milena/tests/io/magick/load.cc b/milena/tests/io/magick/load.cc
index 1525545..34af3f8 100644
--- a/milena/tests/io/magick/load.cc
+++ b/milena/tests/io/magick/load.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010, 2013 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -42,21 +43,6 @@ int main(int /* argc */, char* argv[])
{
using namespace mln;
- /* From http://www.graphicsmagick.org/Magick++/Image.html:
-
- The InitializeMagick() function MUST be invoked before
- constructing any Magick++ objects. This used to be optional,
- but now it is absolutely required. This function initalizes
- semaphores and configuration information necessary for the
- software to work correctly. Failing to invoke
- InitializeMagick() is likely to lead to a program crash or
- thrown assertion. If the program resides in the same directory
- as the GraphicsMagick files, then argv[0] may be passed as an
- argument so that GraphicsMagick knows where its files reside,
- otherwise NULL may be passed and GraphicsMagick will try to use
- other means (if necessary). */
- Magick::InitializeMagick(*argv);
-
// Compare Milena's built-in PBM loaded and Magick++'s support for PBM.
{
typedef image2d<bool> I;
diff --git a/milena/tests/io/magick/save.cc b/milena/tests/io/magick/save.cc
index d01643e..d650180 100644
--- a/milena/tests/io/magick/save.cc
+++ b/milena/tests/io/magick/save.cc
@@ -1,5 +1,5 @@
-// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2009, 2010, 2013 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -70,21 +70,6 @@ int main(int /* argc */, char* argv[])
{
using namespace mln;
- /* From http://www.graphicsmagick.org/Magick++/Image.html:
-
- The InitializeMagick() function MUST be invoked before
- constructing any Magick++ objects. This used to be optional,
- but now it is absolutely required. This function initalizes
- semaphores and configuration information necessary for the
- software to work correctly. Failing to invoke
- InitializeMagick() is likely to lead to a program crash or
- thrown assertion. If the program resides in the same directory
- as the GraphicsMagick files, then argv[0] may be passed as an
- argument so that GraphicsMagick knows where its files reside,
- otherwise NULL may be passed and GraphicsMagick will try to use
- other means (if necessary). */
- Magick::InitializeMagick(*argv);
-
point2d p(0,0);
// Grayscale values (PBM -> PBM -> PBM).
--
1.7.2.5
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch unstable/scribo has been updated
via 2a9b240ff2100b6f9d02969deb754f58d701e251 (commit)
from 62dbacde6331505524aa418e00c4ec111f679799 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
2a9b240 doc/img/2dgrid.png: New. Add missing file.
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 4 ++++
milena/doc/img/2dgrid.png | Bin 0 -> 6092 bytes
2 files changed, 4 insertions(+), 0 deletions(-)
create mode 100644 milena/doc/img/2dgrid.png
hooks/post-receive
--
Olena, a generic and efficient image processing platform
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch unstable/scribo has been updated
via 62dbacde6331505524aa418e00c4ec111f679799 (commit)
from effa1b7572027494c649d84e43bd0d066b8317e4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
62dbacd Remove references to external directory.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 7 +++++++
Makefile.am | 2 +-
configure.ac | 1 -
3 files changed, 8 insertions(+), 2 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch sandbox/anthony has been updated
via d4b28f4648097e6b349300f4fb4d89449629f490 (commit)
from 99b36312a31ce549eb18103576794165e61281f3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
d4b28f4 Work with mutlipages PDF
-----------------------------------------------------------------------
Summary of changes:
scribo/sandbox/icdar_13_table/Makefile | 13 ++-
scribo/sandbox/icdar_13_table/src/main.cc | 184 +++++++++++++++++------------
2 files changed, 114 insertions(+), 83 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform