bitmap(3tk)
β¨ bitmap(3tk) β¨
okay so bestie, welcome to the bitmap page β it's one of the Tk Built-In Commands, and it's literally the blueprint for images that only ever show two colors (or ghost mode π»). buckle up, this is cute AND useful.
π NAME π
bitmap β Images that display two colors. that's it, that's the whole vibe. two colors. iconic minimalist behavior.
π SYNOPSIS π
image create bitmap ?name? ?options?
imageName cget option
imageName configure ?option? ?value option value ...?
π¦ DESCRIPTION π¦
so a bitmap is an image whose pixels can display either of two colors or be transparent. like, it has range, but only three modes. main character energy tbh.
a bitmap image is defined by four things, no cap:
- a background color
- a foreground color
- a bitmap called the source
- a bitmap called the mask
each of the bitmaps specifies 0/1 values for a rectangular array of pixels, and the two bitmaps must have the same dimensions β mismatched sizes? not the vibe, don't do it. π
here's how the pixels get decided:
- where the mask is zero, the image displays nothing β transparent effect, it's giving invisibility cloak β¨
- for other pixels, it shows the foreground color if the source data is one
- and the background color if the source data is zero
simple as that. the mask is the bouncer, the source is the outfit. π
π CREATING BITMAPS π
like all images, bitmaps get created using the image create command. bitmaps support the following options, and bestie I'm listing every single one:
-background colorβ sets a background color for the image, in any of the standard ways Tk accepts. and here's the fun part: if you set this option to an empty string, then the background pixels become transparent. that effect is achieved by using the source bitmap as the mask bitmap, and it ignores any-maskdataor-maskfileoptions you gave it. so those two just get β¨uninvitedβ¨.-data stringβ specifies the contents of the source bitmap as a string. that string must adhere to X11 bitmap format (like, the stuff thebitmapprogram generates). and if you specify both-dataand-file, then-datatakes precedence. it wins, it's the favorite child.-file nameβ name gives the name of a file whose contents define the source bitmap. the file must adhere to X11 bitmap format (e.g., as generated by thebitmapprogram).-foreground colorβ specifies a foreground color for the image, in any of the standard ways accepted by Tk.-maskdata stringβ specifies the contents of the mask as a string. string must adhere to X11 bitmap format (e.g., as generated by thebitmapprogram). if you specify both-maskdataand-maskfile, then-maskdatatakes precedence. again: winner winner.-maskfile nameβ name gives the name of a file whose contents define the mask. the file must adhere to X11 bitmap format (e.g., as generated by thebitmapprogram).
π«Ά little reminder bestie: "X11 bitmap format" keeps showing up because it's the whole dress code here. every bitmap string/file has to follow it, no exceptions.
π IMAGE COMMAND π
when a bitmap image is created, Tk also creates a new command whose name is the same as the image. this command lets you invoke various operations on the image. it has this general form:
imageName option ?arg ...?
option and the args decide the exact behavior of the command. for bitmap images, the following commands are possible:
imageName cget optionβ returns the current value of the configuration option given by option. option may have any of the values accepted by theimage create bitmapcommand. it's the "what are you wearing rn" query. πimageName configure ?option? ?value option value ...?β query or modify the configuration options for the image. and okay, this one has layers, so let's break it down:- if no option is specified β returns a list describing all of the available options for
imageName(seeTk_ConfigureInfofor info on the format of this list). - if option is specified with no value β the command returns a list describing that one named option (this list will be identical to the corresponding sublist of the value returned when no option is specified).
- if one or more option-value pairs are specified β the command modifies the given option(s) to have the given value(s); in this case the command returns an empty string. nothing. silence. it did the thing and left no receipt. π
- option may have any of the values accepted by the
image create bitmapcommand.
- if no option is specified β returns a list describing all of the available options for
β KEYWORDS β
bitmap, image
and that's the whole page bestie!! π§ go forth and make two-color art. this was Tk version 4.0, from the bitmap(3tk) page β sending you love from the manpage crypt, mwah ππΈ
π¦ where this page comes from
- debian trixie: tk9.0-doc 9.0.1-3
- ubuntu questing: tk9.0-doc 9.0.2-1
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 1994 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms