How can I take image from Rmagick object?
I try image.set_data(blob), but this wrong…
Is possible make scrollable StaticBitmap?

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.

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


Thanks you, it’s work))

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs