wxruby: paint monochrome bitmaps in other colors

C

crystalbrittle

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.

- \/\/
 
A

Alex Fenton

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
 

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

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top