X Bitmaps In

X Bitmaps In

TUGboat, Volume 12 (1991)' No. 2 The crucial line in this is the grep, which ta,kes all imal notation (see figure 1). Each pixel line starts the lines from example. log containing % diagramf with a new byte; the last byte in a line is normally and puts them in example. dia. padded with zero bits. And so we've achieved labelled diagrams in METAFONT. The diagramf package is free software, #define bildo-width 50 and is available from the Aston archive. #define bildoleight 30 static char bildo-bits[] = i 3 Acknowledgements 0x00, 0x60, Oxff , . The inspiration, and many of the original ideas, for . this article came from Alan Hoenig's talk on the . OxeO, 0x013; same subject at Cork. I'd also like to thank Jeremy Gibbons and Damian Cugley for comments, advice Figure 1: Example of the C bitmap format in X and allowing me to bounce ideas off them. Apart from being suited for inclusion in C o Alan Jeffrey programs where it can be processed by the Xlib Programming Research Group routines XCreat eImage or XCreat ePixmapFromBit - Oxford University mapData, this format can be read by the Xlib rou- 11 Keble Road tine XReadBitmapFile or written by XWriteBit- Oxford OX1 3QD mapFile. It is also supported by several programs, Alan.JeffreyQprg,ox.ac.uk including a graphic editor ( bitmap), conversion pro- @ 1990 Alan Jeffrey grams from/to ASCII character maps (atobm, bm- toa), and a screen dump utility (Bruce Schuchardt's xgrabsc). So it has become a true standard for the representation of bitmaps. Graphics X Bitmaps in Reinhard Foameier Abstract A new I4m style, bitmap.sty, allows the direct Figure 2: An example from the X Window System inclusion of bitmaps from the X Window System in bitmaps (xlogo64) documents. With a tiny modification, the macros can be used with plain 7!$X, too. 2 The bitmap. sty style Resumo A new style "bitmap" provides a macro to Nova ordonaro bitmap. sty por permesas rek- include and print such bitmaps in documents. tan enkludon de bit-matricoj el la fenestro-sistemo X The macro is called \Bitmap and has two arguments: en Dw-aj dokumentoj. Post eta modzfo, la mak- the name of the file containing the bitmap, and the rooj estas uzeblaj ankati por simpla m. pixel size desired. The latter is saved in \bmpsiz 1 Introduction and used to set the value of \baselineskip: The X Window System uses a special C language 1 \newcount\bmhpoz syntax to describe bitmaps, images made up from 2 \newcount\bmwid black and white pixels. The syntax consists of sev- 3 \newif \ifbmblack eral C definitions that specify the width and height 4 \newdimen\bmrlen of the bitmap and possibly the position of a "hot 5 \newdimen\bmpsiz spot", and the declaration of a character array for 6 \catcode' ,=\active the bitmap information, with initializers in hexadec- TUGboat, Volume 12 (1991)' No. 2 Figure 4: Another example (Abraracourcix, Gaul- ish tribe chief) Figure 3: Example of an included bitmap, taken from an Asterix cartoon The comma, separating the hex-numbers in the file, is made an active character; its function is to an- alyse the hexadecimal information and translate it into \vrules. It also throws away the leading Ox of the hex numbers: the second and third argu- ment (the hex figures) are swapped and each given to \HexFig for further analysis. Then. \bmhpoz is incremented by 8 columns and checked against the width of the bitmap; if the former exceeds the latter, the line is terminated and \brnhpoz is reset to 1. 12 \catcodel,=\active 13 \def,##iOx##2##3{% Figure 5: The bitmap logo of the Akademio Inter- 14 \HexFig{##3)\HexFig{##2)% nacia de la Sciencoj (AIS) San Marino 15 \advance\bmhpoz 8 16 \ifnum\brnhpoz>\bmwid 17 \O\hfil \vskip Opt Black pixels are printed as rectangular spots, pro- 18 \bmhpoz=l \bmrlen=Opt duced by \vrule. To save space in m's memory, 19 \fi) \O and \1 collect sequences of equal bits and put them together to longer \vrules. Invisible \vrules The \HexFig macro analyses a hexadecimal figure of height 0 are used for the white space rather than and translates it to four calls of the macros \O or \hskips because they, too, save a little memory \l, for white and black pixels, respectively. As the space. The length of the current sequence of 0 or hex figures A to F normally are not capitalized in 1 bits is kept in the dimension \bmrlen, the color bitmap files, \uppercase is used to convert them if of the current pixel is remembered in the value of necessary. \ifbmblack. 20 \def\HexFig##l{% 39 \def\O{\ifbmblack 21 \uppercase{\if case "##I) 40 \vrule width \bmrlen height \bmpsiz 22 \O\O\O\O\or 41 \bmrlen=\bmpsiz \bmblackfalse 23 \l\O\O\O\or 42 \else 24 \O\l\O\O\or 43 \advance \bmrlen\bmpsiz 25 \l\I\O\O\or 44 \fi) TUGboat, Volume 12 (1991), No. 2 (discarded) width (discarded) (discarded) Table 1: Arguments of \BmContent in the example of figure 1 45 \def \l(\ifbmblack 46 \advance \bmrlen\bmpsiz 47 \else 48 \vrule width \bmrlen height Opt 49 \bmrlen=\bmpsiz \bmblacktrue 50 \fi) Figure 6: Yet another example . The only pieces of information used from the bitmap file are the width of the bitmap and its picture 3 Possible extensions information; height and hot spot coordinates are To draw boxes around bitmaps, they can be put discarded. The contents of the file are read with into a \vbox. In its present form, the macro doesn't \@@input; a macro \BmContent gathers the width compute the necessary width of such a box, although as its second and the picture information as its fifth this information is available from the bitmap header. argument. The other arguments are ignored; their This functionality can be achieved by adding to only purpose is to get rid of the rest of the bitmap \BmContent, after the definition of \bmwid in line header. \BmContent is prefixed with \expandafter, 53, the statement to capture the result of \@@input in its arguments. \hsize \bmwid\bmpsiz Sometimes it is interesting to have statistics about 51 \def\BmContent the complexity of a bitmap. To this end, a \new- 52 ##I-width ##2 ##3[1 ##4 ##5;(% count\Complty may be introduced, initialized to 53 \bmwid=##2 zero and incremented by 54 \bmhpoz=l 55 ,##5 \advance\Complty I 56 1% end of \BmContent either in \I before the \ifbmblack at line 45 (to 57 \expandafter\BmContent\@@input #1 count black pixels) or in \O within the \ifbmblack 58 \egroup>% end of \Bitmap at line 39 (to count \vrules). The result may be issued by a \message statement. Finally, the comma's \catcode is reset to "other": 59 \catcode',=12 % other 4 Problems, conclusion Unfortunately, typesetting bitmaps is slow. A 60x85 In the example of figure 1, the arguments of \Bm- bitmap (like the one shown in figure 6) can easily Content would be like shown in table 1. Obvious- consume more of m'stime than an ordinary text ly, the 3rd and 4th argument could be combined page. Moreover, the many \vrules consume a lot into one; yet this way provides some more security of W'sspace, even with runlength encoding. Tests against erroneous use. show that drawing bitmaps with two printing char- The macros can be used with plain TEX, too, if acters (e. g., - and +) for \O and \I saves some time \@@input in the last line of \BmContent is replaced but needs even more space. For really big bitmaps, with \input. The L4-m macro \input doesn't Big may have to be used; it was, however, not work with the \expandafter technique. necessary for this article. Figure 2 shows the X logo bitmap, included in this document from the X bitmap file xlogo64. Fig- ures 3 to 7 show some more examples, which may serve to show the versatility of even small bitmaps. All bitmaps presented here are far under 100x100 pixels. TUGboat, Volume 12 (1991), No. 2 Output devices Report on the DVI Driver Standard Joachim Schrod Secretary TUG DVI Driver Standards Committee The DVI Driver Standard will be available in several stages. The basic stage is now called level 0. It covers only those driver capabilities which are Figure 7: . and another. really necessary to output a DVI document on an output device. All other driver capabilities will be called features (and may even be realized outside This problem could be alleviated by creating 16 a driver). In the future we will publish several special drawing characters for the bitmap patterns additional standard documents which will cover corresponding to the 16 hexadecimal figures. The ranges of features; those documents will represent complexity of a bitmap, however, will always be re- "tiers" built upon level 0 or on previous tiers. In flected in the cost of its typesetting. Remember that this way they will be available as future stages of a the aforementioned bitmap contains about as many complete standard. (One may doubt whether the pixels as there are characters on an average page. standard will ever be complete as there may be Serious problems may arise if the bitmap file always new features to standardize.) contains C language comments. They are discour- The basic stage, level 0, consists of three parts: aged when using bitmap.sty. The brtmap editor (1) The pure standard document telling what a discards them anyway, so they aren't normally used; driver must be able to do. however.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us