Wxruby: paint monochrome bitmaps in other colors

Is there an easy way to change the black and white pixels in a
monochrome bitmap to arbitrary color values? I just want to load in a
monochrome gif (or png) and display it in a window with, say, orange
for the black pixels, and yellow for the white… I thought about
swapping the palette of a loaded image file, but I can’t seem to
actually create a Palette. But maybe this isn’t the best way.

  • //

[email protected] wrote:

Is there an easy way to change the black and white pixels in a
monochrome bitmap to arbitrary color values? I just want to load in a
monochrome gif (or png) and display it in a window with, say, orange
for the black pixels, and yellow for the white

Set the drawing device context’s text_foreground and text_background to
be the colours you want, then a mono bitmap will be drawn in those
colours; http://wxruby.rubyforge.org/doc/dc.html#DC_drawbitmap

bitmap.depth = 1
dc.text_foreground = Wx::Colour.new(255, 128, 0)
dc.text_background = Wx::Colour.new(255, 255, 0)
dc.draw_bitmap(bitmap, 0, 0, false)

wxRuby specific questions are usually better posted at
http://rubyforge.org/mailman/listinfo/wxruby-users

alex

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