https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix io magick save.
* milena/mln/io/magick/save.hh (get_colo): Magic fix.
* milena/tests/io/magick/save.cc: Update.
mln/io/magick/save.hh | 10 +++++-----
tests/io/magick/save.cc | 10 ++++++++--
2 files changed, 13 insertions(+), 7 deletions(-)
Index: milena/mln/io/magick/save.hh
--- milena/mln/io/magick/save.hh (revision 4148)
+++ milena/mln/io/magick/save.hh (working copy)
@@ -31,7 +31,7 @@
/// Define a function which saves an image of kind magick with
/// given path.
///
-/// FIXME: there seems to be roundness errors while computing rgb values.
+/// \todo At the moment it works; is it a miracle?
# include <mln/core/image/image2d.hh>
# include <mln/metal/equal.hh>
@@ -71,15 +71,15 @@
inline
Magick::Color get_color(const value::int_u8& value)
{
- return Magick::ColorGray(value / (double)256.0f);
+ return Magick::ColorGray(256 - value);
}
inline
Magick::Color get_color(const value::rgb8& value)
{
- return Magick::ColorRGB(value.red() / (double)256.0f,
- value.green() / (double)256.0f,
- value.blue() / (double)256.0f);
+ return Magick::ColorRGB(256 - value.red(),
+ 256 - value.green(),
+ 256 - value.blue());
}
template <typename I>
Index: milena/tests/io/magick/save.cc
--- milena/tests/io/magick/save.cc (revision 4148)
+++ milena/tests/io/magick/save.cc (working copy)
@@ -27,24 +27,30 @@
#include <mln/io/magick/load.hh>
#include <mln/io/magick/save.hh>
#include <mln/io/ppm/load.hh>
-
+#include <mln/io/ppm/save.hh>
#include <mln/data/compare.hh>
+#include "tests/data.hh"
#include <mln/io/magick/load.hh>
-#include "tests/data.hh"
int main()
{
using namespace mln;
+ point2d p(0,0);
+
image2d<value::rgb8> lena_mln;
io::ppm::load(lena_mln, MLN_IMG_DIR "/tiny.ppm");
+ value::rgb8 c = lena_mln(p);
io::magick::save(lena_mln, "tiny.png");
image2d<value::rgb8> lena_im;
io::magick::load(lena_im, "tiny.png");
+ mln_assertion(lena_im(p) == c);
+
+ io::ppm::save(lena_im, "tiny.ppm");
mln_assertion(lena_im.domain() == lena_mln.domain());
mln_assertion(lena_im == lena_mln);