[gimp-perl] Doc that $region->data only good in iterator. Also address bug 731935.



commit f02e68348b8c6dedd2d0737e6f67fd84e1af0857
Author: Ed J <edj src gnome org>
Date:   Fri Jun 20 01:17:03 2014 +0100

    Doc that $region->data only good in iterator. Also address bug 731935.

 Gimp/Lib.xs       |    5 +++++
 Gimp/PixelRgn.pod |    6 +++++-
 examples/iland    |    2 --
 3 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/Gimp/Lib.xs b/Gimp/Lib.xs
index eca93ee..46a7e49 100644
--- a/Gimp/Lib.xs
+++ b/Gimp/Lib.xs
@@ -315,12 +315,14 @@ static SV *new_gpixelrgn (SV *gdrawable, int x, int y, int width, int height, in
   static HV *stash;
   SV *sv = newSVn (sizeof (GimpPixelRgn));
   GimpPixelRgn *pr = (GimpPixelRgn *)SvPV_nolen(sv);
+  verbose_printf (2, "new_gpixelrgn(%d, %d, %d, %d, %d, %d)\n", x, y, width, height, dirty, shadow);
 
   if (!stash)
     stash = gv_stashpv (PKG_PIXELRGN, 1);
 
   GimpDrawable *gd = old_gdrawable(gdrawable);
   gimp_pixel_rgn_init (pr, gd, x, y, width, height, dirty, shadow);
+  verbose_printf (2, "gimp_pixel_rgn now={%d, %d, %d, %d, %d, %d}\n", pr->bpp, pr->rowstride, pr->x, pr->y, 
pr->w, pr->h, pr->dirty, pr->shadow);
 
   sv_magic (sv, SvRV(gdrawable), '~', 0, 0);
   mg_find (sv, '~')->mg_virtual = &vtbl_gpixelrgn;
@@ -2156,6 +2158,9 @@ gimp_pixel_rgn_data(pr,newdata=0)
        GimpPixelRgn_PDL *      pr
        pdl * newdata
        CODE:
+       verbose_printf (2, "gimp_pixel_rgn_data(%lx, %lx)\n", (long)pr, (long)newdata);
+       if (!pr->rowstride)
+         croak("gimp_pixel_rgn_data called, rowstride == 0; only call within an iterator!");
        if (newdata)
          {
            guchar *src;
diff --git a/Gimp/PixelRgn.pod b/Gimp/PixelRgn.pod
index ddbe60e..5ba1e76 100644
--- a/Gimp/PixelRgn.pod
+++ b/Gimp/PixelRgn.pod
@@ -80,7 +80,7 @@ region, and a writable "destination" region:
   my ($x,$y,$w,$h)=($dst->x,$dst->y,$dst->w,$dst->h);
   my $pdl = $src->get_rect($x,$y,$w,$h);
   $pdl += 7; # trivial operation
-  $dst->data($pdl);
+  $dst->set_rect($pdl, $x, $y);
   $drawable->merge_shadow(1);
 
 However, it B<is> possible to use dirty=1, shadow=0; see the "setpixel"
@@ -185,6 +185,10 @@ Once the operation is complete and the shadow tiles have all been set with
 the right data, C<$drawable-E<gt>merge_shadow($undo)> is called. C<$undo>
 is a boolean telling GIMP "whether to add an undo step for the operation".
 
+=item data method only valid for iterators
+
+The C<$region-E<gt>data> method is only valid for use within an iterator.
+
 =back
 
 =head1 NON-PDL METHODS
diff --git a/examples/iland b/examples/iland
index e38f7fd..f08a2f1 100755
--- a/examples/iland
+++ b/examples/iland
@@ -29,7 +29,6 @@ podregister {
   $newimage->insert_layer($layer, 0, -1);
   my $newdrawable = $newimage->get_active_drawable;
   my $dest = Gimp::PixelRgn->new($newdrawable, 0, 0, $width, $height, 1, 1);
-#  my $srcdata = $src->data;
   my $srcdata = $src->get_rect($drawable->bounds);
   my $destdata = $srcdata->zeroes;
   Gimp::Progress->init("Rendering...");
@@ -73,7 +72,6 @@ podregister {
     Gimp::Progress->update($y / $height);
   }
   Gimp::Progress->update(1);
-#  $dest->data($destdata);
   $dest->set_rect($destdata, 0, 0);
 #  die "merge_shadow failed for $newdrawable\n" unless
     $newdrawable->merge_shadow(TRUE); # returns false but works and is needed


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]