Le patch de mandor est appliqué.
Index: olena/ChangeLog
from Nicolas Burrus <burrus_n(a)lrde.epita.fr>
* oln/io/pnm_write_2d.hh: Store in the header the maximal value of
the encoding, not of the actual image values.
* tests/io/tests/headers: New test.
* tests/io/Makefile.am: Remove headers.pgm.
Index: olena/tests/io/Makefile.am
--- olena/tests/io/Makefile.am Tue, 05 Aug 2003 21:39:33 +0200 burrus_n
(oln/e/49_Makefile.a 1.23 640)
+++ olena/tests/io/Makefile.am Mon, 03 Nov 2003 21:49:33 +0100 burrus_n
(oln/e/49_Makefile.a 1.23 640)
@@ -6,6 +6,7 @@
CLEANFILES += \
black-test.pbm white-test.pbm \
+ headers.pgm \
lena \
lena.ppm lena.pgm lena.pbm \
lena.pppm lena.ppgm lena.ppbm \
Index: olena/oln/io/pnm_write_2d.hh
--- olena/oln/io/pnm_write_2d.hh Sat, 27 Sep 2003 18:30:39 +0200 burrus_n
(oln/u/44_pnm_write_ 1.4 600)
+++ olena/oln/io/pnm_write_2d.hh Mon, 03 Nov 2003 21:55:41 +0100 burrus_n
(oln/u/44_pnm_write_ 1.4 600)
@@ -129,9 +129,7 @@
pnm2d_info info;
info.cols = im.ncols();
info.rows = im.nrows();
- oln::utils::f_minmax<oln_value_type(I)> f;
- traverse(f, im);
- info.max_val = f.max();
+ info.max_val = ntg_max_val(oln_value_type(I));
if (info.max_val > ntg::to_ntg(65535U))
return false;
Index: olena/tests/io/tests/headers
--- olena/tests/io/tests/headers Mon, 03 Nov 2003 21:56:54 +0100 burrus_n ()
+++ olena/tests/io/tests/headers Mon, 03 Nov 2003 21:49:33 +0100 burrus_n
(oln/v/32_headers 644)
@@ -0,0 +1,38 @@
+// -*- c++ -*-
+
+#include "loadsave.hh"
+
+#include <fstream>
+#include <sstream>
+
+template <class T>
+bool check_type()
+{
+ image2d<T> ima (5, 5);
+ io::save(ima, "headers.pgm");
+
+ // Read the actual maximal value in the header of the written file
+ std::fstream f ("headers.pgm");
+ assert(f);
+ std::string line;
+ for (unsigned i = 0; i < 4; ++i)
+ std::getline(f, line);
+ f.close();
+
+ // It should be the same value as ntg_max_val(T)
+ std::istringstream s (line);
+ unsigned value;
+ s >> value;
+ return value != ntg_max_val(T);
+}
+
+bool
+check(void)
+{
+ bool fail = false;
+
+ fail |= check_type<int_u8>();
+ fail |= check_type<int_u16>();
+
+ return fail;
+}