Version 22 of bitmap

Updated 2008-04-24 23:46:43 by andy

Documentation can be found at http://www.purl.org/tcl/home/man/tcl8.4/TkCmd/bitmap.htm .

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 photos, on the other hand... hehehe.)

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


"How to edit an executable's desktop icon"


Sometimes people want to know how to edit an X bitmap or to create a new one. See Paul Obermeier's http://www.posoft.de/ 's poBitmap, part of poSoft utilities for one tool.

KPV See Bitmap Editor for a simple tool to create and edit bitmaps.

Also http://www.sfu.ca/~gay/bme.zip


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

While Tk offers many interesting bitmap capabilities, it can be difficult tracking down their documentation. A good starting point is the distribution man page for the library entry point Tk_GetBitmap [L1 ]. Along with much else, it 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 pictures as ...

http://tcl.typoscriptics.de/misc/bitmap.gif


See also: