URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-13 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Plugin gimp support the undo system.
* sandbox/nivault/plugin-gimp/src/build-image.hh,
* sandbox/nivault/plugin-gimp/src/build-image.hxx,
* sandbox/nivault/plugin-gimp/src/main.cc: Use two image for reading
and writing.
---
build-image.hh | 3 ++-
build-image.hxx | 15 +++++++++------
main.cc | 27 ++++++++++++++++-----------
3 files changed, 27 insertions(+), 18 deletions(-)
Index: trunk/milena/sandbox/nivault/plugin-gimp/src/build-image.hxx
===================================================================
--- trunk/milena/sandbox/nivault/plugin-gimp/src/build-image.hxx (revision 1470)
+++ trunk/milena/sandbox/nivault/plugin-gimp/src/build-image.hxx (revision 1471)
@@ -45,9 +45,10 @@
}
};
-void build_milena_image(GimpPixelRgn *region)
+void build_milena_image(GimpPixelRgn *in,
+ GimpPixelRgn *out)
{
- I tmp(region);
+ I tmp(in);
// g_message(region->dirty ? "saaale" : "pas saaale");
// g_message(region->shadow ? "shadoooow" : "pas shadoooow");
ima = tmp;
@@ -65,13 +66,15 @@
mln::level::transform(ima, fun, tmp2);
mln::border::resize(tmp2, 0);
- gimp_pixel_rgn_set_rect(region,
+ gimp_pixel_rgn_set_rect(out,
(const guchar *) tmp2.buffer(),
0,
0,
- region->w,
- region->h);
- gimp_displays_flush ();
+ out->w,
+ out->h);
+
+ gimp_drawable_flush (out->drawable);
+ gimp_drawable_merge_shadow (out->drawable->drawable_id, TRUE);
}
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 1470)
+++ trunk/milena/sandbox/nivault/plugin-gimp/src/main.cc (revision 1471)
@@ -96,8 +96,10 @@
{
static GimpParam values[1];
GimpDrawable *drawable;
- GimpPixelRgn region;
+ GimpPixelRgn in, out;
gint32 image_ID;
+ gint x1, y1, x2, y2;
+ gint width, height;
GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
@@ -107,18 +109,16 @@
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,
- 0,
- 0,
- drawable->width,
- drawable->height,
- FALSE,
- FALSE);
+ gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2,
&y2);
- build_milena_image(®ion);
+ width = drawable->width;
+ height = drawable->height;
+
+ gimp_pixel_rgn_init(&in, drawable, 0, 0, width, height, FALSE, FALSE);
+ gimp_pixel_rgn_init(&out, drawable, 0, 0, width, height, TRUE, TRUE);
+
+ build_milena_image(&in, & out);
if (strcmp (name, PROCEDURE_NAME) == 0)
{
@@ -143,6 +143,11 @@
status = GIMP_PDB_CALLING_ERROR;
}
+ gimp_drawable_update (drawable->drawable_id, x1, y1, (x2 - x1), (y2 - y1));
+
+ gimp_displays_flush ();
+ gimp_drawable_detach (drawable);
+
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
}
Index: trunk/milena/sandbox/nivault/plugin-gimp/src/build-image.hh
===================================================================
--- trunk/milena/sandbox/nivault/plugin-gimp/src/build-image.hh (revision 1470)
+++ trunk/milena/sandbox/nivault/plugin-gimp/src/build-image.hh (revision 1471)
@@ -43,7 +43,8 @@
# include <mln/io/ppm/save.hh>
-void build_milena_image(GimpPixelRgn *region);
+void build_milena_image(GimpPixelRgn *in,
+ GimpPixelRgn *out);
gboolean draw_milena_image(GtkWidget* area,
GdkEventExpose *event,