Debian Codegraph @

html/bitmap.html

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 <!-- manual page source format generated by PolyglotMan v3.0.8+XFree86, -->
2 <!-- available via anonymous ftp from ftp.cs.berkeley.edu:/ucb/people/phelps/tcltk/rman.tar.Z -->
3
4 <HTML>
5 <HEAD>
6 <TITLE>bitmap(n) manual page</TITLE>
7 </HEAD>
8 <BODY BGCOLOR="#efefef" TEXT="black" LINK="blue" VLINK="#551A8B" ALINK="red">
9 <A HREF="#toc">Table of Contents</A><P>
10
11 <H2><A NAME="sect0" HREF="#toc0">Name</A></H2>
12 bitmap - Define a new bitmap from a Tcl script
13
14 <H2><A NAME="sect1" HREF="#toc1">Synopsis</A></H2>
15 <B>bitmap define <I>bitmapName data</I></B> ?<I>option value</I>?... <P>
16 <B>bitmap compose <I>bitmapName
17 text</I></B> ?<I>option value</I>?... <P>
18 <B>bitmap exists <I>bitmapName</I></B> <P>
19 <B>bitmap source <I>bitmapName</I></B> <P>
20 <B>bitmap
21 data <I>bitmapName</I></B> <P>
22 <B>bitmap height <I>bitmapName</I></B> <P>
23 <B>bitmap width <I>bitmapName</I></B>
24 <H2><A NAME="sect2" HREF="#toc2">Description</A></H2>
25 The
26 <B>bitmap</B> command lets you create new bitmaps directly from your Tcl script.
27 The bitmap can be specified as a list of data or a text string which is
28 converted into a bitmap. You can arbitrarily scale or rotate the bitmap
29 too.
30 <H2><A NAME="sect3" HREF="#toc3">Introduction</A></H2>
31 Bitmaps are commonly used within Tk. In label and button
32 widgets, you display bitmaps them instead of text strings and in the canvas
33 and text widgets, they're used for stippling. But Tk let's you can create
34 new bitmaps only by reading the bitmap data from a file. This makes bitmaps
35 cumbersome to manage, especially in packaging the program as a <B>wish</B> script,
36 since each bitmap must be its own file. It would be nicer if you could
37 create new bitmaps directly from your Tcl script. <P>
38 The <B>bitmap</B> command lets
39 you do just that. You can specify the bitmap as in various formats (such
40 as the X11 bitmap format). You can also compose a bitmap from a text string.
41 The <B>bitmap</B> command also lets you and arbitrarily rotate or scale the bitmap.
42 For example, you could use this to create button widgets with the text
43 label rotated 90 degrees.
44 <H2><A NAME="sect4" HREF="#toc4">Example</A></H2>
45 &lt;&lt;&lt;&lt;&lt;&lt;&lt; bitmap.mann You can define a new bitmap
46 with the <B>define</B> operation. For example, let's say you are using the X11
47 bitmap "gray1". Normally to use it, you would specify the location of the
48 file. <BR>
49 <CODE>label .l -bitmap @/usr/X11R6/include/X11/bitmaps/gray1<BR>
50 </CODE><P>But you can simply cut and paste the contents of "gray1" into the <B>bitmap</B>
51 command. <BR>
52 <CODE>bitmap define gray1 {<BR>
53 #define gray1_width 2<BR>
54 #define gray1_height 2<BR>
55 static char gray1_bits[] = {<BR>
56 0x01, 0x02};<BR>
57 }<BR>
58 label .l -bitmap gray1<BR>
59 </CODE><P>Tk will recognize "gray1" as a bitmap which can now be used with any widget
60 that accepts bitmaps. <BR>
61 <CODE></CODE><P>The bitmap data can be specified in a mulitude of forms. The following commands
62 are all equivalent. <BR>
63 <CODE>bitmap define gray1 {<BR>
64 #define gray1_width 2<BR>
65 #define gray1_height 2<BR>
66 static char gray1_bits[] = {<BR>
67 0x01, 0x02};<BR>
68 }<BR>
69 bitmap define gray1 { { 2 2 } { 0x01, 0x02 } }<BR>
70 bitmap define gray1 { { 2 2 } { 0x01 0x02 } }<BR>
71 bitmap define gray1 { { 2 2 } { 1 2 } }<BR>
72 </CODE><P>Either the data is in the standard X11 bitmap form, or it's a list of two
73 lists. The first list contains the height and width of the bitmap. The second
74 list is the bitmap source data. Each element of that list is an hexadecimal
75 number specifying which pixels are <A HREF="foreground.1.html">foreground (1)</A>
76 and which are background
77 (0) of the bitmap. Note that the format of the source data is exactly that
78 of the XBM format. <P>
79 You can scale or rotate the bitmap as you create it,
80 by using the <B>-scale</B> or<B>-rotate</B> options. <BR>
81 <CODE>bitmap define gray1 {<BR>
82 #define gray1_width 2<BR>
83 #define gray1_height 2<BR>
84 static char gray1_bits[] = {<BR>
85 0x01, 0x02};<BR>
86 } -scale 2.0 -rotate 90.0<BR>
87 </CODE><P>In addition, you can compose bitmaps from text strings. This makes it easy
88 to create rotated buttons or labels. The text string can have multi-line.
89 <BR>
90 <CODE>bitmap compose rot_text "This is rotated\ntext" \<BR>
91 <tt>&#32;</tt>&nbsp;<tt>&#32;</tt>&nbsp;-rotate 90.0 -font fixed<BR>
92 </CODE><P>There are also a number of ways to query bitmaps. This isn't limited to
93 bitmaps that you create, but any bitmap. <BR>
94 <CODE>bitmap exists rot_text<BR>
95 bitmap width rot_text<BR>
96 bitmap height rot_text<BR>
97 bitmap data rot_text<BR>
98 bitmap source rot_text<BR>
99 </CODE><P>The <B>exists</B> operation indicates if a bitmap by that name is defined. You
100 can query the dimensions of the bitmap using the <B>width</B> and <B>height</B> operations.
101 The <B>data</B> operation returns the list of the data used to create the bitmap.
102 For example, you could query the data of a bitmap and <B>send</B> it across
103 the network to another Tk application. <BR>
104 <CODE>set data [bitmap data @/usr/X11R6/include/X11/bitmaps/ghost.xbm]<BR>
105 send {wish #2} bitmap define ghost $data<BR>
106
107 <H2><A NAME="sect5" HREF="#toc5"></CODE><P>Operations</A></H2>
108 The following operations are available for <B>bitmap</B>:
109 <DL>
110
111 <DT><B>bitmap compose
112 <I>bitmapName text </I></B>?<I>option value</I>?... </DT>
113 <DD>Creates a bitmap <I>bitmapName</I> from the text
114 string <I>text</I>. A bitmap <I>bitmapName</I> can not already exist. The following options
115 are available. <blockquote></DD>
116
117 <DT><B>-font <I>fontName</I></B> </DT>
118 <DD>Specifies a font to use when drawing text
119 into the bitmap. If this option isn't specified then <I>fontName</I> defaults to
120 <I>*-Helvetica-Bold-R-Normal-*-140-*</I>. </DD>
121
122 <DT><B>-rotate <I>theta</I></B> </DT>
123 <DD>Specifies the angle of rotation
124 of the text in the bitmap. <I>Theta</I> is a real number representing the angle
125 in degrees. It defaults to <I>0.0</I> degrees. </DD>
126
127 <DT><B>-scale <I>value</I></B> </DT>
128 <DD>Specifies the scale of
129 the bitmap. <I>Value</I> is a real number representing the scale. A scale of 1.0
130 indicates no scaling is necessary, while 2.0 would double the size of the
131 bitmap. There is no way to specify differents scales for the width and
132 height of the bitmap. The default scale is <I>1.0</I>. </DD>
133 </DL>
134 </blockquote>
135
136 <DL>
137
138 <DT><B>bitmap data <I>bitmapName</I></B> </DT>
139 <DD>Returns
140 a list of both the dimensions of the bitmap <I>bitmapName</I> and its source data.
141 </DD>
142
143 <DT><B>bitmap define <I>bitmapName data</I></B> ?<I>option value</I>?... </DT>
144 <DD>Associates <I>bitmapName</I> with
145 in-memory bitmap data so that <I>bitmapName</I> can be used in later calls to <B>Tk_GetBitmap</B>.
146 The <I>bitmapName</I> argument is the name of the bitmap; it must not previously
147 have been defined in either a call to Tk_DefineBitmap or <B>bitmap</B>. The argument
148 <I>data</I> describes the bitmap to be created. It is either the X11 bitmap format
149 (a C structure) or a list of two lists: the dimensions and source data.
150 The dimensions are a list of two numbers which are the width and height
151 of the bitmap. The source data is a list of hexadecimal values in a format
152 similar to the X11 or X10 bitmap format. The values may be optionally separated
153 by commas and do not need to be prefixed with "0x". The following options
154 are available. <blockquote></DD>
155
156 <DT><B>-rotate <I>theta</I></B> </DT>
157 <DD>Specifies how many degrees to rotate the bitmap.
158 <I>Theta</I> is a real number representing the angle. The default is <I>0.0</I> degrees.
159 </DD>
160
161 <DT><B>-scale <I>value</I></B> </DT>
162 <DD>Specifies how to scale the bitmap. <I>Value</I> is a real number representing
163 the scale. A scale of 1.0 indicates no scaling is necessary, while 2.0 would
164 double the size of the bitmap. There is no way to specify differents scales
165 for the width and height of the bitmap. The default scale is <I>1.0</I>. </DD>
166 </DL>
167 </blockquote>
168
169 <DL>
170
171 <DT><B>bitmap exists
172 <I>bitmapName</I></B> </DT>
173 <DD>Returns <I>1</I> if a bitmap <I>bitmapName</I> exists, otherwise <I>0</I>. </DD>
174
175 <DT><B>bitmap
176 height <I>bitmapName</I></B> </DT>
177 <DD>Returns the height in pixels of the bitmap <I>bitmapName</I>.
178 </DD>
179
180 <DT><B>bitmap source <I>bitmapName</I></B> </DT>
181 <DD>Returns the source data of the bitmap <I>bitmapName</I>.
182 The source data is a list of the hexadecimal values. </DD>
183
184 <DT><B>bitmap width <I>bitmapName</I></B>
185 </DT>
186 <DD>Returns the width in pixels of the bitmap <I>bitmapName</I>. </DD>
187 </DL>
188
189 <H2><A NAME="sect6" HREF="#toc6">Limitations</A></H2>
190 Tk currently
191 offers no way of destroying bitmaps. Once a bitmap is created, it exists
192 until the application terminates.
193 <H2><A NAME="sect7" HREF="#toc7">Keywords</A></H2>
194 bitmap <P>
195
196 <HR><P>
197 <A NAME="toc"><B>Table of Contents</B></A><P>
198 <UL>
199 <LI><A NAME="toc0" HREF="#sect0">Name</A></LI>
200 <LI><A NAME="toc1" HREF="#sect1">Synopsis</A></LI>
201 <LI><A NAME="toc2" HREF="#sect2">Description</A></LI>
202 <LI><A NAME="toc3" HREF="#sect3">Introduction</A></LI>
203 <LI><A NAME="toc4" HREF="#sect4">Example</A></LI>
204 <LI><A NAME="toc5" HREF="#sect5">Operations</A></LI>
205 <LI><A NAME="toc6" HREF="#sect6">Limitations</A></LI>
206 <LI><A NAME="toc7" HREF="#sect7">Keywords</A></LI>
207 </UL>
208 </BODY></HTML>