URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-12 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Plug-in gimp works and compute images.
* sandbox/nivault/plugin-gimp/src/build-image.hh,
* sandbox/nivault/plugin-gimp/src/build-image.hxx,
* sandbox/nivault/plugin-gimp/src/gimp-image.hh,
* sandbox/nivault/plugin-gimp/src/main.cc: Update.
* mln/level/transform.hh: Add the "out algo(in)" form.
---
mln/level/transform.hh | 17 ++++++++++++
sandbox/nivault/plugin-gimp/src/build-image.hh | 12 +++++---
sandbox/nivault/plugin-gimp/src/build-image.hxx | 33 +++++++++++++++++++++++-
sandbox/nivault/plugin-gimp/src/gimp-image.hh | 21 +++++++++++----
sandbox/nivault/plugin-gimp/src/main.cc | 1
5 files changed, 74 insertions(+), 10 deletions(-)
Index: trunk/milena/mln/level/transform.hh
===================================================================
--- trunk/milena/mln/level/transform.hh (revision 1468)
+++ trunk/milena/mln/level/transform.hh (revision 1469)
@@ -64,6 +64,11 @@
void transform(const Image<I>& input, const Function_v2v<F>& f,
Image<O>& output);
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform(const Image<I>& input, const Function_v2v<F>& f);
+
+
# ifndef MLN_INCLUDE_ONLY
namespace impl
@@ -131,6 +136,18 @@
}
+ template <typename I, typename F>
+ mln_ch_value(I, mln_result(F))
+ transform(const Image<I>& input, const Function_v2v<F>& f)
+ {
+ mln_precondition(exact(input).has_data());
+ mln_ch_value(I, mln_result(F)) output;
+ initialize(output, input);
+ transform(input, f, output);
+ return output;
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::level
Index: trunk/milena/sandbox/nivault/plugin-gimp/src/build-image.hxx
===================================================================
--- trunk/milena/sandbox/nivault/plugin-gimp/src/build-image.hxx (revision 1468)
+++ trunk/milena/sandbox/nivault/plugin-gimp/src/build-image.hxx (revision 1469)
@@ -36,11 +36,42 @@
return ima;
}
+struct toto : mln::Function_v2v<toto>
+{
+ typedef mln::value::rgb8 result;
+ mln::value::rgb8 operator()(const mln::value::rgb8& c) const
+ {
+ return mln::value::rgb8(255 - c.red(), 255 - c.green(), 255 - c.blue());
+ }
+};
+
void build_milena_image(GimpPixelRgn *region)
{
I tmp(region);
+// g_message(region->dirty ? "saaale" : "pas saaale");
+// g_message(region->shadow ? "shadoooow" : "pas shadoooow");
ima = tmp;
- mln::level::fill(ima, mln::literal::blue);
+ mln::point2d p1(0,0);
+ mln::point2d p2(0,5);
+ mln::point2d p3(20,50);
+// mln::io::ppm::save(ima, "/goinfre/out.ppm");
+ std::cout << p1 << " : " << ima(p1) << std::endl;
+ std::cout << p2 << " : " << ima(p2) << std::endl;
+ std::cout << p3 << " : " << ima(p3) << std::endl;
+// mln::level::fill(ima, mln::literal::blue);
+
+ toto fun;
+ mln::image2d<mln::value::rgb8> tmp2(ima.domain());
+ mln::level::transform(ima, fun, tmp2);
+ mln::border::resize(tmp2, 0);
+
+ gimp_pixel_rgn_set_rect(region,
+ (const guchar *) tmp2.buffer(),
+ 0,
+ 0,
+ region->w,
+ region->h);
+ gimp_displays_flush ();
}
gboolean draw_milena_image(GtkWidget* area,
Index: trunk/milena/sandbox/nivault/plugin-gimp/src/main.cc
===================================================================
--- trunk/milena/sandbox/nivault/plugin-gimp/src/main.cc (revision 1468)
+++ trunk/milena/sandbox/nivault/plugin-gimp/src/main.cc (revision 1469)
@@ -107,6 +107,7 @@
run_mode = (GimpRunMode) param[0].data.d_int32;
image_ID = param[1].data.d_int32;
drawable = gimp_drawable_get (param[2].data.d_drawable);
+ gimp_image_undo_enable(image_ID);
gimp_pixel_rgn_init(®ion,
drawable,
Index: trunk/milena/sandbox/nivault/plugin-gimp/src/gimp-image.hh
===================================================================
--- trunk/milena/sandbox/nivault/plugin-gimp/src/gimp-image.hh (revision 1468)
+++ trunk/milena/sandbox/nivault/plugin-gimp/src/gimp-image.hh (revision 1469)
@@ -37,6 +37,10 @@
# include <mln/value/set.hh>
# include <mln/value/rgb8.hh>
# include <mln/core/line_piter.hh>
+# include <mln/literal/all.hh>
+
+# include <iostream>
+# include <sstream>
namespace mln
{
@@ -265,8 +269,8 @@
mln_assertion(rgn != NULL);
buffer_ = (typename gimp_image<t>::value*) rgn->data;
b_ = make::box2d(rgn->y, rgn->x,
- rgn->y + rgn->h,
- rgn->x + rgn->w);
+ rgn->y + rgn->h - 1,
+ rgn->x + rgn->w - 1);
allocate_();
}
@@ -408,8 +412,12 @@
{
// mln_precondition(this->owns_(p));
// FIXME HERE value*) this->data_->rgn->data
- static mln::value::rgb8 c(200,200,200);
- return c; // this->data_->array_[p.row()][p.col()];
+
+ static mln::value::rgb8 c;
+ gimp_pixel_rgn_get_pixel(this->data_->rgn_,
+ (guchar *) &c,
+ p[1], p[0]);
+ return c;
}
template <GimpImageType t>
@@ -417,7 +425,10 @@
gimp_image<t>::operator()(const point& p)
{
// mln_precondition(this->owns_(p));
- static mln::value::rgb8 c(0,0,0);
+ static mln::value::rgb8 c;
+ gimp_pixel_rgn_get_pixel(this->data_->rgn_,
+ (guchar *) &c,
+ p[1], p[0]);
return c; // this->data_->array_[p.row()][p.col()];
// return this->data_->array_[p.row()][p.col()];
}
Index: trunk/milena/sandbox/nivault/plugin-gimp/src/build-image.hh
===================================================================
--- trunk/milena/sandbox/nivault/plugin-gimp/src/build-image.hh (revision 1468)
+++ trunk/milena/sandbox/nivault/plugin-gimp/src/build-image.hh (revision 1469)
@@ -32,12 +32,16 @@
# include <libgimp/gimpui.h>
# include <src/gimp-image.hh>
+# include <mln/core/point2d.hh>
# include <mln/level/fill.hh>
-// # include <mln/core/image2d.hh>
-// # include <mln/value/rgb8.hh>
+# include <mln/core/image2d.hh>
+# include <mln/value/rgb8.hh>
# include <mln/literal/all.hh>
-// # include <mln/display/show.hh>
-// # include <mln/display/remove.hh>
+# include <mln/core/concept/function.hh>
+# include <mln/level/transform.hh>
+# include <mln/border/resize.hh>
+
+# include <mln/io/ppm/save.hh>
void build_milena_image(GimpPixelRgn *region);