[Image of Linux]
The Personal Web Pages of Chris X. Edwards

Simplified TK Reference

--------------------------
Keyword:

bitmap

Description: The bitmap command allows pixel graphics features to adorn various widgets. It also sets up other functionality like pattern fill in canvas widgets. It's best to use a separate namespace when naming images so that you don't clobber anything important. The recommended naming scheme is ::img::yourpichere which should avoid problems.
Example:

image create bitmap ::img::bike -data "#define bike_width 29
#define bike_height 17
static unsigned char bike_bits[] = {
   0x80, 0x03, 0x3f, 0x00, 0x60, 0x02, 0x3e, 0x00, 0x10, 0x02, 0x08, 0x00,
   0x10, 0xfe, 0x0f, 0x00, 0x60, 0x02, 0x0c, 0x00, 0x00, 0x07, 0x0e, 0x00,
   0xf8, 0x09, 0xfa, 0x03, 0x86, 0x09, 0x39, 0x0c, 0x82, 0x12, 0x39, 0x08,
   0xc1, 0xb2, 0x24, 0x10, 0x41, 0xa4, 0xc4, 0x10, 0x21, 0xc4, 0xe4, 0x11,
   0x01, 0x44, 0x1f, 0x10, 0x01, 0x44, 0x04, 0x10, 0x02, 0x62, 0x08, 0x08,
   0x06, 0x03, 0x18, 0x0c, 0xf8, 0x00, 0xe0, 0x03 };"
label .lvelo -image ::img::bike       
button .bvelo -image ::img::bike -command {put www.xed.ch}
radiobutton .rvelo -image ::img::bike
checkbutton .cvelo -image ::img::bike
pack .lvelo .bvelo .rvelo .cvelo -side left

  
Example:
 
# Here's how to bake your own bitmaps from scratch. This is a 19x5
# bitmap, but we need 3 bytes per row (24x5) because rows must be in
# byte multiples. The bit values for each pixel are summed to produce
# a hex digit. The pairs of hex digits are swapped to form the byte.
#  1248 1248  1248 1248  1248 1248 <-bit value                     ;
#  .... XX..  .... ..XX  XXX. .... --> 0 3  0 C  7 0 --> 30 C0 70  ;
#  ..XX ..X.  .... .X..  .XX. .... --> C 4  0 2  6 0 --> 4C 20 60  ;
#  XX.. ...X  XXXX XXXX  X... .... --> 3 8  F F  1 0 --> 83 FF 01  ;
#  ..XX ..X.  .... .X..  .XX. .... --> C 4  0 2  6 0 --> 4C 20 60  ;
#  .... XX..  .... ..XX  XXX. .... --> 0 3  0 C  7 0 --> 30 C0 70  ;
image create bitmap ::img::tarr -data "#define foo_width 19      
#define foo_height 5
static unsigned char foo_bits[] = {
  0x30, 0xC0, 0x07,
  0x4C, 0x20, 0x06,
  0x83, 0xFF, 0x01,
  0x4C, 0x20, 0x06,
  0x30, 0xC0, 0x07 };"
label .ta -image ::img::tarr -bg coral -width 50 -height 20; pack .ta

 
Official
Syntax:
http://www.scriptics.com/man/tcl8.4/TkCmd/bitmap.htm

--------------------------
Previous Home Next
This page was created with only free, open-source, publicly licensed software.
This page was designed to be viewed with any browser on any system.
Chris X. Edwards ~ January 2004