Images from data



Hi all,

The archives seem to be strewn with messages about building an image from data, but I can't seem to find one that answers my question.

I would like to be able to define an image for a button within my package in a similar fashion to perl/Tk, which would do it like so:

  my $insert = pack("b14" x 14, ("..............",
                                 "..........11..",
                                 "..........11..",
                                 "..........11..",
                                 "..........11..",
                                 ".....1....11..",
                                 "....11....11..",
                                 "...111....11..",
                                 "..1111111111..",
                                 "..111111111...",
                                 "...111........",
                                 "....11........",
                                 ".....1........",
                                 ".............."));
  $mw->DefineBitmap(my_insert => 14, 14, $insert);

DefineBitmap creates a registered name (in this case my_insert) for a bitmap 14 x 14 pixels with the data given. 1 is a black pixel, . is a blank pixel.

Now while I don't need the name registering bit, I'm having no luck converting the above data into anything I can display on screen. I even started getting X errors when I started playing around with Gtk2::Gdk::Bitmap/Gtk2::Gdk::Drawable/Gtk2::Image, which was a little disheartening.

So, in Gtk2, what's the easiest way of defining/using inline image data?

MB


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]