* tests/convert/Makefile.am,
* tests/subsampling/Makefile.am: Add targets for these new tests.
* tests/convert/to_qimage.cc,
* tests/convert/to_qimage_nocopy.cc,
* tests/subsampling/antialiased.cc: New.
---
milena/ChangeLog | 11 ++++
milena/tests/convert/Makefile.am | 25 ++++++++-
.../tests/{data/split.cc => convert/to_qimage.cc} | 54 +++++++++++++------
.../{data/split.cc => convert/to_qimage_nocopy.cc} | 42 ++++++++-------
milena/tests/subsampling/Makefile.am | 12 ++++-
.../antialiased.cc} | 57 +++++++++-----------
6 files changed, 131 insertions(+), 70 deletions(-)
copy milena/tests/{data/split.cc => convert/to_qimage.cc} (52%)
copy milena/tests/{data/split.cc => convert/to_qimage_nocopy.cc} (73%)
copy milena/tests/{data/paste_without_localization.cc => subsampling/antialiased.cc}
(58%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a4fe97b..62075e5 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,16 @@
2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add new tests.
+
+ * tests/convert/Makefile.am,
+ * tests/subsampling/Makefile.am: Add targets for these new tests.
+
+ * tests/convert/to_qimage.cc,
+ * tests/convert/to_qimage_nocopy.cc,
+ * tests/subsampling/antialiased.cc: New.
+
+2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix conversion routines towards qimage.
* mln/convert/to_qimage.hh: Fix invalid conversions.
diff --git a/milena/tests/convert/Makefile.am b/milena/tests/convert/Makefile.am
index ab369d9..c5a5c14 100644
--- a/milena/tests/convert/Makefile.am
+++ b/milena/tests/convert/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+# Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
# Laboratory (LRDE).
#
# This file is part of Olena.
@@ -19,6 +19,7 @@
## Process this file through Automake to create Makefile.in.
include $(top_srcdir)/milena/tests/tests.mk
+include $(top_srcdir)/build-aux/autotroll.mk
SUBDIRS = impl
@@ -41,4 +42,26 @@ check_PROGRAMS += to_hsl
to_hsl_SOURCES = to_hsl.cc
#>>
+
+
+if HAVE_QT
+
+check_PROGRAMS += to_qimage
+to_qimage_SOURCES = to_qimage.cc
+to_qimage_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS) -I$(srcdir)
+to_qimage_CXXFLAGS = $(QT_CXXFLAGS) $(AM_CXXFLAGS) -O3
+to_qimage_LDFLAGS = $(QT_LDFLAGS) $(LDFLAGS)
+to_qimage_LDADD = $(QT_LIBS) $(LDADD)
+
+check_PROGRAMS += to_qimage_nocopy
+to_qimage_nocopy_SOURCES = to_qimage_nocopy.cc
+to_qimage_nocopy_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS) -I$(srcdir)
+to_qimage_nocopy_CXXFLAGS = $(QT_CXXFLAGS) $(AM_CXXFLAGS) -O3
+to_qimage_nocopy_LDFLAGS = $(QT_LDFLAGS) $(LDFLAGS)
+to_qimage_nocopy_LDADD = $(QT_LIBS) $(LDADD)
+
+
+endif HAVE_QT
+
+
TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/data/split.cc b/milena/tests/convert/to_qimage.cc
similarity index 52%
copy from milena/tests/data/split.cc
copy to milena/tests/convert/to_qimage.cc
index f7a0d0a..dfa659b 100644
--- a/milena/tests/data/split.cc
+++ b/milena/tests/convert/to_qimage.cc
@@ -23,32 +23,54 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
+/// \file
+///
+/// Test of mln::convert::to_qimage
+
+#include <QtGui/QtGui>
+#include <QColor>
+
+#include "tests/data.hh"
+
#include <mln/core/image/image2d.hh>
-#include <mln/data/split.hh>
-#include <mln/make/image.hh>
-#include <mln/data/compare.hh>
#include <mln/value/rgb8.hh>
#include <mln/value/int_u8.hh>
-#include <mln/debug/iota.hh>
+#include <mln/io/ppm/load.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/data/convert.hh>
+
+#include <mln/convert/to_qimage.hh>
+
int main()
{
using namespace mln;
- using value::rgb8;
-
- rgb8 data[2][2] = { { rgb8(1, 1, 1), rgb8(2, 2, 2) },
- { rgb8(3, 3, 3), rgb8(4, 4, 4) } };
- image2d<rgb8> ima = make::image(data);
+ {
+ image2d<value::int_u8> input;
+ io::pgm::load(input, MLN_IMG_DIR "/picasso.pgm");
+ QImage test = convert::to_qimage(input);
+ QImage refpix(MLN_IMG_DIR "/picasso.pgm");
- image2d<value::int_u8> ref(ima.domain());
- debug::iota(ref);
+ // Do NOT use operator== since it compares the raw buffer and
+ // padding data is not initialized by Qt...
+ for (int row = 0; row < test.height(); ++row)
+ for (int col = 0; col < test.width(); ++col)
+ mln_assertion(refpix.pixel(col, row) == test.pixel(col, row));
+ }
+ {
+ image2d<value::rgb8> input;
+ io::ppm::load(input, MLN_IMG_DIR "/picasso.ppm");
+ QImage test = convert::to_qimage(input);
+ QImage refpix(MLN_IMG_DIR "/picasso.ppm");
- image2d<value::int_u8> r, g, b;
- data::split(ima, r, g, b);
+ test = test.convertToFormat(refpix.format());
- mln_assertion(ref == r);
- mln_assertion(ref == g);
- mln_assertion(ref == b);
+ // Do NOT use operator== since it compares the raw buffer and
+ // padding data is not initialized by Qt...
+ for (int row = 0; row < test.height(); ++row)
+ for (int col = 0; col < test.width(); ++col)
+ mln_assertion(refpix.pixel(col, row) == test.pixel(col, row));
+ }
}
diff --git a/milena/tests/data/split.cc b/milena/tests/convert/to_qimage_nocopy.cc
similarity index 73%
copy from milena/tests/data/split.cc
copy to milena/tests/convert/to_qimage_nocopy.cc
index f7a0d0a..e2b83cc 100644
--- a/milena/tests/data/split.cc
+++ b/milena/tests/convert/to_qimage_nocopy.cc
@@ -23,32 +23,34 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
+/// \file
+///
+/// Test of mln::convert::to_qimage
+
+#include <QtGui/QtGui>
+
+#include "tests/data.hh"
+
#include <mln/core/image/image2d.hh>
-#include <mln/data/split.hh>
-#include <mln/make/image.hh>
-#include <mln/data/compare.hh>
#include <mln/value/rgb8.hh>
#include <mln/value/int_u8.hh>
-#include <mln/debug/iota.hh>
+#include <mln/io/ppm/load.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/data/convert.hh>
-int main()
-{
- using namespace mln;
- using value::rgb8;
+#include <mln/convert/to_qimage_nocopy.hh>
- rgb8 data[2][2] = { { rgb8(1, 1, 1), rgb8(2, 2, 2) },
- { rgb8(3, 3, 3), rgb8(4, 4, 4) } };
-
- image2d<rgb8> ima = make::image(data);
-
- image2d<value::int_u8> ref(ima.domain());
- debug::iota(ref);
+main()
+{
+ using namespace mln;
- image2d<value::int_u8> r, g, b;
- data::split(ima, r, g, b);
+ {
+ image2d<value::rgb8> input;
+ io::ppm::load(input, MLN_IMG_DIR "/picasso.ppm");
+ QImage test = convert::to_qimage_nocopy(input);
+ QImage refpix(MLN_IMG_DIR "/picasso.ppm");
- mln_assertion(ref == r);
- mln_assertion(ref == g);
- mln_assertion(ref == b);
+ mln_assertion(refpix == test.convertToFormat(refpix.format()));
+ }
}
diff --git a/milena/tests/subsampling/Makefile.am b/milena/tests/subsampling/Makefile.am
index 89676d0..e59ed8d 100644
--- a/milena/tests/subsampling/Makefile.am
+++ b/milena/tests/subsampling/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -18,3 +18,13 @@
## Process this file through Automake to create Makefile.in.
include $(top_srcdir)/milena/tests/tests.mk
+
+
+check_PROGRAMS = \
+ antialiased
+
+
+antialiased_SOURCES = antialiased.cc
+
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/data/paste_without_localization.cc
b/milena/tests/subsampling/antialiased.cc
similarity index 58%
copy from milena/tests/data/paste_without_localization.cc
copy to milena/tests/subsampling/antialiased.cc
index dd0f479..871a063 100644
--- a/milena/tests/data/paste_without_localization.cc
+++ b/milena/tests/subsampling/antialiased.cc
@@ -23,59 +23,52 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
+
#include <mln/core/image/image2d.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/ppm/load.hh>
-#include <mln/data/paste_without_localization.hh>
#include <mln/data/compare.hh>
-#include <mln/debug/iota.hh>
-#include <mln/debug/println.hh>
+#include <mln/subsampling/antialiased.hh>
+
+#include "tests/data.hh"
int main()
{
using namespace mln;
+ using namespace mln::value;
- box2d b(point2d(1,2), point2d(6,8));
- image2d<unsigned> ima(b, 3);
- debug::iota(ima);
-
- image2d<unsigned> tmp(6, 7, 3);
- image2d<unsigned> ref(6, 7, 3);
- debug::iota(ref);
+ int_u8 refgl[3][3] = { { 123, 152, 115 },
+ { 105, 116, 158 },
+ { 92, 136, 106 } };
+ rgb8 refrgb[3][3] = { { rgb8(197, 93, 91), rgb8(206, 131, 127), rgb8(170, 94, 101) },
+ { rgb8(163, 78, 95), rgb8(173, 90, 105), rgb8(203, 143, 127) },
+ { rgb8(135, 70, 96), rgb8(201, 111, 109), rgb8(158, 80, 90) } };
- // Lines
- {
- data::impl::paste_without_localization_lines(ima, tmp);
- mln_assertion(tmp == ref);
- }
+ image2d<int_u8> refgl_ima = make::image(refgl);
+ image2d<rgb8> refrgb_ima = make::image(refrgb);
+ box2d bref(3, 3);
- // Fastest
{
- data::impl::paste_without_localization_fastest(ima, tmp);
- mln_assertion(tmp == ref);
- }
+ image2d<value::int_u8> input;
+ io::pgm::load(input, MLN_IMG_DIR "/tiny.pgm");
- // Fast
- {
- data::impl::paste_without_localization_fast(ima, tmp);
- mln_assertion(tmp == ref);
- }
+ image2d<value::int_u8> tmp = subsampling::antialiased(input, 6);
- // Generic
- {
- data::impl::generic::paste_without_localization(ima, tmp);
- mln_assertion(tmp == ref);
+ mln_assertion(tmp == refgl_ima);
}
- // Dispatch
{
- data::paste_without_localization(ima, tmp);
- mln_assertion(tmp == ref);
- }
+ image2d<value::rgb8> input;
+ io::ppm::load(input, MLN_IMG_DIR "/tiny.ppm");
+ image2d<value::rgb8> tmp = subsampling::antialiased(input, 6);
+ mln_assertion(tmp == refrgb_ima);
+ }
}
--
1.5.6.5