From: Olivier Andrieu Message-ID: <16278.44802.299222.468101 at akasha.ijm.jussieu.fr> Date: Wed, 22 Oct 2003 18:23:30 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="A/4FrjBwnE" Content-Transfer-Encoding: 7bit To: Richard Jones Cc: lablgtk at kaba.or.jp Subject: Re: Crashing bug in lablgtk2 2.2.0 when reading image from pixmap (Windows only) In-Reply-To: <20031021161441.GD5277 at redhat.com> References: <20031021123817.GA5277 at redhat.com> <20031021124207.GB5277@redhat.com> <20031021124824.GC5277@redhat.com> <16277.22158.816434.308669@akasha.ijm.jussieu.fr> <20031021161441.GD5277@redhat.com> --A/4FrjBwnE Content-Type: text/plain; charset=us-ascii Content-Description: message body and .signature Content-Transfer-Encoding: 7bit Richard Jones [Tuesday 21 October 2003] : > > For accessing the pixel values I think you should definitively use > > pixbufs and the get_pixels function : > > > > val get_pixels : pixbuf -> Gpointer.region > > So I changed the program now to copy the drawable into a pixbuf and > access the data as you suggest. It now works. > > However I did come across a strangeness. Our code looks like this, > where width = 800 and height = 600. > > self#paint_drawable (pixmap :> GDraw.drawable) width height; > > (* Create a pixbuf (client side) from the drawable. *) > let pb = GdkPixbuf.create ~width ~height ~has_alpha:false ~bits:8 > ~colorspace:`RGB () in > GdkPixbuf.get_from_drawable ~dest:pb (pixmap#pixmap); > > (* Get a pointer to the pixels. *) > let ptr = GdkPixbuf.get_pixels pb in > > let length = Gpointer.length ptr in > > At this point, length = 1438400, which is 1600 bytes short of what > it should be. Yeah, this one's a bug in lablgtk. -- Olivier --A/4FrjBwnE Content-Type: text/plain Content-Disposition: attachment; filename="pixbuf.patch" Content-Transfer-Encoding: 7bit Index: src/gdkPixbuf.ml =================================================================== RCS file: /staff2/garrigue/repos/lablgtk/src/gdkPixbuf.ml,v retrieving revision 1.6 diff -u -r1.6 gdkPixbuf.ml --- src/gdkPixbuf.ml 6 Aug 2003 00:12:39 -0000 1.6 +++ src/gdkPixbuf.ml 22 Oct 2003 16:20:36 -0000 @@ -34,7 +34,7 @@ let get_pixels pixbuf = let obj, pos = _get_pixels pixbuf in let get_length (_, pixbuf) = - get_rowstride pixbuf * (get_height pixbuf - 1) + get_width pixbuf + pos + get_rowstride pixbuf * (get_height pixbuf - 1) + (get_width pixbuf * get_n_channels pixbuf) + pos in let r = Gpointer.unsafe_create_region ~path:[|0|] ~get_length (obj, pixbuf) in --A/4FrjBwnE--