From: Pawel Szymczykowski Date: 2005-10-19T16:13:54+09:00 Subject: Re: FXImage problems ------=_Part_209_8894751.1129706031881 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Oops! Sorry. I was supposed to post this to the fxruby list instead. Feel free to just ignore it or chide me a bit if it helps to equalize things. -Pawel On 10/19/05, Pawel Szymczykowski wrote: > > Hi, > > I'm trying to combine FXRuby with RMagick. I've searched the mail archive= s > (I had to index them myself! Is there an easy to use official search page > somewhere?) and apparently it's been done before, but I can't seem to get > it > to work. > > Basically I'm processing my image and then doing an export_pixels and > trying > to convert it to the FXImage format. It works the first time, but when I > try > to do it again it crashes on my saying 'invalid image' in Linux, or > something useless about abnormal termination in Windows. > > This is the piece of code that seems to be giving me the specific trouble= : > > pixels =3D [] > @current_image.export_pixels(0, 0, @current_image.columns, > @current_image.rows, > "RGBA").each_slice(4) { |rgba| pixels << FXRGBA( *rgba ) } > an_image =3D FXImage.new(app, pixels, IMAGE_OWNED|IMAGE_KEEP, > @current_image.columns, @current_image.rows ) > > That works the first time - I get a nice picture as expected when drawn t= o > the canvas. The next time it happens via a timeout, I get the crash. > Actually, it's more like it works fine if I do it before calling > app.create(or maybe run?), but not afterwards. > > I've also tried the following as mentioned in one of the messages in the > archives, but it complains that it's looking for an Array (buffer is > FXMemoryBuffer class of course): > > buffer =3D FXMemoryBuffer.new( pixels ) > an_image =3D FXImage.new(app, buffer, IMAGE_OWNED|IMAGE_KEEP, > @current_image.columns, @current_image.rows ) > > I've tried several different combinations of the flags, and putting > an_image.create in various places. The former didn't help at all, but in > the > latter I just got a black image. > > Am I doing something idiotic somewhere? I'm kind of new to ruby and GUI > development in general being more of web app guy. I can post a runnable > version of the code up somewhere if the problem isn't completely obvious > and > of course if someone is feeling charitable enough to take a look at it. > > Thanks for your help! > > -Pawel > > ------=_Part_209_8894751.1129706031881--