Date: Tue, 21 Oct 2003 17:14:41 +0100 To: Olivier Andrieu Cc: lablgtk at kaba.or.jp Subject: Re: Crashing bug in lablgtk2 2.2.0 when reading image from pixmap (Windows only) Message-ID: <20031021161441.GD5277 at redhat.com> References: <20031021123817.GA5277 at redhat.com> <20031021124207.GB5277 at redhat.com> <20031021124824.GC5277 at redhat.com> <16277.22158.816434.308669 at akasha.ijm.jussieu.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16277.22158.816434.308669 at akasha.ijm.jussieu.fr> From: Richard Jones On Tue, Oct 21, 2003 at 05:53:50PM +0200, Olivier Andrieu wrote: > Richard Jones [Tuesday 21 October 2003] : > > > > > > OK, ignore the previous version. Here is a much more minimal way to > > reproduce the bug. After compiling & running it, click on the button a > > few times and notice the console error messages. > > which GTK+ version are you using ? In the NEWS file of GTK+-2.2.4 > there's : > > * Win32 > - Fix GdkImage memory leak > > might fix your pb. We're using 2.2.2, so this might be the problem. > On a side note, I don't know how GdkImage and GdkPixmap are > implemented on Windows but on Unix your program is a bit weird : you > have a client-side pixel buffer (pixbuf), then you send it to the > server (pixmap), then you send it back to the client (image) ... Yes, that's because this program is just a demonstration of the bug. In reality our big program draws complex stuff into a drawable on the "server" side, and then tries to copy this into an image on the client side so it can write it out to a file. > 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. I worked around that ... Rich. -- Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you. "I wish more software used text based configuration files!" -- A Windows NT user, quoted on Slashdot.