"Fossies" - the Fresh Open Source Software Archive

Member "SAOImageDS9/tk8.6/doc/GetBitmap.3" (13 Nov 2019, 10207 Bytes) of package /linux/misc/ds9.8.1.tar.gz:

As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 '\"
    2 '\" Copyright (c) 1990 The Regents of the University of California.
    3 '\" Copyright (c) 1994-1998 Sun Microsystems, Inc.
    4 '\"
    5 '\" See the file "license.terms" for information on usage and redistribution
    6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    7 '\" 
    8 .TH Tk_AllocBitmapFromObj 3 8.1 Tk "Tk Library Procedures"
    9 .so man.macros
   10 .BS
   11 .SH NAME
   12 Tk_AllocBitmapFromObj, Tk_GetBitmap, Tk_GetBitmapFromObj, Tk_DefineBitmap, Tk_NameOfBitmap, Tk_SizeOfBitmap, Tk_FreeBitmapFromObj, Tk_FreeBitmap \- maintain database of single-plane pixmaps
   14 .nf
   15 \fB#include <tk.h>\fR
   16 .sp
   17 Pixmap
   18 \fBTk_AllocBitmapFromObj(\fIinterp, tkwin, objPtr\fB)\fR
   19 .sp
   20 Pixmap
   21 \fBTk_GetBitmap(\fIinterp, tkwin, info\fB)\fR
   22 .sp
   23 Pixmap
   24 \fBTk_GetBitmapFromObj(\fItkwin, objPtr\fB)\fR
   25 .sp
   26 int
   27 \fBTk_DefineBitmap(\fIinterp, name, source, width, height\fB)\fR
   28 .sp
   29 const char *
   30 \fBTk_NameOfBitmap(\fIdisplay, bitmap\fB)\fR
   31 .sp
   32 \fBTk_SizeOfBitmap(\fIdisplay, bitmap, widthPtr, heightPtr\fB)\fR
   33 .sp
   34 \fBTk_FreeBitmapFromObj(\fItkwin, objPtr\fB)\fR
   35 .sp
   36 \fBTk_FreeBitmap(\fIdisplay, bitmap\fB)\fR
   38 .AS "unsigned long" *pixelPtr
   39 .AP Tcl_Interp *interp in
   40 Interpreter to use for error reporting; if NULL then no error message
   41 is left after errors.
   42 .AP Tk_Window tkwin in
   43 Token for window in which the bitmap will be used.
   44 .AP Tcl_Obj *objPtr in/out
   45 String value describes desired bitmap; internal rep will be
   46 modified to cache pointer to corresponding Pixmap.
   47 .AP "const char" *info in
   48 Same as \fIobjPtr\fR except description of bitmap is passed as a string and
   49 resulting Pixmap is not cached.
   50 .AP "const char" *name in
   51 Name for new bitmap to be defined.
   52 .AP "const void" *source in
   53 Data for bitmap, in standard bitmap format.
   54 Must be stored in static memory whose value will never change.
   55 .AP "int" width in
   56 Width of bitmap.
   57 .AP "int" height in
   58 Height of bitmap.
   59 .AP "int" *widthPtr out
   60 Pointer to word to fill in with \fIbitmap\fR's width.
   61 .AP "int" *heightPtr out
   62 Pointer to word to fill in with \fIbitmap\fR's height.
   63 .AP Display *display in
   64 Display for which \fIbitmap\fR was allocated.
   65 .AP Pixmap bitmap in
   66 Identifier for a bitmap allocated by \fBTk_AllocBitmapFromObj\fR or
   67 \fBTk_GetBitmap\fR.
   68 .BE
   70 .PP
   71 These procedures manage a collection of bitmaps (one-plane pixmaps)
   72 being used by an application.  The procedures allow bitmaps to be
   73 re-used efficiently, thereby avoiding server overhead, and also
   74 allow bitmaps to be named with character strings.
   75 .PP
   76 \fBTk_AllocBitmapFromObj\fR returns a Pixmap identifier for a bitmap
   77 that matches the description in \fIobjPtr\fR and is suitable for use
   78 in \fItkwin\fR.  It re-uses an existing bitmap, if possible, and
   79 creates a new one otherwise.  \fIObjPtr\fR's value must have one
   80 of the following forms:
   81 .TP 20
   82 \fB@\fIfileName\fR
   83 \fIFileName\fR must be the name of a file containing a bitmap
   84 description in the standard X11 format.
   85 .TP 20
   86 \fIname\fR
   87 \fIName\fR must be the name of a bitmap defined previously with
   88 a call to \fBTk_DefineBitmap\fR.  The following names are pre-defined
   89 by Tk:
   90 .RS
   91 .TP 12
   92 \fBerror\fR
   93 The international
   94 .QW don't
   95 symbol:  a circle with a diagonal line across it.
   96 .TP 12
   97 \fBgray75\fR
   98 75% gray: a checkerboard pattern where three out of four bits are on.
   99 .TP 12
  100 \fBgray50\fR
  101 50% gray: a checkerboard pattern where every other bit is on.
  102 .TP 12
  103 \fBgray25\fR
  104 25% gray: a checkerboard pattern where one out of every four bits is on.
  105 .TP 12
  106 \fBgray12\fR
  107 12.5% gray: a pattern where one-eighth of the bits are on, consisting of
  108 every fourth pixel in every other row.
  109 .TP 12
  110 \fBhourglass\fR
  111 An hourglass symbol.
  112 .TP 12
  113 \fBinfo\fR
  114 A large letter
  115 .QW i .
  116 .TP 12
  117 \fBquesthead\fR
  118 The silhouette of a human head, with a question mark in it.
  119 .TP 12
  120 \fBquestion\fR
  121 A large question-mark.
  122 .TP 12
  123 \fBwarning\fR
  124 A large exclamation point.
  125 .PP
  126 In addition, the following pre-defined names are available only on the
  127 \fBMacintosh\fR platform:
  128 .TP 12
  129 \fBdocument\fR
  130 A generic document.
  131 .TP 12
  132 \fBstationery\fR
  133 Document stationery.
  134 .TP 12
  135 \fBedition\fR
  136 The \fIedition\fR symbol.
  137 .TP 12
  138 \fBapplication\fR
  139 Generic application icon.
  140 .TP 12
  141 \fBaccessory\fR
  142 A desk accessory.
  143 .TP 12
  144 \fBfolder\fR
  145 Generic folder icon.
  146 .TP 12
  147 \fBpfolder\fR
  148 A locked folder.
  149 .TP 12
  150 \fBtrash\fR
  151 A trash can.
  152 .TP 12
  153 \fBfloppy\fR
  154 A floppy disk.
  155 .TP 12
  156 \fBramdisk\fR
  157 A floppy disk with chip.
  158 .TP 12
  159 \fBcdrom\fR
  160 A cd disk icon.
  161 .TP 12
  162 \fBpreferences\fR
  163 A folder with prefs symbol.
  164 .TP 12
  165 \fBquerydoc\fR
  166 A database document icon.
  167 .TP 12
  168 \fBstop\fR
  169 A stop sign.
  170 .TP 12
  171 \fBnote\fR
  172 A face with balloon words.
  173 .TP 12
  174 \fBcaution\fR
  175 A triangle with an exclamation point.
  176 .RE
  177 .LP
  178 Under normal conditions, \fBTk_AllocBitmapFromObj\fR
  179 returns an identifier for the requested bitmap.  If an error
  180 occurs in creating the bitmap, such as when \fIobjPtr\fR refers
  181 to a non-existent file, then \fBNone\fR is returned and an error
  182 message is left in \fIinterp\fR's result if \fIinterp\fR is not
  183 NULL. \fBTk_AllocBitmapFromObj\fR caches information about the return
  184 value in \fIobjPtr\fR, which speeds up future calls to procedures
  185 such as \fBTk_AllocBitmapFromObj\fR and \fBTk_GetBitmapFromObj\fR.
  186 .PP
  187 \fBTk_GetBitmap\fR is identical to \fBTk_AllocBitmapFromObj\fR except
  188 that the description of the bitmap is specified with a string instead
  189 of an object.  This prevents \fBTk_GetBitmap\fR from caching the
  190 return value, so \fBTk_GetBitmap\fR is less efficient than
  191 \fBTk_AllocBitmapFromObj\fR.
  192 .PP
  193 \fBTk_GetBitmapFromObj\fR returns the token for an existing bitmap, given
  194 the window and description used to create the bitmap.
  195 \fBTk_GetBitmapFromObj\fR does not actually create the bitmap; the bitmap
  196 must already have been created with a previous call to
  197 \fBTk_AllocBitmapFromObj\fR or \fBTk_GetBitmap\fR.  The return
  198 value is cached in \fIobjPtr\fR, which speeds up
  199 future calls to \fBTk_GetBitmapFromObj\fR with the same \fIobjPtr\fR
  200 and \fItkwin\fR.
  201 .PP
  202 \fBTk_DefineBitmap\fR associates a name with
  203 in-memory bitmap data so that the name can be used in later
  204 calls to \fBTk_AllocBitmapFromObj\fR or \fBTk_GetBitmap\fR.  The \fInameId\fR
  205 argument gives a name for the bitmap;  it must not previously
  206 have been used in a call to \fBTk_DefineBitmap\fR.
  207 The arguments \fIsource\fR, \fIwidth\fR, and \fIheight\fR
  208 describe the bitmap.
  209 \fBTk_DefineBitmap\fR normally returns \fBTCL_OK\fR; if an error occurs
  210 (e.g. a bitmap named \fInameId\fR has already been defined) then
  211 \fBTCL_ERROR\fR is returned and an error message is left in
  212 interpreter \fIinterp\fR's result.
  213 Note:  \fBTk_DefineBitmap\fR expects the memory pointed to by
  214 \fIsource\fR to be static:  \fBTk_DefineBitmap\fR does not make
  215 a private copy of this memory, but uses the bytes pointed to
  216 by \fIsource\fR later in calls to \fBTk_AllocBitmapFromObj\fR or
  217 \fBTk_GetBitmap\fR.
  218 .PP
  219 Typically \fBTk_DefineBitmap\fR is used by \fB#include\fR-ing a
  220 bitmap file directly into a C program and then referencing
  221 the variables defined by the file.
  222 For example, suppose there exists a file \fBstip.bitmap\fR,
  223 which was created by the \fBbitmap\fR program and contains
  224 a stipple pattern.
  225 The following code uses \fBTk_DefineBitmap\fR to define a
  226 new bitmap named \fBfoo\fR:
  227 .CS
  228 Pixmap bitmap;
  229 #include "stip.bitmap"
  230 Tk_DefineBitmap(interp, "foo", stip_bits,
  231     stip_width, stip_height);
  232 \&...
  233 bitmap = Tk_GetBitmap(interp, tkwin, "foo");
  234 .CE
  235 This code causes the bitmap file to be read
  236 at compile-time and incorporates the bitmap information into
  237 the program's executable image.  The same bitmap file could be
  238 read at run-time using \fBTk_GetBitmap\fR:
  239 .CS
  240 Pixmap bitmap;
  241 bitmap = Tk_GetBitmap(interp, tkwin, "@stip.bitmap");
  242 .CE
  243 The second form is a bit more flexible (the file could be modified
  244 after the program has been compiled, or a different string could be
  245 provided to read a different file), but it is a little slower and
  246 requires the bitmap file to exist separately from the program.
  247 .PP
  248 Tk maintains a database of all the bitmaps that are currently in use.
  249 Whenever possible, it will return an existing bitmap rather
  250 than creating a new one.
  251 When a bitmap is no longer used, Tk will release it automatically.
  252 This approach can substantially reduce server overhead, so
  253 \fBTk_AllocBitmapFromObj\fR and \fBTk_GetBitmap\fR should generally
  254 be used in preference to Xlib procedures like \fBXReadBitmapFile\fR.
  255 .PP
  256 The bitmaps returned by \fBTk_AllocBitmapFromObj\fR and \fBTk_GetBitmap\fR
  257 are shared, so callers should never modify them.
  258 If a bitmap must be modified dynamically, then it should be
  259 created by calling Xlib procedures such as \fBXReadBitmapFile\fR
  260 or \fBXCreatePixmap\fR directly.
  261 .PP
  262 The procedure \fBTk_NameOfBitmap\fR is roughly the inverse of
  263 \fBTk_GetBitmap\fR.
  264 Given an X Pixmap argument, it returns the textual description that was
  265 passed to \fBTk_GetBitmap\fR when the bitmap was created.
  266 \fIBitmap\fR must have been the return value from a previous
  267 call to \fBTk_AllocBitmapFromObj\fR or \fBTk_GetBitmap\fR.
  268 .PP
  269 \fBTk_SizeOfBitmap\fR returns the dimensions of its \fIbitmap\fR
  270 argument in the words pointed to by the \fIwidthPtr\fR and
  271 \fIheightPtr\fR arguments.  As with \fBTk_NameOfBitmap\fR,
  272 \fIbitmap\fR must have been created by \fBTk_AllocBitmapFromObj\fR or
  273 \fBTk_GetBitmap\fR.
  274 .PP
  275 When a bitmap is no longer needed, \fBTk_FreeBitmapFromObj\fR or
  276 \fBTk_FreeBitmap\fR should be called to release it.
  277 For \fBTk_FreeBitmapFromObj\fR the bitmap to release is specified
  278 with the same information used to create it; for
  279 \fBTk_FreeBitmap\fR the bitmap to release is specified
  280 with its Pixmap token.
  281 There should be exactly one call to \fBTk_FreeBitmapFromObj\fR
  282 or \fBTk_FreeBitmap\fR for each call to \fBTk_AllocBitmapFromObj\fR or
  283 \fBTk_GetBitmap\fR.
  284 .SH BUGS
  285 .PP
  286 In determining whether an existing bitmap can be used to satisfy
  287 a new request, \fBTk_AllocBitmapFromObj\fR and \fBTk_GetBitmap\fR
  288 consider only the immediate value of the string description.  For
  289 example, when a file name is passed to \fBTk_GetBitmap\fR,
  290 \fBTk_GetBitmap\fR will assume it is safe to re-use an existing
  291 bitmap created from the same file name:  it will not check to
  292 see whether the file itself has changed, or whether the current
  293 directory has changed, thereby causing the name to refer to
  294 a different file.
  296 bitmap, pixmap