ch69 (3)


Slackware Linux Unleashed 3rd. Edition - 69 - Graphics Tools in Linux The pbm Toolkit Listing 69.1. The files from the pbmplus toolkit. xv FIGURE 69.1. FIGURE 69.2. FIGURE 69.3. FIGURE 69.4. Geomview FIGURE 69.5. FIGURE 69.6. TIP FIGURE 69.7. The Mesa/OpenGL Toolkit Listing 69.2. The makefile for sample programs. TIP Listing 69.3. A simple test program. Summary - 69 - Graphics Tools in Linux by Kamran Husain IN THIS CHAPTER The pbm Toolkit xv Geomview The Mesa/OpenGL Toolkit This chapter will introduce you to the following graphics tools and libraries available under Linux: The Portable Bitmap Toolkit The xv toolkit Geomview for 3D geometric viewing The Mesa/OpenGL toolkit for programming in OpenGL The pbm Toolkit The Portable Bitmap Toolkit (pbm toolkit), developed in 1991, is a very powerful toolkit for converting graphics images from one format to another. The toolkit consists of a set of programs that convert data images in a graphics format to or from a PBM format. The pbm toolkit has no graphical user interface, and all the commands operate on images via the command-line interface. The toolkit programs all work by utilizing the standard input and output features of programs. Each program in the toolkit reads image data from its standard input and writes back to standard output. The pbm toolkit is available from Linux FTP sites in both binary and source forms. At the ftp://sunsite.unc.edu site, the files can be found in the pub/Linux/apps/graphics/convert subdirectory. The file used for this chapter was the binary archive for Linux: pbmplus-10dec91-bin.tar. Untar the files in a directory, and you then see a README file and man and bin directories under the pbmplus10dec91 directory. Point your PATH to the bin directory. If you cannot get the binary files to work in your installation, you can download the source code in the file pbmplus-10dec91_tar.Z. Uncompress and untar the file to a subdirectory, and follow the instructions in the README file to build the pbmplus executables. The man directory contains a well-documented set of man pages for the utilities in the toolkit. You can view the contents with the command nroff -man filename where filename is the name of the man file you want to look at. The complete list of binary files extracted from this tar archive is shown in Listing 69.1. Listing 69.1. The files from the pbmplus toolkit. $ ls pbmplus10dec91/bin -rwxr-xr-x 1 root root 3568 Oct 21 1996 atktopbm -rwxr-xr-x 1 root root 2112 Oct 21 1996 brushtopbm -rwxr-xr-x 1 root root 2136 Oct 21 1996 cmuwmtopbm -rwxr-xr-x 1 root root 3864 Oct 21 1996 fitstopgm -rwxr-xr-x 1 root root 2628 Oct 21 1996 fstopgm -rwxr-xr-x 1 root root 6532 Oct 21 1996 g3topbm -rwxr-xr-x 1 root root 2844 Oct 21 1996 gemtopbm -rwxr-xr-x 1 root root 6184 Oct 21 1996 giftoppm -rwxr-xr-x 1 root root 2320 Oct 21 1996 gouldtoppm -rwxr-xr-x 1 root root 2320 Oct 21 1996 hipstopgm -rwxr-xr-x 1 root root 2504 Oct 21 1996 icontopbm -rwxr-xr-x 1 root root 6108 Oct 21 1996 ilbmtoppm -rwxr-xr-x 1 root root 2804 Oct 21 1996 imgtoppm -rwxr-xr-x 1 root root 2540 Oct 21 1996 lispmtopgm -rwxr-xr-x 1 root root 2248 Oct 21 1996 macptopbm -rwxr-xr-x 1 root root 2144 Oct 21 1996 mgrtopbm -rwxr-xr-x 1 root root 1884 Oct 21 1996 mtvtoppm -rwxr-xr-x 1 root root 1844 Oct 21 1996 pbmlife -rwxr-xr-x 1 root root 1836 Oct 21 1996 pbmmake -rwxr-xr-x 1 root root 3104 Oct 21 1996 pbmmask -rwxr-xr-x 1 root root 2996 Oct 21 1996 pbmreduce -rwxr-xr-x 1 root root 3116 Oct 21 1996 pbmtext -rwxr-xr-x 1 root root 2768 Oct 21 1996 pbmto10x -rwxr-xr-x 1 root root 1796 Oct 21 1996 pbmtoascii -rwxr-xr-x 1 root root 2424 Oct 21 1996 pbmtoatk -rwxr-xr-x 1 root root 1964 Oct 21 1996 pbmtobbnbg -rwxr-xr-x 1 root root 1988 Oct 21 1996 pbmtocmuwm -rwxr-xr-x 1 root root 1956 Oct 21 1996 pbmtoepson -rwxr-xr-x 1 root root 5552 Oct 21 1996 pbmtog3 -rwxr-xr-x 1 root root 2124 Oct 21 1996 pbmtogem -rwxr-xr-x 1 root root 2988 Oct 21 1996 pbmtogo -rwxr-xr-x 1 root root 2548 Oct 21 1996 pbmtoicon -rwxr-xr-x 1 root root 2164 Oct 21 1996 pbmtolj -rwxr-xr-x 1 root root 3020 Oct 21 1996 pbmtomacp -rwxr-xr-x 1 root root 1916 Oct 21 1996 pbmtomgr -rwxr-xr-x 1 root root 1884 Oct 21 1996 pbmtopi3 -rwxr-xr-x 1 root root 1876 Oct 21 1996 pbmtoplot -rwxr-xr-x 1 root root 1876 Oct 21 1996 pbmtoptx -rwxr-xr-x 1 root root 3596 Oct 21 1996 pbmtox10bm -rwxr-xr-x 1 root root 3180 Oct 21 1996 pbmtoxbm -rwxr-xr-x 1 root root 1836 Oct 21 1996 pbmtoybm -rwxr-xr-x 1 root root 3556 Oct 21 1996 pbmtozinc -rwxr-xr-x 1 root root 7288 Oct 21 1996 pbmupc -rwxr-xr-x 1 root root 3532 Oct 21 1996 pcxtoppm -rwxr-xr-x 1 root root 1572 Oct 21 1996 pgmbentley -rwxr-xr-x 1 root root 5644 Oct 21 1996 pgmcrater -rwxr-xr-x 1 root root 2140 Oct 21 1996 pgmedge -rwxr-xr-x 1 root root 2164 Oct 21 1996 pgmenhance -rwxr-xr-x 1 root root 1916 Oct 21 1996 pgmhist -rwxr-xr-x 1 root root 3556 Oct 21 1996 pgmnorm -rwxr-xr-x 1 root root 1868 Oct 21 1996 pgmoil -rwxr-xr-x 1 root root 2372 Oct 21 1996 pgmramp -rwxr-xr-x 1 root root 12404 Oct 21 1996 pgmtexture -rwxr-xr-x 1 root root 2992 Oct 21 1996 pgmtofits -rwxr-xr-x 1 root root 2468 Oct 21 1996 pgmtofs -rwxr-xr-x 1 root root 2204 Oct 21 1996 pgmtolispm -rwxr-xr-x 1 root root 6972 Oct 21 1996 pgmtopbm -rwxr-xr-x 1 root root 2412 Oct 21 1996 pgmtoppm -rwxr-xr-x 1 root root 1844 Oct 21 1996 pi1toppm -rwxr-xr-x 1 root root 1844 Oct 21 1996 pi3topbm -rwxr-xr-x 1 root root 16752 Oct 21 1996 picttoppm -rwxr-xr-x 1 root root 4556 Oct 21 1996 pjtoppm -rwxr-xr-x 1 root root 4316 Oct 21 1996 pnmarith -rwxr-xr-x 1 root root 4684 Oct 21 1996 pnmcat -rwxr-xr-x 1 root root 5524 Oct 21 1996 pnmconvol -rwxr-xr-x 1 root root 2556 Oct 21 1996 pnmcrop -rwxr-xr-x 1 root root 2268 Oct 21 1996 pnmcut -rwxr-xr-x 1 root root 2188 Oct 21 1996 pnmdepth -rwxr-xr-x 1 root root 1804 Oct 21 1996 pnmenlarge -rwxr-xr-x 1 root root 1892 Oct 21 1996 pnmfile -rwxr-xr-x 1 root root 3772 Oct 21 1996 pnmflip -rwxr-xr-x 1 root root 2712 Oct 21 1996 pnmgamma -rwxr-xr-x 1 root root 1604 Oct 21 1996 pnminvert -rwxr-xr-x 1 root root 1556 Oct 21 1996 pnmnoraw -rwxr-xr-x 1 root root 3308 Oct 21 1996 pnmpaste -rwxr-xr-x 1 root root 5916 Oct 21 1996 pnmrotate -rwxr-xr-x 1 root root 6508 Oct 21 1996 pnmscale -rwxr-xr-x 1 root root 3228 Oct 21 1996 pnmshear -rwxr-xr-x 1 root root 1804 Oct 21 1996 pnmtile -rwxr-xr-x 1 root root 8072 Oct 21 1996 pnmtops -rwxr-xr-x 1 root root 4224 Oct 21 1996 pnmtorast -rwxr-xr-x 1 root root 4836 Oct 21 1996 pnmtoxwd -rwxr-xr-x 1 root root 3404 Oct 21 1996 ppmdither -rwxr-xr-x 1 root root 13204 Oct 21 1996 ppmforge -rwxr-xr-x 1 root root 1836 Oct 21 1996 ppmhist -rwxr-xr-x 1 root root 1652 Oct 21 1996 ppmmake -rwxr-xr-x 1 root root 12620 Oct 21 1996 ppmpat -rwxr-xr-x 1 root root 6876 Oct 21 1996 ppmquant -rwxr-xr-x 1 root root 1972 Oct 21 1996 ppmrelief -rwxr-xr-x 1 root root 5956 Oct 21 1996 ppmtoacad -rwxr-xr-x 1 root root 4852 Oct 21 1996 ppmtogif -rwxr-xr-x 1 root root 4412 Oct 21 1996 ppmtoicr -rwxr-xr-x 1 root root 4136 Oct 21 1996 ppmtoilbm -rwxr-xr-x 1 root root 4116 Oct 21 1996 ppmtopcx -rwxr-xr-x 1 root root 4740 Oct 21 1996 ppmtopgm -rwxr-xr-x 1 root root 2444 Oct 21 1996 ppmtopi1 -rwxr-xr-x 1 root root 3680 Oct 21 1996 ppmtopict -rwxr-xr-x 1 root root 3652 Oct 21 1996 ppmtopj -rwxr-xr-x 1 root root 2228 Oct 21 1996 ppmtopuzz -rwxr-xr-x 1 root root 1956 Oct 21 1996 ppmtorgb3 -rwxr-xr-x 1 root root 2964 Oct 21 1996 ppmtosixel -rwxr-xr-x 1 root root 6312 Oct 21 1996 ppmtotga -rwxr-xr-x 1 root root 3644 Oct 21 1996 ppmtouil -rwxr-xr-x 1 root root 3160 Oct 21 1996 ppmtoxpm -rwxr-xr-x 1 root root 2148 Oct 21 1996 ppmtoyuv -rwxr-xr-x 1 root root 2276 Oct 21 1996 psidtopgm -rwxr-xr-x 1 root root 2004 Oct 21 1996 qrttoppm -rwxr-xr-x 1 root root 3484 Oct 21 1996 rasttopnm -rwxr-xr-x 1 root root 2244 Oct 21 1996 rawtopgm -rwxr-xr-x 1 root root 3764 Oct 21 1996 rawtoppm -rwxr-xr-x 1 root root 2132 Oct 21 1996 rgb3toppm -rwxr-xr-x 1 root root 7836 Oct 21 1996 sldtoppm -rwxr-xr-x 1 root root 2636 Oct 21 1996 spctoppm -rwxr-xr-x 1 root root 2052 Oct 21 1996 sputoppm -rwxr-xr-x 1 root root 4776 Oct 21 1996 tgatoppm -rwxr-xr-x 1 root root 3492 Oct 21 1996 xbmtopbm -rwxr-xr-x 1 root root 4588 Oct 21 1996 ximtoppm -rwxr-xr-x 1 root root 4084 Oct 21 1996 xpmtoppm -rwxr-xr-x 1 root root 6684 Oct 21 1996 xwdtopnm -rwxr-xr-x 1 root root 2120 Oct 21 1996 ybmtopbm -rwxr-xr-x 1 root root 2220 Oct 21 1996 yuvtoppm Four types of base formats are supported in the pbm toolkit: PBM for 1 bits per pixel PGM for grayscale images PPM for full-color images PNM for device-independent images You usually convert from a format to either PPM or PNM. Programs that work with PPM files can write only PPM files. Programs that process PNM files can write PBM, PPM, or PGM files. This powerful toolkit is surprisingly easy to use. Let's say you want to convert a GIF image into a PCX image. This is the command you would use on the file myfile.gif to get myfile.pcx: $ giftoppm < myfile.gif | ppmtopcx > myfile.pcx The pnm* functions let you manipulate the contents of images. You can rotate or scale an image with these functions. For example, to scale the original GIF image down by a factor of two, you would use the following command: $ giftoppm < myfile.gif | pnmscale 3 | ppmtopcx > myfile.pcx Particularly interesting is the pbmtext program, which converts text files into PPM files. You can therefore take text lines and convert them into images for use in World Wide Web server applications for generating non-editable messages using a fixed font. This would be a typical usage of pbmtext: $ pbmtext < /etc/motd | pnmscale 4 | ppmtogif > motd.gif The scale factor would have to be adjusted to fit the particular GIF image size you want. To get rotated text at a 45-degree angle (0 degrees is a horizontal line going from left to right), try the following command: $ pbmtext < /etc/motd | pnmrotate 45 | ppmtogif > motd.gif The angle parameter should be between -90 and 90 degrees. For angles greater than that, try flipping the image with pnmflip to get that extra 180-degree rotation. The best use for the pbm toolkit is from within shell scripts where you do not want to have any user interaction, especially if you are doing only basic scalar operations on images or converting data from one graphical format to another. Of course, the major thing lacking with the pbm toolkit is the capability to graphically show the data. Let's see how to display the data we create with the pbm toolkit by using the xv toolkit. xv The xv program in Linux is written by John Bradley. The version number of the program on the CD-ROM is 3.10 and is dated 12/16/94. To see an image, issue the following command: $ xv filename & It's a good idea to run xv in the background to free up the terminal on which you are working. For example, to see the motd.gif image we just created with the pbm toolkit, we would issue this command: $ xv motd.gif & You can bring up the main menu for the screen by clicking the right mouse button anywhere on the display window. You are presented with the menu shown in Figure 69.1.

Wyszukiwarka

Podobne podstrony:
ch69 (2)
ch69

więcej podobnych podstron