bitmap

Difference between version 30 and 31 - Previous - Next
** Summary **

** Documentation **

   [http://www.tcl.tk/man/tcl/TkCmd/bitmap.htm%|%man page]:   
   [http://www.tcl.tk/man/tcl8.5/TkLib/GetBitmap.htm%|%Tk_GetBitmap man page]:   

** See Also **

   [How to edit an executable's desktop icon]:   
   [Bitmap Editor]:   a simple tool to create and edit bitmaps
   poBitmap:   [poSoft utilities], by [Paul Obermeier], is an editor for X bitmaps
   [http://www.sfu.ca/~gay/bme.zip%|%Bitmap editor, by Ian Gay]:   
   [Tk syntax help]:   
   [Arts and crafts of Tcl-Tk programming]:   
   [bitmap.to.photo]:   
   [bme]:   
   [bitmap images with 2 colors and transparency]:   

** Description **

A bitmap is monochromatic representation.  

Use a [photo] [image] when you want color or greyscale images or icons (aka a
[pixmap]).

[Tk] uses bitmaps in two senses: directly (via various widgets' '''-bitmap'''
options) and indirectly through the `bitmap` [image] type. ''They are
different!'' Bitmap images are, first and foremost, images. Naked bitmaps are
distinctly uncommon, as well as being difficult to work with in practice.
''([AMG]: Naked [photo]s, on the other hand... hehehe.)''

If you want to edit the bitmap image, it's easier to use a [photo] with just
two colors.

----

A variant [Tk]-pertinent sense of "bitmap" is as a permissible argument to
specific [canvas] subcommands.  A model of such uses is

======
.canvas itemconfig rectangle -stipple $bitmap
======


Along with much else
[http://www.tcl.tk/man/tcl8.5/TkLib/GetBitmap.htm%|%Tk_GetBitmap] provides a
list--"error", "gray50", "question", and so on--of standard bitmaps built in to
Tk.  Apparently Tk provides no script-level [introspection] to access this
list.  To view these built-ins, therefore, it's necessary to perform something
like the script below. Note, however, that the last 16 bitmaps (from document
to caution) are only available on the Mac platform.

======
set bitmap_list {error gray75 gray50 gray25 gray12 hourglass
    info questhead question warning document stationery edition
    application accessory folder pfolder trash floppy ramdisk
    cdrom preferences querydoc stop note caution}

eval destroy [winfo children .]

canvas .c -height 200 -width 200 -background linen
listbox .l -height [llength $bitmap_list]

foreach bitmap $bitmap_list {
    .l insert end $bitmap
}
pack .c .l -fill x


bind .l <ButtonRelease-1> show_bitmap

proc show_bitmap {} {
    set pattern [.l get [.l curselection]]
    .c delete bitmap
    .c create bitmap 100 100 -bitmap $pattern -tags bitmap
}
======

Run this and you'll see such an interface such as ... 

[http://www.ece.ualberta.ca/~wyard/wiki.tcl.tk/bitmap.jpg]
[LES] With sadness in my heart, I discovered that all items below "warning" are available only on the Macintosh platform. It says so in the manual.


<<categories>> Command | Graphics | Arts and Crafts of Tcl-Tk Programming