FXImage problems

  • Thread starter Pawel Szymczykowski
  • Start date
P

Pawel Szymczykowski

------=_Part_145_16722959.1129705722483
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi,

I'm trying to combine FXRuby with RMagick. I've searched the mail archives
(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 i=
t
to work.

Basically I'm processing my image and then doing an export_pixels and tryin=
g
to convert it to the FXImage format. It works the first time, but when I tr=
y
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 to
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 th=
e
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 an=
d
of course if someone is feeling charitable enough to take a look at it.

Thanks for your help!

-Pawel

------=_Part_145_16722959.1129705722483--
 
P

Pawel Szymczykowski

------=_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

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--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,181
Messages
2,570,970
Members
47,537
Latest member
BellCorone

Latest Threads

Top