Forum: wxRuby StaticBitmap

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
72b416125e0048f8279b1b57f973b66b?d=identicon&s=25 Cyrill Jakovlev (cyrill)
on 2008-11-16 03:47
How can I take image from Rmagick object?
I try image.set_data(blob), but this wrong..
Is possible make scrollable StaticBitmap?
3396e4a3df8a840faec520af8555a400?d=identicon&s=25 Mario Steele (Guest)
on 2008-11-16 06:08
(Received via mailing list)
You will need to convert the data over from Rmagick format to wxRuby
format.  You have the basic idea, in which you need to retrieve the RGB
Pixel data from the RMagick object, and then apply that to a wxRuby
object.  However, you will also need to grab the Palette from RMagick,
apply to the wxRuby Image Object, through Wx::Image#set_palette().

I believe this is the method in which you need to go about this,
I've never worked with Rmagick, and wxRuby personally.  But you
need to go through Image#set_data() and Image#set_palette to make it
I think Alex may have a bit more experience with this, so he may be able
give you a clearer answer to this question.
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2008-11-17 11:26
(Received via mailing list)
Cyrill Jakovlev wrote:
> How can I take image from Rmagick object?
> I try image.set_data(blob), but this wrong..

set_data uses a raw, uncompressed format, but it looks like RMagick's
to_blob method exports in known image formats.

I would use ruby's stdlib StringIO to create an in-memory representation
that Wx::Image can read from.

require 'stringio'
str_io = StringIO( rmagick_img.to_blob ) # with whatever arguments are
needed for to_blob
img =, Wx::BITMAP_TYPE_PNG) # or other image

Then use Wx::Bitmap.from_image to get an object suitable for drawing on
the screen.

> Is possible make scrollable StaticBitmap?

Use Wx::ScrolledWindow to create a scrollable viewing for any contents,
including Wx::StaticBitmap. There's different ways to use ScrolledWindow
for which see the docs, but probably you could just use

scroll_win =
image = scroll_win, :label => bmp)
scroll_win.virtual_size = [ bmp.width, bmp.height ] # tell the window
how big the whole canvas is
scroll_win.set_scroll_rate(5, 5) # scroll 5 pixels at a time, change as

72b416125e0048f8279b1b57f973b66b?d=identicon&s=25 Cyrill Jakovlev (cyrill)
on 2008-11-20 22:45
Thanks you, it's work))
This topic is locked and can not be replied to.