bitmap images with 2 colors and transparency

MGS aka Mark G. Saye [2003/09/12] - You can create bitmap images with two colors and transparency using the -data and -mask options to the image create command.

Example:


   set data {
     #define data_width 16
     #define data_height 16
     static unsigned char data_bits[] = {
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
       0x03, 0xe0, 0x07, 0xe0, 0x07, 0xe0, 0x07, 0xe0, 0x07, 0xc0, 0x03,
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
   }

   set mask {
     #define mask_width 16
     #define mask_height 16
     static unsigned char mask_bits[] = {
       0xe0, 0x07, 0xf8, 0x1f, 0xfc, 0x3f, 0x3e, 0x7c, 0x0e, 0x70, 0xcf,
       0xf3, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xcf, 0xf3,
       0x0e, 0x70, 0x3e, 0x7c, 0xfc, 0x3f, 0xf8, 0x1f, 0xe0, 0x07 };
   }

   set image [image create bitmap \
     -data $data \
     -maskdata $mask \
     -background blue \
     -foreground red \
   ]

   label .l -bg yellow -fg magenta -image $image

   catch {.l configure -compound left -text "This bitmap image has 2 colors"}

   pack .l

Screenshots Section

gold added pix

bitmap images with 2 colors and transparency screen.jpeg (image link appears broken on Sep. 15, 2011)