Commit 033b2497 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

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.
parent ef48505d
2010-06-25 Guillaume Lazzara <z@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@lrde.epita.fr>
 
Fix conversion routines towards qimage.
# 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)
// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// 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/value/rgb8.hh>
#include <mln/value/int_u8.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;
{
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");
// 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");
test = test.convertToFormat(refpix.format());
// 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));
}
}
// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// 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/value/rgb8.hh>
#include <mln/value/int_u8.hh>
#include <mln/io/ppm/load.hh>
#include <mln/io/pgm/load.hh>
#include <mln/data/convert.hh>
#include <mln/convert/to_qimage_nocopy.hh>
main()
{
using namespace mln;
{
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(refpix == test.convertToFormat(refpix.format()));
}
}
# 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)
// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// 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/compare.hh>
#include <mln/subsampling/antialiased.hh>
#include "tests/data.hh"
int main()
{
using namespace mln;
using namespace mln::value;
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) } };
image2d<int_u8> refgl_ima = make::image(refgl);
image2d<rgb8> refrgb_ima = make::image(refrgb);
box2d bref(3, 3);
{
image2d<value::int_u8> input;
io::pgm::load(input, MLN_IMG_DIR "/tiny.pgm");
image2d<value::int_u8> tmp = subsampling::antialiased(input, 6);
mln_assertion(tmp == refgl_ima);
}
{
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);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment