netpbm-free-10.0-1/0040755004714500471450000000000007776237775014355 5ustar aba-guestaba-guestnetpbm-free-10.0-1/amiga/0040755004714500471450000000000007776237751015425 5ustar aba-guestaba-guestnetpbm-free-10.0-1/amiga/DICE.PATCH0100644004714500471450000000215307716230207016667 0ustar aba-guestaba-guest*** ppm/ppmforge.c.old Mon Oct 04 10:12:28 1993 --- ppm/ppmforge.c Thu Feb 10 01:06:08 1994 *************** *** 662,670 **** --- 662,676 ---- AtSat(ib, 255); inx = PlanetAmbient + (1.0 - PlanetAmbient) * di; + #ifndef _DCC ir *= inx; ig *= inx; ib *= inx; + #else + ir = ir * inx; + ig = ig * inx; + ib = ib * inx; + #endif /* _DCC */ } PPM_ASSIGN(*rpix, ir, ig, ib); *** ppm/picttoppm.c.old Fri Jan 28 10:19:18 1994 --- ppm/picttoppm.c Thu Feb 10 00:59:44 1994 *************** *** 3008,3017 **** --- 3008,3024 ---- double xscale; double yscale; { + #ifndef _DCC r->left *= xscale; r->right *= xscale; r->top *= yscale; r->bottom *= yscale; + #else + r->left = r->left * xscale; + r->right = r->right * xscale; + r->top = r->top * yscale; + r->bottom = r->bottom * yscale; + #endif /* _DCC */ } static void netpbm-free-10.0-1/amiga/NETPBM.INTRO0100644004714500471450000002530007716230207017203 0ustar aba-guestaba-guest NETPBM Image conversion and processing package Amiga information Binaries -------- Binaries are available at ftp.informatik.uni-oldenburg.de [134.106.1.9] in /pub/netpbm/amiga, or on all Aminet sites in /pub/aminet/gfx/pbm. The full distribution consists of these archives: texts.lha REQ textfiles, miscellaneous stuff manuals.lha REQ formatted Unix manuals mergedbin.lha REQ* merged binaries pbmbin.lha REQ* PBM binaries, for B&W images pgmbin.lha REQ* PGM binaries, for greyscale images ppmbin1.lha REQ* PPM binaries #1, for color images ppmbin2.lha REQ* PPM binaries #2, for color images pnmbin.lha REQ* PNM binaries, tools and special converters scripts.lha OPT Unix shell scripts source1.lha DEV source: tools and main libraries source2.lha DEV source: TIFF library, Unix nroff manuals, VMS stuff dicelibs.lha DEV compiled link libraries, for DICE REQ = required, OPT = optional, DEV = only useful for programmers *: You need either all the p?mbin archives, or just the mergedbin archive. See the section "Merged binaries vs Separate binaries" for an explanation. What is NETPBM? --------------- NETPBM is a revised version of the PBMplus package, containing corrections and enhancements to the 10dec91 version of PBMplus. It is not "official" in the sense of being released by the original author, but the idea of a net supported version has been approved by him. NETPBM is a collection of tools which do the following: 1. Import - read images in popular formats and convert to one of the internal PBM formats. 2. Image processing - manipulate the image data to produce many effects including scaling, contrast and gamma adjustment, edge detection, etc. 3. Export - write images in popular formats for use with other software. NETPBM uses three intermediate formats: PBM = `portable bitmap' (black&white) PGM = `portable gray map' (greyscale, usually 8bit) PPM = `portable pix map' (color, usually 24bit) The formats are upward compatible, PGM programs can read both PBM and PGM and write PGM, PPM programs can read all three and write PPM. There are also PNM programs (PNM = `portable anymap'), these work on all three formats. The difference between PPM and PNM programs is that PPM programs always write PPM, but PNM programs can write any of the three formats (usually they write the same format as they got as input). There is no PNM format! The great advantage of using intermediate formats is that for a conversion between N formats only 2*N converters are needed instead of N^2; and if yet another graphic format appears, all that is needed are the newtop?m and p?mtonew filters, and you are immediately able to convert the new format to and from any other old format. The disadvantage is that two commands are needed to convert an image: giftoppm mypic.gif >mypic.ppm ppmtoilbm -hamif mypic.ppm >mypic.iff or on Unix-like shells: giftoppm mypic.gif | ppmtoilbm > mypic.iff Another disadvantage is that the intermediate formats are very simple and therefore the files get quite big, for example a 1024x768 PPM picture needs 1024*768*3 bytes = 2.25MB. NETPBM also includes a lot of tools that manipulate the intermediate formats in some way: scaling, rotating, reducing the number of colors and more. For example, to convert a GIF of any size to a 320*200 IFF-ILBM you could do this: giftoppm mypic.gif >mypic.ppm pnmscale -xysize 320 200 mypic.ppm >mypic.ppm2 ppmtoilbm -hamif mypic.ppm2 >mypic.iff or giftoppm mypic.gif | pnmscale -xysize 320 200 | ppmtoilbm -hamif >mypic.iff If you are not using an Unix-like shell, you can use the PIPE: handler to avoid using temporary files: run giftoppm mypic.gif >pipe:1 run pnmscale -xysize 320 200 pipe:2 run ppmqvga pipe:3 ppmtoilbm -aga mypic.iff Requirements ------------ * OS 2.04 or higher, or 1.3 with disk-based mathieeesingbas/mathieeesingtrans libraries (available from C=). * mathtrans, mathieeedoubbas and mathieeedoubtrans libraries in LIBS: A hard disk, a fast CPU, and lots of memory are recommended. It will work on 68000's if you have sufficient memory; on machines with 020+MMU, non-EC 030, or non-EC 040, a virtual memory program like GigaMem will be useful if you are processing large images. A full binary installation takes 1MB of HD space for merged binaries, 3MB for separate binaries (see below for an explanation). Source (not including libtiff source, unix nroff manuals and the vms subdir) takes another 3MB. There is no special 68020/881 binary distribution. The FPU is already used by the math libraries, and most programs are I/O-bound instead of CPU-bound. Merged binaries vs Separate binaries ------------------------------------ Netpbm consists of more than 130 programs, each being stand-alone and not depending on the other programs. This means a lot of disk space is wasted, since all programs use the same routines for reading, writing, allocation etc., and the code for these routines has to be in every single program. To avoid this, the programs can be merged into a single huge executable (actually four of them) and the individual programs are just hardlinks to this binary. Both methods have advantages and disadvantages: Separate binaries: + executables can be individually tuned for maximum performance (register args and small data model are used whenever possible). + most executables are "pure" and can be made resident - full installation takes MUCH more disk space (3MB) Merged binaries: + only 4 executables and a bunch of links. Requires only 1MB of disk space for a full installation. - executables are slower, since all have to be compiled with stack-args and large data model - executables are huge and require more RAM to execute. This will be fixed in the future by using overlays. Why no shared library? Its just too much work. If you think your life depends on having a pbm.library, go ahead and create it... or pay me for a month or two of full-time work, and I'm doing it :-) Installation ------------ Separate binaries: You need the following archives: pbmbin, pgmbin, ppmbin1, ppmbin2, pnmbin. Extract the programs that you need from the archives and copy them to a directory in your search path. Merged binaries: You only need the mergedbin archive. Extract the four p?mmerge programs and copy them to a directory in your search path. Then CD to this directoy and execute the "link_merged" script. This generates all the hardlinks. Links are not supported by 1.3, so if you are still running it, you have no choice but to use the separate binaries. Some 2.x and 3.x filesystems have bugs with links that trashes the disk if the original file is deleted and a link still exists. A safe way is to use the merged binaries on these systems is to install them in their own directory, and if you decide one day to de- install them do it in this way: delete ~(#?merge) delete #? X11 color names file: Some programs (for example pgmtoppm and ppmmake) can use a color names file, so you can specify colors by names instead of RGB values. An example color names file is included in the texts archives, as "RGB.txt". Just copy the file to a convenient place (S: is a good choice) and set the environment variable "RGBDEF" to the full path and name of this file: setenv RGBDEF "s:RGB.txt" Unix shell scripts: I didn't bother to convert the scripts to AmigaDOS-scripts (it's almost impossible anyway). If you want to run them, use a Bourne-shell or Csh clone. Stack size: Don't worry about it. The programs automatically allocate a larger stack if they need more. Memory usage ------------ You can control the way how the programs allocate their memory with the environment variable "PBMMEM". The following keywords are used: fast The programs will not try to allocate chipmem if they run out of fastmem. If this keyword is not used, then the programs will allocate both fast- and chipmem (fastmem first). pool pool= With this keyword, the programs use memory pools. This is faster and avoids run-time memory fragmentation, but unfortunately crashes if used with GigaMem. Note that OS 3.x is *NOT* required, it works under 2.x (tested on 2.1) and probably even under 1.3 (not tested). The optional number selects the size of the pools, the default being 32K. If this keyword is not used, all allocations are done with normal AllocMem() calls. This should work on all systems and with virtual memory programs like GigaMem. max= The maximum memory a program allocates. This does not include the memory used for the code, data and stack segments. The default value (if this keyword is not used) is "unlimited" (2GB, to be precise). Multiple keywords are delimited by whitespace or commas. Numbers can be in decimal, hex (prefix "0x") or octal (prefix "0") and can be given in bytes, Kbytes (suffix "k") or megabytes (suffix "m"). Example: setenv PBMMEM "pool=64k,fast,max=2M" Selects allocation via memory pools, fast memory only, and sets the poolsize to 64KB and the maximum memory usage to 2MB. Misc info --------- NETPBM does not include converters for JPEG, but the freely distributable programs "djpeg" and "cjpeg" can convert JPEG to and from P?M. You can get them from Aminet:/pub/aminet/gfx/conv, look for an archive called "jpegV?.lha" or "AmigaJPEG?.lha" or something similar. The hpcdtoppm included in NETPBM converter is an older version, an up-to-date version is available on Aminet:/pub/aminet/gfx/pbm, archive "hpcdtoppm*.lha". All programs have two hidden options, "-version" and "-quiet". The first does the obvious: it prints version and configuration information of the program. The other suppresses all messages from the program (unfortunately, some programs ignore this option). Most programs print usage information if a "-?" option is given. Support ------- Your can reach me via E-mail: Ingo.Wilken@informatik.uni-oldenburg.de IRC: Nobody (usually on channel "#amigager") Carrier pigeon and other ancient communication channels: Ingo Wilken Bloherfelder Str. 72 26129 Oldenburg W-Germany For bug reports, please describe exactly what you were doing, what went wrong (guru number?) what OS version you are using, your machine configuration, and everything else that could be important. If possible, provide the following: * "enforcer" & "mungwall" output * "showconfig" output * a sample image that triggers the bug (unless it appears with any image) * the output of running the NETPBM-program with the -version option Also, make sure that it's really the NETPBM-program thats causing the problems, not some background-utility playing corewar. netpbm-free-10.0-1/amiga/README.DICE0100644004714500471450000001057607716230207016775 0ustar aba-guestaba-guestThis file describes how to compile NETPBM with DICE (registered version). You need a real "make" program (the "dmake" supplied with DICE won't work for this), and "patch". The "make" program should ignore a WARN return code. Compilation requires about 4MB RAM and 6MB of HD space, and takes about 45 minutes on a 25MHz 68030. Compilation of the TIFF library is not covered in this file. A compiled TIFF lib is available in the dicelibs archive (see "NETPBM.INTRO" for FTP addresses). Copy this library to the netpbm/libtiff directory. (1) CD into netpbm/amiga and compile dice_stack.c with dcc -c dice_stack.c (2) Set the environment variable "USER" to your name, like this: setenv USER "Al Bundy" CD into the toplevel netpbm directory and execute the shell-script "stamp-date.amiga". This will create the file "compile.h". (3) Apply the patch: patch -l < amiga/DICE.PATCH This installs a workaround for a DICE bug in two source files. If you are using a DICE version newer than 2.07.56R, this bug might already be fixed. To test this, compile this program: main() { double d = 0.5; int i = 2; i *= d; printf("%d\n", i); } If the result is "0", the bug still exists. (4) Edit pbmplus.h. The following symbols should be set: A_SMALLSTACK (obsolete, no longer used) A_FRAGARRAY A_RGBENV (optional, but recommended) A_STRERROR (5) There is no toplevel Makefile. CD into netpbm/pbm and type make -f Makefile.dice all for separate binaries or make -f Makefile.dice merge for a merged binary (see "NETPBM.INTRO") Repeat this in the directories netpbm/pgm, netpbm/ppm and netpbm/pnm, in this order. If you are changing the compiler options, make sure to change them in all four makefiles. (6) The binaries are now in netpbm/p?m/bin, just move them to a directory in your search path. See the file "NETPBM.INTRO" for more installation info. Note that binaries created by you will not use the PBMMEM environment variable. Here is a short explanations of compiler options used in the DICE Makefiles: -E xxx write error messages into file xxx -ms place strings constants in read-only code hunk -mu unix-compat, if there are two definitions for the same variable (at the same scope), merge them into one -gs generate stack-checking code (see dice_stack.c: whenever available stack falls below _stack_fudge, allocate a new stack of size _stack_chunk) -proto strict prototype checking -mRR functions take their args in registers (requires full prototyping) -mD large data model (absolute addressing instead of A4-rel) -mC large code model (absolute addressing instead of PC-rel) -r generate "pure" executable (no -mD and -mC allowed) -S alternate library section naming (used for link libs only) -s DEBUG: don't strip symbol information from executable -d1 DEBUG: include LINE information in executable (for Enforcer's FindHit) Naming conventions in the Makefiles: RLIBP?M small data library, args in registers RLLIBP?M large data library, args in registers SLIBP?M small data library, args on stack SLLIB?M large data library, args on stack RALLCFLAGS options to compile register-args executables SALLCFLAGS options to compile stack-args executables MALLCFLAGS options to compile merged executable BINS small data executables, register-args LBINS large data executables, register-args SBINS small data executables, stack-args SLBINS large data executables, stack-args MATHBINS \ LMATHBINS \ same as above, but need floating-point SMATHBINS / version of printf/scanf (link with math-lib) SLMATHBINS / *.or library object file (small data, reg-args) *.os library object file (small data, stack args) *.olr library object file (large data, reg-args) *.ols library object file (large data, stack args) *.om object file for merged binary (large data, stack args) I tried to use small data/reg-args whenever possible. Some programs had to be compiled with large data, and some with stack-args or the compiler would complain. -Ingo email: Ingo.Wilken@informatik.uni-oldenburg.de netpbm-free-10.0-1/amiga/README.SASC0100644004714500471450000000407707716230207017021 0ustar aba-guestaba-guestSAS/C SMakefiles for SAS/C 6.0 and greater have been created by Robert A. Knop Jr. (rknop@cco.caltech.edu). These Makefiles have been tested with SAS/C 6.51. They are based on the 7dec1993 release of netpbm. See also README.AMIGA for DICE, Amiga binary, and Amiga general information from Ingo Wilken. The following files are specific to SAS/C SMakefiles: SMakefile - Top level makefile, runs SMakefiles in pbm, pgm, ppm, pnm SCOPTIONS - SAS/C options file foreach_amiga.lha - Amiga Shell utility needed in the SMakefiles pbm/SMakefile - make file for pbm, run by top level SMAkefile pbm/SCOPTIONS - should be same as top level SCOPTIONS pgm/SMakefile - make file for pgm, run by top level SMAkefile pgm/SCOPTIONS - should be same as top level SCOPTIONS ppm/SMakefile - make file for ppm, run by top level SMAkefile ppm/SCOPTIONS - should be same as top level SCOPTIONS pnm/SMakefile - make file for pnm, run by top level SMAkefile pnm/SCOPTIONS - should be same as top level SCOPTIONS The shell script stamp-date.amiga by Ingo Wilken is used by the SAS/C Amiga SMakefile. To build netpbm with SAS/C: (1) Decompact the netpbm source archive (presumably you've already done this if you are reading this file). The top level directory should have, among others, subdirectories "pbm", "pgm", "ppm", and "pnm". CD to this top level directory. (2) Install foreach somewhere in your path, e.g. c: (3) In the top level directory, type "smake". This will build all of the binaries. (4) Edit the top-level SMakefile, changing the definition of the variables INSTALLBINARIES, INSTALLMANUALS1, INSTALLMANUALS3, and INSTALLMANUALS5 to reflect where on your system you want the executables and man pages to go. (5) In the top level directory, type "smake install". This will copy the executables to $(INSTALLBINARIES) and the man pages to $(INSTALLMANUALS?). (6) In the top level directory, type "smake clean". This will delete the copies of the executables from the source tree, the .o object files, and other chaff. -R. Knop 93/01/26netpbm-free-10.0-1/amiga/compat.amiga0100644004714500471450000000172107716230207017665 0ustar aba-guestaba-guest; compat.amiga - AmigaShell aliases to allow users of old versions of PBM ; to keep their habits. alias giftoppm "giftopnm" alias pbmcatlr "pnmcat -lr" alias pbmcattb "pnmcat -tb" alias pbmcrop "pnmcrop" alias pbmcut "pnmcut" alias pbmenlarge "pnmenlarge" alias pbmfliplr "pnmflip -lr" alias pbmfliptb "pnmflip -tb" alias pbmpaste "pnmpaste" alias pbmtops "pnmtops" alias pbmtorast "pnmtorast" alias pbmtoxwd "pnmtoxwd" alias pbmtrnspos "pnmflip -xy" alias pcxtopbm "pcxtoppm" alias pgmtops "pnmtops" alias picttopbm "picttoppm" alias ppmarith "pnmarith" alias ppmconvol "pnmconvol" alias ppmcscale "pnmdepth" alias ppmrotate "pnmrotate" alias ppmscale "pnmscale" alias ppmshear "pnmshear" alias ppmsmooth "pnmsmooth" alias ppmtops "pnmtops" alias ppmtorast "pnmtorast" alias ppmtoxwd "pnmtoxwd" alias rasttopbm "rasttopnm" alias rasttoppm "rasttopnm" alias tifftopbm "tifftopnm" alias tifftopgm "tifftopnm" alias xwdtopbm "xwdtopnm" alias xwdtoppm "xwdtopnm" netpbm-free-10.0-1/amiga/dice_stack.c0100644004714500471450000000007307716230207017636 0ustar aba-guestaba-guestlong _stack_fudge = 16*1024; long _stack_chunk = 32*1024; netpbm-free-10.0-1/amiga/foreach.lha0100644004714500471450000001223007716230207017474 0ustar aba-guestaba-guestD-lh5- 0% Foreach_sѴܣ8v(nz>,Eq:1\en[99=@MTʩ |mVUU|UPh]0U "FQvJm\l+l}d6ryvᬍ"wɿiǻA69{=T-xA^$v9J#MfslƱZ W=J<A65nR4rFFH> ,XIm`@15N+̧"JFAz ]ɤtBCw;_Q'LtAz`65WX]r?RS<ܖq Ϗ;j{(>ˬINia6uU `@Na~ lė-V |K ? a-(ޤ2SXyP.k[t@6ޚ.Ãtˌ=XVw)֧D*tY4z?UA0k~{ φ%_Q];ɰ38A D56ؚgaTS]pO&r^`Jx7JY%[4tg9WՕo=?Wlhv^zgTbukB;9 j-}BֈG4Ɨ;\|5M}k:&%Q6~YDcw6?oco1Ě[-{3LhbDӛypzi'Q'Ԇǹ!b&Ǻ_b%Ca14ۚ?UWuL6=:u%6c#]?/y_ylUǜq Bwjq>ZaU+oR w]ٵ1I>Ɛk w%8YeA1HU e[ߜp"Z_~ ܴ/Sˤ ,mA$4N_$rEbAda-fTaҳo9 h)r hrx$'̝h%Z=O:ݺʺ A>',p{U6E7ȫqSg<ϝk?~|tna\4bu!pŝlPO&4۲DLPvKkD޺@Ѝ=;V |qr]?C^2FqҾpn5iia`5 cx$;/|МR`{=#z&fHvCucxq|3xnNRce{;dnciݲ[ЇR2Ÿù1HFm9D[R~QL[7 Eum<DE/I\}dOos7^f/tz$s[I>kIľmy45D['Ac |/0)B0~yDv4Md T_FE"S4]GN-z)Q5OhJ'gn'ߡ>&룇0׋?vdg1Wku"di֧7!>n|ԁǼ8rRS3o;4x\C=[1n!2}lV ΓL1M#n[1}@9a]VS:4֦}ab`0?NmQxVPzd\pנۍ4MF+LVk~tW f4aЫb-i7n, r)(NN&^圴%))'̑M N4jhg08Éfmh-ёLOfltJtG ۘ4=.qkf/;r9𓑦ΏE1WʵU+Έymls>|*zIdWKl89wAs8U,l9絇0Xk %u!OkS$֘:?ӈ7V(!nIP:4l--t W-w؛LCq ^_*}b9F7l|?)y3+G߸iD!;}&dtff;^iݻ1]NdYt45> tIN'ޮ23)px!hHwM0.(ט,Q,C:xqƅԀJY$npsMH{Sw kKL .]1ȸ Rh)}_G"MAA`AN:%0-TS7v.AP}9ϰib[lGz{}cVk;fH`m==a:Cyb;!P-lh5- Y Foreach.docsqܷ`FQ='0Gjl4t tE$kJO5|n'Me] xx{@ζ֛]nĺ3:R;Jt׎P1ͶԧScs%JUQJӕ`=SS X's&hЦ츑d] ȼ/`cVS*ZkzM|1:uQSju-fI& uKPYe[KT JBhS;I绉.Lj=ka/)0()x&B OsE5[hYe$&qef`dYj]+P\Jdjj}Eԭvӝu,y~p>71z܎Ӯf~ԛОV7t{i%!nwތWyB[OM^//8m8#ÊL8,Q4L#&a :QMÉ0i4z+IN6ʬnqz6moNC%^⎜cj1O]r߮$"76"qʤym.o-`M֐Jӥe U1ڎ8J3 UQWUdF jTyFFV=cVH|*TF4b($T$G"Q`=zҀn{n἟,nmX##xg/=v-Z`<<_&xHl5%#.ٗjSф㠨=q2\T/Bc'0`@7LNmzS(ꪀ.Dx}-ML&5$4LNtBBEҶ" _$ƩAHOLhE *P%n,iD/qd)W$:txdF"yAEI3+Xţؔ{bp2Bxhm,B$ON;'a1c@`tIw)e*|;kU Ac}x@R":A$x; DdEP)p$G1Y.-FZء xcFԯv*+'0 @_adۆ>y}i&`3Y ś[Aҭ } Ҹ^ZG FrbJf顔 k8@da?p.(WsDeQ_]YSNu{u$G oIaoz'nR:VKa7@tdU,S$q,k98!(T7JͺU"=T iދ:wW\a[3K$Ti{D9j$Ab㤕G@T;fJlh̦72g(wx:A03{]d6`7iMydH7'DfC:D&P4#ӻS(|Q&e+'jόhIDUmQEagW5!'7@ G åugV̵$.]9u/_Pq[JG8[f [+EN -ᆞ,d=SU379#½s^8a yVk+,s.h:o <՘,|:OI#P NƧ8# aHRv5jqoA(p^A>O?<;E؟gN xpO6پ )wDŽ\W F qO>eY1YxAbmnetpbm-free-10.0-1/amiga/link_merged0100644004714500471450000001530707716230207017612 0ustar aba-guestaba-guest; this script creates the hardlinks for merged binaries ; it must be executed in the directory where the merged binaries are makelink from atktopbm to pbmmerge hard makelink from brushtopbm to pbmmerge hard makelink from cmuwmtopbm to pbmmerge hard makelink from g3topbm to pbmmerge hard makelink from icontopbm to pbmmerge hard makelink from gemtopbm to pbmmerge hard makelink from macptopbm to pbmmerge hard makelink from mgrtopbm to pbmmerge hard makelink from pbmclean to pbmmerge hard makelink from pbmlife to pbmmerge hard makelink from pbmmake to pbmmerge hard makelink from pbmmask to pbmmerge hard makelink from pbmpscale to pbmmerge hard makelink from pbmreduce to pbmmerge hard makelink from pbmtext to pbmmerge hard makelink from pbmto10x to pbmmerge hard makelink from pbmto4425 to pbmmerge hard makelink from pbmtoascii to pbmmerge hard makelink from pbmtoatk to pbmmerge hard makelink from pbmtobbnbg to pbmmerge hard makelink from pbmtocmuwm to pbmmerge hard makelink from pbmtoepsi to pbmmerge hard makelink from pbmtoepson to pbmmerge hard makelink from pbmtog3 to pbmmerge hard makelink from pbmtogem to pbmmerge hard makelink from pbmtogo to pbmmerge hard makelink from pbmtoicon to pbmmerge hard makelink from pbmtolj to pbmmerge hard makelink from pbmtoln03 to pbmmerge hard makelink from pbmtolps to pbmmerge hard makelink from pbmtomacp to pbmmerge hard makelink from pbmtomgr to pbmmerge hard makelink from pbmtopi3 to pbmmerge hard makelink from pbmtopk to pbmmerge hard makelink from pbmtoplot to pbmmerge hard makelink from pbmtoptx to pbmmerge hard makelink from pbmtox10bm to pbmmerge hard makelink from pbmtoxbm to pbmmerge hard makelink from pbmtoybm to pbmmerge hard makelink from pbmtozinc to pbmmerge hard makelink from pbmupc to pbmmerge hard makelink from pi3topbm to pbmmerge hard makelink from pktopbm to pbmmerge hard makelink from xbmtopbm to pbmmerge hard makelink from ybmtopbm to pbmmerge hard makelink from bioradtopgm to pgmmerge hard makelink from fstopgm to pgmmerge hard makelink from hipstopgm to pgmmerge hard makelink from lispmtopgm to pgmmerge hard makelink from pbmtopgm to pgmmerge hard makelink from pgmbentley to pgmmerge hard makelink from pgmcrater to pgmmerge hard makelink from pgmedge to pgmmerge hard makelink from pgmenhance to pgmmerge hard makelink from pgmhist to pgmmerge hard makelink from pgmkernel to pgmmerge hard makelink from pgmnoise to pgmmerge hard makelink from pgmnorm to pgmmerge hard makelink from pgmoil to pgmmerge hard makelink from pgmramp to pgmmerge hard makelink from pgmtexture to pgmmerge hard makelink from pgmtopbm to pgmmerge hard makelink from pgmtofs to pgmmerge hard makelink from pgmtolispm to pgmmerge hard makelink from psidtopgm to pgmmerge hard makelink from rawtopgm to pgmmerge hard makelink from spottopgm to pgmmerge hard makelink from fitstopnm to pnmmerge hard makelink from giftopnm to pnmmerge hard makelink from pnmalias to pnmmerge hard makelink from pnmarith to pnmmerge hard makelink from pnmcat to pnmmerge hard makelink from pnmcomp to pnmmerge hard makelink from pnmconvol to pnmmerge hard makelink from pnmcrop to pnmmerge hard makelink from pnmcut to pnmmerge hard makelink from pnmdepth to pnmmerge hard makelink from pnmenlarge to pnmmerge hard makelink from pnmfile to pnmmerge hard makelink from pnmflip to pnmmerge hard makelink from pnmgamma to pnmmerge hard makelink from pnminvert to pnmmerge hard makelink from pnmhistmap to pnmmerge hard makelink from pnmnlfilt to pnmmerge hard makelink from pnmnoraw to pnmmerge hard makelink from pnmpaste to pnmmerge hard makelink from pnmrotate to pnmmerge hard makelink from pnmscale to pnmmerge hard makelink from pnmshear to pnmmerge hard makelink from pnmtile to pnmmerge hard makelink from pnmtoddif to pnmmerge hard makelink from pnmtofits to pnmmerge hard makelink from pnmtops to pnmmerge hard makelink from pnmtorast to pnmmerge hard makelink from pnmtosgi to pnmmerge hard makelink from pnmtosir to pnmmerge hard makelink from pnmtotiff to pnmmerge hard makelink from pnmtoxwd to pnmmerge hard makelink from rasttopnm to pnmmerge hard makelink from sgitopnm to pnmmerge hard makelink from sirtopnm to pnmmerge hard makelink from tifftopnm to pnmmerge hard makelink from xwdtopnm to pnmmerge hard makelink from zeisstopnm to pnmmerge hard makelink from bmptoppm to ppmmerge hard makelink from gouldtoppm to ppmmerge hard makelink from ilbmtoppm to ppmmerge hard makelink from imgtoppm to ppmmerge hard makelink from hpcdtoppm to ppmmerge hard makelink from mtvtoppm to ppmmerge hard makelink from pcxtoppm to ppmmerge hard makelink from pgmtoppm to ppmmerge hard makelink from pi1toppm to ppmmerge hard makelink from picttoppm to ppmmerge hard makelink from pjtoppm to ppmmerge hard makelink from ppm3d to ppmmerge hard makelink from ppmbrighten to ppmmerge hard makelink from ppmchange to ppmmerge hard makelink from ppmdim to ppmmerge hard makelink from ppmdist to ppmmerge hard makelink from ppmdither to ppmmerge hard makelink from ppmflash to ppmmerge hard makelink from ppmforge to ppmmerge hard makelink from ppmhist to ppmmerge hard makelink from ppmmake to ppmmerge hard makelink from ppmmix to ppmmerge hard makelink from ppmnorm to ppmmerge hard makelink from ppmntsc to ppmmerge hard makelink from ppmpat to ppmmerge hard makelink from ppmquant to ppmmerge hard makelink from ppmqvga to ppmmerge hard makelink from ppmrelief to ppmmerge hard makelink from ppmshift to ppmmerge hard makelink from ppmspread to ppmmerge hard makelink from ppmtoacad to ppmmerge hard makelink from ppmtobmp to ppmmerge hard makelink from ppmtogif to ppmmerge hard makelink from ppmtoicr to ppmmerge hard makelink from ppmtoilbm to ppmmerge hard makelink from ppmtomap to ppmmerge hard makelink from ppmtomitsu to ppmmerge hard makelink from ppmtopcx to ppmmerge hard makelink from ppmtopgm to ppmmerge hard makelink from ppmtopi1 to ppmmerge hard makelink from ppmtopict to ppmmerge hard makelink from ppmtopj to ppmmerge hard makelink from ppmtopjxl to ppmmerge hard makelink from ppmtopuzz to ppmmerge hard makelink from ppmtorgb3 to ppmmerge hard makelink from ppmtosixel to ppmmerge hard makelink from ppmtotga to ppmmerge hard makelink from ppmtouil to ppmmerge hard makelink from ppmtoxpm to ppmmerge hard makelink from ppmtoyuv to ppmmerge hard makelink from ppmtoyuvsplit to ppmmerge hard makelink from qrttoppm to ppmmerge hard makelink from rawtoppm to ppmmerge hard makelink from rgb3toppm to ppmmerge hard makelink from sldtoppm to ppmmerge hard makelink from spctoppm to ppmmerge hard makelink from sputoppm to ppmmerge hard makelink from tgatoppm to ppmmerge hard makelink from ximtoppm to ppmmerge hard makelink from xpmtoppm to ppmmerge hard makelink from xvminitoppm to ppmmerge hard makelink from yuvtoppm to ppmmerge hard makelink from yuvsplittoppm to ppmmerge hard netpbm-free-10.0-1/amiga/stamp-date.amiga0100644004714500471450000000204707716230207020443 0ustar aba-guestaba-guest.bra { .ket } ; ; Copyright (C) 1993 by Ingo Wilken ; ; Permission to use, copy, modify, and distribute this software and its ; documentation for any purpose and without fee is hereby granted, provided ; that the above copyright notice appear in all copies and that both that ; copyright notice and this permission notice appear in supporting ; documentation. This software is provided "as is" without express or ; implied warranty. ; ; This shell script creates a file called "compile.h" which holds ; a define stating the compilation time. This is used for the -version ; flag. ; set OUTFILE compile.h set DATE `date` if "$USER" eq "*$USER" set USER "unknown" endif echo "/** compile.h This file tells the package when it was compiled **/" > $OUTFILE echo "/** DO NOT EDIT - THIS FILE IS MAINTAINED AUTOMATICALLY **/" >> $OUTFILE echo "#define COMPILE_TIME *"$DATE*"" >> $OUTFILE echo "#ifndef COMPILED_BY" >> $OUTFILE echo "#define COMPILED_BY *"$USER*"" >> $OUTFILE echo "#endif" >> $OUTFILE netpbm-free-10.0-1/COPYRIGHT.PATENT0100644004714500471450000000744107716762513016630 0ustar aba-guestaba-guestNetpbm consists of code contributed by many authors. In every file of the source code, there is a copyright notice, telling you what you may or may not do with the code. All authors have granted you the right to use and distribute their code without having to pay them, as long as you meet some simple requirements. Most of the components require you to include a copy of their copyright notices and warranty disclaimers in any copies or derivations you distribute. Another restriction that some of the software has is that in order to have permission to copy it (which includes writing anything derived from it), you must distribute source code for your copy or derivation and propagate the same restriction to people who would copy your derivation. In other words, the price the author wants for the use of his proprietary work is your contribution to the free software cause. One component prohibits you from selling it or using it in a commercial way: hpcdtoppm. Some components are contributed to the public domain. The copyrights on individual components of this package are detailed at appropriate places within the package. These security fixes for netpbm are (c) Copyright 2002 Red Hat Inc. Red Hat has not fixed those items with patent claims or commercial use restrictions. These changes include NO WARRANTY and are provided under the Open Software License v.1 (see file OPENLICENSE). PATENTS ------- These are the patents the Netpbm maintainer knows about that relate to Netpbm. It is basically just information the maintainer has stumbled over at some point -- no search has been done. No licenses have been granted by patent owners to the maintainer of Netpbm. Therefore, if you need a patent to use something in Netpbm, you need your own license. A note about patents in general: A patent gives an inventor the exclusive right to make, sell, or use the invention. If you independently invent something without knowing that the patent holder already did, that makes no difference -- the patent holder still has the exclusive right. It makes no difference if you give the original inventor credit. The patent applies to a method, not its expression, so writing a program from scratch to implement a certain method is still a patent infringement. Infringing a patent is not a crime per se, but to the extent that it costs the patent holder money, the infringer has to make it up. The original purpose of patents is probably perverted when patents are applied to things you implement in computer programs. This is one of the Free Software Foundation's causes. See . Unisys owns a patent on LZW compression, which is used by ppmtogif, and maybe on LZW decompression, which is used by giftoppm. IBM also owns a patent that may cover the GIF tools. Unisys offers a license of the patent for trivial use for $5000. Its patent expires in 2003. Neither company has ever enforced the patent against trivial users of it. is an article dated April 18, 2000 on the issue. is Unisys' view of the matter. For information from another perspective, see http://www.gnu.org/philosophy/gif.html or http://burnallgifs.org/. The following Netpbm components may be restricted by this patent: ppmtogif, giftopnm. A good substitute for GIF if the patents are a problem is PNG (see pngtopnm, pnmtopng), which was developed with a primary purpose of not using any patented technology. You can also use the -nolzw option on ppmtogif to avoid using the LZW patent. The images so generated are larger than traditional LZW-compressed GIFs, but any GIF decoder can decode them just the same. The jbigtopnm and pnmtojbig programs use arithmetic coding patents and other patents covering various aspects of the "front end." netpbm-free-10.0-1/GNUmakefile0100644004714500471450000001642107732352703016405 0ustar aba-guestaba-guest# Makefile for Netpbm # Configuration should normally be done in the included file Makefile.config. # Targets in this file: # # nonmerge: Build everything, in the source directory. # merge: Build everything as merged executables, in the source dir # install: install-run + install-dev # install-run: install stuff needed to run Netpbm programs # install-dev: Install stuff needed to develop/build programs that use # Netpbm libraries: headers and static libraries. # install.bin: Install executables # install.lib: Install Netpbm shared libraries # install.man: Install man pages # install.staticlib: Install Netpbm static libraries # install.sharedlibstub: Install the ".so" file - the file used at link # time to prepare a program for runtime linking of a library # install.hdr: Install Netpbm library interface headers # Neue Targets # build # .bin # .lib # .static # .shared # install # .bin # .lib # .static # .old-static (no auto) # .shared # .lib # .devel # .old-devel (no auto) # .old-shared (no auto) # .lib # .devel # .hdr # .man # .bin # .lib # .old-lib (no auto) # .general # the DEFAULT_TARGET variable set by Makefile.config. # About the "merge" target: Normally the Makefiles build and install # separate executables for each program. However, on some systems # (especially those without shared libraries) this can mean a lot of # space. In this case you might try building a "merge" instead. The # idea here is to link all the programs together into one huge # executable, along with a tiny dispatch program that runs one of the # programs based on the command name with which it was invoked. You # install the merged executable with a file system link for the name # of each program it includes. On a Sun3 under SunOS 3.5 the space # for executables went from 2970K to 370K in an older Netpbm. # On a Linux x86 system with Netpbm 8.4, it saved 615K. # To build a "merge" system, just set DEFAULT_TARGET to "merge" instead # of "nomerge" in Makefile.config. In that case, you should probably also # set NETPBMLIBTYPE to "unixstatic", since shared libraries don't do you # much good. # The CURDIR variable presents a problem because it was introduced in # GNU Make 3.77. We need the CURDIR variable in order for our 'make # -C xxx -f xxx' commands to work. If we used the obvious alternative # ".", that wouldn't work because it would refer to the directory # named in -C, not the directory the make file you are reading is # running in. The -f option is necessary in order to have separate # source and object directories in the future. ifeq ($(CURDIR)x,x) $(GOALS): @echo "YOU NEED AT LEAST VERSION 3.77 OF GNU MAKE TO BUILD NETPBM." @echo "Netpbm's makefiles need the CURDIR variable that was " @echo "introduced in 3.77. Your version does not have CURDIR." @echo @echo "You can get a current GNU Make via http://www.gnu.org/software" @echo @echo "If upgrading is impossible, try modifying GNUMakefile and " @echo "Makefile.common to replace \$(CURDIR) with \$(shell /bin/pwd) " else ifeq ($(SRCDIR)x,x) SRCDIR := $(CURDIR) endif BUILDDIR = . # Some day, we'll figure out how to make BUILDDIR != SRCDIR include Makefile.config all: build build: build.bin build.lib build.lib: build.lib.static build.lib.shared build.old-lib: build.lib.old-static build.lib.old-shared install: install.bin install.lib install.man install.lib: install.lib.static install.lib.shared install.lib.hdr install.lib.old-shared: install.lib.old-shared.lib install.lib.old-shared.devel install.lib.shared: install.lib.shared.lib install.lib.shared.devel install.man: install.man.bin install.man.lib install.man.general build.lib.default: build.lib.shared # should be an option GOALS := \ build.bin build.lib \ build.lib.static build.lib.shared \ install.bin install.lib install.man \ install.lib.static install.lib.shared install.lib.hdr \ install.lib.shared.lib install.lib.shared.devel \ install.man.bin install.man.lib install.man.general \ clean SUBGOALS := \ build.bin \ install.bin \ install.man.bin install.man.general install.man.old-lib \ clean .PHONY: depend .depend depend: @buildtools/depend.pl > .depend include .depend lib/static lib/shared: mkdir -p $@ .PHONY: config config: Makefile.config Makefile.config: $(SRCDIR)/Makefile.config.in $(SRCDIR)/configure $< @echo @echo .PHONY: install-run ifeq ($(DEFAULT_TARGET),merge) install-run: install.merge install.lib install.man else install-run: install.bin install.lib install.man endif MERGELIST = $(patsubst %,%.merge,$(SUBDIRS)) .PHONY: $(MERGELIST) $(MERGELIST): $(MAKE) -C $(patsubst %.merge,%,$@) \ -f $(SRCDIR)/$(patsubst %.merge,%,$@)/Makefile merge # e.g. make -C pbm -f /usr/src/netpbm/pbm/Makefile merge .PHONY: merge merge: $(MERGELIST) SUBDIRS = pbm pgm ppm pnm include deprecated #$(GOALS): $(patsubst %,x$@-%, $(SUBDIRS)) $(SUBGOALS):%: local-% pbm-% pgm-% pnm-% ppm-% include-% deprecated-% $(SUBGOALS):%: pbmtoppa-% pnmtopalm-% ppmtompeg-% ifneq ($(BUILD_FIASCO), N) $(SUBGOALS):%: fiasco-% endif $(patsubst %, %-build.bin, $(SUBDIRS)): buildtools/libopt build.lib.shared $(patsubst %, %-install.bin, $(SUBDIRS)): buildtools/libopt local-%: @true pbm-%: $(MAKE) -C pbm $* pgm-%: $(MAKE) -C pgm $* pnm-%: $(MAKE) -C pnm $* ppm-%: $(MAKE) -C ppm $* include-%: $(MAKE) -C include $* deprecated-%: $(MAKE) -C deprecated $* pbmtoppa-%: $(MAKE) -C pbm/pbmtoppa $* fiasco-%: $(MAKE) -C pnm/fiasco $* pnmtopalm-%: $(MAKE) -C pnm/pnmtopalm $* ppmtompeg-%: $(MAKE) -C ppm/ppmtompeg $* buildtools/libopt: $(MAKE) -C buildtools libopt build.lib.static: \ lib/static/libnetpbm.a build.lib.old-static: \ lib/static/libpbm.a \ lib/static/libpgm.a \ lib/static/libpnm.a \ lib/static/libppm.a build.lib.shared: \ lib/shared/libnetpbm.so build.lib.old-shared: \ lib/shared/libpbm.so \ lib/shared/libpgm.so \ lib/shared/libpnm.so \ lib/shared/libppm.so install.lib.hdr: local-install.lib.hdr include-install.lib.hdr \ deprecated-install.lib.hdr ppm-install.lib.hdr install.man.lib: install.man.old-lib local-install.man.general: $(MANCP) $(SRCDIR)/netpbm.1 \ $(INSTALLMANUALS1)/netpbm.$(SUFFIXMANUALS1) ; $(MANCP) $(SRCDIR)/pbm/pbmfilters.1 \ $(INSTALLMANUALS1)/pbmfilters.$(SUFFIXMANUALS1) ; local-install.man.lib: $(MANCP) $(SRCDIR)/libnetpbm.3 \ $(INSTALLMANUALS3)/libnetpbm.$(SUFFIXMANUALS3) ; # Note that you might install the development package and NOT the runtime # package. If you have a special system for building stuff, maybe for # multiple platforms, that's what you'd do. Ergo, install.lib is here even # though it is also part of the runtime install. local-install.lib.hdr: # See notes in Makefile.common about how $(INSTALL) varies from one # platform to another. $(INSTALL) -c -m $(INSTALL_PERM_HDR) \ $(SRCDIR)/shhopt/shhopt.h $(INSTALLHDRS)/netpbm-shhopt.h local-clean: for i in urt shhopt buildtools; do \ $(MAKE) -C $$i -f $(SRCDIR)/$$i/Makefile clean ; \ done mkdir -p lib/static lib/shared -rm lib/*/* .PHONY: distclean distclean: clean rm -f Makefile.config build-env: mkdir -p lib/static lib/shared ln -sf shhopt.h shhopt/netpbm-shhopt.h # The following endif is for the else block that contains virtually the # whole file, for the test of the existence of CURDIR. endif netpbm-free-10.0-1/HISTORY0100644004714500471450000015557107776237374015447 0ustar aba-guestaba-guestJef Poskanzer (jef@acme.com) invented the PBM format in the 1980s to provide the computer graphics world with a common, trouble-free format, a lingua-franca, for bitmaps. The format was designed to be simple enough that it could transmitted within an email message without any special encapsulating and survive any translations and recoding that an email message might go through and be easily extractable on the other end. In 1988, Jef distributed the forerunner of Netpbm, Pbmplus, which gathered together the various tools he had developed to work with PBM files. These were mainly tools to convert between PBM and other existing graphics formats, making it possible to deal with the Tower Of Babel situation that had arisen with the proliferation of graphics formats. By the end of 1988, Jef had added the PGM and PPM formats and lots more tools to Pbmplus. In 1991, Jef added a variety of programs and code contributed by the user community, and then stopped maintaining Pbmplus. Jef never formally renounced support for it, but simply didn't get around to distributing any updates for over a year. In 1993, Netpbm was developed to replace Pbmplus. Netpbm was nothing more than a new release of Pbmplus, and named for the fact that people all over the world would maintain the package by submitting fixes and enhancements over the Net. This was a time when such worldwide collaboration was still novel. Then Netpbm apparently fell into neglect with the last release by its regular maintainer in March 1994. In September of 1995 Anthony Thyssen released an unofficial update of it called Netpbm-1mar1994.p1, while disclaiming any responsibity for ongoing upkeep. The documentation in that 1995 release mentioned two different official mailing lists concerning the package, but by April 1999, neither existed anymore. In September 1999, Bryan Henderson needed some minor bugs fixed, and wanted to clean up the mess of unsupported versions and outdated documentation of these tools. After checking around to see if anyone had any claims of ownership of the package, and finding none, Bryan assumed control and responsibility for Netpbm. In November 1999, Thorbjoern Ravn Anderson did the same thing, for the same reason (apparently unaware of Bryan's work) and made available an updated version (based on the 1994 release) as described by http://sunsite.auc.dk/netpbm. Shortly thereafter, he discontinued his effort in deference to the new Pbmplus effort mentioned below. Bryan did not know about Anderson's work until March 2000. In parallel, and unknown to Bryan, Jef was working on a new release under the original name Pbmplus and claiming again (or maybe still) to be maintaining Pbmplus. He did a limited release of a beta version of it in November 1999. A mailing list pbmplus@acme.com was active. Bryan learned of this effort's existence in March 2000. Pbmplus and Netpbm were once part of the body of X/Windows contributed software, distributed on ftp.x.org (directory contrib/utilities). Bryan didn't receive a response to an inquiry to the ftp.x.org owner as to the prospect of cleaning up the Netpbm related files there. So Bryan instead made Metalab the new home of the source code. But Metalab had pretty low quality too, and in April 2000 Bryan moved the package's home to Sourceforge. In 2003, Debian created an own upstream with security and freedom in mind; Andreas Barth started to maintain this for Debian. CHANGE HISTORY -------------- 04.01.04 ABa Export now pm_canonstr, pm_openColornameFile, pm_colorget, pm_rgbnorm, pnm_scalesample, pnm_setpamrow and pam_colorname. Add pamstack. [BH] Add pbmtextps. Thanks James McCann . pnmtotiff: Add -indexbits option to allow fewer than 8 bits per sample in apletted image. Thanks Thomas Henlich . pnmtotiff: put zeroes in unused colormap entries. Thanks Thomas Henlich . pbmtext: Add -lspace option. Thanks Denis pnmtops: remove setpagedevice by default. Add -setpage option. [BH] pstopnm: Add a showpage in case the EPS source doesn't have it. Thanks "J. Milgram" . pstopnm: Run Ghostscript directly instead of via a shell. Some Windows environments don't have a Bourne-compatible shell. [BH] pnmtotiff: Don't put bogus colormap in grayscale TIFF. Thanks Thomas Henlich . replaced optParseOptions* by their (existing) pm_*-counterparts. Thanks to Brendan O'Dea for the discussion on IRC picttoppm, ppmtompeg: fix bug with invalid parameter ("b" modes) on popen(). [BH] pnmtopng: fix bug with 'mayscale'. [BH] pnmnorm: Fix bug with bvalue == 0. Thanks "Blake, Chris" pnmtopng: restructure palette generation to make it easier to read. [BH] 03.12.06 ABa ppmtompeg: progress indicator is sent so that non-ttys could use it. #218295 03.11.25 ABa Revisited the the security fixes, and replaced some with "nicer" code. 03.11.10 ABa Fixed more tmpfile-problems in ppmtompeg and others. 03.11.04 ABa Repaired pamstretch-gen. 03.11.04 ABa Fixed insecure tmpfile-handling in anytopnm, pnminterp-gen and others. (#219019) 03.10.04 ABa Fixed bug in pnmnorm (#213366) at taking maximums for brightness. 03.09.18 ABa Fixed libary build scripts Added build target "build-env" Put a "die" in the configure-script as warning 03.08.31 ABa Added a README.Non-Debian. Total rewrite of the make file system: Most of the logic is now in the GNUmakefile and a perl helper Unified the libraries again, but you can also get the old ones. Seperated build space for static and shared libs, so you can build both in parallel. 02.03.15 BJH Release 9.25 Add pamdice. pnmgamma: add -srgbramp. ppmnorm, pgmnorm: replace with pnmnorm ppmnorm: Read only a row at a time into memory. ppmnorm: Add -keephues option. Pnmtotiff: Add -miniswhite option. Pnmtopsnr: Read only a row at a time into memory. Convert bmptoppm to bmptopnm. ppmtopcx: Add -xpos, -ypos options. pcxtoppm: Don't require seekable input. pcxtoppm: Improve messages; add some PCX header validation. ppmtowinicon: Use standard alpha mask (PGM image) instead of PPM image (black/not black) for and file. pnmpad: Add -width, -height, -halign, -valign options. Thanks M. van Beilen . ppmhist: remove 100,000 color limit. pnmnlfilt: works with multi-image streams. Thanks "Steven M. Schultz" . pcxtoppm: Fix bug with negative image position. pnmtopsnr: fix unsigned integer bug giving wrong results on PGMs. libpnm: fix bug: PAM functions write 16 bit samples wrong. Tifftopnm: fix bug: transparency mask all wrong. Thanks Heikki Suonsivu . Makefile improvements for cross compiling. Thanks "Maciej W. Rozycki" . Allow build with existing JBIG library instead of the bundled one. Thanks "Maciej W. Rozycki" . ppmtompeg Makefile: include -R option where needed. Thanks Hans Werner Strube . Add BSD/OS to configure program. Thanks seebs@plethora.net (Peter Seebach) configure: Fix missing newline bug for IRIX. 02.01.27 BJH Release 9.24 Add ppmsvgalib. pnmremap: Use full color resolution of input instead of that of color map to do Floyd-Steinberg dithering. pnmremap: fix bug where Floyd-Steinberg dithering of very dark areas creates spots of maximal brightness. ppmquant: fix same bug as pnmremap. pnmscale: add -nomix option rawtopgm: fix bug. Thanks Joe Krahn . pnmquant: replace with a Perl program that calls pnmcolormap and pnmremap. Fix bug: PAM library routines fail to read 2-byte samples. fix bug: install-dev doesn't install mappam.h. configure sets up install paths. make install does Ldconfig where required. pnmtops: Add "XxY" form of -dpi option. Thanks Vladimir Nadvornik ppmtomap: rewrite to call the new pnmcolormap. pnmscale: clean up code a little; now it appears to produce somewhat better results -- don't know why. exif.h: remove C++ comments various fixes to please Irix compiler. Change some "long" to "uint32n" so it works on 64 bit machines. 02.01.04 BJH Release 9.23 tifftopnm: fix bug from 9.22: always crashes. xpmtoppm: fix bug from 9.21: XPM 3 files not recognized because /* XPM */ comment read twice. xwdtopnm: Use bitmap_pad instead of bitmap_unit on X11 pixmap files with depth > 1. Thanks "Ben Kelley" . pnmtopalm: fix bug: crashes with -colormap and non-color input. ppmforge: fix bug: array subscripts out of bounds. Thanks Rob Menke . giftopnm: fix bug with extraneous "bogus character 0x00" message tifftopnm: add -respectfillorder option. Ignore FILLORDER by default. make install-dev: install shared library stub files (symlinks). ppmtogif: Fix bug: color resolution in wrong bits in logical screen descriptor. Thanks Elmue . Add -lz to Tiff programs; libtiff requires it now. Add ppmcolors. Add pnmremap. Add pnmcolormap. pnmtops: Include setpagedevice directive in Postscript output. Thanks A Braunsdorf . pnmtops: turn-to-fit logic works properly where paper is wider than tall. Thanks A Braunsdorf . giftopnm: cleanup 01.12.10 BJH Release 9.22 Fix bug: pnm_luminosity_factor must be "extern" in pam.h pbmtonokia: can create picture messages. -txt, -net options. tifftopnm: Accept invalid FILLORDER value - assume msb-to-lsb. 01.12.01 BJH Release 9.21 Add pamdeinterlace. Add pnmquant. pnmtops: Accept maxval > 255 input. Rename pnminterp to the more informative pnmstretch. pamstretch: add -xscale, -yscale options pbmtolj: Add -copies option ppmtogif: Add secret -h option to make Latex2html configure program work. ppmquant: output maxval controlled by colormap maxval, not input maxval. pbmclean: Add -black and -white options. Thanks Michael Sternberg . xpmtoppm: Don't require input to start with a comment. Thanks MINAMI . xpmtoppm: Fix bug introduced with 9.20 with XPM 1 files. pnmcut, pamcut: fix bug with cut that begins past right edge of image. pamcut: Same fix as in pnmcut in 9.9. Also fix black fill. pnmtotiff: Process one row at a time instead of reading entire image into memory. pnmstretch: convert from pnm to pam - pamstretch. 01.10.05 BJH Release 9.20 ppmtogif: Add -nolzw option. ppmntsc: do multiple images pnmtojpeg: fix bug from 9.19 causing crash on most images. ilbmtoppm: Correct cmyk -> rgb transformation. ppmtompeg: Fix bug due to missing "breaks". Thanks Wolfgang Mueller eyuvtoppm: fix memory leak, speed up by allocating working storage only once. libopt.c: replace strtok_r() with strtok() so it compiles on Mac OS X. 01.09.18 BJH Release 9.19 pnmtotiff: fix bug from 9.17 causing compile to fail with old Tiff library pnmtojpeg: Add -exif option. ppmtojpeg: Change to pnmtojpeg; PBM/PGM input causes grayscale output. pnmtotiff: Handle LSB2MSB FILLORDER. pnmtotiff: Fix -msb2lsb, -lsb2msb. Used to do nothing but set FILLORDER tag value. Make maxval of a PBM image read as a PGM image 255 instead of 1. libpbm: eliminate external data symbol pm_show_version so it works with Windows. Use subplatform-specific prefixes on Windows shared libraries. Thanks Charles Wilson . 01.09.04 BJH Release 9.18 Fix bug from 9.17: -lm now needed in jpegtopnm link. jpegtopnm: Add -dumpexif and -exif options. pnmtotiff: Fix bug: 16 bit samples byte-swapped on little- endian machines. Remove C++ comments from exif.c 01.09.03 BJH Release 9.17 Add ppmtoneo, neotoppm. Thanks Teemu Hukkanen . pnmtotiff: Add -flate, -adobeflate. Thanks Peter Creath. pnmindex: Fix bug with -size option. Thanks Andr Majorel pnmflip: Fix memory leak, plus make special case for PBM images that uses 12 times less memory. Thanks Stefan Roellin . tifftopnm: Fix incorrect interpretation of FILLORDER tag causing incorrect output with 16 bit samples and FILLORDER not msb2lsb. Thanks Don Reid . tifftopnm: Fix PHOTOMETRIC_MIN_IS_WHITE case. Thanks Don Reid . giftopnm: Fix bug with malformed GIFs that end prematurely. pbmtonokia: Convert C++ style comments to C style so Sun C compiler can handle them. Thanks Jon Parise . Install development package (header files, static libraries) by default. Add ability to build both static and shared libraries. Add merge/nonmerge to Makefile.config/configure, in place of special make targets. Fix Mac OSX build for gcc 3.0. Thanks m-sekino@mb.kcom.ne.jp (Masanori Sekino) Fix make install.hdr. Thanks m-sekino@mb.kcom.ne.jp (Masanori Sekino) 01.07.24 BJH Release 9.16 Builds on Darwin/Mac OS. Thanks m-sekino@mb.kcom.ne.jp (Masanori Sekino) Add pbmtopsg3. (Postscript G3 fax) Thanks Kristof Koehler Add pbmtonokia. Thanks Tim.Ruehsen@OpenMediaSystem.de. Add ppmrainbow. Thanks Arjen Bax . Add pamoil, as replacement for pgmoil. Based on ppmoil by Chris . ppmtogif: Add -alpha option. ppmtojpeg: fix bug: option takes as input filename. xpmtoppm: fix bug: Bogus EOF failure. Thanks "Dr. Larry Pyeatt" . pnmtopng/pngtopnm: update to Release 2.37.5 of the Pnmtopng package. Make -transparent option work like Pnmtogif -- you can add an "=" before the color to specify "exact". fix bug with background color and maxval = 65535. Fix a raft of bugs in pnmtopng from Netpbm 9.15. Remove Tiff library from the package. Proper naming of AIX and HP-UX shared libraries. giftopnm: Add color index to transparency message. Add some -R link options in make files. ppm3d: fix bug: ignores offset argument. tifftopnm: fix bug: shifted right one pixel. pnmshear: remove sscanf so it works better with Cygwin, convert to shhopt, clean up. pgmcrater: Remove black vertical line at right edge. Make craters wrap around the image (enables tiling of image). Thanks Arjen Bax. pgmtopbm: remove sscanf so it works better with Cygwin. Thanks Arjen Bax. Treat all white space, including DOS carriage returns, in color name db file as white space; Thanks Arjen Bax. 01.06.24 BJH Release 9.15 Change format specs to state that sample values are nonlinear instead of linear. pnmtopalm/palmtopnm: Handle PalmOS 4.0 16 bit direct color format. Thanks Bill Janssen . pnmgamma: Add CIE Rec 709 gamma correction option. pnmgamma: Add -ungamma option ppmcie: Add -rec709 color system option as default so that it produces true PPM output (per the new spec) and carefully document what the program generates. ppmcie (work done by Andrew Hamilton in May 1999 but not distributed): 1. Corrected the XYZ -> RGB transformation; 2. Eliminated the -interpwp option, a fudge which had been necessitated by the incorrect XYZ -> RGB transformation; 3. Added a Gamma correction, missing in the original; 4. Added the option to plot u' v' chromaticity instead of x y; 5. Added options to suppress labels and/or axes. pnmscale, pnmscalefixed: Fix bug with unwanted -verbose behavior. pnmscale, pnmscalefixed: Add -reduce option. Thanks Christopher W. Boyd ppmtoeyuv: Speed up by not freeing/reallocating storage for each image. Thanks "Steven M. Schultz" ppmtoeyuv: Fix memory leak. Eliminate pgm_pbmmaxval, ppm_pbmmaxval, and pnm_pbmmaxval from libpgm, libppm, and libpnm. 'maxval' argument to pgm_readpgmrow() and ppm_readppmrow() already accomplishes this. pnm_readpnmrow() changed to do same. external data symbols like this do not work with Mingw. various changes to accomodate Mingw (native Windows) and DLLs with Cygwin (Windows). eyuvtoppm: rewrite. Uses Netpbm libraries now. pstopnm: Remove gratuitous 5% margin. Add -equalpixels, -imageheight, and -imagewidth options. pnmtopng: Read only one row at a time, not the whole image, into memory. Do multiple passes through the (hopefully fully cached) file. This saves memory because pnmtopng's internal format may use 96 times as much space per pixel as the file. libpbm: Add pm_openr_seekable(), pm_seek(), pm_tell(). libppm: Add ppm_computecolorhash2(), ppm_computecolorhist2(). configure: fix bug with Solaris/Sun compiler. Split pbmplus.h into pm_config.h and pbm/pm.h to prepare for automatic generation of pm_config.h. Move pm_*() subroutines from libpbm1.c to new libpm.c for clarity. Remove malloc.h from 411toppm. malloc is included by pm_config.h, in platform-dependent way. 01.05.13 BJH Release 9.14 fix bug in shhopt causing wild branches. winicontoppm: Make alpha mask ("and") output PBM instead of PPM; correct sense so white is opaque, black transparent. ppmtoxpm: Add --alphamask option. Remove 256 color limit. xpmtoppm: Add --alphaout option ppmtogif: Add "=" to -transparent option to specify exact color. configure: change /bin/perl to /usr/bin/perl. Red Hat Linux doesn't have /bin/perl. pnm/Makefile: correct bugs in link. Thanks J Scott Berg Make it build on Unixware. Make it build on OpenBSD. document color indexing and histogram functions. 01.04.22 BJH Release 9.13 ppmtogif: fix divide by zero move much of README file into a new master man page, netpbm.1. pnmcomp: add -align and -valign options. Add thinkjettopbm. Thanks Eric Norum . Builds with Sun compiler. 01.03.25 BJH Release 9.12 Add 411toppm. Thanks Steve Allen . pnmcrop: add -sides option (does what was default behavior until July 2000) ppmtoeyuv: Use netpbm libraries, deal with multi-image input. Add color row color map and Floyd-Steinberg functions from ilbm package to libppm. ilbmtoppm, ppmtoilbm: replace with Ingo Wilken's version from April 13, 1995. jpegtopnm: fix crash with B&W JPEG input. pnmcomp: fix bug: invalid output image when overlay image is "higher" format than underlying image. ppmchange: fix bug: wouldn't work with maxval != 255. pnmtojbig: fix bug: it always says invalid maxval. Thanks Bill Davidsen. pbmtext: fix bug: output is sometimes "not implemented" because of uninitialized variable. pnmpsnr: rewritten so as not to use Fiasco library. Correctly handles maxval != 255. Works with PAM. Add IRIX to the configure program. Thanks Neil Franklin . make files: add ZLIB_DIR and ZHDR_DIR variables to Makefile.config. Thanks Bill Janssen. pcdindex: convert from csh to sh. Thanks Steve McIntyre. 01.02.20 BJH Release 9.11 pnmtopalm: Handle 16 bit direct color format. pnmtotiff: Add -xresolution and -yresolution options. Thanks Tim Ruehsen. Add error message to GNUMakefile for when GNU Make is too old. pnmpsnr: fix bug: PGM files always compared equal. libpbm: improve --version to reflect that libraries are usually dynamically linked now, so it's the version of libpbm, not the program itself. pbmtext: add -space option. asciitopgm: fix crash due to memcpy that should be memset. Thanks Philipp Knirsch . pktopbm: fix numerous bugs. Copied from Red Hat. By jcn 1998.09.22. pstopnm.csh: fix bomb when xres=yres. This program is obsolete (use pstopnm.c instead), but the patch was free, so why not? Copied from Red Hat. By Nalin Dahyabhai 2000.02.14. pnmtotiff: Make photometric for G3/G4 fax MINISWHITE instead of MINISBLACK. Add -minisblack option. Thanks Eric Smith . libppm/ppm_parsecolor: fix rounding error for very small maxvals (e.g. PBM files -- maxval = 1). pnmtopalm, palmtopnm: minor updates bmptoppm: handle BMPs that use ColorsUsed instead of bits per pixel to determine color map size. bmptoppm: add -verbose option. ppmquant: fix bug with maxval > 255 causing arithmetic overflow and arbitrary colors in output. 01.01.10 BJH Release 9.10 giftopnm: add -alphaout. ppmchange: Add -remainder option. Add pnmtopalm, palmtopnm. Thanks Bill Janssen . Add pnmmontage. Thanks Ben Olmstead . ppmtogif: Add -comment option. ppmtogif: fix bug: created GIF89 when it should have created GIF87. giftopnm: fix bug in displaying of comment extensions. jpegtopnm: Add -comments option. ppmtojpeg: Add -comment option. ppmtompeg: fix crash. Thanks Roger Southwick More work on separating source and build directories. GNU Make 3.77 or better now required. 00.11.20 BJH Release 9.9 add ppmtolj: color HP Laserjet graphics (PCL). Thanks Jonathan.Melvin@heywood.co.uk. ppmfade: add -mix option. ppmhist: add -noheader option. rawtopgm: Add --bpp, --maxval, and --littleendian options. pnmindex: Add -noquant, -title options. pnmtotiff: create 16 bits-per-sample Tiff files when maxval > 255 instead of crash. tifftopnm: handle 16 bits-per-sample Tiff files. pnmscale: Use floating point arithmetic instead of 12 bit fixed point to reduce distortion at right and bottom edge of large images with weird scaling factors. Add pnmscalefixed, which is the old fixed point pnmscale, which goes faster. But also fix bug in the fixed point version so the distortion isn't as bad. Add -verbose option. pnmcut: fix bug: right edge wrong or subscript out of bounds. Thanks MURAKAMI Masahiko , Sven Over , Frederic Vivien , Pete Weisz . xpmtoppm: fix reading of 4-character color codes; handles "NONE" color (transparent background); add -v. Thanks Martin Vermeer . ppm/Makefile: fix bug: ppmtompeg, hpcdtoppm not installed. Thanks Mike Castle . ppmpspread: fix bug: invalid memory reference crash. Thanks digger , john joseph iii casey . ppmchange: fix bug: every other argument pair ignored. Thanks Sven Over . Fix error message in pXmmerge (no pm_error()). Thanks Pete Weisz , libppm: add /usr/X11R6/lib/X11/rgb.txt as default rgb.txt file. Thanks ceder@lysator.liu.se (Per Cederqvist). Replace hpcdtoppm version 0.3 (1992) with 0.6 (1994). Add pcdindex. Build fixes for Tru64. Thanks Phil Benchoff . Makefile.config: option to not strip binaries on install. 00.09.01 BJH Release 9.8 jpegtopnm: Add -adobe, -notadobe options. ppmchange: Add -closeness. giftopnm: report transparency information. jpegtopnm: Accept single-hyphen options. Make it build on DJGPP. 00.08.12 BJH Release 9.7 sgitopnm: add -channel option to access more than 3 channels. Thanks Smarasderagd. pnmcut: Add -pad option ppmtobmp: change default from -os2 to -windows. pnmcut: fix bug: height argument misinterpreted. ppmquantall: fix bug: don't crop white borders off images yuvtoppm: fix bugs: don't depend on bigendian representation of integers. reject odd-width images. ppmtoyuv: fix bug: reject odd-width images. anytopnm: fix bug: required nonstandard shell feature. giftopnm: fix bug: when image consists of two gray colors, program converted them to black or white and created PBM file. Thanks Smarasderagd. Also fix memory leak. Make changes since 9.2 build on Cygwin. 00.07.12 BJH Release 9.6 Add pnmtofiasco, fiascotopnm, psnpsnr. Thanks to Ullrich Hafner. Make Pnmcrop use a temporary file instead of huge amounts of memory. bmptoppm: fix crash when OS/2 BMP file has > 8 bits per pixel. anytopnm: fix bug (from 9.0) wherein program almost always crashed. Add gzip, bzip, bzip2 capability. Thanks Charles Howes. parallel.c: Work around SunOS libc problem. Define some newer libtiff macros so it compiles against older libtiff. 00.07.01 BJH Release 9.5 Extend formats to allow multiple images per file. Add -allimages option to pnmfile. Add pnmsplit. Extend pnmtops. Add pbmtowbmp, wbmptopbm. Thanks Terje Sannum. ppmtobmp: Add 24 bit (truecolor) capability. Remove Release 8.3 colormap size update. pnmcut: easier, more expressive syntax for specifying what to cut. pnminterp: handle maxval != 255, convert to use Netpbm libraries. Translate pstopnm from Csh to C, eliminate dependency on the 'bc' program. Fix bug in tiff library build which caused null soname. Add optParseopt2() to shhopt.a so you can use long options with one hyphen instead of two. giftopnm: fix bug with variable used before set. Fix bug (coding error -- 0=>i). Unknown impact. bmptoppm: fix bug with 24 bit (truecolor) Windows BMPs. xwdtopnm: fix one more bug with bits_per_item <> bits_per_pixel. Fix ppmtompeg build bug with static libraries. Make build clean with gcc -ansi (albeit with some files that need extensions declaring the _BSD_SOURCE etc.). 00.06.04 BJH Release 9.4 Rebase pnmtopng, pngtopnm on Pnmtopng 2.37.4. pbmtolj: fix bug where blank lines get discarded. Thanks Charles Howes. ppmtompeg: fix bug with "PNM" format files with maxval != 255. Get rid of built-in PPM file parsing. Fix 'make install' where mkinstalldirs is not found. Fix bug where rle_global.c would not compile with GNU C Library 2. 00.06.01 BJH Release 9.3 pnmfile: check for file size error. ppmhist: handle larger maxvals, image sizes xwdtopnm: Use color map with DirectColor to fix wrong color bug on some DirectColor xwds. xwdtopnm: Correct bug with 24/32 DirectColor LSBfirst xwds. Add pXmcheck() library function. Add leaftoppm and ppmtoleaf. Thanks Bill O'Donnell. Add winicontoppm and ppmtowinicon. Thanks Lee Benfield. Add pgmslice. Thanks to Jos Dingjan. Include subset of RLE library in the package. stamp-date doesn't rely on whoami. Make file fixes to accomodate more install programs. Replace tmpnam() with mkstemp(). Add pXm_init() into all programs that didn't have it. 00.05.15 BJH Release 9.2 Shared libraries now build properly for Solaris, SunOS, NetBSD. Add jbigtopnm, pnmtojbig. Thanks to Markus Kuhn. Add pnminterp, pnminterp-gen by Russell Marks. Add pbm_writepbmrow_packed() and pbm_readpbmrow_packed() to libpbm. ppmdither: fix bug with input maxval != 255. Make output maxval the LCM of the requested numbers of primary levels. xwdtopnm: works with files where there aren't an integeral number of pixels per storage unit (e.g. 24 bits per pixel) Add some missing pXm_init() Make pXmmerge source code automatically generated. 00.05.06 BJH Release 9.1 Add pbmtoppa (renamed from pbm2ppa, renamed from print-pbm). Thanks Tim Norman. Add pbmpage. Thanks Tim Norman. Add pbmtomda, mdatopbm. Thanks John Elliott. Replace gemtopbm with gemtopnm. Thanks to John Elliott. Add ppmntsc: change colors to those acceptable for ntsc or pal. Rename old ppmntsc to ppmtv. pbmtolj: Add compression (-delta, -packbits, -compress) by Dave Platt Look for both /usr/lib/X11/rgb.txt and /usr/openwin/lib/rgb.txt by default. Improved error messages if file not found. pbmtext: renders character codes 0x80-0xff and 0x00-0x1f as whatever the font says, rather than always blank. Thanks Helge Oldach. Fix bug in parsing of rgb.txt file in ppm_colorname(). Add optional static library build to make files. Fix a bunch of build bugs for Solaris, SunOS. Still not all the way there. Thanks Richard Curnow, Philippe Brieu, Benjamin Kuit. Make it build on Cygwin. Thanks Pierre Humblet. Use rm -f;ls instead of ls -sf in make files; some systems don't have ln -f. 00.04.15 BJH Release 9.0 Add the 16-bit-per-sample format for maxval > 255. Change size of samples in the library interface from 8 bits to 32 bits. Library write routines now create the new 16 bit format instead of plain format when you request a maxval > 255 and not 'forceplain'. Make all programs read the new format, and all programs that convert to PNM from a >8 bit input generate it instead of failing or normalizing. Make pnmdepth generate it. pnm_readpnminit(), etc. fails if you request a maxval > 65535 and not 'forceplain'. It used to generate plain format in that case, but you couldn't actually specify a sample value > 255. Add pnmtorle and rletopnm from the Army High Performance Computing Research Center. add ppmcolormask - creates a mask of areas of a certain color in an image. anytopnm: fix infinite loop pbmtext: Ignore non-8-bit characters in bdf files instead of crashing. ppmdither: fix crash with large dithering matrix dimensions. Rename ppmtompeg/headers/search.h to motion_search.h to avoid possible confusion with the OSF system file search.h Fix erroneous shhopt.h dependency in build. 00.04.03 BJH Release 8.4 Add ppmtompeg, adapted from Berkeley's mpeg_encode. Add eyuvtoppm and ppmtoeyuv, and vidtoppm, from Berkeley mpeg tools. Add ppmfade, adapted from Wesley C. Barris' pbmfade. Add ability to extract the alpha channel to tifftopnm, tgatoppm, and ximtoppm. (It's already in pngtoppm, and still missing from ilbmtoppm). pnmtotiff: Change default compression to none, due to removal of LZW capability from Tiff library. Make merge build use symbolic links instead of hard links. Include dependent libraries in the link of the libraries. This is necessary on some systems, and a good idea on others. Use strerror() instead of sys_errlist[] everywhere. If some systems do not have the former, we need to do some work, because strerror() was already used in some places. We do have a report of a BeOS system with no sys_errlist[]. 00.03.24 BJH Release 8.3 Add pnmshadow, by John Walker , dated 1997.08.15. Add ppmlabel, by John Walker, dated June 1995. Add ppmcie by John Walker, dated September 1994. Add character drawing routines by John Walker to libppm. Add sbigtopgm by John Walker, dated January 1998. Handle BMP file color map size parameter in ppmtobmp, bmptoppm. Thanks Marc Moorcroft. Rewrite make files, fix lots of make install bugs. 00.03.20 BJH Release 8.2 Add ppmtojpeg and jpegtopnm. Rename pnmnoraw to pnmtoplainpnm. Add CMYK capability to tifftopnm. Major make file rewrite, especially making install work. Pnmmerge is no longer the default. Shared libraries are. Add pnmtotiffcmyk. Written by Andrew Cooke (Jara Software) jara@andrewcooke.free-online.co.uk 00.03.02 BJH Release 8.1 00.03.02 BJH Add pnmtopng and pngtopnm. I got these from ftp://ftp.au.netbsd.org/pub/NetBSD/packages/distfiles today. Release 2.37.3. I added an "unsigned" and changed the type of 'scaleval' to quiet compiler warnings. 00.03.01 BJH Fix xwdtopnm interpretation of 16 bit TrueColor files. Thanks to Martin Kroeker, mk@daveg.com. 99.09.23 BJH Update xbmtopbm to recognize newer xbm format. CHANGES TO NETPBM THROUGH MARCH 1994 ------------------------------------ Functional changes to Netpbm since 13 October 1993. Minor bug fixes and compatibility fixes are not documented in this file. PBM libpbm1.c strstr() added to libpbm1.c. libpbm5.c BDF font support added. pbmtext BDF font support added. pbmto4425 New filter. pbmtoln03 Command line parsing changed to Pbmplus standard. PGM pgmnoise New filter. PPM picttoppm Updated ppm3d New facility. ppmchange New filter. ppmdim New filter. ppmflash New filter. ppmmix New filter. ppmntsc New filter. ppmqvga Option parsing changed to Pbmplus standard. ppmshift New filter. ppmspread New filter. ppmtoxpm Prototypes added. xpmtoppm Prototypes added. ilbmtoppm Updated. ppmtoilbm Updated. PNM pnmtoddif New filter. pnmhistmap New facility. pnmtops New option (-nocenter) added. Functional changes to Netpbm since 7 December 1993. Minor bug fixes and compatibility fixes are not documented in this file. PGM asciitopgm New filter. fitstopgm Replaced by fitstopnm. pgmtofits Replaced by pnmtofits. pgmtopbm Upgraded. pgmkernel New filter. PPM ppmchange Upgraded. xvminitoppm New filter. PNM pnmalias New filter. pnmtofits Replacement for pgmtofits. fitstopnm Replacement for fitstopgm. pnmtosgi New filter. sgitopnm New filter. pstopnm New filter. CHANGES BETWEEN PBMPLUS AND THE ORIGINAL NETPBM ----------------------------------------------- The following is new in Netpbm (compared to Pbmplus): PBM pbmtext BDF font support added. pbmto4425 Display on an AT&T 4425 Ascii terminal. pbmtoascii A new improved version. pbmtoln03 Convert to DEC LN03+. pbmtolps Fast PostScript creator. pbmtopk Conversion to/from a packed (PK) format font. pktopbm pbmclean Flip isolated pixels. pbmpscale Enlarge pbm image with edge smoothing. PGM asciitopgm Convert an ascii image into pgm. pbmtopgm Convert pbm to pgm by averaging areas. rawtopgm Handles input files without specification of the file size, assuming the input image is quadratic. It also supports a -tb (top bottom flip) option. bioradtopgm Conversion utility for files created by Biorad confocal microscopes. spottopgm Convert SPOT satellite images to pgm. pgmkernel Generate a convolution kernel. pgmnoise Create a pgm file with random pixels. PPM bmptoppm Conversion to/from windows bitmap format. ppmtobmp ppmtogif Updated version. giftoppm Removed (see giftopnm). ppmtoilbm Updated version. ilbmtoppm picttoppm Updated version. ppmtopict ppmtoxpm Updated version, which supports xpm version 3. xpmtoppm ppmtomap Extract all colours from a ppm file. ppmtomitsu Convert to Mitsubishi S340-10 printer format. xvminitoppm Convert an XV thumbnail picture to ppm. ppmtoyuvsplit Conversion to/from YUV triplets. (MPEG / JPEG). yuvsplittoppm ppm3d Create a red/blue stereo image. ppmbrighten Change image saturation and value on an HSV map. ppmchange Change all pixels of one colour to another in a portable pixmap ppmdim Dim a ppm file down to total blackness. ppmdist Simplistic grayscale assignment for machine generated colour images. ppmflash Brighten a picture up to complete white-out ppmmix Blend together two portable pixmaps. ppmnorm Normalize the contrast in a portable pixmap. ppmntsc Make a portable pixmap look like taken from an American TV. ppmqvga Eight plane quantization. ppmshift Shift lines of a portable pixmap left or right by a random amount. ppmspread Displace a portable pixmap's pixels by a random amount. ppmtopjxl Convert a ppm file into an HP PaintJet XL PCL file. PNM pnmtops New option (-nocenter) added. pnmtofits Replacement for pgmtofits/fitstopgm fitstopnm pnmtosgi Conversion to/from sgi image format. sgitopnm pnmtosir Conversion to/from Solitaire image recorder format. sirtopnm giftopnm Replaces giftoppm. Examines the input image and produces a pbm, pgm, or ppm output. pstopnm Convert PostScript to pnm. Requires Ghostscript. zeisstopnm Conversion utility for files created by Zeiss confocal microscopes (the old standard). pnmalias Anti aliasing filter. pnmcomp Composite two portable anymaps together. pnmcrop New options added. pnmpad Add borders to anymap. LIBTIFF A new release of libtiff is included. Please read its supporting documentation. CHANGE LOG FROM PBMPLUS ----------------------- Changes since the 30oct91 patch version: Fixed uninitialized variable in ppmtotga. (John Walker) Added pgmcrater, ppmforge, ppmtoacad, sldtoppm. (John Walker) Slight change to the p?mmerge.c front-ends to allow for main programs that return instead of exitting. Minor clarifications to the pnmconvol man page. Fixed xwdtopnm to read some 16-bit True/Direct files. (David Elliott) Fixed uninitialized variables in pnmtotiff. (Larry Rosenstein, Bayles Holt) Added a couple of checks for \r while reading whitespace. (Larry Rosenstein) Removed all the BROKENPUTC stuff. Now we ignore all return values from putc(), and check ferror() in pm_close(). Added pm_close() calls to many of the filters. Fixed pnmdepth to check for too-large newmaxvals. Improved rounding in pnmdepth and PPM_DEPTH macro. (Tom Lane) Minor fix to ppmtouil. (Mohsen Banan) Added new Imakefiles. (Rainer Klute) Changes since the 05oct91 X11R5 contrib tape version: Fixed minor SysV config error in pbmplus.h. (Tom Lane) Fixed tifftopnm so that BITSPERSAMPLE and SAMPLESPERPIXEL default correctly. Fixed possible bug in tgatoppm line-interleaving code. (Arthur David Olson) Fixed tifftopnm so that colormapped files are read correctly. (PauL Drews, Mike Wade) Corrected use of DefaultRGBDatabase / RGB_DB for imake sites. (Randal L. Schwartz) Bugfix to pnmtops color PostScript in -rle mode. (Angus Duggan) Added auto-turning to pnmtops. Added run-length encoding to ppmtotga. Space optimization to pgmoil. Changes since the 27sep91 comp.sources.misc distribution: Fixed spelling error in giftoppm. Fixed ppmrelief to not shrink the image by 2 rows and columns. Minor fix to pgmramp. Fixed off-by-one error in pnmtoxwd. Man page fix for pnmgamma. (Arthur David Olson) Converted ANSI trigraphs in ppmtosixel into good old octal. (Jeff Glover) Fix to 24/32 bit case in rasttopnm. (Behr de Ruiter) Float/double portability fix to libppm4. (Bruce Holmer, Ronald Khoo) Fixed typo in compat.ksh. (Larry Virden) Fixed int/short incompatibility in tifftopnm. (Salik Rafiq) Changes during the extended beta test period, starting on 15jan91: Lots of fixes from: Anthony A. Datri, Arthur David Olson, David Brooks, David Elliott, Doug Claar, Duncan Sinclair, Francois Pinard, Gerard Leurs, Jim Hanko, Ken Laprade, Klaus U. Schallhorn, Markus Bolz, Mike Hench, Philip Gladstone, R C Smith, Selden E. Ball, Jr., Stephen Uitti, Steve Allen, Tom Lane, update.kpj-jaakkola@athena.dsv.su.se, Charles Karney, Unmesh Agarwala, Ed Pendzik, Juha Sarlin, Tom Tulinsky, Phillip Smith, Lai-King Mau, David Koblas, Mark Donovan. Added a global -version flag. Added bunches of statics and prototypes. Now compiles with zero warnings under gcc -ansi -pedantic. Changed #ifdef __STDC__ to #if __STDC__, since some non-compliant compilers define it as 0. Changed pm_message and pm_error to be varargs routines. Added a portable version of vfprintf for those systems which don't have it. Removed the option of not compiling the pgm and ppm parts. Very few people used it, and it added amazing complexity to the pnm programs, turning them into maintenance nightmares. Merged pbmpaste into pnmpaste. Merged pgmtops and ppmtops into pnmtops. Added auto-scaling and dpi / page size flags to pnmtops. Changed the interpretation of bits in pbmlife to conform with other tools. Changed xwdtopnm to ignore the pixel number in the xwd color structure. Added a -pseudodepth flag to pnmtoxwd. Updated tifftopnm for libtiff 2.4. Added many option flags to pnmtotiff. (J.T. Conklin) Added support for X11R5's new color specifiers rgb: and rgbi:. Added pgmtexture. (James Darrell McCauley) Added ppmtopj, pjtoppm, and ppmdither. (Christos Zoulas) Added ppmtotga. (Mark Shand) Added ppmtosixel. (Rick Vinci) Added pbmtoatk and atktopbm. (Bill Janssen) Added ppmtoyuv and yuvtoppm. (Marc Boucher) Fixes to picttoppm. (George Phillips) Added 24-bit support to ilbmtoppm. (Mark Thompson) Changes since the X.V11R4 / comp.sources.misc distribution of 22nov89: Added pgmramp, pgmedge, pgmtoppm, rgb3toppm, ppmtoxpm, pnmgamma, ximtoppm, pgmtofs, picttoppm, ppmtopict, ppmquantall, anytopnm, pi1toppm, ppmtopi1, sputoppm, spctoppm, pbmto10x, ppmtoicr, ppmmake, xpmtoppm, ppmtopuzz, ppmtouil, ybmtopbm, pbmtoybm, lispmtopgm, pgmtolispm, pbmtogem, pi3topbm, pbmtopi3, pbmtoepson, pbmtoplot, pbmtozinc, pbmtext, pnmnoraw, pnmmargin, pnmfile, pnmindex, ppmtorgb3, gouldtoppm, pgmbentley, pgmoil, ppmrelief, pnmtotiff, ppmtopcx. Merged some filters: rasttopbm and rasttoppm into rasttopnm; pbmtorast and ppmtorast into pnmtorast; xwdtopbm and xwdtoppm into xwdtopnm; pbmtoxwd and ppmtoxwd into pnmtoxwd. Promoted some filters: pcxtopbm to pcxtoppm; ppmarith to pnmarith; ppmconvol to pnmconvol; ppmcscale to pnmdepth; ppmrotate to pnmrotate; ppmscale to pnmscale; ppmshear to pnmshear; ppmsmooth to pnmsmooth; tifftopgm to tifftopnm - new version based on Sam Leffler's libtiff. Bugfixes to pbmtoicon, ppmtops. The Makefiles now have a "merge" option. All flags are now case-insensitive. Added $(MAKE) stuff to Makefile. Changed pnmsmooth from a csh script to a sh script. Made macro use in pbmtox10bm and pbmtoxbm more portable. Moved compataliases to compat.csh, and added compat.ksh. Made ppmtoilbm less Amiga-specific. Added -headerskip and -rowskip flags to rawtopgm. Enhanced rasttopnm to interpret 8-bit rasters with no colormap as grayscale. Changed sscanf %g to %f - some systems can't handle %g on input. Added -expand flag to pbmmask. Speedup to pnmflip - don't buffer if possible. Added color-name-to-value routine to ppm - uses X11's rgb.txt if present. Updated Imakefile support to reflect X.V11R4. Removed picttopbm. Improved pnmcut argument syntax so that negative coords work like pnmpaste. Added "magic" file, for use with the "file" program. 40% speedup for pgmnorm from Robert Stockton (rgs@cs.cmu.edu). Fixed long-standing bug involving colormaps on SPARCstations when compiled with gcc -- had to do with passing structs by value. Removed the -x flag from pnmtorast -- it's not really needed. Fixed subtle bug in the pnm reading code that caused pnmcat to blow it on images that differed greatly in width or height. New version of giftoppm that handles the GIF89a standard, and doesn't use fseek. Fixed fitstopgm to handle three-axis images, such as the Hubble pix. Xwdtopnm and pnmtoxwd finally handle byte-order properly. Added -xysize flag to pnmscale. Added conditional ANSI function prototypes to library routines. Added -noantialias flag to pnmrotate and pnmshear. Removed the TIPS file. No one ever sent in any new tips, so I just moved the few I had into the relevant man pages. That's probably where they belonged in the first place. Added justification flags to pnmcat. Added -map flag to ppmquant - user-specifiable colormap. Also, the Floyd-Steinberg error diffusion finally works right. Added -map flag to pgmtoppm. Added DirectColor support to xwdtopnm and pnmtoxwd. Speedup to pgmtolj from Arthur David Olson: avoid sending whitespace. Fix to pbmtogo from Bo Thide': 2D compression now works. Patch 1 to the X.V11R4 / comp.sources.misc distribution of 22nov89: Fixed bug in pgmtops -rle. Changes since the alt.sources distribution of 13sep89: Small corrections to ppmtorast, pgmtops. Moved pbm/tifftopbm to pgm/tifftopgm - it now handles grayscale TIFF files. Fixed tifftopgm to handle non-native byte order. Changes to tifftopgm to handle bogus AppleScan TIFF files, to have better command syntax, and to use stdio. Optimizations to xbmtopbm, pbmtoxbm, and pbmtox10bm, courtesy of Juha Sarlin, to make them go about three times as fast. Optimization to pgmtops and ppmtops to make them go three times as fast. Optimization to pnmcrop. Added PBMPLUS_BROKENPUTC defines in pbmplus.h to handle systems (such as ULTRIX) which have broken putc() macros. Rewrote ppmscale, pnmcat, and pgmhist to operate line-by-line, instead of reading in the whole image. Rewrote pnmflip to keep only one copy of the image in memory. Added pgmtofits, courtesy of Wilson H. Bent, plus bugfixes to fitstopgm and a patch to giftoppm to handle black&white GIF files. Added picttopbm and rawtopgm. Fixes to xwdtoppm and ppmtoxwd so they compile with SunOS cc as well as gcc. Another small change to ppmtoxwd having to do with colormap size. Changed macptopbm's -headersize flag to be -extraskip. Changed tgatoppm to read color values as BGRA instead of ARGB; the Targa documentation is apparently wrong about the order. Some changes to the Makefiles, partially to work around bugs in gnumake. Got g3topbm working, and added pbmtog3, courtesy of Paul Haeberli. Added some pixrect work-alike code so that rasttopbm, pbmtorast, rasttoppm, and ppmtorast can be used on non-Sun systems. This also provides a final solution to the persistent byte- and bit-order problems on 386's. Moved the SYSV-checking #ifdefs to *after* the include of pbm.h, which defines SYSV. Made all the #else's and #endif's ANSI-compliant. Added manual pages for libpbm, libpgm, libppm, and libpnm, courtesy of Tony Hansen. Changed man page installation so that pages from different sections can go in different directories. Fixed Imakefiles. Changes since the expo.lcs.mit.edu FTP distribution of 06sep89: Added #ifdefs to pnm/libpnm3.c to allow the PBM-PNM-only configuration. Small corrections to TIPS, pnm/Makefile, pnm/Imakefile, ppm/ppmrotate.1, ppm/ppmshear.1, ppm/ppmtoilbm.c, pbm/xwdtopbm.c, ppm/xwdtoppm.c, ppm/ppmtoxwd.c, ppm/ppmtoxwd.1, pbm/x11wd.h. Changes since the comp.sources.misc distribution of 31oct88: Added pbmreduce, pbmlife, pbmmask, and pbmupc. Added gemtopbm, tifftopbm, pcxtopbm, pbmtogo, mgrtopbm, pbmtomgr, cmuwmtopbm, pbmtocmuwm, g3topbm, and pbmtobg. Minor bugfix to pbmtolj. Slight restructuring of most of the programs to use vastly less memory. Various other minor optimizations. Fixed pbmtorast and rasttopbm to handle byte-swapped big-endian 386 boxes. Slight changes to argument syntax of pbmcrop, pbmmake, pbmreduce. Moved to the new PGM package: pbmtops (which now produces Conforming PS). Moved to the new PPM package: giftopbm. Moved to the new PNM package: pbmcrop pbmcut pbmenlarge pbminvert. Consolidated into a single pnmflip tool: pbmfliplr pbmfliptb pbmtrnspos. Consolidated into a single pnmcat tool: pbmcatlr pbmcattb. Added compataliases script for upward compatability with changed tools. Removed xxxtopbm. Added a -headersize flag to macptopbm, to help get around annoying problems in MacPaint file format. Added the RAWBITS compilation-time option, to use a more compact and much faster (but less portable) external format. Removed the CBM format - use compress(1) and / or RAWBITS instead. Pbmpaste (and the new pnmpaste) now accepts negative x and y coords, which are interpreted relative to the right and bottom sides. Changed all programs to accept a "-" file argument as meaning standard input. Removed pbmtox10wd, since it was never very useful (X10 doesn't have xwud). Added Imakefiles, for X11 types to use. Changes since the X.V11R3 distribution of 31aug88: The cbm format has been revised to support run-length encoding. Pbmtops now does run-length encoding. Major changes since the X.V11R2 distribution of 28mar88: The pbm format now has a "magic number". New conversion filters: brushtopbm, giftopbm, pbmtolj, pbmtomacp, pbmtoxwd, and pbmtox10wd. Icontopbm converter has a better parser -- it knows to skip over any extraneous comments at the beginning of the icon file. Pbmtops generates a different PostScript wrapper program -- it should handle huge bitmaps better. Xwdtopbm now handles byte-swapping correctly. Pbmmake takes a flag to specify the color of the new bitmap. Pbmpaste now implements 'or', 'and', and 'xor' operations as well as the default 'replace'. netpbm-free-10.0-1/Makefile0100644004714500471450000000130607716230207015763 0ustar aba-guestaba-guest# The Netpbm make files exploit features of GNU Make that other Makes # do not have. Because it is a common mistake for users to try to build # Netpbm with a different Make, we have this make file that does nothing # but tell the user to use GNU Make. # If the user were using GNU Make now, this file would not get used because # GNU Make uses a make file named "GNUmakefile" in preference to "Makefile" # if it exists. Netpbm is shipped with a "GNUmakefile". all merge install clean dep: @echo "You must use GNU Make to build Netpbm. You are running some " @echo "other Make. GNU Make may be installed on your system with " @echo "the name 'gmake'. If not, see http://www.gnu.org/software ." @echo netpbm-free-10.0-1/Makefile.common0100644004714500471450000003617207724372231017266 0ustar aba-guestaba-guest# This is a make file inclusion, to be included in all the # Netpbm make files. # This file is meant to contain rules that are substantially the same # in each of the pbm, pgm, ppm, and pnm subdirectory makes, to avoid # duplication of effort. # The following variables must be set in any make file that uses these # rules: # # SRCDIR: The top level directory of Netpbm source code. # BUILDDIR: The top level directory into which Netpbm is built (built, # not installed). Right now, this is always = SRCDIR, but some day, they # may be separate. # OBJECTS: .o files to be built from .c files with the standard rule. # PORTBINARIES: list of conventional executables to be built with the standard # rule # MATHBINARIES: list of conventional executables to be built with the standard # rule, but that need math functions too. # LIBROOT: pbm, pgm, ppm, or pnm, whichever is the root of library names # for this build. # MAJ: major number of shared libraries # MIN: minor number of shared libraries # The minor number in the filename corresponds to the point release of # Netpbm at which the library last changed. Do not change the major # number (and soname) unless the new library is not backward compatible. # LIBOBJECTS: list of the object files that make up the library, all of which # are to be built with the standard rule for library objects. # LIBOBJECTS_X: same as LIBOBJECTS, but not built with standard rule # NETPBMLIBSUFFIX: the suffix, e.g. "so" for the main libraries we build, # whatever type they may be. # STATICLIBSUFFIX: the suffix, e.g. "a" on a static library. This need # not be defined if the user doesn't want to build a static libraries in # addition to the main libraries. # BINARIES: list of all the executables that need to be installed. # MERGEBINARIES: subset of BINARIES that can be included in a merge build # NOMERGEBINARIES: subset of BINARIES that cannot be included in a merge build # INSTALLBINARIES: directory where binaries and Windows DLLs need to be # installed. # SCRIPTS: list of all the scripts that need to be installed # INSTALLSCRIPTS: directory where scripts need to be installed. # MANUALS1: list of all the topic names of Section 1 man pages that need # to be installed (e.g. "pnmtotiff" for the Pnmtotiff man page). # SUFFIXMANUALS1: suffix for Section 1 man pages (typically "1"). # INSTALLMANUALS1: directory where Section 1 man pages need to go. # (Analogous variables for Sections 3 and 5) # INSTALLLIBS: directory where shared libraries (except Windows DLLs) and other # data files need to be installed. # INSTALLSTATICLIBS: directory where link-time libraries (those used at # link time but never run time -- i.e. static libraries and dynamic library # stubs) need to be installed. # MANCP: command to use to copy man pages where they belong. Typically "cp". # INSTALL: command to use to copy files to where they belong # INSTALL_PERM_BIN: file permissions for installed binaries # INSTALL_PERM_LIB: ...same for libraries # INSTALL_PERM_HDR: ...same for headers # INSTALL_PERM_MAN: ...same for man pages # MERGENAME: name of the merged executable (e.g. pbmmerge). # MERGE_OBJECTS: list of object files that make up the merged executable, # not counting the master object (e.g. pbmmerge.o). All of these are to # be built with the standard rule for merged objects. # NETPBMLIBS: list of Netpbm libraries needed by the merged executable # being built # LIBLIBS: list of Netpbm libraries needed by the Netpbm library being built. # CC: C compiler command for the merge main object # CFLAGS: C compiler general options for the merge main object # CFLAGS_SHLIB: Extra C compiler options for compiling a .o file that will # be in a shared library. (usually null or -fpic). # LD: linker command # LDFLAGS: linker options # INCLUDE: Compiler option string to establish the search path for include # files when compiling things or computing dependencies (make dep). # Some day, SRCSUBDIR will be the subdirectory of the source tree that # corresponds to the current directory, which is a build subdirectory. # For example, the source might be in /usr/src/netpbm (so # SRCDIR=/usr/src/netpbm) but the build directory might be /tmp/buildnetpbm # (so BUILDDIR=/tmp/buildnetpbm). The current directory is # /tmp/buildnetpbm/pgm and SRCSUBDIR=/usr/src/netpbm/pgm. ifeq ($(SRCSUBDIR)x,x) SRCSUBDIR := $(CURDIR) endif LIBOPT = $(BUILDDIR)/buildtools/libopt NETPBMLIB := $(SRCDIR)/lib/shared/libnetpbm.so all: build.bin $(NETPBMLIB): make -C $(SRCDIR) build.lib.default build.bin: $(BINARIES) INCLUDE := $(INCLUDE) -I $(SRCDIR)/include/ # We build the symbolic links to header files in the current directory # just so the compile commands don't have to be littered with -I's. $(BUILDDIR)/Makefile.config: $(BUILDDIR)/Makefile.config.in $(MAKE) -C $(BUILDDIR) Makefile.config # Rule to make C source from lex source. %.c:%.l $(LEX) -t $< >$@ # Rule for objects. $(OBJECTS): %.o: $(SRCSUBDIR)/%.c # Note that the user may have configured -I options into CFLAGS. $(CC) -c $(INCLUDE) $(CFLAGS) $(CDEBUG) -o $@ $< # Rules for conventional single-object file executables $(PORTBINARIES): %: %.o $(NETPBMLIB) # Note that LDFLAGS might contain -L options, so order is important. $(LD) -o $@ $@.o $(NETPBMLIB) $(LDFLAGS) $(CDEBUG) # Same as above, but needing math functions $(MATHBINARIES): %: %.o $(NETPBMLIB) # Note that LDFLAGS might contain -L options, so order is important. $(LD) -o $@ $@.o -lm $(NETPBMLIB) $(LDFLAGS) $(CDEBUG) # MERGE STUFF $(MERGE_OBJECTS): %.o2: $(SRCSUBDIR)/%.c # Note that the user may have configured -I options into CFLAGS. $(CC) -c $(INCLUDE) $(CFLAGS) "-Dmain=main_$*" \ $(CFLAGS_MERGE) $(CDEBUG) -o $@ $< merge.h: $(SRCDIR)/buildtools/make_merge.sh $(MERGEBINARIES) $(MERGENAME).o: $(SRCSUBDIR)/$(MERGENAME).c merge.h # $(HEADERLINKS) $(CC) $(CFLAGS) -Wno-implicit $(INCLUDE) $(CDEBUG) -c -o $@ $< $(MERGENAME): $(MERGENAME).o $(MERGE_OBJECTS) $(NETPBMLIB) # Note that LDFLAGS might contain -L options, so order is important. $(LD) -o $@ $< $(MERGE_OBJECTS) \ $(NETPBMLIB) -lm $(LDFLAGS) $(CDEBUG) ############################################################################# # BUILDING THE LIBRARIES ############################################################################# #---------------------------------------------------------------------------- # Following are rules for building shared libraries. # Note that the user may specify a shared library as his "main" library # type, but request a static library in addition. #---------------------------------------------------------------------------- $(LIBOBJECTS): %.o: $(SRCSUBDIR)/%.c # $(HEADERLINKS) # Note that the user may have configured -I options into CFLAGS. $(CC) -c $(INCLUDE) $(CFLAGS) $(CFLAGS_SHLIB) $(CDEBUG) -o $@ $< SONAME = lib$(LIBROOT).so.$(MAJ) ifeq ($(NETPBMLIBTYPE),unixshared) # The libxxx.so link is needed to link the executables. lib$(LIBROOT).$(NETPBMLIBSUFFIX): $(SONAME) rm -f $@ $(SYMLINK) $< $@ # The $(SONAME) link is only needed to test the programs without # installing the libraries (in that case, you also need to direct the # dynamic linker to the source directories, e.g. set LD_LIBRARY_PATH). $(SONAME): lib$(LIBROOT).$(NETPBMLIBSUFFIX).$(MAJ).$(MIN) rm -f $@ $(SYMLINK) $< $@ lib$(LIBROOT).$(NETPBMLIBSUFFIX).$(MAJ).$(MIN): \ $(LIBOBJECTS) $(LIBOBJECTS_X) $(LIBLIBS) $(LIBOPT) $(LD) $(LDSHLIB) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \ `$(LIBOPT) $(LIBLIBS)` -lc $(CDEBUG) endif ifeq ($(NETPBMLIBTYPE),dll) $(NETPBMSHLIBPREFIX)$(LIBROOT).dll: $(LIBOBJECTS) $(LIBOBJECTS_X) $(LIBLIBS) $(LIBOPT) dlltool -z lib$(LIBROOT).def --export-all-symbols \ $(LIBOBJECTS) $(LIBOBJECTS_X) $(LD) $(LDSHLIB) -Wl,-soname,$(NETPBMSHLIBPREFIX)$(LIBROOT).dll \ -Wl,--out-implib,lib$(LIBROOT).dll.a -o $@ lib$(LIBROOT).def \ $(LIBOBJECTS) $(LIBOBJECTS_X) `$(LIBOPT) $(LIBLIBS)` $(CDEBUG) endif ifeq ($(NETPBMLIBTYPE),dylib) lib$(LIBROOT).dylib: lib$(LIBROOT).$(MAJ).dylib rm -f $@ $(SYMLINK) $< $@ lib$(LIBROOT).$(MAJ).dylib: lib$(LIBROOT).$(MAJ).$(MIN).dylib rm -f $@ $(SYMLINK) $< $@ lib$(LIBROOT).$(MAJ).$(MIN).dylib: $(LIBOBJECTS) $(LIBOBJECTS_X) $(LIBLIBS) \ $(LIBOPT) $(LD) $(LDSHLIB) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \ `$(LIBOPT) $(LIBLIBS)` -lc $(CDEBUG) endif #-------------------------------------------------------------------------- # The rule for building a static library is below (if needed). This is # tricky because the user can be building the static library as his main # library or in addition to some other kind of main library. In fact, # he may have specified it both as the main library type and an # additional library type. In that case, NETPBMLIBSUFFIX and # STATICLIBSUFFIX are redundant -- we hope they're the same. # # We must not include a rule for static libraries if he doesn't want us # to build any. The library name we come up with might conflict with # the name of the library he actually is building. In fact, in that case # STATICLIB_SUFFIX may just be arbitrary. #----------------------------------------------------------------------------- ifeq ($(NETPBMLIBTYPE),unixstatic) BUILD_STATICLIB = y else ifeq ($(STATICLIB_TOO),y) BUILD_STATICLIB = y else BUILD_STATICLIB = n endif endif ifeq ($(BUILD_STATICLIB),y) lib$(LIBROOT).$(STATICLIBSUFFIX): $(LIBOBJECTS) $(LIBOBJECTS_X) -rm -f $@ ar rc $@ $(LIBOBJECTS) $(LIBOBJECTS_X) -$(RANLIB) $@ endif ########################################################################### # INSTALLING ########################################################################### # Some maintenance notes about $(INSTALL): Some install programs can # install multiple files in one shot; others can take only one file at # a time. Some have a -c option; others ignore -c. Some can take # permissions in mnemonic form (u=rwx,go=rx); others can't, but all # take the encoded form (755). Some have a -d option to install # directories and never install them implicitly. Others create # directories only implicitly. Installbsd and OSF1 Install need a # space in "-m 755". Others don't care. 2000.05.17. OSF1 Install # takes only one parameter: the source file. It picks a destination # directory by default, or you can specify it with a -f option. # 2000.06.15 # DJGPP can do SYMKINKs for programs but not for ordinary files, so # it define SYMLINKEXE, other system don't need it ifeq ($(SYMLINKEXE)x,x) SYMLINKEXE := $(SYMLINK) endif # Before Netpbm 8.4, we did hard links instead of symbolic. A user # requested symbolic, and I couldn't see a reason for hard (original reason # may have been lack of symbolic capability), so I changed it. -Bryan .PHONY: install.merge.common install.merge.common: $(MERGENAME) $(NOMERGEBINARIES) install.script -(cd $(INSTALLBINARIES) && rm -f $(BINARIES) $(MERGE_ALIASES)) ifneq ($(MERGENAME)x,x) $(INSTALL) -c $(STRIPFLAG) -m $(INSTALL_PERM_BIN) \ $(MERGENAME) $(INSTALLBINARIES) cd $(INSTALLBINARIES) && \ for i in $(MERGEBINARIES) $(MERGE_ALIASES) ; \ do $(SYMLINKEXE) $(MERGENAME)$(EXE) $$i ; \ done endif ifneq ($(NOMERGEBINARIES)x,x) for x in $(NOMERGEBINARIES); \ do \ $(INSTALL) -c $(STRIPFLAG) -m $(INSTALL_PERM_BIN) \ $$x $(INSTALLBINARIES)/$$x; \ done endif .PHONY: install.bin install.bin: $(BINARIES) install.script # Note that on Cygwin, the executables are actually pbmmake.exe, etc. # Make and Install know that pbmmake.exe counts as pbmmake. for x in $(BINARIES); \ do \ $(INSTALL) -c $(STRIPFLAG) -m $(INSTALL_PERM_BIN) \ $$x $(INSTALLBINARIES)/$$x; \ done .PHONY: install.script install.script: $(SCRIPTS) ifneq ($(SCRIPTS)x,x) for x in $(SCRIPTS); \ do \ $(INSTALL) -c -m $(INSTALL_PERM_BIN) $(SRCSUBDIR)/$$x \ $(INSTALLSCRIPTS)/$$x; \ done endif .PHONY: install.man.bin install.man.old-lib install.man.general install.man.bin: ifneq ($(MANUALS1)x,x) for i in $(MANUALS1) ; do \ $(MANCP) $(SRCSUBDIR)/$$i.1 \ $(INSTALLMANUALS1)/$$i.$(SUFFIXMANUALS1) ; \ done endif install.man.old-lib: ifneq ($(MANUALS3)x,x) for i in $(MANUALS3) ; do \ $(MANCP) $(SRCSUBDIR)/$$i.3 \ $(INSTALLMANUALS3)/$$i.$(SUFFIXMANUALS3) ; \ done endif install.man.general: ifneq ($(MANUALS5)x,x) for i in $(MANUALS5) ; do \ $(MANCP) $(SRCSUBDIR)/$$i.5 \ $(INSTALLMANUALS5)/$$i.$(SUFFIXMANUALS5) ; \ done endif # Install a static library # .PHONY: install.staticlib install.staticlib: lib$(LIBROOT).$(STATICLIBSUFFIX) $(INSTALL) -c -m $(INSTALL_PERM_LIBS) $< $(INSTALLSTATICLIBS)/$< # Install a shared library stub -- the ".so" file used at link time to # prepare a program for dynamically linking a library at run time .PHONY: install.sharedlibstub install.sharedlibstub: ifeq ($(NETPBMLIBTYPE),unixshared) # install the link-time (.so) links to the runtime libraries cd $(INSTALLSTATICLIBS) ; \ $(SYMLINK) $(INSTALLLIBS)/lib$(LIBROOT).$(NETPBMLIBSUFFIX).$(MAJ) \ lib$(LIBROOT).$(NETPBMLIBSUFFIX) endif ifeq ($(NETPBMLIBTYPE),dll) $(INSTALL) -c -m $(INSTALL_PERM_LIBS) \ lib$(LIBROOT).dll.a $(INSTALLSTATICLIBS) endif # Install a shared library # .PHONY: install.lib.common ifeq ($(NETPBMLIBTYPE),unixshared) # install a Unix-style shared library install.lib.common: lib$(LIBROOT).$(NETPBMLIBSUFFIX).$(MAJ).$(MIN) -(cd $(INSTALLLIBS) && rm -f lib$(LIBROOT).$(NETPBMLIBSUFFIX).$(MAJ).*) $(INSTALL) -c -m $(INSTALL_PERM_LIBD) $< $(INSTALLLIBS)/$< cd $(INSTALLLIBS) && \ $(SYMLINK) $< lib$(LIBROOT).$(NETPBMLIBSUFFIX).$(MAJ) endif ifeq ($(NETPBMLIBTYPE),dll) #install a Windows DLL shared library #Note that unlike Unix libraries, a Windows DLL must go into a directory #that is in the PATH, so we use INSTALLBINARIES instead of INSTALLLIBS. install.lib.common: $(NETPBMSHLIBPREFIX)$(LIBROOT).dll -( cd $(INSTALLBINARIES) && rm -f $(NETPBMSHLIBPREFIX)$(LIBROOT).dll ) $(INSTALL) -c $(STRIPFLAG) -m $(INSTALL_PERM_LIBD) \ $< $(INSTALLBINARIES) endif ifeq ($(NETPBMLIBTYPE),dylib) # install a Darwin-style shared library install.lib.common: lib$(LIBROOT).$(MAJ).$(MIN).dylib -(cd $(INSTALLLIBS) && rm -f lib$(LIBROOT).*.dylib) $(INSTALL) -c -m $(INSTALL_PERM_LIBD) $< $(INSTALLLIBS)/$< cd $(INSTALLLIBS) && \ $(SYMLINK) $< lib$(LIBROOT).dylib cd $(INSTALLLIBS) && \ $(SYMLINK) $< lib$(LIBROOT).$(MAJ).dylib endif .PHONY: clean.common ifneq ($(EXE)x,x) EXEPATTERN = *$(EXE) else EXEPATTERN = endif clean.common: -rm -f *.o *.o2 *.a *.so *.so.* *.dll *.dylib *.cat *~ *.i *.s \ $(EXEPATTERN) \ merge.h compile.h *.def *.lnk \ core *.core \ $(BINARIES) $(MERGENAME) # $(HEADERLINKS) .PHONY: dep dep: # $(HEADERLINKS) # We use -MG here because of ../compile.h. It need not exist # before the first make after a clean. $(CC) -MM -MG $(INCLUDE) $(SRCSUBDIR)/*.c >Makefile.depend # The automatic dependency generation is a pain in the butt and # totally unnecessary for people just installing the distributed code, # so to avoid needless failures in the field and a complex build, the # 'distclean' program simply makes Makefile.depend an empty file. A # developer may do 'make dep' to create a Makefile.depend full of real # dependencies. include Makefile.depend netpbm-free-10.0-1/Makefile.config.djgpp0100644004714500471450000003055607716762513020355 0ustar aba-guestaba-guest# This is a make file inclusion, to be included in all the Netpbm make # files. This makefile has been customized for DJGPPv2 # This file is meant to contain variable settings that customize the # build for a particular target system configuration. # The distribution contains the file Makefile.config.in. You edit # Makefile.config.in in ways relevant to your particular environment # to create Makefile.config. The "configure" program will do this # for you in simple cases. # Some of the variables that the including make file must set for this # file to work: # # SRCDIR: The directory at the top of the Netpbm source tree. Note that # this is typically a relative directory, and it must be relative to the # make file that includes this file. So it's normally "..". #DEFAULT_TARGET = nonmerge DEFAULT_TARGET = merge # Fiasco has some special requirements that make it fail to compile on # some systems, and since it isn't very important, just set this to "N" # and skip it on those systems unless you want to debug it and fix it. # OpenBSD: #BUILD_FIASCO = N BUILD_FIASCO = Y # The following are commands for the build process to use. These values # do not get built into anything. # The C compiler (including macro preprocessor) #Tru64 (= Digital Unix): #CC = cc #CC = gcc CC = gcc # The linker. LD = $(CC) #LD = ld #Tru64: #LD = cc #LD = gcc # The native C compiler and linker (when cross-compiling). CC_FOR_BUILD = $(CC) LD_FOR_BUILD = $(LD) SHELL = $(DJDIR)/bin/sh # MAKE is set automatically by Make to what was used to invoke Make. INSTALL = ginstall #Solaris: #INSTALL = /usr/ucb/install #Tru64: #INSTALL = installbsd #OSF1: #INSTALL = $(SRCDIR)/buildtools/installosf #Red Hat Linux: #INSTALL = install # STRIPFLAG is the option you pass to the above install program to make it # strip unnecessary information out of binaries. STRIPFLAG = -s # If you don't want to strip the binaries, just leave it null: #STRIPFLAG = #SYMLINK = ln -s # At least some Windows environments don't have any concept of symbolic # links, but direct copies are usually a passable alternative. SYMLINK = cp # DJGPP can do symlink's for programs SYMLINKEXE = ln -s # Normally the man pages are installed using "install". But via this # variable, you can use something else, for example a script that # calls compress or pack. Mantocat, included with Netpbm, is used on # systems which use man pages in the "cat" format. #MANCP = $(INSTALL) -c -m $(INSTALL_PERM_MAN) #DJGPP/Windows: MANCP = $(SRCDIR)/buildtools/mantocat AR = ar RANLIB = ranlib #LEX = flex # Solaris: # LEX = flex -e # Or just skip parts that need Lex: LEX = # C compiler options # gcc: # -ansi and -Werror should work too, but are not included # by default because there's no point in daring the build to fail. # -pedantic isn't a problem because it causes at worst a warning. CFLAGS = -pedantic -O3 -Wall -Wno-uninitialized # On DEC Tru64 4.0F (at least), you need -DLONG_32 for ppmtompeg. #Tru64: #CFLAGS = -O2 -std1 -DLONG_32 #AIX: #CFLAGS= -O3 -D_ALL_SOURCE #HP-UX: #CFLAGS= -O3 -fPIC # EXE is a suffix that the linker puts on any executable it generates. # In cygwin, this is .exe and most programs deal with its existence without # us having to know about it. Some don't though, so set this: #EXE = #Cygwin, DJGPP/Windows: EXE = .exe # linker options. # On some systems you have to build into an executable the list of # directories where its dynamically linked libraries can be found at # run time. This is typically done with a -R or --rpath linker # option. Even on systems that don't require it, you might prefer to do # that rather than set up environment variables or configuration files # to tell the system where the libraries are. A "Y" here means to put # the directory information in the executable at link time. # Solaris, SunOS, NetBSD: NEED_RUNTIME_PATH = N #NEED_RUNTIME_PATH = Y LDFLAGS = # Eunice users may want to use -noshare so that the executables can # run standalone: #LDFLAGS = -noshare #Tru64: # Russ Allberry says on 2001.06.09 that -oldstyle_liblookup may be necessary # to keep from finding an ancient system libjpeg.so that isn't compatible with # NetPBM. #LDFLAGS = -call_shared -oldstyle_liblookup #AIX: #LDFLAGS=-L /usr/pubsw/lib #HP-UX: #LDFLAGS = -Wl,+b,/usr/pubsw/lib ifeq ($(NEED_RUNTIME_PATH),Y) #If the linker is gcc (e.g. NetBSD): #LDFLAGS += -Wl,--rpath,$(INSTALLLIBS) #Any other linker: LDFLAGS += -R$(INSTALLLIBS) endif # Linker options for created Netpbm shared libraries. # Here, $(SONAME) resolves to the soname for the shared library being created. # The following are gcc options. This works on GNU libc systems. LDSHLIB = -shared -Wl,-soname,$(SONAME) # You need -nostart instead of -shared on BeOS. Though the BeOS compiler is # ostensibly gcc, it has the -nostart option, which is not mentioned in gcc # documentation and doesn't exist in at least one non-BeOS installation. # BeOS doesn't have sonames built in. #LDSHLIB = -nostart #LDSHLIB = -G # Solaris, SunOS with GNU Ld: # These systems have no soname option. #LDSHLIB = -shared # Solaris with Sun Ld: #LDSHLIB = -Wl,-B,dynamic,-G,-h,$(SONAME) #Tru64: #LDSHLIB = -shared -expect_unresolved "*" ifeq ($(NEED_RUNTIME_PATH),Y) #If the linker is gcc (e.g. NetBSD): #LDSHLIB += -Wl,--rpath,$(INSTALLLIBS) #Any other linker: LDSHLIB += -R$(INSTALLLIBS) endif # On older systems, you have to make shared libraries out of position # independent code, so you need -fpic or fPIC here. (The rule is: if # -fpic works, use it. If it bombs, go to fPIC). On newer systems, # it isn't necessary, but can save real memory at the expense of # execution speed. Without position independent code, the library # loader may have to patch addresses into the executable text. On an # older system, this would cause a program crash because the loader # would be writing into read-only shared memory. But on newer # systems, the system silently creates a private mapping of the page # or segment being modified (the "copy on write" phenomenon). So it # needs its own private real page frame. In one experiment, A second # copy of Pbmtext used 16K less real memory when built with -fpic than # when built without. 2001.06.02. CFLAGS_SHLIB = # Solaris or SunOS with gcc, and NetBSD: #CFLAGS_SHLIB = -fpic #CFLAGS_SHLIB = -fPIC # Sun compiler: #CFLAGS_SHLIB = -Kpic #CFLAGS_SHLIB = -KPIC # The following variables tell where your various libraries on which # Netpbm depends live. The xxxHDR_DIR variable is the directory in which # the interface headers for the library live (e.g. /usr/include) and # xxxLIB_DIR is the directory in which the link library (not necessarily # the library used at run time) lives, e.g. /usr/lib. If you don't have # the library in question, use a value of NONE and the build will simply # skip the programs that require that library. If the library is in your # compiler's/linker's default search path, it doesn't matter what you put # here. # The TIFF library. See above. If you want to build the tiff # converters, you must have the tiff library already installed. #TIFFLIB_DIR = NONE #TIFFHDR_DIR = NONE TIFFLIB_DIR = $(DJDIR)/lib TIFFHDR_DIR = $(DJDIR)/include # If your Tiff library depends on libraries other than libc and libm, # put the required linker options here. TIFFLIB_LDFLAGS = # libtiff 3.5.5 with the lzw patch needs libz: #TIFFLIB_LDFLAGS = -lz # The JPEG library. See above. If you want to build the jpeg # converters you must have the jpeg library already installed. # Tiff files can use JPEG compression, so the Tiff library can reference # the JPEG library. If your Tiff library references a dynamic JPEG # library, you must specify at least JPEGLIB_DIR here, or the Tiff # converters will not build. Note that your Tiff library may have the # JPEG stuff statically linked in, in which case you won't need # JPEGLIB_DIR in order to build the Tiff converters. #JPEGLIB_DIR = NONE #JPEGHDR_DIR = NONE JPEGLIB_DIR = $(DJDIR)/lib JPEGHDR_DIR = $(DJDIR)/include # The PNG library. See above. If you want to build the PNG # converters you must have the PNG library already installed. #PNGLIB_DIR = NONE #PNGHDR_DIR = NONE PNGLIB_DIR = $(DJDIR)/lib PNGHDR_DIR = $(DJDIR)/include # The zlib compression library. See above. You need it to build # anything that needs the PNG library (see above). If you selected # NONE for the PNG library, it doesn't matter what you specify here -- # it won't get used. ZLIB_DIR = $(DJDIR)/lib ZHDR_DIR = $(DJDIR)/include # The JBIG lossless image compression library (aka JBIG-KIT): JBIGHDR_DIR = $(SRCDIR)/pnm/jbig JBIGLIB_DIR = $(SRCDIR)/pnm/jbig # And the Utah Raster Toolkit (aka URT aka RLE) library: URTHDR_DIR = $(SRCDIR)/urt URTLIB_DIR = $(SRCDIR)/urt # These are -l options to link in the network libraries. Often, these are # built into the standard C library, so this can be null. If you don't # want any network functions, make it NONE. The only thing that requires # network functions is the option in ppmtompeg to run it on multiple # computers simultaneously. #NETWORKLD = # Solaris, SunOS: #NETWORKLD = -lsocket -lnsl # Don't build network functions: #DJGPP/Windows, Tru64: # (there's some minor header problem that prevents network functions from # building on Tru64 2000.10.06) NETWORKLD = NONE VMS = #VMS: #VMS = yes # The following variables are used only by 'make install' (and the # variants of it). Paths here don't, for example, get built into any # programs. # EXCEPTION: If you used a -R $(INSTALL_LIBS) option above, # then INSTALL_LIBS gets built into your shared libraries. # File permissions for installed files. # Note that on some systems (e.g. Solaris), 'install' can't use the # mnemonic permissions - you have to use octal. # binaries (pbmmake, etc) INSTALL_PERM_BIN = 755 # u=rwx,go=rx # shared libraries (libpbm.so, etc) INSTALL_PERM_LIBD = 755 # u=rwx,go=rx # static libraries (libpbm.a, etc) INSTALL_PERM_LIBS = 644 # u=rw,go=r # header files (pbm.h, etc) INSTALL_PERM_HDR = 644 # u=rw,go=r # man pages (pbmmake.1, etc) INSTALL_PERM_MAN = 644 # u=rw,go=r # data files (pnmtopalm color maps, etc) INSTALL_PERM_DATA = 644 # u=rw,go=r # Everything gets installed relative to directory INSTALL_PREFIX. If # you're spreading Netpbm across your system, use "/". # DEC Tru64: #INSTALL_PREFIX = /usr/local1/DEC/packages/netpbm # DJGPP/Windows: INSTALL_PREFIX = $(TMPDIR)/netpbm # Typical: #INSTALL_PREFIX = /usr/local/ #INSTALL_PREFIX = /usr/local/netpbm # Specify the directory where you want the executables. # If you need scripts and binaries to be in different directories, you # can set that up too. INSTALLBINARIES = $(INSTALL_PREFIX)/bin #INSTALLBINARIES = /usr/local/bin/netpbm INSTALLSCRIPTS = $(INSTALLBINARIES) # Specify the directory where you want the shared libraries # installed. For this to be effective, you must have set up this location # to be searched by your system's program executor for runtime libraries. INSTALLLIBS = $(INSTALL_PREFIX)/lib #INSTALLLIBS = /usr/local/lib/netpbm # Specify the directories that you want the man page sources, # plus the suffix you want them to have. INSTALLMANUALS1 = $(INSTALL_PREFIX)/man/cat1 SUFFIXMANUALS1 = 1 INSTALLMANUALS3 = $(INSTALL_PREFIX)/man/cat3 SUFFIXMANUALS3 = 3 INSTALLMANUALS5 = $(INSTALL_PREFIX)/man/cat5 SUFFIXMANUALS5 = 5 # Specify the directory where you want the interface header files for # the Netpbm libraries installed. INSTALLHDRS = $(INSTALL_PREFIX)/include # Specify the directory where you want data files that the Netpbm programs # access to be installed INSTALLDATA = $(INSTALL_PREFIX)/lib #NETPBMLIBTYPE tells the kind of libraries that will get built to hold the #Netpbm library functions. The value is used only in make file tests. # "unix" means a unix-style shared library, typically named like libxyz.so.2.3 #NETPBMLIBTYPE = unixshared # "static" means a unix-style static library, (like libxyz.a) NETPBMLIBTYPE = unixstatic # "dll" means a Windows DLL shared library #NETPBMLIBTYPE = dll # "dylib" means a Darwin/Mac OS shared library #NETPBMLIBTYPE = dylib #NETPBMLIBSUFFIX is the suffix used on whatever kind of library is #selected above. All this is used for is to construct library names. #The make files never examine the actual value. #NETPBMLIBSUFFIX = so # "a" is the suffix for unix-style static libraries. Also for AIX shared # libraries. NETPBMLIBSUFFIX = a # For HP-UX shared libraries: #NETPBMLIBSUFFIX = sl # Darwin/Mac OS shared library: #NETPBMLIBSUFFIX = dylib # Windows shared library: #NETPBMLIBSUFFIX = dll netpbm-free-10.0-1/Makefile.config.in0100644004714500471450000003551207723461056017650 0ustar aba-guestaba-guest# This is a make file inclusion, to be included in all the Netpbm make # files. # This file is meant to contain variable settings that customize the # build for a particular target system configuration. # The distribution contains the file Makefile.config.in. You edit # Makefile.config.in in ways relevant to your particular environment # to create Makefile.config. The "configure" program will do this # for you in simple cases. # # As this file is included in the debian distribution, it makes it right # for the debian build system # Some of the variables that the including make file must set for this # file to work: # # SRCDIR: The directory at the top of the Netpbm source tree. Note that # this is typically a relative directory, and it must be relative to the # make file that includes this file. So it's normally "..". DEFAULT_TARGET = nonmerge #DEFAULT_TARGET = merge # Fiasco has some special requirements that make it fail to compile on # some systems, and since it isn't very important, just set this to "N" # and skip it on those systems unless you want to debug it and fix it. # OpenBSD: #BUILD_FIASCO = N BUILD_FIASCO = Y # The following are commands for the build process to use. These values # do not get built into anything. # The C compiler (including macro preprocessor) #Tru64 (= Digital Unix): #CC = cc #CC = gcc CC = gcc # The linker. LD = $(CC) #LD = ld #Tru64: #LD = cc #LD = gcc # CC and LD are for building the Netpbm programs, which are not necessarily # intended to run on the same system on which Make is running. But when we # build a build tool such as Libopt, it is meant to run only on the same # system on which the Make is running. The variables below define programs # to use to compile and link build tools. CC_FOR_BUILD = $(CC) LD_FOR_BUILD = $(LD) # MAKE is set automatically by Make to what was used to invoke Make. # INSTALL must be autocreate the neccessary directories INSTALL = install -D # INSTALL = ginstall #Solaris: #INSTALL = /usr/ucb/install #Tru64: #INSTALL = installbsd #OSF1: #INSTALL = $(SRCDIR)/buildtools/installosf #Red Hat Linux: #INSTALL = install # STRIPFLAG is the option you pass to the above install program to make it # strip unnecessary information out of binaries. STRIPFLAG = -s # If you don't want to strip the binaries, just leave it null: #STRIPFLAG = # SYMLINK must force SYMLINK = ln -sf # At least some Windows environments don't have any concept of symbolic # links, but direct copies are usually a passable alternative. #SYMLINK = cp # Normally the man pages are installed using "install". But via this # variable, you can use something else, for example a script that # calls compress or pack. Mantocat, included with Netpbm, is used on # systems which use man pages in the "cat" format. MANCP = $(INSTALL) -c -m $(INSTALL_PERM_MAN) #DJGPP/Windows: #MANCP = $(SRCDIR)/mantocat AR = ar RANLIB = ranlib LEX = flex # Solaris: # LEX = flex -e # Or just skip parts that need Lex: # LEX = # C compiler options # gcc: # -ansi and -Werror should work too, but are not included # by default because there's no point in daring the build to fail. # -pedantic isn't a problem because it causes at worst a warning. CFLAGS = -pedantic -O3 -Wall -Wno-uninitialized # On DEC Tru64 4.0F (at least), you need -DLONG_32 for ppmtompeg. #Tru64: #CFLAGS = -O2 -std1 -DLONG_32 #AIX: #CFLAGS= -O3 -D_ALL_SOURCE #HP-UX: #CFLAGS= -O3 -fPIC # EXE is a suffix that the linker puts on any executable it generates. # In cygwin, this is .exe and most programs deal with its existence without # us having to know about it. Some don't though, so set this: EXE = #Cygwin, DJGPP/Windows: #EXE = .exe # linker options. # On some systems you have to build into an executable the list of # directories where its dynamically linked libraries can be found at # run time. This is typically done with a -R or --rpath linker # option. Even on systems that don't require it, you might prefer to do # that rather than set up environment variables or configuration files # to tell the system where the libraries are. A "Y" here means to put # the directory information in the executable at link time. # Solaris, SunOS, NetBSD: NEED_RUNTIME_PATH = N #NEED_RUNTIME_PATH = Y LDFLAGS = # Eunice users may want to use -noshare so that the executables can # run standalone: #LDFLAGS = -noshare #Tru64: # Russ Allberry says on 2001.06.09 that -oldstyle_liblookup may be necessary # to keep from finding an ancient system libjpeg.so that isn't compatible with # NetPBM. #LDFLAGS = -call_shared -oldstyle_liblookup #AIX: #LDFLAGS=-L /usr/pubsw/lib #HP-UX: #LDFLAGS = -Wl,+b,/usr/pubsw/lib ifeq ($(NEED_RUNTIME_PATH),Y) #If the linker is gcc (e.g. NetBSD): #LDFLAGS += -Wl,--rpath,$(INSTALLLIBS) #Any other linker: LDFLAGS += -R$(INSTALLLIBS) endif # Linker options for created Netpbm shared libraries. # Here, $(SONAME) resolves to the soname for the shared library being created. # The following are gcc options. This works on GNU libc systems. LDSHLIB = -shared -Wl,-soname,$(SONAME) # You need -nostart instead of -shared on BeOS. Though the BeOS compiler is # ostensibly gcc, it has the -nostart option, which is not mentioned in gcc # documentation and doesn't exist in at least one non-BeOS installation. # BeOS doesn't have sonames built in. #LDSHLIB = -nostart #LDSHLIB = -G # Solaris, SunOS with GNU Ld: # These systems have no soname option. #LDSHLIB = -shared # Solaris with Sun Ld: #LDSHLIB = -Wl,-B,dynamic,-G,-h,$(SONAME) #Tru64: #LDSHLIB = -shared -expect_unresolved "*" ifeq ($(NEED_RUNTIME_PATH),Y) #If the linker is gcc (e.g. NetBSD): #LDSHLIB += -Wl,--rpath,$(INSTALLLIBS) #Any other linker: LDSHLIB += -R$(INSTALLLIBS) endif # On older systems, you have to make shared libraries out of position # independent code, so you need -fpic or fPIC here. (The rule is: if # -fpic works, use it. If it bombs, go to fPIC). On newer systems, # it isn't necessary, but can save real memory at the expense of # execution speed. Without position independent code, the library # loader may have to patch addresses into the executable text. On an # older system, this would cause a program crash because the loader # would be writing into read-only shared memory. But on newer # systems, the system silently creates a private mapping of the page # or segment being modified (the "copy on write" phenomenon). So it # needs its own private real page frame. In one experiment, A second # copy of Pbmtext used 16K less real memory when built with -fpic than # when built without. 2001.06.02. # CFLAGS_SHLIB = CFLAGS_SHLIB = -fPIC # Solaris or SunOS with gcc, and NetBSD: #CFLAGS_SHLIB = -fpic #CFLAGS_SHLIB = -fPIC # Sun compiler: #CFLAGS_SHLIB = -Kpic #CFLAGS_SHLIB = -KPIC # The following variables tell where your various libraries on which # Netpbm depends live. The xxxHDR_DIR variable is the directory in which # the interface headers for the library live (e.g. /usr/include) and # xxxLIB_DIR is the directory in which the link library (not necessarily # the library used at run time) lives, e.g. /usr/lib. If you don't have # the library in question, use a value of NONE and the build will simply # skip the programs that require that library. If the library is in your # compiler's/linker's default search path, it doesn't matter what you put # here. # The TIFF library. See above. If you want to build the tiff # converters, you must have the tiff library already installed. TIFFLIB_DIR = /usr/lib TIFFHDR_DIR = /usr/include/libtiff #NetBSD: #TIFFLIB_DIR = $(LOCALBASE)/lib #TIFFHDR_DIR = $(LOCALBASE)/include # OSF, Tru64: #TIFFLIB_DIR = /usr/local1/DEC/lib #TIFFHDR_DIR = /usr/local1/DEC/include #TIFFLIB_DIR = NONE #TIFFHDR_DIR = NONE # If your Tiff library depends on libraries other than libc and libm, # put the required linker options here. TIFFLIB_LDFLAGS = # libtiff 3.5.5 with the lzw patch needs libz: #TIFFLIB_LDFLAGS = -lz # The JPEG library. See above. If you want to build the jpeg # converters you must have the jpeg library already installed. # Tiff files can use JPEG compression, so the Tiff library can reference # the JPEG library. If your Tiff library references a dynamic JPEG # library, you must specify at least JPEGLIB_DIR here, or the Tiff # converters will not build. Note that your Tiff library may have the # JPEG stuff statically linked in, in which case you won't need # JPEGLIB_DIR in order to build the Tiff converters. JPEGLIB_DIR = /usr/lib JPEGHDR_DIR = /usr/include/jpeg # Netbsd: #JPEGLIB_DIR = ${LOCALBASE}/lib #JPEGHDR_DIR = ${LOCALBASE}/include # OSF, Tru64: #JPEGLIB_DIR = /usr/local1/DEC/lib #JPEGHDR_DIR = /usr/local1/DEC/include # Typical: #JPEGLIB_DIR = /usr/local/lib #JPEGHDR_DIR = /usr/local/include # Don't build JPEG stuff: #JPEGLIB_DIR = NONE #JPEGHDR_DIR = NONE # The PNG library. See above. If you want to build the PNG # converters you must have the PNG library already installed. PNGLIB_DIR = /usr/lib PNGHDR_DIR = /usr/include/png # NetBSD: #PNGLIB_DIR = $(LOCALBASE)/lib #PNGHDR_DIR = $(LOCALBASE)/include # OSF/Tru64: #PNGLIB_DIR = /usr/local1/DEC/lib #PNGHDR_DIR = /usr/local1/DEC/include # Typical: #PNGLIB_DIR = /usr/local/lib #PNGHDR_DIR = /usr/local/include # No PNG: #PNGLIB_DIR = NONE #PNGHDR_DIR = NONE # The zlib compression library. See above. You need it to build # anything that needs the PNG library (see above). If you selected # NONE for the PNG library, it doesn't matter what you specify here -- # it won't get used. ZLIB_DIR = /usr/lib ZHDR_DIR = /usr/include # The JBIG lossless image compression library (aka JBIG-KIT): JBIGHDR_DIR = $(SRCDIR)/pnm/jbig JBIGLIB_DIR = $(SRCDIR)/pnm/jbig # And the Utah Raster Toolkit (aka URT aka RLE) library: URTHDR_DIR = $(SRCDIR)/urt URTLIB_DIR = $(SRCDIR)/urt # The Linux SVGA library (Svgalib) is a facility for displaying graphics # on the Linux console. It is required by Ppmsvgalib. LINUXSVGAHDR_DIR = NONE LINUXSVGALIB_DIR = NONE #LINUXSVGALIB_DIR = /usr/lib #LINUXSVGAHDR_DIR = /usr/include/svgalib # These are -l options to link in the network libraries. Often, these are # built into the standard C library, so this can be null. If you don't # want any network functions, make it NONE. The only thing that requires # network functions is the option in ppmtompeg to run it on multiple # computers simultaneously. NETWORKLD = # Solaris, SunOS: #NETWORKLD = -lsocket -lnsl # Don't build network functions: #DJGPP/Windows, Tru64: # (there's some minor header problem that prevents network functions from # building on Tru64 2000.10.06) #NETWORKLD = NONE VMS = #VMS: #VMS = yes # The following variables are used only by 'make install' (and the # variants of it). Paths here don't, for example, get built into any # programs. # EXCEPTION: If you used a -R $(INSTALL_LIBS) option above, # then INSTALL_LIBS gets built into your shared libraries. # File permissions for installed files. # Note that on some systems (e.g. Solaris), 'install' can't use the # mnemonic permissions - you have to use octal. # binaries (pbmmake, etc) INSTALL_PERM_BIN = 755 # u=rwx,go=rx # shared libraries (libpbm.so, etc) INSTALL_PERM_LIBD = 755 # u=rwx,go=rx # static libraries (libpbm.a, etc) INSTALL_PERM_LIBS = 644 # u=rw,go=r # header files (pbm.h, etc) INSTALL_PERM_HDR = 644 # u=rw,go=r # man pages (pbmmake.1, etc) INSTALL_PERM_MAN = 644 # u=rw,go=r # data files (pnmtopalm color maps, etc) INSTALL_PERM_DATA = 644 # u=rw,go=r # Everything except /etc/netpbm gets installed relative to directory # INSTALL_PREFIX. If you're spreading Netpbm across your system, use # "/". # DEC Tru64: #INSTALL_PREFIX = /usr/local1/DEC/packages/netpbm # DJGPP/Windows: #INSTALL_PREFIX = /djgpp # Typical: #INSTALL_PREFIX = /usr/local/ #INSTALL_PREFIX = /usr/local/netpbm ifneq ($(PREFIX)x,x) INSTALL_PREFIX = $(PREFIX) else INSTALL_PREFIX = debian/tmp endif # Specify the directory where you want the executables. # If you need scripts and binaries to be in different directories, you # can set that up too. INSTALLBINARIES = $(INSTALL_PREFIX)/bin #INSTALLBINARIES = /usr/local/bin/netpbm INSTALLSCRIPTS = $(INSTALLBINARIES) # Specify the directory where you want the shared libraries # installed. For this to be effective, you must have set up this location # to be searched by your system's dynamic linker. INSTALLLIBS = $(INSTALL_PREFIX)/lib #INSTALLLIBS = /usr/local/lib/netpbm # Specify the directory where you want the static libraries installed. INSTALLSTATICLIBS = $(INSTALL_PREFIX)/lib #INSTALLSTATICLIBS = /usr/local/lib/netpbm #INSTALLSTATICLIBS = /usr/local/link/netpbm # Specify the directories that you want the man page sources, # plus the suffix you want them to have. ifeq ($(INSTALLMAN)x,x) INSTALLMAN = $(INSTALL_PREFIX)/man endif INSTALLMANUALS1 = $(INSTALLMAN)/man1 SUFFIXMANUALS1 = 1 INSTALLMANUALS3 = $(INSTALLMAN)/man3 SUFFIXMANUALS3 = 3 INSTALLMANUALS5 = $(INSTALLMAN)/man5 SUFFIXMANUALS5 = 5 # Specify the directory where you want the interface header files for # the Netpbm libraries installed. INSTALLHDRS = $(INSTALL_PREFIX)/include # Specify the directory where you want data files that the Netpbm programs # access to be installed INSTALLDATA = $(INSTALL_PREFIX)/share/netpbm #NETPBMLIBTYPE tells the kind of libraries that will get built to hold the #Netpbm library functions. The value is used only in make file tests. # "unixshared" means a unix-style shared library, typically named like # libxyz.so.2.3 NETPBMLIBTYPE = unixshared # "unixstatic" means a unix-style static library, (like libxyz.a) #NETPBMLIBTYPE = unixstatic # "dll" means a Windows DLL shared library #NETPBMLIBTYPE = dll # "dylib" means a Darwin/Mac OS shared library #NETPBMLIBTYPE = dylib #NETPBMLIBSUFFIX is the suffix used on whatever kind of library is #selected above. All this is used for is to construct library names. #The make files never examine the actual value. NETPBMLIBSUFFIX = so # "a" is the suffix for unix-style static libraries. Also for AIX shared # libraries. #NETPBMLIBSUFFIX = a # For HP-UX shared libraries: #NETPBMLIBSUFFIX = sl # Darwin/Mac OS shared library: #NETPBMLIBSUFFIX = dylib # Windows shared library: #NETPBMLIBSUFFIX = dll #STATICLIB_TOO is "y" to signify that you want a static library built #and installed in addition to whatever library type you specified by #NETPBMLIBTYPE. If NETPBMLIBTYPE specified a static library, #STATICLIB_TOO simply has no effect. STATICLIB_TOO = y #STATICLIB_TOO = n #STATICLIBSUFFIX is the suffix that static libraries have. It's #meaningless if you aren't building static libraries. STATICLIBSUFFIX = a #SHLIBPREFIXLIST is a blank-delimited list of prefixes that a filename #of a shared library may have on this system. Traditionally, it's #just "lib", as in libc or libpbm. On Windows, though, varying #prefixes are used when multiple alternative forms of a library are #available. The first prefix in this list is what we use to name the #Netpbm shared libraries. SHLIBPREFIXLIST = lib #Cygwin: #SHLIBPREFIXLIST = cyg lib NETPBMSHLIBPREFIX = $(firstword $(SHLIBPREFIXLIST)) netpbm-free-10.0-1/Netpbm.programming0100644004714500471450000001741707776237374020050 0ustar aba-guestaba-guestThis file is an attempt to give some basic guidelines for those who wish to write new Netpbm programs. The guidelines ensure: A) Your program functions consistently with the rest of the package. B) Your program works in myriad environments on which you can't test it. C) You don't miss an important detail of the Netpbm formats. D) Your program is immune to small changes in the Netpbm formats. We don't include any basic coding style in these guidelines. Where you put your braces is a matter of personal style and other people working with your code will just have to live with it. However, no Netpbm source code may contain tab characters. If you generate such a file, the Netpbm maintainer will convert it to spaces and possibly change all your indenting at the same time. Tabs are not appropriate for code that multiple people must edit because they don't necessarily look the same in every editing environment. Spaces, on the other hand, look the same for everyone. Modern editors let you compose code just as easily with spaces as with tabs. The easiest way to write your own Netpbm program is to take an existing one, similar to the one you want to write, and to modify it. This saves a lot of time, and ensures conformity with these rules. But pick a recent one (check the file modification date and the HISTORY file), because many things you see in old programs are grandfathered in. Pamtopnm is good example of a thoroughly modern Netpbm program. Pamcut is another good one. The Netpbm maintainer accepts programs that do not meet these guidelines, so don't feel you need to hold back a contribution because you wrote it before you read these. * See the libp?m.3 man pages for documentation of the various library routines you should use to read and write Netpbm images and perform other common operations. * See the p?m.5 man pages for specifications of the Netpbm formats, but don't depend very much on these; use the library functions instead to read and write the image files. * Your new program must belong to one of the four Netpbm classes, which are loosely based on the Netpbm formats. They are defined as follows: pbm: These programs take PBM (bitmap - pixels are black or white) files as input or output or both. They never have PGM or PPM primary input or output. They use the libpbm Netpbm library. They have "pbm" in their names. pgm: These programs take PBM or PGM (grayscale) files as input, or produce PGM files as output, or both. They treat PBM input as if it were the equivalent PGM input. They never produce PBM primary output and never have PPM primary input or output. They use the libpbm and libpgm Netpbm libraries. They have "pgm" in their names. ppm: These programs take PBM or PGM or PPM (color) files as input, or produce PPM files as output, or both. They treat PBM and PGM input as if it were the equivalent PPM input. They never produce PBM or PGM primary output. They use the libpbm, libpgm, and libppm Netpbm libraries. They have "ppm" in their names. pnm: These are the most general programs. They handle all four Netpbm formats (PBM, PGM, PPM, and PAM). They use all Netpbm formats as input or output or both. They recognize the difference between PBM, PGM, and PPM input, so a PBM input might produce a different result than the equivalent PGM input. These programs use the libpbm, libpgm, libppm, and libpnm Netpbm libraries. They have "pnm" or "pam" in their names. Decide which one of these classes your program belongs to. * If your program involves transparency (alpha masks), follow the example of Pngtopnm/Pnmtopng and Giftopnm/Pnmtogif command syntax, etc. And don't consider inventing a new Netpbm format that includes transparency. That's been carefully considered in the past and determined to violate the simple building block principle of Netpbm. In Netpbm, an alpha mask is represented as a separate PGM image. * Declare all your symbols except 'main' as static so that they won't cause problems to other programs when you do a "merge build" of Netpbm. * Declare main() with return type 'int', not 'void'. Some systems won't compile void main(). * Always start the code in main() with a call to p?m_init(). * Use shhopt for option processing. i.e. call pm_optParseOptions3(). This is really easy if you just copy the parse_command_line() function and struct cmdline_info declaration from pamcut.c and adapt it to your program. When you do this, you get a command line syntax consistent with all the other Netpbm programs, you save coding time and debugging time, and it is trivial to add options later on. Do not use shhopt's short option alternative unless you need to be compatible with another program that has short options. Short options are traditional one-character Unix options, which can be stacked up like "foo -cderx myfile", and they are far too unfriendly to be accepted by the Netpbm philosophy. Note that long options in shhopt can always be abbreviated to the shortest unique prefix, even one character. In messages and examples in documentation, always refer to an option by its full name, not the abbreviation you usually use. E.g. if you have a "-width" option which can be abbreviated "-w", don't use -w in documentation. -width is far clearer. * Use pm_error() and pm_message() for error messages and other messages. Note that the universal -quiet option (processed by p?m_init()) causes messages issued via pm_message() to be suppressed. And that's what Netpbm's architecture requires. * Properly use maxvals. As explained in the format specifications, every sample value in an image must be interpreted relative to the image's maxval. For example, a pixel with value 24 in an image with maxval 24 is the same brightness as a pixel with value 255 in an image with a maxval of 255. 255 is a popular maxval (use the PPM_MAXMAXVAL etc. macros) because it makes samples fit in a single byte and at one time was the maximum possible maxval in the format. Note that the Pnmdepth program converts an image from one maxval to another. * Don't include extra function. If you can already do something by piping the input or output of your program through another Netpbm program, don't make an option on your program to do it. That's the Netpbm philosophy -- simple building blocks. Similarly, if your program does two things which would be useful separately, write two programs and advise users to pipe them together. Or add a third program that simply calls the first * Your program should, if appropriate, allow the user to use Standard Input and Output for images. This is because Netpbm users commonly use pipes. * Don't forget to write a proper manual page! Here are some things you will see in old Netpbm programs, but they are obsolete and you shouldn't propagate them into a new program: * Tolerating non-standard C libraries. You may assume all users have ANSI and POSIX compliant C libraries. E.g. use strrchr() and forget about rindex(). * pm_keymatch() for option processing. Use shhopt instead, as described above. * pm_optParseOptions() and pm_optParseOptions2(). These are obsoleted by pm_optParseOptions3(), which is easier to use and more powerful. * K&R C function declarations. Always use ANSI function declarations exclusively (e.g. use void foo(int arg1){} instead of void foo(arg1) int arg1; {} * for (col=0, xP = row; col < cols; col++, xP++) foo(*xP); This was done in the days before optimizing compilers because it ran faster than the more readable: for (col=0; col < cols; col++) foo(row[col]); Now, just use the latter. netpbm-free-10.0-1/README0100644004714500471450000003771507776237374015242 0ustar aba-guestaba-guest NETPBM Release 10.0 THIS IS THE PRIMARY DOCUMENTATION DISTRIBUTED WITH NETPBM. SEE THE doc DIRECTORY IN THE SOURCE TREE FOR OTHER INFORMATION, SUCH AS INSTALLATION INSTRUCTIONS. Netpbm is a toolkit for manipulation of graphic images, including conversion of images between a variety of different formats. There are over 220 separate tools in the package including converters for more than 80 graphics formats. Examples of the sort of image manipulation we're talking about are: Shrinking an image by 10%; Cutting the top half off of an image; Making a mirror image; Creating a sequence of images that fade from one image to another; The man page Netpbm.1 in the package has a more complete description of what the package does. The package is intended to be portable to many platforms. It has, at least at one time, been tested under various Unix-based systems, Windows, Mac OS X, VMS and Amiga OS. The maintainer uses and builds it on a platform that consists (in relevant part) mainly of GNU software (you probably know this kind of system by the name "Linux"). The goal of Netpbm is to be a single source for all the primitive graphics utilities, especially converters, one might need. So if you know of some freely redistributable software in this vein which is not in the package yet, you should bring it to the attention of the Netpbm maintainer so it can be included in the next release. Netpbm does not contain interactive tools and doesn't have a graphical interface. Netpbm replaces the widely spread Pbmplus package (released December 10, 1991). A lot of improvements and additions have been made. After the latest release of Pbmplus, a lot of additional filters began circulating on the net. The aim of Netpbm was to collect these and to turn them into a package. This work has been performed by programmers all over the world. If _you_ have some code to add, please contact the Netpbm maintainer. DISTRIBUTION ------------ You'll find the latest release of Netpbm source code at . A prebuilt version for Cygwin (Windows) is at Contact Pierre A. Humblet . A prebuilt version for DJGPP/GNU (DOS/Windows) is maintained by Mariano Alvarez Fernandez . See . A prebuilt version for Windows using Mingw32 and GNU Bash is distributed by the GnuWin32 Project. See . A prebuilt version for Solaris is at . Contact Mark Ashley . Check out to see if the distribution has changed since this file was written. PREREQUISITES ------------- Don't sweat the prerequisites too much. In most cases, if you're missing something, the build of the programs that depend on it will bomb, but the rest of the Netpbm programs will build just fine. And you may not need the more demanding programs. If you have trouble getting, building, or installing the prerequisites, the Netpbm maintainer wants to know. Since he uses them himself, he can help you. And if there is a problem with a prerequisite package that its own maintainer cannot fix, it may be possible to ship a fix with Netpbm. To build and install Netpbm, you need GNU Make and a Perl interpreter. You can get GNU Make from http://www.gnu.org/software and Perl from http://www.cpan.org. It's possible to get around the Perl requirement by running some of the steps on a different machine that has Perl and doing others manually. There is no practical substitute for GNU Make. To build pnmtotiff or tifftopnm or pnmtotiffcmyk, you need the Tiff library. You can get it from http://www.libtiff.org. To build ppmtojpeg or jpegtopnm, you need the JPEG/JFIF library from the Independent JPEG Group (IJG). You can get it at ftp://ftp.uu.net/graphics/jpeg. See http://www.ijg.org for more information. You need Release 6 or better. With Release 5, Netpbm build fails with undefined jpeg symbols. The basic JPEG library installation procedure installs only the runtime part of the package -- you nee the development part as well, so run 'make install-lib'. The JPEG library documentation erroneously calls this installing "the library itself." This apparently was written before shared libraries. With shared libraries, "the library itself" is part of the runtime installation, but install-lib still installs the compile-time stuff you need. You may also need the JPEG library to build the Tiff converters. If your Tiff library references a shared JPEG library, then you do. The Tiff library may also include a static copy of the JPEG library, in which case you won't need a separate JPEG library. Or it may have been built without any JPEG compression capability, in which case you won't need a separate JPEG library, but the Tiff converters won't be able to handle Tiff with JPEG compression. The same goes for Ppmtompeg. You need the jpeg library if you want to create MPEGs from JPEGs (without the loss of quality that comes with converting from JPEG to PPM first), and if you don't have the JPEG library and don't say so in Makefile.config, you won't be able to build Ppmtompeg at all. To build or use Pnmtopng and Pngtopnm, you need the Zlib compression library and the PNG library (libpng). You can get Zlib from ftp://quest.jpl.nasa.gov/pub/zlib or ftp://metalab.unc.edu/pub/Linux/libs. You can get libpng from http://www.libpng.org/pub/png/libpng.html or http://libpng.sourceforge.net. Older libpng won't work -- you get unresolved external references to png_sig_cmp and png_set_sig_bytes. You may also need the Zlib to build the Tiff converters, in the same way as the Tiff converters require the JPEG libraries, as explained above. Pstopnm (the Postscript to PNM image converter) requires Ghostscript (installed with the name 'gs' in your command search path). And it requires in particular that Ghostscript be built with the relevant PNM device drivers. See http://www.gnu.org/ghostscript/ . The Utah Raster Toolkit is not a prerequisite because Netpbm includes a subset of it that meets the needs of Pnmtorle and Rletopnm. However, you can also substitute the real package by properly configuring Makefile.config. You can get it from ftp://ftp.cs.utah.edu/pub/dept/OLD/pub/urt-3.1b.tar.Z. There's a patch at ftp://ptolemy.berkeley.edu/pub/misc/urt/urt-3.1b-3.1b1.patch For more prerequisite information for CYGWIN (Windows), see the Cygwin section below. INSTALLATION ------------ For most typical platforms, you can just do configure followed by make To build all the programs. Then make install to install them all. The 'configure' program is not GNU Autoconf -- it is a simple program specific to Netpbm that prompts you for information about your system. If your system is not typical, you'll have to do a little more work, as described below under "custom installation." When you don't set up the build properly (and Configure is unable to guess your configuration), the build error messages you get are anything but indicative of your mistake. So if you have build error messages you can't interpret, see the COMMON BUILD ERROR MESSAGES section. The only tricky part about installing is setting up the shared libraries that are part of Netpbm. 'make install' copies them into place, but that may not be enough. If you get mysterious "file not found" kinds of errors and are not an expert with shared libraries, see the section "SHARED LIBRARIES" below. You may want to append the contents of the file 'magic' to your 'file' database (typically /etc/magic). This allows the 'file' program to recognize a bunch of file formats, including the Netpbm formats. The --keep-going option to Make is handy, because it causes Make to make anything it can, as opposed to quitting as soon as something goes wrong. With so many parts having so many requirements, it's not unusual for a few things to fail to build, but that doesn't affect everything else. You can work on the failed parts and repeat the make and it will attempt to build whatever it hasn't successfully built yet. INSTALLATION - CYGWIN --------------------- (See also the general installation instructions above). Cygwin is a software package that sets up a Unix-like platform on a Windows (win32) system. Here are some specific things you need in that environment to build and use Netpbm. All these programs and libraries are parts of cygwin package. Programs: 1) gcc suite 2) binutils 3) bash 4) dlltool 5) flex & byacc 6) patch 7) install 8) rm, ln, cp and other file utilities Libraries: 1) libtiff (cygtiff3.dll) 2) libpng (cygpng2.dll) 3) libjpeg6b (cygjpeg6b.dll) 4) libz (cygz.dll) Find Cygwin at http://sources.redhat.com/cygwin/ . One problem special to Windows is the common existence of directories with space in their names (e.g. Windows 2000's "Documents and Settings" directory. (Such filenames are possible on non-Windows systems, but are highly unconventional). Don't try to build Netpbm in such a directory or with files in such a directory. It ought to work, but it just doesn't. And the error messages are far from helpful, since those spaces completely change the nature of the commands that include them. One way to deal with this is to use the Cygwin "mount" facility to map the Windows path "c:/Documents and Settings/aaa/bbb/cccc/Distributions" to something short and friendly, such as /Distributions. INSTALLATION - MAKING ONLY THE PARTS YOU NEED --------------------------------------------- If you don't need the whole package, but just want one tool in it that you heard about, you can make just that one. For example, to make Ppmtojpeg, just do configure cd ppm make ppmtojpeg It will build Ppmtojpeg and any of its dependencies, but nothing else. You have to install it manually. When you build just one program, you should request static libraries in the configure step, because for just one program, the shared libraries would be pure masochism. CUSTOM INSTALLATION ------------------- This section explains how to customize the installation in the case that your platform is, or your requirements are, not among the simple cases that 'configure' understands. 'configure' is really just a convenient way to build the Makefile.config file, and in the most general case, you build that file manually. Makefile.config contains settings for various things that vary from one system to the next, like file paths. Start with the distributed file Makefile.config.in. Copy it as Makefile.config, then edit it. Search for your platform name (Solaris, SunOS, NetBSD, Cygwin, BeOS, and Tru64 are among those mentioned) to see recommended settings for your platform. Unless you want to do some make file rewriting, you will need to use GNU Make even if nothing else on your system is GNU, because the Netpbm make files exploit some advanced features of GNU Make. Often, systems have both GNU Make and a native Make. In this case, GNU Make is named 'gmake'. If you don't have it yet, see www.gnu.org/software. GNU Make is free, easy to install, and works just about anywhere. If your system is even too exotic to accomodate with settings in Makefile.config, you may need to modify things in the main make files or pm_config.h. If you figure out how to install on other platforms, contact the Netpbm maintainer to have the 'configure' program or these instructions improved for the next person. INSTALLATION - MISCELLANEOUS ---------------------------- After installing the manual pages, you may want to create the "whatis" file by doing a catman -w -M , or makewhatis -w, or whatever the equivalent is on your system. Without Whatis, you may have a hard time finding the Netpbm tools you have installed. INSTALLATION - SHARED LIBRARIES ------------------------------- There are over 220 programs in the Netpbm package and they do a lot of common things. In order to avoid the expense of copying the code for those common things into every program, Netpbm places it in 4 shared libraries: libpbm, libpgm, libppm, and libpnm. When you invoke a Netpbm program, your system notices that it needs these libraries and accesses them too. The tricky part of installing the shared (runtime) libraries is telling your system where to find them in the event that you invoke a Netpbm program. And that varies from one system to the next. On a GNU libc system (essentially, any Linux system), if you put the Netpbm shared libraries in a conventional spot (say, /lib) and reboot your system, chances are you will have no trouble running Netpbm programs. But if you want to fine tune things, read up on ld-linux.so (GNU libc's dynamic linker) and ldconfig and consider the /etc/ld.so.conf file and LD_LIBRARY_PATH environment variables. Use 'ldd' to see if you have a shared library issue. If it shows any shared library as "not found", you've got library trouble. One final note: New Netpbm executables often can run OK with old Netpbm shared libraries. This means if you don't correctly install the new libraries, you may run what you think is a new Netpbm program, but in actuality be accessing the old Netpbm library, and you may not even notice a problem right away. But eventually, you may find some things not working the way they should. Again, 'ldd' will give you peace of mind. INSTALLATION WITHOUT SHARED LIBRARIES ------------------------------------- Since shared libraries can be such a pain, and in fact some systems don't even have them, you can build Netpbm with static libraries instead. Just answer "static" to the static/shared question when you run 'configure' (if you don't use 'configure', set NETPBMLIBTYPE as directed in Makefile.config). If you do this, you probably want to do a merge build instead of the normal build (there's a question for that in the Configure program). This creates several large ("merged") programs that contain the functions of lots of smaller programs. When you invoke a merged program, it behaves like the smaller program whose name matches the command you used to invoke the merged program. For example, Ppmtogif and Ppmtobmp get merged into a program called Ppmmerge. You install it with a symbolic link such that when you invoke 'ppmtogif' you get 'ppmmerge'. When you invoke 'ppmtogif', Ppmmerge executes Ppmtogif. Hence, 'make install' installs the large merged programs and creates lots of symbolic links to them. The point of this is to reduce the duplication of all the library functions across large numbers of programs. COMMON BUILD ERROR MESSAGES --------------------------- When you fail to configure Netpbm properly for your environment (and the Configure program isn't smart enough to do it for you), the error messages you get are anything but indicative of your mistake. I've compiled some of the common ones that have been reported to me here with explanations of the root cause. [actually, I don't have any yet. Email me yours and I'll add it.] SUPPORT ------- The maintainer of Netpbm, since September 1999, is Bryan Henderson: bryanh@giraffe-data.com. Or as a backup, giraffedata@yahoo.com. Bryan actively maintains the package and wants to know about any bugs or problems people have with Netpbm or suggestions for improvement. There is no bug reporting database or mailing list. These would not be very useful with Netpbm because Bryan personally responds to all bug reports and requests for help immediately and releases fixes to known bugs before others have a chance to encounter them. The HISTORY file in the package may be useful if you want to find out whether upgrading to the current release would solve your problem. HISTORY ------- See the file HISTORY. MORE INFORMATION ---------------- A good place to start for information about the wide world of computer graphics is http://www.faqs.org/faqs/graphics/ . Information about PNG is at http://schaik.com/png. COPYRIGHTS ---------- See the file COPYRIGHT. netpbm-free-10.0-1/README.1st0100644004714500471450000000056507776237554015741 0ustar aba-guestaba-guestWelcome to netpbm ~~~~~~~~~~~~~~~~~ The documentation is just under re-construction. Please see the following files at the moment: * doc/html/outside-debian.html for information on usage of netpbm outside of Debian (Yes, we support this). * debian/copyright on the copyright of the programms included into netpbm * doc/licenses: the verbatim text of different licenses netpbm-free-10.0-1/README.DJGPP0100644004714500471450000000407207776237374016073 0ustar aba-guestaba-guestWarning: The Netpbm distribution uses long filenames, so you can only build the package in a W9x environment, with LFN support. To build Netpbm with DJGPP v2.0x you need: - djgpp: gcc, make, and binutils - bash - fileutils - sed - groff (to convert man pages to cat format) - man and less (to read the converted man pages) You can fetch all packages on Simtelnet in the DJGPP tree: ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/ You need too four external libraries to add tiff, png and jpeg support to Netpbm (you can build without them, modifying Makefile.config.djgpp but I think it makes Netpbm useless). - Libtiff (www.libtiff.org) - Libjpeg (www.ijg.org) - Libpng (www.libpng.org/pub/png/libpng.html) - Libz (www.info-zip.org/pub/infozip) All libraries come with guidelines to compile ok with DJGPP. At this time you can get binary packages of libjpeg, libpng and libz on Simtelnet. To build the Netpbm programs do the following: Copy Makefile.config.djgpp to Makefile.config Run "touch Makefile.config" to prevent Make from updating the file. Read the Makefile.config and make any changes you want Do "make merge" Do "make install-merge" to install binaries and man pages. Makefile.config.djgpp is set up to install these in TMPDIR/netpbm (normally /dgjpp/tmp/netpbm). If everything worked OK, you can move the contents of this directory to your DJGPP production tree. WARNING There are some problems that have to be addressed if using the binaries in pure DOS OS, without long file names, but it works OK using "netpbm " ( is the real Netpbm program to be used, for example: netpbm ppmtobmp testimg.bmp instead of the usual ppmtobmp testimg.bmp). This procedure and the code to adapt Netpbm to DJGPP was contributed by M.Alvarez in August 2001. You can find his current information on using Netpbm with DJGPP and prebuilt binaries at . netpbm-free-10.0-1/TODO0100644004714500471450000000441507776237374015041 0ustar aba-guestaba-guestThis file has the usage to remind the maintainer what he should do. You don't need to read this file if you extracted tagged code out of alioth: The warnings below don't apply then. Warning. This is work in progress. Use it only if the progression bar is on a useable state. The total goal is to take the debian package to current without loosing the security fixes and the code audits. And: Be warned that some programs may not be DFSG-free. This will be fixed before release. Get to 9.25 =>Get to 10.0 Include the trivial patch parts (means: some patches are applied only half) Include the not-so-trivial patch parts Make the legacy links Make sure the package is DFSG-free Make sure the package is compileable and other final polishing Get to 10. Small todo: - #142579 if I get a patch (as I have asked) Recheck: - pnm/pnmnorm - pnm/pamstretch-gen - pnm/pnmcolormap - pnm/pnmpad (overflow_add) - is it ok to move bitio.c to libpbm? Yes, because ppm always includes pbm. - picttoppm.1 +> file was dropped in stable because "error unfixable ..." Why? Todo: - who owns / License ppmfade -> contributed to pd -> mistake wrote in orig file according to Bryan, waiting for explicit ok - Make system is really broken -> make don't stop on errors!! - review the tmpfile-patches - repair ppmquantall - why has ppmtompeg different output if using parallel? Left over from 10.0: Add pamendian. [BH] Add pamtohdiff, hdifftopam. [BH] ppmqvga: remove; appears to be obsoleted by Pnmquant. [BH] ppmtouil: rename to pamtouil, add transparency. [BH] Export now pm_canonstr, pm_openColornameFile, pm_colorget, pm_rgbnorm, pnm_scalesample, pnm_setpamrow and pam_colorname. manpages for that! - bitio.h??? Later: http://www.kirchgessner.net/pnm.html http://www.cs.cmu.edu/People/dkindred/netpbm-patches/ ./ppm/ppmtompeg/iframe.c: sprintf(fileName, "%s.decoded.%d", outputFileName ... is ugly ./ppm/ppmtompeg/parallel.c: fixed. ./ppm/ppmtorgb3.c: Write warning in manual page ./pnm/fiasco/lib/bit-io.c: writes anywhere in the path. Ok? ./ppm/ppmfade ./pnm/pnmquant: Don't use "UNLINK => $TRUE"! remove buildtools/libopt copyright of hdifftopam, pamtohdiff (Bryan) (c) of pnmendian? move libpnm4.c -> rast.c ? ..pcdindex? /pcdovtoppm bmp.h ppmtouil -> pamtouil.c ... netpbm-free-10.0-1/configure0100755004714500471450000006345607732352703016254 0ustar aba-guestaba-guest#!/usr/bin/perl -w die "You don't want to use this\nRead the comment at the start of the file"; # Sorry, but this script is probably broken # # It is not changed for the new makefile methods, and we don't use it at # debian, so we also don't test it. We're happy if someone fixes it, and # would welcome patches on this. use strict; use English; my ($TRUE, $FALSE) = (1,0); # This program generates Makefile.config, which is included by all of the # Netpbm makefiles. You run this program as the first step in building # Netpbm. (The second step is 'make'). # This program is only a convenience. It is supported to create # Makefile.config any way you want. In fact, an easy way is to copy # Makefile.config.in and follow the instructions in the comments therein # to uncomment certain lines and make other changes. # Note that if you invoke 'make' without having first run 'configure', # the make will call 'configure' itself when it finds # 'Makefile.config' missing. That might look a little messy to the # user, but it isn't the normal build process. # The argument to this program is the filepath of the Makefile.config.in # file. If unspecified, the default is 'Makefile.config.in' in the # current directory. # For explanations of the stuff we put in the make files, see the comments # in Makefile.config.in. sub symlink_command(); sub getsvga($); my $config_in_path; if (@ARGV > 0) { $config_in_path = $ARGV[0]; } else { $config_in_path = "Makefile.config.in"; } if (stat("Makefile.config")) { print("Discard existing Makefile.config?\n"); print("Y or N (N) ==> "); my $answer = ; chomp($answer); if (uc($answer) ne "Y") { exit(1); } } print("\n"); my $platform; { print("Which of the following best describes your platform?\n"); print("gnu GNU/Linux\n"); print("sun Solaris or SunOS\n"); print("hp HP-UX\n"); print("aix AIX\n"); print("win Windows/DOS (Cygwin, DJGPP, Mingw32)\n"); print("tru64 Tru64\n"); print("irix Irix\n"); print("bsd NetBSD, BSD/OS\n"); print("openbsd OpenBSD\n"); print("osx Darwin or Mac OS X\n"); print("unixware Unixware\n"); print("beos BeOS\n"); print("none none of these are even close\n"); print("\n"); my $default; if ($OSNAME eq "linux") { $default = "gnu"; } elsif ($OSNAME eq "aix") { $default = "aix"; } elsif ($OSNAME eq "cygwin") { $default = "win"; } # OK - if you know what $OSNAME is on any other platform, send me a patch! print("Your choice "); if (defined($default)) { print("($default)"); } print("==> "); my $response = ; print("\n"); if (!defined($response)) { print("Aborting.\n"); exit; } chomp($response); if ($response eq "") { if (defined($default)) { $response = $default; } else { print("Aborting.\n"); exit; } } my %platform = ("gnu" => "GNU", "sun" => "SOLARIS", "hp" => "HP-UX", "aix" => "AIX", "tru64" => "TRU64", "irix" => "IRIX", "win" => "WINDOWS", "beos" => "BEOS", "bsd" => "NETBSD", "openbsd" => "OPENBSD", "unixware" => "UNIXWARE", "osx" => "DARWIN", "none" => "NONE" ); $platform = $platform{$response}; if (!defined($platform)) { print("'$response' isn't one of the choices.\n"); exit 8; } } if ($platform eq "NONE") { print("You will have to construct Makefile.config manually. To do \n"); print("this, copy Makefile.config.in as Makefile.config, and then \n"); print("edit it. Follow the instructions and examples in the file. \n"); print("Please report your results to the Netpbm maintainer so he \n"); print("can improve the configure program. \n"); exit; } my $subplatform; if ($platform eq "WINDOWS") { print("Are you building in/for the Cygwin environment?\n"); print("\n"); my $default; if ($OSNAME eq "cygwin") { $default = "y"; } else { $default = "n"; } print("(y)es or (n)o ($default)=> "); my $response = ; chomp($response); if ($response eq "") { $response = $default; } if (uc($response) =~ /^(Y|YES)$/) { $subplatform = "cygwin"; } elsif (uc($response) =~ /^(N|NO)$/) { $subplatform = "other"; } else { print("'$response' isn't one of the choices. \n" . "You must choose 'yes' or 'no' (or 'y' or 'n').\n"); exit 12; } } my $compiler; if ($platform eq "SOLARIS") { print("GNU compiler or Sun compiler?\n"); print("\n"); my $default = "gcc"; print("gcc or sun ($default)=> "); my $response = ; chomp($response); if ($response eq "") { $response = $default; } if ($response eq "gcc") { $compiler = "gcc"; } elsif ($response eq "sun") { $compiler = "sun"; } else { print("'$response' isn't one of the choices. \n" . "You must choose 'gcc' or 'sun'.\n"); exit 12; } } my $default_target; print("Do you want a regular build or a merge build (see README)?\n"); print("\n"); { my $default = "regular"; print("regular or merge ($default)=> "); my $response = ; chomp($response); if ($response eq "") { $response = $default; } if ($response eq "regular") { $default_target = "nonmerge"; } elsif ($response eq "merge") { $default_target = "merge"; } else { print("'$response' isn't one of the choices. \n" . "You must choose 'regular' or 'merge'.\n"); exit 12; } } print("\n"); my ($netpbmlibtype, $netpbmlibsuffix, $shlibprefixlist); my $willBuildShared; print("Do you want static-linked Netpbm libraries or shared?\n"); print("\n"); { my $default = ($default_target eq "merge") ? "static" : "shared"; print("static or shared ($default)=> "); my $response = ; chomp($response); if ($response eq "") { $response = $default; } if ($response eq "shared") { $willBuildShared = $TRUE; if ($platform eq "WINDOWS") { $netpbmlibtype = "dll"; $netpbmlibsuffix = "dll"; if ($subplatform eq 'cygwin') { $shlibprefixlist = "cyg lib"; } else { $shlibprefixlist = "lib"; } } elsif ($platform eq "DARWIN") { $netpbmlibtype = "dylib"; $netpbmlibsuffix = "dylib"; $shlibprefixlist = "lib"; } else { $netpbmlibtype = "unixshared"; if ($platform eq "AIX") { $netpbmlibsuffix = "a"; } elsif ($platform eq "HP-UX") { $netpbmlibsuffix = "sl"; } else { $netpbmlibsuffix = "so"; } $shlibprefixlist = "lib"; } } elsif ($response eq "static") { $willBuildShared = $FALSE; $netpbmlibtype = "unixstatic"; $netpbmlibsuffix = "a"; $shlibprefixlist = "lib"; # not used in Makefile static # targets, but needed for building # libopt } else { print("'$response' isn't one of the choices. \n" . "You must choose 'static' or 'shared'.\n"); exit 12; } } print("\n"); my $staticlib_too; if ($netpbmlibtype eq "unixshared" or $netpbmlibtype eq "dll") { print("Do you want to build static libraries too (for linking to \n"); print("programs not in the Netpbm package?\n"); print("\n"); my $default = "y"; print("(y)es or (n)o ($default)=> "); my $response = ; chomp($response); if ($response eq "") { $response = "y"; } if (uc($response) =~ /^(Y|YES)$/) { $staticlib_too = "y"; } elsif (uc($response) =~ /^(N|NO)$/) { $staticlib_too = "n"; } else { print("'$response' isn't one of the choices. \n" . "You must choose 'yes' or 'no' (or 'y' or 'n').\n"); exit 12; } } else { $staticlib_too = "n"; } print("\n"); #****************************************************************************** # # INSTALLATION QUESTIONS # #***************************************************************************** print("The remaining questions concern how Netpbm is installed when you do\n"); print("'make install'. None of these answers affect what gets built by\n"); print("'make'. In particular, none of the directory paths you specify\n"); print("are built into any Netpbm program or library -- you can move them\n"); print("around as you like.\n"); print("\n"); my $install_prefix; print("Enter the installation directory. Everything gets installed under\n"); print("This directory. If you want to spread Netpbm across your system,\n"); print("specify '/'\n"); print("\n"); { my $default; if ($platform eq "TRU64") { $default = "/usr/local1/DEC/packages/netpbm"; } elsif ($platform eq "WINDOWS" and stat("/djgpp")) { $default = "/djgpp"; } elsif ($platform eq "WINDOWS" and $subplatform eq "cygwin") { $default = "/usr/local"; } else { $default = "/usr/local/netpbm"; } print("install prefix ($default)=> "); my $response = ; chomp($response); if ($response eq "") { $response = $default; } $install_prefix = $response; } print("\n"); my $installbinaries; print("Enter the install location for programs, relative to " . "$install_prefix.\n"); print("\n"); { my $default; if ($platform eq "WINDOWS") { $default = "bin/netpbm"; } else { $default = "bin"; } print("program directory ($default)=> "); my $response = ; chomp($response); if ($response eq "") { $response = $default; } elsif (substr($response,0,1) eq "/") { die("Cannot start with '/'. This is a _relative_ path."); } $installbinaries = '$(INSTALL_PREFIX)/' . $response; } print("\n"); my $installlibs; if ($willBuildShared) { print("Enter the install location for shared (runtime) libraries,\n"); print("relative to $install_prefix.\n"); print("\n"); { my $default = "lib"; print("library directory ($default)=> "); my $response = ; chomp($response); if ($response eq "") { $response = $default; } elsif (substr($response,0,1) eq "/") { die("Cannot start with '/'. This is a _relative_ path."); } $installlibs = '$(INSTALL_PREFIX)/' . $response; } } print("\n"); my $installstaticlibs; print("Enter the install location for linktime libraries,\n"); print("relative to $install_prefix.\n"); print("These are libraries that get used when you build a program that\n"); print("is not in the Netpbm package, but uses the Netpbm subroutine\n"); print("libraries. This includes both static-linking libraries and\n"); print("stubs for shared libraries\n"); print("\n"); { my $default = "lib"; print("link directory ($default)=> "); my $response = ; chomp($response); if ($response eq "") { $response = $default; } elsif (substr($response,0,1) eq "/") { die("Cannot start with '/'. This is a _relative_ path."); } $installstaticlibs = '$(INSTALL_PREFIX)/' . $response; } print("\n"); my $installhdrs; print("Enter the install location for interface headers,\n"); print("relative to $install_prefix.\n"); print("These get used when you compile a program which is not in the\n"); print("Netpbm package, but uses the Netpbm subroutine libraries.\n"); print("\n"); { my $default = "include"; print("header directory ($default)=> "); my $response = ; chomp($response); if ($response eq "") { $response = $default; } elsif (substr($response,0,1) eq "/") { die("Cannot start with '/'. This is a _relative_ path."); } $installhdrs = '$(INSTALL_PREFIX)/' . $response; } print("\n"); my $installman; print("Enter the install location for man pages,\n"); print("relative to $install_prefix.\n"); print("\n"); { my $default = "man"; print("man page directory ($default)=> "); my $response = ; chomp($response); if ($response eq "") { $response = $default; } elsif (substr($response,0,1) eq "/") { die("Cannot start with '/'. This is a _relative_ path."); } $installman = '$(INSTALL_PREFIX)/' . $response; } print("\n"); my ($linuxsvgahdr, $linuxsvgalib) = getsvga($platform); #****************************************************************************** # # BUILD THE FILE # #***************************************************************************** my @Makefile_config; # This is the complete Makefile.config contents. We construct it here # and ultimately write the whole thing out as Makefile.config. # First, we just read the 'Makefile.config.in' in open (CONFIG_IN,"<$config_in_path") or die("Unable to open file '$config_in_path' for input. That file is " . "supposed to be in the Netpbm source top level directory, the " . "same as the 'configure' program."); @Makefile_config = ; unshift(@Makefile_config, "####This file was automatically created by 'configure.'\n", "####Many variables are set twice -- a generic setting, then \n", "####a system-specific override at the bottom of the file.\n", "####\n"); close(CONFIG_IN); # Now, add the variable settings that override the default settings that are # done by the Makefile.config.in contents. push(@Makefile_config, "\n\n\n\n"); push(@Makefile_config, "####Lines above were copied from Makefile.config.in " . "by 'configure'.\n"); push(@Makefile_config, "####Lines below were added by 'configure' based on " . "the $platform platform.\n"); push(@Makefile_config, "DEFAULT_TARGET = $default_target\n"); push(@Makefile_config, "NETPBMLIBTYPE=$netpbmlibtype\n"); push(@Makefile_config, "NETPBMLIBSUFFIX=$netpbmlibsuffix\n"); push(@Makefile_config, "SHLIBPREFIXLIST=$shlibprefixlist\n"); push(@Makefile_config, "STATICLIB_TOO=$staticlib_too\n"); if ($platform eq "GNU") { # All the defaults are designed for a typical GNU system, so we don't # have to do much here. # # Red Hat Linux doesn't have 'ginstall', for some crazy reason, but # # of course 'install' is GNU install. # my $ginstall_result = `ginstall --version 2>/dev/null`; # if (!$ginstall_result) { # # System doesn't have 'ginstall', so use 'install' instead. # push(@Makefile_config, "INSTALL = install\n"); # } push(@Makefile_config, "CFLAGS = -pedantic -O3 " . "-Wall -Wno-uninitialized -Wmissing-declarations\n"); # The merged programs have a main_XXX subroutine instead of main(), # which would cause a warning with -Wmissing-declarations push(@Makefile_config, "CFLAGS_MERGE = -Wno-missing-declarations\n"); } elsif ($platform eq "SOLARIS") { # push(@Makefile_config, "INSTALL = /usr/ucb/install\n"); # If the system uses gcc as a linker, the following LDFLAGS isn't right. push(@Makefile_config, 'LDFLAGS = -R$(INSTALLLIBS)', "\n"); # If the system uses GNU Ld, the following LDSHLIB isn't right. push(@Makefile_config, 'LDSHLIB = -Wl,-B,dynamic,-G,-h,$(SONAME) -R$(INSTALLLIBS)', "\n"); push(@Makefile_config, 'NEED_RUNTIME_PATH = Y', "\n"); if ($compiler eq "sun") { push(@Makefile_config, "CC = cc\n"); push(@Makefile_config, "CFLAGS = -O\n"); push(@Makefile_config, "CFLAGS_SHLIB = -Kpic\n"); } push(@Makefile_config, "NETWORKLD = -lsocket -lnsl\n"); } elsif ($platform eq "HP-UX") { push(@Makefile_config, 'CFLAGS = -O3 -fPIC $(CDEBUG)', "\n"); push(@Makefile_config, 'LDFLAGS = -Wl,+b,/usr/pubsw/lib', "\n"); } elsif ($platform eq "AIX") { push(@Makefile_config, 'CFLAGS = -O3 -D_ALL_SOURCE $(CDEBUG)', "\n"); push(@Makefile_config, 'LDFLAGS = -L /usr/pubsw/lib', "\n"); } elsif ($platform eq "TRU64") { push(@Makefile_config, "CC=cc\n"); push(@Makefile_config, "LD=cc\n"); # push(@Makefile_config, "INSTALL = installbsd\n"); push(@Makefile_config, 'CFLAGS = -O2 -std1 -DLONG_32 $(CDEBUG)', "\n"); push(@Makefile_config, "LDFLAGS = -call_shared -oldstyle_liblookup\n"); push(@Makefile_config, "LDSHLIB = -shared -expect_unresolved \"*\"\n"); push(@Makefile_config, "TIFFHDR_DIR = /usr/local1/DEC/include\n"); push(@Makefile_config, "TIFFLIB_DIR = /usr/local1/DEC/lib\n"); push(@Makefile_config, "JPEGLIB_DIR = /usr/local1/DEC/lib\n"); push(@Makefile_config, "JPEGHDR_DIR = /usr/local1/DEC/include\n"); push(@Makefile_config, "PNGLIB_DIR = /usr/local1/DEC/lib\n"); push(@Makefile_config, "PNGHDR_DIR = /usr/local1/DEC/include\n"); push(@Makefile_config, "NETWORKLD = NONE\n"); } elsif ($platform eq "IRIX") { push(@Makefile_config, "CC=cc\n"); # push(@Makefile_config, "INSTALL = install\n"); push(@Makefile_config, 'MANCP = $(SRCDIR)/buildtools/mantocat', "\n"); push(@Makefile_config, 'RANLIB = true', "\n"); push(@Makefile_config, 'CFLAGS = -n32 -O3', "\n"); push(@Makefile_config, 'LDFLAGS = -n32', "\n"); push(@Makefile_config, 'LDSHLIB = -shared -n32', "\n"); } elsif ($platform eq "WINDOWS") { # Until 9.15 (June 2001), we set MANCP here because it appeared that DJGPP # required it. Now I'm not sure. # push(@Makefile_config, 'MANCP = $(SRCDIR)/buildtools/mantocat', "\n"); push(@Makefile_config, "EXE = .exe\n"); push(@Makefile_config, "NETWORKLD = NONE\n"); # # Though it may not have the link as "ginstall", "install" in a Windows # # Unix environment is usually GNU install. # my $ginstall_result = `ginstall --version 2>/dev/null`; # if (!$ginstall_result) { # # System doesn't have 'ginstall', so use 'install' instead. # push(@Makefile_config, "INSTALL = install\n"); # } push(@Makefile_config, 'SYMLINK = ', symlink_command(), "\n"); push(@Makefile_config, "LDSHLIB = " . '-shared -Wl,--enable-auto-image-base', "\n"); push(@Makefile_config, 'TIFFHDR_DIR = /usr/include', "\n"); push(@Makefile_config, 'TIFFLIB_DIR = /usr/lib', "\n"); push(@Makefile_config, 'JPEGLIB_DIR = /usr/lib', "\n"); push(@Makefile_config, 'JPEGHDR_DIR = /usr/include', "\n"); push(@Makefile_config, 'PNGLIB_DIR = /usr/lib', "\n"); push(@Makefile_config, 'PNGHDR_DIR = /usr/include', "\n"); push(@Makefile_config, 'ZLIB_DIR = /usr/lib', "\n"); push(@Makefile_config, 'ZHDR_DIR = /usr/include', "\n"); } elsif ($platform eq "BEOS") { push(@Makefile_config, "LDSHLIB = -nostart\n"); } elsif ($platform eq "NETBSD") { push(@Makefile_config, 'LDFLAGS = -Wl,--rpath,$(INSTALLLIBS)', "\n"); push(@Makefile_config, 'CFLAGS_SHLIB = -fpic', "\n"); push(@Makefile_config, 'TIFFHDR_DIR = $(LOCALBASE)/include', "\n"); push(@Makefile_config, 'TIFFLIB_DIR = $(LOCALBASE)/lib', "\n"); push(@Makefile_config, 'JPEGLIB_DIR = $(LOCALBASE)/lib', "\n"); push(@Makefile_config, 'JPEGHDR_DIR = $(LOCALBASE)/include', "\n"); push(@Makefile_config, 'PNGLIB_DIR = $(LOCALBASE)/lib', "\n"); push(@Makefile_config, 'PNGHDR_DIR = $(LOCALBASE)/include', "\n"); push(@Makefile_config, "\n"); } elsif ($platform eq "OPENBSD") { # vedge@vedge.com.ar says on 2001.04.29 that there are a ton of # undefined symbols in the Fiasco stuff on OpenBSD. So we'll just # cut it out of the build until someone feels like fixing it. push(@Makefile_config, 'BUILD_FIASCO = N', "\n"); } elsif ($platform eq "UNIXWARE") { # Nothing to do. } elsif ($platform eq "DARWIN") { push(@Makefile_config, "CC = cc -no-cpp-precomp\n"); push(@Makefile_config, 'CFLAGS_SHLIB = -fno-common', "\n"); push(@Makefile_config, 'LDSHLIB = -dynamiclib -install_name $(INSTALLLIBS)/lib$(LIBROOT).$(MAJ).dylib', "\n"); # push(@Makefile_config, "INSTALL = install\n"); push(@Makefile_config, 'TIFFHDR_DIR = $(LOCALBASE)/include', "\n"); push(@Makefile_config, 'TIFFLIB_DIR = $(LOCALBASE)/lib', "\n"); push(@Makefile_config, 'JPEGLIB_DIR = $(LOCALBASE)/lib', "\n"); push(@Makefile_config, 'JPEGHDR_DIR = $(LOCALBASE)/include', "\n"); push(@Makefile_config, 'PNGLIB_DIR = $(LOCALBASE)/lib', "\n"); push(@Makefile_config, 'PNGHDR_DIR = $(LOCALBASE)/include', "\n"); } else { die ("Internal error: invalid value for \$platform: '$platform'\n"); } my $flex_result = `flex --version`; if (!$flex_result) { # System doesn't have 'flex'. Maybe 'lex' will work; we don't really # know yet. 2001.05.16. # lex may work; we don't really know yet. Schwarb Manfred reports # that it compiles OK, but with warnings, on Solaris. Solaris Lex # has a -e option that eliminates the lex warnings, but causes # compiler warnings. AIX and Flex don't have a -e option. # -Bryan 2001.05.16. push(@Makefile_config, "LEX = lex\n"); # We could also set LEX to null, and then the one part that requires # it -- thinkjettopbm -- would simply not get built. # print("\n"); # print("There is no 'flex' command in your environment, so we will not\n"); # print("Build the part that requires it: thinkjettopbm.\n"); # print("\n"); # print("Press ENTER to continue.\n"); my $key = ; } if (defined($linuxsvgahdr)) { push(@Makefile_config, "LINUXSVGAHDR_DIR = $linuxsvgahdr\n"); } if (defined($linuxsvgalib)) { push(@Makefile_config, "LINUXSVGALIB_DIR = $linuxsvgalib\n"); } push(@Makefile_config, "INSTALL_PREFIX = $install_prefix\n"); push(@Makefile_config, "# Some people specify PREFIX= on the command line, " . "because that's conventional\n"); push(@Makefile_config, 'ifneq ($(PREFIX)x,x)', "\n"); push(@Makefile_config, ' INSTALL_PREFIX = $(PREFIX)', "\n"); push(@Makefile_config, 'endif', "\n"); if (defined($installbinaries)) { push(@Makefile_config, "INSTALLBINARIES = $installbinaries\n"); } if (defined($installlibs)) { push(@Makefile_config, "INSTALLLIBS = $installlibs\n"); } if (defined($installstaticlibs)) { push(@Makefile_config, "INSTALLSTATICLIBS = $installstaticlibs\n"); } if (defined($installhdrs)) { push(@Makefile_config, "INSTALLHDRS = $installhdrs\n"); } if (defined($installman)) { push(@Makefile_config, "INSTALLMAN = $installman\n"); } #****************************************************************************** # # WRITE OUT THE FILE # #***************************************************************************** open(MAKEFILE_CONFIG, ">Makefile.config") or die("Unable to open Makefile.config for writing in the current " . "directory."); print MAKEFILE_CONFIG @Makefile_config; close(MAKEFILE_CONFIG) or die("Error: Close of Makefile.config failed.\n"); print("\n"); print("We have created the file 'Makefile.config'. You can now \n"); print("proceed to enter the 'make' command.\n"); print("\n"); print("Note, however, that we guessed a lot at your configuration,\n"); print("and you may want to look at Makefile.config and\n"); print("edit it to your requirements and taste before doing the make. \n"); exit 0; sub symlink_command() { my $retval; # Some Windows environments don't have symbolic links (or even a # simulation via a "ln" command, but have a "cp" command which works # in a pinch. # I wish I knew how to eliminate the stderr messages from these, # but I don't think I can count on /dev/null existing on these # systems. print("We now check to see if the 'ln' and 'cp' commands exist on \n"); print("your system. Ignore any error messages.\n"); my $ln_rc = system("ln"); my $cp_rc = system("cp"); # I think 127 is universally the return code for "command not found" if ($ln_rc != 127) { $retval = "ln -s"; } elsif ($cp_rc != 127) { $retval = "cp"; } else { # Well, maybe we just made a mistake. $retval = "ln -s"; } return $retval; } sub getsvga($) { my ($platform) = @_; my ($linuxsvgahdr, $linuxsvgalib); if ($platform eq "GNU") { # Look for SVGALIB if (-f "/usr/include/vga.h") { $linuxsvgahdr = "/usr/include"; } elsif (-d "/usr/include/svgalib") { $linuxsvgahdr = "/usr/include/svgalib"; } else { print("Cannot find the include files for SVGALIB. Enter the " . "directory where they reside, or NONE. " . "If NONE, a default " . "make will not build programs that require " . "the SVGALIB library.\n"); print("Svgalib header location (NONE)=> "); my $response = ; chomp($response); if ($response eq "") { $response = "NONE"; } $linuxsvgahdr = $response; } if ($linuxsvgahdr eq "NONE") { $linuxsvgalib = "NONE"; } else { if (-f "/usr/lib/svgalib.so") { $linuxsvgalib = "/usr/lib/svgalib.so"; } elsif (-d "/usr/link/svgalib") { $linuxsvgalib = "/usr/link/svgalib"; } else { print("Cannot find the link libraries for SVGALIB. " . "Enter the " . "directory where they reside, or NONE. If NONE, " . "a default make will not build programs that require " . "the SVGALIB library.\n"); print("Svgalib link lib location (NONE)=> "); my $response = ; chomp($response); if ($response eq "") { $response = "NONE"; } $linuxsvgalib = $response; } } } return($linuxsvgahdr, $linuxsvgalib); } netpbm-free-10.0-1/libnetpbm.30100644004714500471450000000160307725054351016367 0ustar aba-guestaba-guest.TH libnetpbm 3 .SH NAME libnetpbm - functions to read and write the netpbm image files .SH "NOTE" libnetpbm is the common library of the netpbm-package. It consists of the functions that were previously available in the four seperate libraries libpbm (3), libpgm (3), libppm (3) and libpnm (3). Please see these manpages for the commands. .SH "SEE ALSO" .BR libpbm (3), .BR libpgm (3), .BR libppm (3), .BR libpnm (3), .BR pbm (5) .SH AUTHOR Copyright (C) 1989, 1991 by Tony Hansen and Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/magic0100644004714500471450000000076607716230207015337 0ustar aba-guestaba-guest0 string P7 Netpbm PAM image file 0 string \131\246\152\225 Sun rasterfile 0 string \115\115 TIFF file, big-endian 0 string \111\111 TIFF file, little-endian 0 string \117\072 Solitaire Image Recorder format >4 string \013 MGI Type 11 >4 string \021 MGI Type 17 0 string .MDA MicroDesign data >21 byte 48 version 2 >21 byte 51 version 3 0 string .MDP MicroDesign page data >21 byte 48 version 2 >21 byte 51 version 3 netpbm-free-10.0-1/netpbm-deprecated0100644004714500471450000000023307720475620017634 0ustar aba-guestaba-guestpgmnorm pnmnorm 2002 ppmnorm pnmnorm 2002 bmptopmm bmptopnm 2002 pnminterp-gen pamstretch-gen pnminterp pamstretch ppmtomap pnmcolormap (!) ppmtojpeg netpbm-free-10.0-1/netpbm.10100644004714500471450000007323207717167171015713 0ustar aba-guestaba-guest.TH netpbm 1 .SH NAME netpbm - package of graphics manipulation programs and libraries .SH DESCRIPTION .B Netpbm is a package of graphics programs and programming libraries. There are over 220 separate programs in the package, most of which have "pbm", "pgm", "ppm", or "pnm" in their names. For example, .B pnmscale and .BR giftopnm . For example, you might use .B pnmscale to shrink an image by 10%. Or use .B pnmcomp to overlay one image on top of another. Or use .B pbmtext to create an image of text. Or reduce the number of colors in an image with .BR pnmquant . .SH The Netpbm Formats All of the programs work with a set of graphics formats called the "netpbm" formats. Specifically, these formats are .BR pbm (5), .BR pgm (5), .BR ppm (5), and .BR pam (5). The first three of these are sometimes known generically as .BR pnm . Many of the Netpbm programs convert from a Netpbm format to another format or vice versa. This is so you can use the Netpbm programs to work on graphics of any format. It is also common to use a combination of Netpbm programs to convert from one non-Netpbm format to another non-Netpbm format. Netpbm has converters for over 80 graphics formats, and as a package Netpbm lets you do more graphics format conversions than any other computer graphics facility. The Netpbm formats are all raster formats, i.e. they describe an image as a matrix of rows and columns of pixels. In the PBM format, the pixels are black and white. In the PGM format, pixels are shades of gray. In the PPM format, the pixels are in full color. The PAM format is more sophisticated. A replacement for all three of the other formats, it can represent matrices of general data including but not limited to black and white, grayscale, and color images. Programs designed to work with PBM images have "pbm" in their names. Programs designed to work with PGM, PPM, and PAM images similarly have "pgm", "ppm", and "pam" in their names. All Netpbm programs designed to read PGM images see PBM images as if they were PGM too. All Netpbm programs designed to read PPM images see PGM and PBM images as if they were PPM. See the section "Implied Format Conversion" below. Programs that have "pnm" in their names read PBM, PGM, and PPM but unlike "ppm" programs, they distinguish between them and their function depends on the format. For example, .B pnmtogif creates a black and white GIF output image if its input is PBM or PGM, but a color GIF output image if its input is PPM. And .B pnmscale produces an output image of the same format as the input. A .B ppmscale program would read all three PNM input formats, but would see them all as PPM and would always generate PPM output. If it seems wasteful to you to have three separate PNM formats, be aware that there is a historical reason for it. In the beginning, there were only PBMs. PGMs came later, and then PPMs. Much later came PAM, which realizes the possibility of having just one aggregate format. The formats are described in the man pages .BR pbm (5), .BR pgm (5), .BR ppm (5), and .BR pam (5), .SH Implied Format Conversion A program that uses the PGM library to read an image can read a PBM image as well as a PGM image. The program sees the PBM image as if it were the equivalent PGM image, with a maxval of 255. A program that uses the PPM library to read an image can read a PGM image as well as a PPM image and a PBM image as well as a PGM image. The program sees the PBM or PGM image as if it were the equivalent PPM image, with a maxval of 255 in the PBM case and the same maxval as the PGM in the PGM case. .SH Netpbm and Transparency In many graphics format, there's a means of indicating that certain parts of the image are wholly or partially transparent, meaning that if it were displayed "over" another image, the other image would show through there. Netpbm formats deliberately omit that capability, since their purpose is to be extremely simple. In Netpbm, you handle transparency via a transparency mask in a separate (slightly redefined) PGM image. In this pseudo-PGM, what would normally be a pixel's intensity is instead it an opaqueness value. See .BR pgm (5). .B pnmcomp is an example of a program that uses a PGM transparency mask. .SH The Netpbm Programs The Netpbm programs are generally useful run by a person from a command shell, but are also designed to be used by programs. A common characteristic of Netpbm programs is that they are simple, fundamental building blocks. They are most powerful when stacked in pipelines. Netpbm programs do not use graphical user interfaces (in fact, none of them display graphics at all, except for a very simple Linux Svgalib displayer) and do not seek input from a user. Each of these programs has its own man page. .SH Common Options There are a few options that are present on all programs that are based on the Netpbm libraries, including virtually all Netpbm programs. These are not mentioned in the individual man pages for the programs. .TP .B -quiet Suppress all informational messages that would otherwise be issued to Standard Error. (To be precise, this only works to the extent that the program in question implements the Netpbm convention of issuing all informational messages via the .B pm_message() service of the Netpbm libraries). .TP .B -version Instead of doing anything else, report the version of the .B libpbm library linked with the program (it may have been linked statically into the program, or dynamically linked at run time). Normally, the Netpbm programs and the libraries are installed at the same time, so this tells you the version of the program and all the other Netpbm libraries and files it uses as well. Here is a directory of the Netpbm programs. You can also use .B man -k to search for a program that does what you want. .SS Converters .TP .B ppmtompeg convert series of PPM frames to an MPEG movie .TP .B jpegtopnm convert JFIF/JPEG/EXIF file to Netpbm format .TP .B pnmtojpeg convert PPM to JPEG/JFIF/EXIF format .TP .B anytopnm convert any graphics format to Netpbm format .TP .B bmptoppm convert Windows or OS/2 Bitmap file to PPM .TP .B ppmtobmp convert PPM to Windows or OS/2 Bitmap file .TP .B winicontoppm convert Windows icon file to PPM .TP .B ppmtowinicon convert PPM to Windows icon file .TP .B giftopnm convert GIF to portable anymap .TP .B ppmtogif convert PPM to GIF .TP .B pnmtopng convert Netpbm format to Portable Network Graphics .TP .B pngtopnm convert PNG (Portable Network Graphics) to Netpbm formats .TP .B palmtopnm convert Palm pixmap to Netpbm formats .TP .B pnmtopalm convert Netpbm formats to Palm pixmap .TP .B jbigtopbm convert JBIG BIE (compressed bitmap) to PBM .TP .B pamtopnm convert a PAM image to PBM, PGM, or PPM .TP .B pbmtojbig convert PBM to JBIG BIE (compressed bitmap) .TP .B pnmtofiasco convert Netpbm image to Fiasco (wfa) highly compressed format .TP .B fiascotopnm convert Fiasco (wfa) highly compressed format to Netpbm image .TP .B hpcdtoppm convert photo CD to PPM .TP .B pbmtonokia convert PBM to Nokia Smart Messaging Format (SMF) .TP .B pbmtowbmp convert PBM to WAP (Wireless App Protocol) Wireless Bitmap .TP .B wbmptopbm convert WAP (Wireless App Protocol) Wireless Bitmap to PBM .TP .B neotoppm convert Atari Neochrome (.neo) image to PPM .TP .B ppmtoneo convert PPM image to Atari Neochrome (.neo) .TP .B pbmtomda convert from PBM to Microdesign (for Amstrad PCWs) .TP .B mdatopbm convert from Microdesign (for Amstrad PCWs) to PBM .TP .B atktopbm convert Andrew Toolkit raster object to PBM .TP .B pbmtoatk convert PBM to Andrew Toolkit raster object .TP .B brushtopbm convert Xerox doodle brushes to PBM .TP .B cmuwmtopbm convert CMU window manager format to PBM .TP .B g3topbm convert Group 3 FAX to PBM .TP .B pbmtog3 convert PBM to Group 3 FAX .TP .B icontopbm convert Sun icon to PBM .TP .B pbmtoicon convert PBM to Sun icon .TP .B gemtopnm convert GEM .img format to PBM or pixmap .TP .B macptopbm convert MacPaint to PBM .TP .B pbmtomacp convert PBM to MacPaint .TP .B mgrtopbm convert MGR format to PBM .TP .B pbmtomgr convert PBM to MGR format .TP .B pi3topbm convert Atari Degas .pi3 to PBM .TP .B pbmtopi3 convert PBM to Atari Degas .pi3 .TP .B xbmtopbm convert X10 or X11 bitmap to PBM .TP .B pbmtoxbm convert PBM to X11 bitmap .TP .B pbmtox10bm convert PBM to X10 bitmap .TP .B ybmtopbm convert Bennet Yee "face" file into PBM .TP .B pbmtoybm convert PBM into Bennet Yee "face" file .TP .B pbmto10x convert PBM to Gemini 10x printer graphics .TP .B pbmtoascii convert PBM to ASCII graphic form .TP .B asciitopgm convert ASCII character graphics to PGM .TP .B pbmtobbnbg convert PBM to BBN BitGraph graphics .TP .B pbmtocmuwm convert PBM to CMU window manager format .TP .B pbmtoepson convert PBM to Epson printer graphics .TP .B pbmtogem convert PBM into GEM .img file .TP .B pbmtogo convert PBM to GraphOn graphics .TP .B pbmtolj convert PBM to HP LaserJet black and white graphics .TP .B ppmtolj convert PPM to HP LaserJet color graphics (PCL) .TP .B pjtoppm convert HP PaintJet file to PPM .TP .B ppmtopj convert PPM to HP PaintJet file .TP .B thinkjettopbm convert HP Thinkjet printer stream to PBM .TP .B pbmtoplot convert PBM into Unix plot(5) file .TP .B pbmtoptx convert PBM to Printronix graphics .TP .B pbmtozinc convert PBM to Zinc Interface Library icon .TP .B fitstopnm convert FITS format to portable anymap .TP .B pnmtofits convert Netpbm formats to FITS format .TP .B fstopgm convert Usenix FaceSaver(tm) format to PGM .TP .B pgmtofs convert PGM to Usenix FaceSaver(tm) format .TP .B hipstopgm convert HIPS format to PGM .TP .B lispmtopgm convert a Lisp Machine bitmap file into PGM format .TP .B pgmtolispm convert PGM into Lisp Machine format .TP .B pnmtops convert Netpbm formats to Postscript .TP .B pstopnm convert Postscript to Netpbm formats .TP .B psidtopgm convert PostScript "image" data to PGM .TP .B pbmtolps convert PBM image to Postscript using lines .TP .B pbmtoepsi convert a PBM image to encapsulated Postscript preview bitmap .TP .B pbmtopsg3 convert PBM images to Postscript using G3 fax compression. .TP .B rawtopgm convert raw grayscale bytes to PGM .TP .B pgmtopbm convert PGM to PBM .TP .B gouldtoppm convert Gould scanner file to PPM .TP .B ilbmtoppm convert IFF ILBM to PPM .TP .B ppmtoilbm convert PPM to IFF ILBM .TP .B imgtoppm convert Img-whatnot to PPM .TP .B mtvtoppm convert MTV ray-tracer output to PPM .TP .B pcxtoppm convert PC Paintbrush format to PPM .TP .B pgmtoppm colorize a portable graymap into a PPM .TP .B pi1toppm convert Atari Degas .pi1 to PPM .TP .B ppmtopi1 convert PPM to Atari Degas .pi1 .TP .B picttoppm convert Macintosh PICT to PPM .TP .B ppmtopict convert PPM to Macintosh PICT .TP .B qrttoppm convert QRT ray-tracer output to PPM .TP .B rawtoppm convert raw RGB bytes to PPM .TP .B sldtoppm convert an AutoCAD slide file into a PPM .TP .B spctoppm convert Atari compressed Spectrum to PPM .TP .B sputoppm convert Atari uncompressed Spectrum to PPM .TP .B tgatoppm convert TrueVision Targa file to PPM .TP .B ppmtotga convert PPM to TrueVision Targa file .TP .B ximtoppm convert Xim to PPM .TP .B xpmtoppm convert XPM format to PPM .TP .B ppmtoxpm convert PPM to XPM format .TP .B yuvtoppm convert Abekas YUV format to PPM .TP .B eyuvtoppm convert Encoder/Berkeley YUV format to PPM .TP .B ppmtoeyuv convert PPM to Encoder/Berkeley YUV format .TP .B ppmtoyuv convert PPM to Abekas YUV format .TP .B ppmtoyuvsplit convert PPM to 3 subsampled raw YUV files .TP .B yuvsplittoppm merge 3 subsampled raw YUV files to one PPM .TP .B ppmtoacad convert PPM to AutoCAD database or slide .TP .B ppmtoicr convert PPM to NCSA ICR graphics .TP .B ppmtopcx convert PPM to PC Paintbrush format .TP .B ppmtopgm convert PPM to portable graymap .TP .B ppmtopuzz convert PPM to X11 "puzzle" file .TP .B rasttopnm convert Sun raster file to Netpbm formats .TP .B pnmtorast convert Netpbm formats to Sun raster file .TP .B tifftopnm convert TIFF file to portable anymap .TP .B pnmtotiff convert Netpbm formats to TIFF RGB file .TP .B pnmtotiffcmyk convert Netpbm formats to TIFF CMYK file .TP .B xwdtopnm convert X10 or X11 window dump to Netpbm formats .TP .B pnmtoxwd convert Netpbm formats to X11 window dump .TP .B pnmtoplainpnm convert regular Netpbm format image into plain Netpbm format .TP .B pbmtopgm convert PBM file to PGM by averaging areas .TP .B 411toppm convert 411 (Sony Mavica) to PPM .TP .B ppmtosixel convert PPM to DEC sixel format .TP .B ppmtouil convert PPM to Motif UIL icon file .TP .B sbigtopgm convert Santa Barbara Instrument Group CCD file to PGM .TP .B vidtoppm convert Parallax XVideo JPEG to sequence of PPM files .TP .B pnmtorle convert PNM to Utah Raster Toolkit (urt/rle) file .TP .B rletopnm convert Utah Raster Toolkit (urt/rle) file to PNM .TP .B ppmtoleaf convert PPM to Interleaf .TP .B leaftoppm convert Interleaf to PPM .TP .B bioradtopgm convert Biorad confocal image to PGM .TP .B pbmtoln03 convert PGM image to Dec LN03+ Sixel image .TP .B pbmtopk convert PBM image to packed format (PK) font .TP .B pktopbm convert packed format (PK) font to PBM image .SS Image Generators All of these generate Netpbm format output. .TP .B pbmmake create a blank PBM image of a specified size .TP .B ppmmake create a PPM image of a specified size and color .TP .B pgmramp generate a grayscale ramp .TP .B ppmpat create a pretty PPM image .TP .B ppmrainbow create a spectrum-like image with colors fading together. .TP .B pgmnoise create a PGM image of white noise .TP .B pbmtext render text into a PBM image .TP .B pbmupc create a Universal Product Code PBM image .TP .B ppmcie generate a CIE color map PPM image .TP .B pbmpage create a printer test pattern page in PBM format .TP .B ppmcolors create a color map (PPM image) containing all possible colors of given maxval .SS Image Editors All of these work on the Netpbm formats .TP .B ppmlabel Add text to an image .TP .B pnmshadow add a shadow to an image so it looks like it's floating .TP .B ppmbrighten brighten or dim an image -- change saturation and value .TP .B ppmdim dim an image - different way from ppmbrighten .TP .B pbmreduce reduce a PBM N times, using Floyd-Steinberg .TP .B pgmnorm normalize contrast in a PGM image .TP .B ppmnorm normalize contrast in a PPM image .TP .B pbmpscale enlarge a PBM image with edge smoothing .TP .B pnmscale scale an image with high precision .TP .B pnmscalefixed scale an image quickly with low precision .TP .B pnmenlarge enlarge an image N times .TP .B ppmdither ordered dither for color images .TP .B pnmcolormap Choose the N best colors to represent an image; create a colormap .TP .B pnmremap Replace colors in an image with those from a color map .TP .B ppmquant quantize colors in a color image down to fewer colors .TP .B pnmquant quantize colors/shades in a color or grayscale image down to fewer .TP .B ppmquantall quantize colors on many files .TP .B ppmrelief run a Laplacian Relief filter on a PPM .TP .B pnmarith perform arithmetic on two images .TP .B pnmcat concatenate images .TP .B pnmpad add borders to an image .TP .B pnmcomp create composite (overlay) of images .TP .B ppmmix mix (overlay) two images. .TP .B pnmcrop crop all like-colored borders off an image .TP .B pamcut select a rectangular region from an image .TP .B pnmcut obsolete version of .B pamcut (kept because it may have fewer bugs) .TP .B pamdice slice an image into many horizontally and/or vertically .TP .B pamdeinterlace remove every other row from an image .TP .B pamchannel extract a single plane (channel, e.g. R, G, or B) from an image .TP .B pnmdepth change the maxval in an image .TP .B pnmflip perform one or more flip operations on an image .TP .B pamstretch scale up an image by inserting interpolated pixels .TP .B pamstretch-gen scale by non-integer values using pamstretch and pnmscale .TP .B pnminvert invert an image .TP .B pnmgamma perform gamma correction on an image .TP .B pnmhisteq histogram equalize image to increase contrast .TP .B pnmmargin add a margin to an image .TP .B pnmpaste paste a rectangle into an image .TP .B pnmrotate rotate an image .TP .B pnmshear shear an image .TP .B pnmsmooth smooth am image .TP .B pnmtile replicate an image into a specified size .TP .B pbmclean remove lone pixels (snow) from a PBM image .TP .B pnmalias antialias an image .TP .B ppmchange change all of one color to another in PPM image .TP .B pnmnlfilt filter an image by replacing each pixel with a function of nearby pixels .TP .B ppmshift shift lines of PPM image left or right a random amount .TP .B ppmspread move pixels of PPM image a random amount .TP .B pnmconvol general MxN convolution on an image .TP .B rgb3toppm combine three portable graymaps into one PPM .TP .B ppmtorgb3 separate a PPM into three portable graymaps .TP .B pbmlife apply Conway's rules of Life to a PBM image .TP .B ppmdist map colors to high contrast grayscales arbitrarily .TP .B ppmntsc adjust colors so they are legal for NTSC or PAL television .SS Image Analyzers These all work on the Netpbm formats as input. .TP .B pnmfile describe an image's vital characteristics .TP .B pnmpsnr measure difference between two images .TP .B pgmedge edge-detect a PGM image .TP .B pgmenhance edge-enhance a PGM image .TP .B pgmslice print grayscale values for a row or column of a PGM image .TP .B pgmtexture calculate textural features on a PGM image .TP .B pgmhist print a histogram of the values in a PGM image .TP .B ppmhist print a histogram of a PPM .TP .B pnmhistmap draw a histogram of a PGM or PPM .TP .B ppmtomap generate a map of all colors in an image .TP .B ppm3d generate a blue/green 3D glasses image from two images .SS Miscellaneous .TP .B ppmsvgalib display a PPM image on a Linux virtual console using Svgalib .TP .B pbmmask create a mask bitmap from a regular bitmap .TP .B ppmcolormask create mask of areas of a certain color in an image .TP .B pnmsplit split a multi-image Netpbm file into multiple 1-image files .TP .B pnmindex build a visual index of a bunch of Netpbm images .TP .B pcdindex build a visual index of a photo CD from PCD overview file .TP .B pnmmontage build multiple Netpbm images into a single montage image .TP .B pgmbentley Bentleyize a PGM image .TP .B pgmcrater create cratered terrain by fractal forgery .TP .B pamoil turn a PNM or PAM image into an oil painting .TP .B ppmforge fractal forgeries of clouds, planets, and starry skies .TP .B pgmkernel generate a convolution kernel .TP .B ppmtv Make an image lined so it looks like an old TV .TP .B pbmto4425 Display PBM image on AT&T 4425 ASCII terminal with gfx chars .SS Uncatalogued As Yet .TP .B pnmtoddif .TP .B pnmtosgi .TP .B pnmtosir .TP .B ppmflash .TP .B ppmqvga .TP .B ppmtomitsu .TP .B ppmtopjxl .TP .B sgitopnm .TP .B sirtopnm .TP .B spottopgm .TP .B xvminitoppm .TP .B zeisstopnm .SH The Netpbm Libraries The Netpbm programming libraries, .BR libpbm (3), .BR libpgm (3), .BR libppm (3), and .BR libpnm (3), make it easy to write programs that manipulate graphic images. Their main function is to read and write files in the Netpbm format, and because the Netpbm package contains converters for all the popular graphics formats, if your program reads and writes the Netpbm formats, you can use it with any formats. But the libraries also contain some utility functions, such as character drawing and RGB/YCrCb conversion. The libraries have the conventional C linkage. Virtually all programs in the Netpbm package are based on the Netpbm libraries. .SS Application Notes As a collection of primitive tools, the power of Netpbm is multiplied by the power of all the other unix tools you can use with them. These notes remind you of some of the more useful ways to do this. Often, when people want to add high level functions to the Netpbm tools, they have overlooked some existing tool that, in combination with Netpbm, already does it. Often, you need to apply some conversion or edit to a whole bunch of files. As a rule, Netpbm programs take one input file and produce one output file, usually on Standard Output. This is for flexibility, since you so often have to pipeline many tools together. Here is an example of a shell command to convert all your of PNG files (named *.png) to JPEG files named *.jpg: .B for i in *.png; do pngtopnm $i | ppmtojpeg >`basename $i .png`.jpg; done Or you might just generate a stream of individual shell commands, one per file, with awk or perl. Here's how to brighten 30 YUV images that make up one second of a movie, keeping the images in the same files: .B ls *.yuv \ .br .B | perl -ne 'chomp; .br .B print "yuvtoppm $_ | ppmbrighten -v 100 | ppmtoyuv >tmp$$.yuv;", .br .B "mv tmp$$.yuv $_\n" .br .B ' \ .br .B | sh The tools .B find (with the .B -exec option) and .B xargs are also useful for simple manipulation of groups of files. Some shells' "process substitution" facility can help where a non-Netpbm program expects you to identify a disk file for input and you want it to use the result of a Netpbm manipulation. Say printcmyk takes the filename of a Tiff CMYK file as input and what you have is a PNG file .BR abc.png . Try: .B printcmyk <({ pngtopnm abc.png | pnmtotiffcmyk ; }) It works in the other direction too, if you have a program that makes you name its output file and you want the output to go through a Netpbm tool. .SS Other Graphics Software Netpbm contains primitive building blocks. It certainly is not a complete graphics library. The first thing you will need to make use of any of these tools is a viewer. For the X inclined, there is .BR xzgv . See .BR ftp://metalab.unc.edu/pub/Linux/apps/graphics/viewers/X . .B xloadimage and its extension .B xli are also common ways to display a graphic image in X. .B ImageMagick is like a visual version of Netpbm. Using the X/Window system on Unix, you can do basic editing of images and lots of format conversions. The package does include at least some non-visual tools. Convert, Mogrify, Montage, and Animate are popular programs from the .B ImageMagick package. .B ImageMagick runs on Unix, Windows, Windows NT, Macintosh, and VMS. The Gimp is a visual image editor for Unix and X, in the same category as the more famous, less capable, and much more expensive Adobe Photoshop, etc. for Windows. See .BR http://www.gimp.org . The .B file program looks at a file and tells you what kind of file it is. It recognizes most of the graphics formats with which Netpbm deals, so it is pretty handy for graphics work. Netpbm's .B anytopnm program depends on .B file. See .BR ftp://ftp.astron.com/pub/file . The Utah Raster Toolkit serves a lot of the same purpose as Netpbm, but without the emphasis on format conversions. This package is based on the RLE format, which you can convert to and from the Netpbm formats. .B http://www.cs.utah.edu/research/projects/alpha1/urt.html gives some information on the Utah Raster Toolkit, but does not tell where to get it. There are some Netpbm-like graphics tools distributed by the Army High Performance Computing Research Center at .BR http://www.arc.umn.edu/gvl-software/media-tools.html . These operate directly on non-Netpbm format images, so they aren't included in the Netpbm package. However, you can use them with any image format by using the Netpbm format converters. .B Ivtools is a suite of free X Windows drawing editors for Postscript, Tex, and web graphics production, as well as an embeddable and extendable vector graphic shell. It uses the Netpbm facilities. See .BR http://www.ivtools.org . .B Ilib is a C subroutine library with functions for adding text to an image (as you might do at a higher level with .BR pbmtext ", " pnmcomp , etc.). It works with Netpbm input and output. Find it at .BR http://www.radix.net/~cknudsen/Ilib . Netpbm also includes character drawing functions in the .B libppm library, but they do not have as fancy font capabilities (see .B ppmlabel for an example of use of the Netpbm character drawing functions). .B GD is a library of graphics routines that is part of PHP. It has a subset of Netpbm's functions and has been found to resize images more slowly and with less quality. .B pnm2ppa converts to HP's "Winprinter" format (for HP 710, 720, 820, 1000, etc). It is a superset of Netpbm's .B pbmtoppa and handles, notably, color. However, it is more of a printer driver than a Netpbm-style primitive graphics building block. See .BR http://sourceforge.net/project/?group_id=1322 . The program .B morph morphs one image into another. It uses Targa format images, but you can use .B tgatoppm and .B ppmtotga to deal with that format. You have to use the graphical (X/Tk) Xmorph to create the mesh files that you must feed to .BR morph . .B morph is part of the Xmorph package. See .BR http://www.colorado-research.com/~gourlay/software/Graphics/Xmorph . To create an animated GIF, or extract a frame from one, use .BR gifsicle . .B gifsicle converts between animated GIF and still GIF, and you can use .B ppmtogif and .B giftopnm to connect up to all the Netpbm utilities. See .BR http://www.lcdf.org/gifsicle . To convert an image of text to text (optical character recongition - OCR), use .B gocr (think of it as an inverse of .BR pbmtext ). See .BR http://altmark.nat.uni-magdeburg.de/~jschulen/ocr/ . .B http://schaik.com/pngsuite contains a PNG test suite -- a whole bunch of PNG images exploiting the various features of the PNG format. Another version of .BR pnmtopng / pngtopnm is at .BR http://www.schaik.com/png/pnmtopng.html . The version in Netpbm was actually based on that package a long time ago, and you can expect to find better exploitation of the PNG format, especially recent enhancements, in that package. It may be a little less consistent with the Netpbm project and less exploitive of recent Netpbm format enhancements, though. .B jpegtran Does some of the same transformations as Netpbm is famous for, but does them specifically on JPEG files and does them without loss of information. By contrast, if you were to use Netpbm, you would first decompress the JPEG image to Netpbm format, then transform the image, then compress it back to JPEG format. In that recompression, you lose a little image information because JPEG is a lossy compression. .B jpegtran comes with the Independent Jpeg Group's (http://www.ijg.org) JPEG library. Some tools to deal with EXIF files (see also Netpbm's .B jpegtopnm and .BR pnmtojpeg ): To dump (interpret) an EXIF header: Exifdump ((http://topo.math.u-psud.fr/~bousch/exifdump.py) or Jhead (http://www.sentex.net/~mwandel/jhead). A Python EXIF library and dumper: http://pyexif.sourceforge.net. Latex2html converts Latex document source to HTML document source. Part of that involves graphics, and Latex2html uses Netpbm tools for some of that. But Latex2html through its history has had some rather esoteric codependencies with Netpbm. Older Latex2html doesn't work with current Netpbm. Latex2html-99.2beta8 works, though. .SS Other Graphics Formats People never seem to tire of inventing new graphics formats, often completely redundant with pre-existing ones. Netpbm cannot keep up with them. Here is a list of a few that we know Netpbm does .I not handle (yet). CAL (originated by US Department Of Defense, favored by architects). http://www.landfield.com/faqs/graphics/fileformats-faq/part3/section-24.html array formats dx, general, netcdf, CDF, hdf, cm CGM+ Windows Meta File (.WMF). Libwmf converts from WMF to things like Latex, PDF, PNG. Some of these can be input to Netpbm. Microsoft Word, RTF. Microsoft keeps a proprietary hold on these formats. Any software you see that can handle them is likely to cost money. DXF (AutoCAD) .SH HISTORY Netpbm has a long history, starting with Jef Poskanzer's .B Pbmplus package in 1988. The file .I HISTORY in the Netpbm source code contains a historical overview as well as a detailed history release by release. .SH AUTHOR .B Netpbm is based on the .B Pbmplus package by Jef Poskanzer, first distributed in 1988 and maintained by him until 1991. But the package contains work by countless other authors, added since Jef's original work. In fact, the name is derived from the fact that the work was contributed by people all over the world via the Internet, when such collaboration was still novel enough to merit naming the package after it. Bryan Henderson has been maintaining .B Netpbm since 1999. In addition to packaging work by others, Bryan has also written a significant amount of new material for the package. netpbm-free-10.0-1/netpbm.lsm0100644004714500471450000000202407716762513016335 0ustar aba-guestaba-guestBegin4 Title: netpbm: collection of primitive graphics tools (converters, etc) Version: 9.25 Entered-date: 2002-03-15 Description: A whole bunch of utilities for primitive manipulation of graphic images. Includes a wide array of converters from one graphics format to another. For example, from g3 fax format to jpeg. Also, many basic graphics editing tools such as magnifying and cropping. This is a successor to Jef Poskanzer's PBMPlus package, and gathers tools by many people from many places. Keywords: pbm, pbmplus, netpbm, graphics, converter, conversion, bitmap, pnm, ppm, pgm, jpeg, mpeg, tiff, png, gif, targa Author: various Maintained-by: bryanh@giraffe-data.com (Bryan Henderson) Primary-site: http://download.sourceforge.net/netpbm/ Alternate-site: metalab.unc.edu /pub/Linux/apps/graphics/convert Platforms: Any unix-like system Copying-policy: GPL End netpbm-free-10.0-1/testgrid.pbm0100644004714500471450000000005107716230207016644 0ustar aba-guestaba-guestP4 14 16 netpbm-free-10.0-1/testimg.ppm0100644004714500471450000030615407716230207016526 0ustar aba-guestaba-guestP6 227 149 255 0/-0/-10.21/51.51.62/62/83/83/:3-:3-:3-:3-:3-:3-:2/91.91.80-80-91.91.:2/80-80-80-80-80-80-80-80-6.+6.+6.+5-*5-*4,)4,)4,)4,)4,)4,)4,)4,)4,)4,)2-)/*$/,%/,%0-&1.'2/(30)30)63,63,74-85.85.96/:70:7.A:0B<0D>2F@4IA4JB5KC6KC6MD5MD5OC3NB2OC3OC3PD4RE5R?1Y?2b@4nB5}E6H8G9F7G:G9E:G;G>G?H@E@FLCLDKEICIBD>B=A;A:@:??-?/?/>.>,=+<+<+?+?+=*=*=*>+?,@/?6>5=2?1B3D3D4D4?0A2F8H;H9oA2T8*C3&=5295495473271160050-50-72/72/72/61.61-50,50,41,//-.0-//-//-0/-0/-2.-2.-5,-4+,4*+3)*7(+=.1E69P:0U?1^A3jC4xD6E4E5C3C4A4A4B7D:E@<@6>/@.?-?-?-?,?-@-@,@+A-A+@*A)@*A,>-?/>.>.>,=+<+<+?+>*=*=*=*>+?,@/@5>5>3>1A3D4C4D5A2C6F8I;G:l@3S9*B4)>63:6595484382271161.61.72/72/72/61.61-50,50,41,//-.0-//-//-0/-0/-2.-2.-3--5,-4*+3)*5)+<-0C47N8:d>=vEAJINLTVajl}r{{ou[[QHuOCiOFeOG_PH_RN_[Yfnot~ojkY][LVSJXSZVRaXQa/.,/.,0/-10.40-40-51.51.72.72.72.72.92,92,92,92,91.80.7/-7/-7/-7/-80.91/80.80.80.80.80.80.80.80.6.,5-+5-+5-+4,*4,*4,*4,*5-+5-+5-+5-+5-+5-+5-+3.*2-'1.'2/(30)30)41*41*52+63,63,63,74-85.96/96/:7.?8.@:.B<0D>2G?4H@5H@3H@3I@1I@1K?1K?1K?/L@0MA1NB2MA1QA1YB2dC2qC3|C2B2A0<-:+;.=2@6D:F=D>CE@FBGBFDFCEAD?D;@:?;@=@@@A=@;@5=.@-@-?,?-?->,@,?-@-@,A+A,?*@*@+>->.>.>.=+=+=+=+>,>,<+<+=,=,?+?.A6?5>3>2A4C5D5C5D8F;I=J=G;h@4Q:,B5,?74=77<66:4494183072/72/62/62/62/51.52-41,41,21,.0-,1-.0-.0-//-//-0/-2.-5//4..5,-4*+4*+9-/>24I56[97l?9|E@IDOM[`fvmw}}u~fmTVMEvLAkMAeOFcQHcMH^NK\[[eqty|xzlfiXZ[MVSLZU[ZT`[S`.-+/.,/.,0/-3/,40-40-40-61-61-61-61-81+81+81+81+7/-7/-6.,6.,6.,6.,7/-7/-80.80.80.80.80.80.80.80.5-+5-+5-+4,*4,*4,*3+)3+)6.,6.,6.,6.,6.,6.,6.,4/,30+30)30)41*41*52+52+52+52+52+63,74-85.85.96/96->7-?9-@:.B<0E=2E=2F>1F>1G=1G>/H<.I=/I=/J>.L@0JA0KD2NE4UD4^D3iD2sB1~A/?-9)9'9*<-@3E8HDCACBCDCCDBC@C?A;@:?;@>@A@B=@9@3=-@,@,@,>,?,?,?+@-?,@+@*@+@*@)?*>,>.>.=-=+=+<*<*=+=+<*<*<+>,>-?-A6?5>2@4B6C8C7B7F|F:b@4L:.A7-@85>96=77<74:5294183083062/62/62/32.52-21,21,12--2.-2./1./1.00.00.10.10.5106005//5,-4+,6,-:01D22T71c;3qA7{E;HDRU_lis}yx}ow`fQRLEyL@pL@hPEgQFfLC^GBVMLZ^^fjnquyxx}wzvwzokoa`bTWYLTTL]WY]V]]V^------.-+/.,0/-10.3/,40-3/,3/,4/+4/+4/+4/+6/)6/)4/,4/,3.+3.+3.+3.+4/,4/,50-50-50-50-50-50-50-50-3.+3.+2-*2-*2-*1,)1,)1,)4/,4/,4/,4/,4/,4/,4/,4/,41,41,41,41,41,52-52-52-52-52-63.63.74/85096196/<5-=6,?8.@9/B:/C;0C;0C;.D:.D:.F:.G;-H<.I=/J>0I@1JG6MH5RG5YF5bE3jD1uB/}>,;):):*=,B2F8J=I?GBDCDBEBBBAA=@<>:?:<<>?>B>C:A5?0?-?,?,?,>->->-?->.?-?,?+?,?+>*>*>,?.>->->-=,=,=,=,=,=,=,<,>->.?.B4A4@1@3A7C9B8A7C;H?LCJ@tE;Z>2E9-<5+@93@85?75>63=52<4194083/62/43/43/23.32.12-12-02--2.,2.-2.-2./1./1.00.10.3205105104..2,,4+,7./=/.N5.Y9.e=1n@3sB;yKKZegpzxu{ks_dTTOGLBwNAmNBhMAeJA`GBYGFXKKWMPU]cc`fbbia`f\Z`TW[MUXMXXP^YV`WX`WZ,,,,,,.-+.-+/.,0/-3/,3/,2.+2.+3.*3.*3.*3.*5.(5-*3.+3.+2-*1,)1,)2-*3.+3.+3.+3.+3.+3.+3.+3.+3.+3.+2-*2-*2-*2-*1,)1,)1,)0+(3.+3.+3.+3.+3.+3.+3.+3.+41,41,41,41,41,41,41,41,41,52-52-63.74/85085085.;4,<5+=6,>7-@7.A9.A9.A9.C9/C9-E9-F:.G;/H<.J>0HA1JG6IH6NG5VF6\E3dC2n@0v>-{<+;);*=,@1F5J:J=H@EAFAE@CA@>>?:<;<:;<=@=C=C8@2>,?,@,?+?+?->,>,?,>-?,?,>,?+>*>)?*>+>->->-=,=,=,<+=,<+<+<+<-=,>/?.B4A2@2B5C9C:B:A;A9I@NGNEoG=S?4A;/96-@93A75?74>63<4194083/74/43/43/34/23.23.02-02-.3--3/-3/.3/.3/02/02/11/11/21/32032040/2.-1-,4..8.,G4-O4)X8+`<0e?6mGFyYdku||w|nudh[[RMLB~OArL@hI=cH>`HB^ECX@BO;@FBGJDMJJQJJQIIQFKQEOUIVWO^YS`YS`XU++++++,,,---/.,/.,0/-0/-1-*1-*1-*1-*2-)2-)2-)2-)2-*2,,1++1++1++1++2,,2,,1++1++1++1++1++1++1++1++2,,2,,2,,1++1++1++0**0**3--3--3--3--3--3--3--3.+41,41,41,30+30+30+30+30+41,41,52-63.74/74/85085.:3+;4,<5-=6.?6/?6-?6-?7,B8.B8.E8/E9-G;/H<0J>2H@3HE6GF4KE5QD4XC2_B2f?.n=,v=,|:*9);*=.B2F7F8FF>E>D@C?@@>>::;:<.>.=->-=.?.?-?-?,>*?*>)>+>->-=,=.=.<-<-<-=-;,<,.=0?/C2B1A1B6C:CCC793@72>71=60:5/94.83/63.43.43.34/13.13..3-.3-.3--3/-3/-3/-3/.3/.3/02/02/00.11/22021/0/-/.,2.-4/,?0+D0)K3)T8-Z<4dFFu]js~tzmpceVSLCK?qI_FB]DBW?AN;?H:BE>HGDMHGQIGQHJRGNVKUXM^ZOaYNaXO++++++,,,,,,.,-/.,0/-0/-1-*1-*1-*1-*2-)2-)2-)2-*2,,1++1++0**0**1++1++2,,0**0**0**0**0**0**0**0**2,,2,,2,,1++1++0**0**0**2,,2,,2,,2,,2,,2,,2,,2,,3/,30+30+30+30+30+30+30+41,41,52-63.63.74/85085092,:3+;4,<5->5.>5.>5.>5,B8/B8.E8/E8/G:1I=1J>2I?3FC4FC4JB5OA4TA2\@2b>0j<-q<.w9*}8)8(:,=/B4B5F:E;F>G?G@FACAB@;;;;>;B;D:D4@->(A-A-@,@.@.?-?->/>.@.?.?->+?*>)>+>->->-=,=.<-<-=-=-<.<.<./>1?1D2C1B4C6C;D>D>EAPL[Te\f]u_T[UIGMACI?<92?82>71;6094.74-63.43.43.34.24/13./4..3-.3-.3--3/-3/-3/-3/.3/.3/02/02///-00.22022010.0/-0/-3/,8,,;,)C0*K70S<6^IHtbnzƄzrxikWWIDE=nG^CAY@CV@DP>EKGQRKWUQ^WU`XS_UR^TT^SY_S^[LaZJaZJ,-/,-/,-/,.-------.-+.-+/.,/.,1-*0,)0,)0,)/+(/+(/+*/+*/+*/+*/+*/+*/+*0,+/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*0,+0,+1-,1-,2.-1-,1-,1-,1-,1-,1-,1-,1-,0,)1-*2.+3/,3/,3/,3/,3/,3/,3/,3/,3/,40-51.62/74/80-92,:3-;4.=4/>5.>5.>5.?4.?5,B5-C6.D7/F90G:1F<2G?4H@5J@6P?5T>3X<1^90b6+m9.t8-|8+9,;/=0?1>0A3A4C8E:G=G>E?C@@?BADAE>D8B1A.B,A.@-?,>.=-=->.?/<,=,<->-=,=+=*>*<+<+=-<,<,<,:-;-=/3@2A5A4E5D4E9I>G@D>EAMGZRf_qfsh~rdjj^V^SIQFLLBJF=B>5<8/95,74+63,33+43.34.14-14-02-/1,,1+,1+-2.-2.-2.-2./1./1./1./1.02/02/11/11/11/11/11/40/4+0;/3A32C4/J;6]OOymyϐكtzjn_bZ[LItHBdA>]>>X?BUAIVLU\U`bbqnn}xv|rulyoguh_k_W_P]\Hb\Fc]G,-/,-/,-/,-/------.,-.-+/.,.-+0,)0,)/+(/+(/+(/+(.*).*).*).*)/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*/+*0,+0,+0,+1-,1-,1-,1-,1-,1-,1-,1-,1-,1-,0,+0,)1-*2.+3/,3/,2.+2.+2.+2.+2.+2.+3/,40-51.62/80.91.:2/;4.=4/>50>50=4-?4.?4.A4.B5-C6.E80G:2H;3H>5H>5L=6O>6Q=4V;2Z90_7/h70p7.w7-9-9.<1<1=1@3A3B5D8E:FF8C2B-B-C.B-@.?-?-?->.>.=,>,=-=,=+>+>*=,<+=+<,<,<,;+;-<-2@6A7B6G9E7G->->->/?0<-=-<.=.>-=,<+=+<*<*<,;+;-<-:-;-<0<0<2>3?4A8C:D9J=H;H>KDKFLGSM`Vsgqz{wsocqbXcUNRDMN@HI;DD8@@49;.46+/1&01)01)/0*/0*./*./*//-//-//-.0-//-//-//-//-//-//-00.00.00.00.00.00.00.1/26+97+98/4;63HE>_^Yzz|DŽ}{|}}wq~n}n~~o~y|{j{i\hTXX@]Y<_[@-.0-.0-.0-.0-.0-.0.......-+.-+-,*-,*.*'.*'.*'.*),*++)*+)*+)*+)**()*()*(),*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+-+,-+,-+,-+,.,-.,-.,-.,-/-./-./-./+*0,+1-,1-,1-,1-,0,+0,+0,+0,+0,+0,+1-,2.-3/.40/91/:20;31<41=31=31=31=4/>3/>3/@2/@3-A4.C60D71E82F93H94I:5J;6L:6N94Q83T50^72e60o6/x8/90:/<1>1?4?4?2?1A2B5D7E:G>H@JAI>F:B5A0@.A-A-?->,>,>,=.>.<,=,=.=-=,=+=-<,;););+;+;,;,;-;,;/<1<1>5@7C:DJCLIQL]Vj^oyzxm{jbm]SZJQUFKO@EI:@D6;=057,13(01)/0(./).-(.-).-)/.,0/-/.,/.,/.,/.,/.,..,/.,..,0/-//-0/-//-//-//-//-2-17,:6*83-1961HJ?bfX{z}|k|iXfOSV;ZV9^Z=+/2+/2+/2+/2-.0-.0......------.-+-,*-,*,+),+),+),*+,*+,*++)*+)**()*()*(),*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*+,*++)*+)*+)*,*+-+,-+,.,-.,-/-./-./-./+*0,+0,+0,+0,+0,+/+*.*)/+*/+*/+*/+*0,+1-,3/.40/901:20;31<42=32=31<20<20=20=2.?1.?1.@2/A30B5/C60D63C84D95E:6G96H94K84N50X72_60i70r7/}:1<1>2>2@6?5?5?3@3C5C6E8E;G=H>G=D8A5?0@/@-@-?.>-=,<,=/=/<.;-0->0-?1.@2/A4.?4.@51@72@93A:4B94C84F74H5/Q51X5/a6/l8-u9.0=1?5>5?5?4B4B4C4D4B5D8E:E;B7?4>1>0?.?+=,=,<+<+<.<.;-<-<.;-;,<,;+;+:*:*9):):+9*9-9-<1<3?6A8CHCNJVR`Zper}~~yup{jdp\]iSR^JJS@BK:>E5:@29<134,22*1.)/,'/))0**1++2,,1++1++1++1++1++0,+0,+0,+1-,1-,1-,1-,/.,/.,/.,2,.8*75(13+(56&EK1\gGudyťέɭʰ˱Ȭ{wrdx]Q_ENR7QQ5SR6,03,03,03,03./1./1./1./1/////////////.,/.,.-+.-+/-..,-.,--+,,*++)*+)**()+)*+)*+)*+)*+)*+)*+)*+)*+)*+)*+)**()*()*())'()'(+)*+)*,*+-+,.,-.,-/-./-./+*/+*/+*/+*/+*.*)-)(,('0,+0,+0,+0,+1-,2.-40/40/:12;23;23<34=32<21<21;10<1/<1/>0/=/.>0->0-?1.>3/=60;60;83<94=:5>93@72C60G4.O4+Y4+d5+n8,x:-;.;.<4<5>3@3A2B1A2@0>1@4B7B9@6>5=2?2?-?->,=+;*;*<-<-;.;.;-;-;.:-:,;,9)9):)9(9*9*~8,~8,<1=4@7B9E>IAKFMFIAH@JFSO]Xhb{ny~wxnjxadr[ZhQQ]IITCCL;>D60-?1.=2.=4-=6.;819919:29:2;81?6/C2+J1,T2)^3*g7+o9-u=.z2B6C7B7?4>2>1>/=.=-<,=,=,=.>/<.<.2>5@6C:G=JBNEOGICIDPJ\Tg`uiu~zytoi}bby]\pUUgOO\HGRAAH8=A388.85.7/,3+)2()2()3)*4*+0*,/+*0*,0**0*,0*,2),2),3*-1+-1+-1+-0,-0,-0,-1+/4)/4*+4-%46!?F%T`8m|Qgtz~z{Ĉːəǝƚ~xvolfZnSJZ?GM3FJ1DF./0+.0+/0+01,01,01,12-21-32.43/43/62/51.41,3/,4/,50-50-4/,3.+2,,1-,0,+0,+.,-.,---/--/,,.++-*).))+.)/.)-/(/.)-/)-.)-.*+.*+/+*/+*-,*.-)--+-.)./*./*------.,-/-./.,0/-2.+2.+2-*4,)5-*6.+8/*:1,:1*;2+=4-=4->50>50>50=4/<3.;2-=2.<1-<1/;0.=/.>0/>0/@1.A0)@2);4*77-39-28.56.:3-?-)F*'L)'S*&Z/(`5,d<0k@0yA0@/A1B3@3=0;/8-;/=.A1B2C2A0>.;,;0:2;1=0?0?/?.>.@1?0>1<0;/:.:-;-{9+~@3w<.q7)w>-w>-v;-}?2{;/@4E9I?LAMBPCNEKISPbYpa}jq|~u{ouiib_[zXZsUZnSWeNPWEJK=C?6@93;0.6**3')3'+3'+1&*,*-)+***,*(),'+.(,1(-2'-3(.3(.3(02(00)10)1/*1/*0/)-1++0-(//#5,>5,>5.>5.>5.=4-<3.<3.=2.<1-;0.;0.=/.=/.>0/@1.C0*C0)A2+>4+:6-95,:3-<1-?-+D*)I*(N+'T/)Z5-_:1e>/pA/xA-A0@2?4=3:2;19..@0A1A1A/?1;2;2<2=0>0@/?/?.@1>/=0<.;.;,:,;,x8,x<1s9-n9+s>.s>.r8*u:,}=1A5E:I=K@NAPCNEJHSRf]wfpww}ovei``YZY{X\wXZnSSaJNUCFH;C@7<737/-3*+2)*1(+.(*,*+**,+),+),-(,/)-2(02(02(02(02(10)1/*1-*3-*3-*12-12.-0,)--%8:,SXBox]iolnpppw{xwy||{xuqnh{eYjWMZHEL<@D5;=/12,12,12,12,23-23-43.43.54/54/85085085074/72.61-80-80-7/,6.+4/,3.+2,,1-,1-./-.0.1/-0--/,,.+*/+)./(/1'//)-/)-/)-/)-.*+.*+0,+0,+/.*/.*/.)0/*0/*0/+//-///0./0./0/-/.,1-*2-*6.+70*90+:1*<1+=3*>4+?5,?6-?6-@7.@7.?6/>5.=4-=4-=2.<1-;0.;0.;0.;0.<1/?1.C2+E0+H/+K--L,/K+.I*/E+.A-,@.*A.(E.(M.)X1*b3-g5,j:,o;-w;0=4<6<5:4:4<2=2>2?3A2A3B5C5?2=/>1>.>/>,=.<,;.<,:-:*;,<)~=+{<+}=1z<1v:/u;/x@1x@1v<.v;-?5B8F=H?JAKANCNFJHTQf\vent{}yximae\a\`]`[|]UrVPhPFYEBP?:D93:2.3,*/)*,)**(0'(1&*1&*1&*0'*1(+0*.0+//*.-+.,+0+,0)-0(-1(-1)-01/23/..*'**"57*PUAmv[|ik~jjnn~mqx|zxvvuwyy}}ywtpmh|cYkUMZHDH9=?299-23-23-34.34.34.45/54/54/650761961:72:72961940940:2/91.91.80-50-4/,4..4..3/03/01/01/20.1..0--/-+.0)02).0*.0*.0*.0*,/+,/+*1-,1-,0/+0/+10+10+10+10,11/1111/010.10.2.+3.+3.*92,92,;2+<3,>4+@6-@6-A7.B8/A8/B90A8/A81@70>5.>5.=2.=2.<1/;0.;0.<1/=20=2.B3.E2.L..R+0V'/U&.P'/I).C/.<1+;2)?2)G0(R/)_.*d/)i9/k;/u<3}<6;8;9;7:6>8@8B9B9C7B7A7A5@1A/@.@.>-<,;+:+8*9*:*:)<){=(x>(x>*>1{7.z7.z<1v;-w=/|A3{@2B7E:H=J?J@MBODQHSJ\Qh[tbgm~v|~}yqoiifgfeggde_~_Zw[PhPK^JBP?8D62:/.4*,/(+*%2&&5%(4%(2&(1'(/)+/+,.,-+++*+-*+-(,-(,/',/',/*+-.*+1++0+'.+"88,PUAiqYvc{hyh|il}mykzmrtq}p}p}s~v~x}x|x}zzwuqnje|bWkRN[GDF9?=1:8,45/45/45/560560560761761872872;83<94<94<94<73<73<41<41;30;3083072/61.61.5106216213122011/00./1-.2,04+.4+.4+.2,.2,,2,,2,,3/.3/,3/,3/,21,21,32-32.32032032032051051.61.61-;4.<5/=4-?6-A7.B8/E8/C9/D:1D:1E;2D:1C90B8/@5/@5/>3/>3/=2.=2.=20=20>31>31@51E31M02T,4X)3W(2R)1K,1B30:6-77+:6*B4)M2)X/)^/)f:1j;3s<7z=:<:<;;;::;7>8A8B9C:C:@9@7C2C1B0?/=.<.:-9-7+8+9+:+~=+x>*v?*x>*9-|/'8/>4w4+s5*}A6}C7E:GJ?KBMDQGWJ|aNzjQpYu]|biu|~{}zwzpzlxlwkumrlmgkd`rX[iRR[HHL=@@4;7,70&5*$6('5''3''1'&.)&+*(++)+-*',('+*)+*)+***,+),+),-)*,#$2*'50*86*BC5UZFfpWn}^teqbuexiwkshtiwkznxlwmxnys{u{w|wyuzwwtsomhd{_WkPN[GCC7>:195,560560671671782782872872983:94=:5>;6>;6>;6>95>95?74?74>63=52;63:5294194184184395484373243151240/6-06-.6-06-.4..4..4..4/,40-40-40-51.32-32-43.43.43/431542540841850940:5/=60>7/@7.A8/C90D:0G:1H;2F<3F<3F<3F<3E;2C90B71A60@51@51?40>3/>31?42@53?53@72C52I35P16T/6S.5P05J22C52=90<:-=:+C7)I6(Q3)W2)]2+d3,l50v64}77877766~75}:4}<6}>5?9@8?9A8B3C1B1@0=/;.:.9-9,9,:,<,|=,y>,x?,|=,5*2,LEXQA8|90F;K=yH:zJ<{M>|N?}OBQEUJ_LrkOosR|uXw]ybiszz|~{y~vpoppp{pwmskj~bfv\_hSV[GOM>GA3@6*=0';,'9+(6+'3+(/,',-'+.').().(+-(-,*/+*3)*4(*7'*7'(3($<3,E>4IG8QR@]bKgqVjyZn]k\l]pbqeodoerfumrjqitnxrzvyvyvvtwvurokjfc|^UlON\ECC7@91;4,671782782782893893983:94:94;:5>;6?<7?<7?<7@;7@;7B:7B:7A96@85=84=84<73<73<73<74<74<74;639529338308/09/.8/080.80.80.61.61-61-61-52-52-63.63.74/74/540540841952:63<94=84@93@70A8/C90D:0G:1H<0I=1I=1J=4J=4J=4I<3F<3D:1B8/A7.A81@70@72?61?61@72@72A83?74@85B86D97G96H96H96H94E80E8/E9-E9+G9,I9*K9+Q7*Z/&d/'n3-z6398;9;:=;A>@:=6<3:3<4=7@7A5B3@2?2=1<0;//|>/}>/=/9/1+<8lf~yZTC(+C&+E$+C&(F5-LC4VQ>[YD`bJgmQiwVj{Wl[gWfWl\oananbrfskojoirnwtyxxwuvssuvsrnlicb{[TmMM]CGH:E<5@707827828938938939:4:94:94;:5<;6?<7@=8@=8@=8A<8A<8C;8C;8C;8B:7?:6>95>95=84>95>95>95>95=85<73:51;30:0.:0.91.91.91/91.91.72.61-61-63.63.63.74/74/74/540651952;83<94?:4B;5B;3A8/B:/C9/E;/H<0I=1J>2J>2K>5K>5J=4J=4F<3E;2C90B8/B92B92A83@72@72A83B94A:4?82@93B;5D=7F=6G<6K<5N;4M6.N6,Q6+Q6+Q7*P9+P9)V6'f6*r6,~;3@9D@HDJGLFQJLDD;;07-7-91=4>5>7=6<5<5=4}=3z>3x@3vA3x@3z>3<3:37331(&=;|zhcG@K@xH:nMhV>lX@t[E`LhPysQwUt\l^__V\Q[T\ouzx̆|~}xvrtuuussr|nyju{amoWgbN_TBUE5R/(9/&7.'6/'81):/)=.+A,+F)+H(+K'+H)'TB4YQ9B?:D?;D?;E@8E>8D=7B;5B;5B;5B;5B:7B;5A:4A:4A83A83A83@72@64>71>71>71<71<71;60:5/85.85.74/74/961961961:70<71=82A:2B;1C:1D<1F<2J>2K?3L@2N@3N@5N@7N@7L?6K>5I<3H;2E;2E;2B90A8/@91?80?80?80@93@93<5/MD=M@:K:3T@9R62O0+a<6\3-`5.`4+^/'^/%f6,m=1q=0I=G;I?KAF>>7=6D;NDPEVJYKOBA5;0>69898655284?8|@6r>1rB4oA2q=0v:07243-1',HIbaEDWUyvVOFu:9:49:49:49:4:;5;<6>=8?>9>=8>=8A>9A>9B?:C@;D?;D?;FA=E@8E>8E>8E>8E>8D=5C<6C<4D;4C:1B92B92B92B92A83A83@93@93>71<71;60;6096/85.74/74/96196/96/:70<71>:1A:0B<0C;0E;/I=1J>0L@2L@2N@3N@3N@5N@7M?6J=4I<3H;2E;2E;2C:1B90@91@91@91@91A:4B92D93I81L/+V.,j76u99{;;ECD?H@IAG>IBNHPLOGD7B4B6C8>37-7-=0C5?0@0E3G6F6H:NELMHL@D9;98>:@8x>3o>0zI;LA?8,+).9DLWKNMM>=@?`\YQ@5TDyaIe[@^]?ihIslOvgJ~dKcNdX_[UZAN,E%D&H'I.N3N6UE8[O5cZ9gaAifEnrOz]zbt^r_p_p`q`udwdwdwfsixrzxyx~}zzromhhd`y[TmMNaERSAVPBUOC8938938939:4;<6<=7?>9@?:@?:@?:C@;C@;C@;C@;D?;D?;FA;FA;FA;E@:E@:E@:G@8F?7JA:I@9H?8G>5F=6E<3F<3E;1D:1D:1D:1D:1D;4D;4D;4C<4?80?80<71;60:5/:5/94.94.96/96/:5/;7.>7/@9/B90C;0E;1F<0I=1K?1M?2M@0NA1M@0P?5M?4L>3K=2I<3H;2E;1D:0C:1C:1A:0A:0?;2@<3@<3D;4UDI?LANBRJUROSLK@4B0@0?1;.7+8+=/E6>+7$:'>-A/C2D:02:BDLLRMRKLA>71{8/v6,x2*1-37=GGWM[FI53:931NKc]J?[J}cLj_CgdEtoOpQhJhNhYbbQZDQ7I1J2N/M*H2O0K1J5L4M2K3L7P@XC[F]IaNcQeUhVkSjRiOiNiNlPoSsVuha|[tUlYldrR]r-2^&'Y0,W:4Q?5B:-:8)>B1LN9VO3aV6e_?heDquTe~iwdxiuerdrcveyhzizjv~zypmg~b^wYTmMPcGSXDXUDYVG7827828939:4;<6=>8@?:A@;BA5G=3F<2E;1D:0D:0E;1E;2D;2E<3E<5E<5@91?80=82<71;60:5/:5/:5/96/96-;7.;7,?8.@:.C;0D0K?/M@0M@0M@/M@0O?2O>4L>3K=2J<3G:1E;1D:0D;2D;2B;1@<1@<3A=4B>5F<3S81[*&:?T`TeUfUcJO30:/>0A3F=IGBH>@B7F5B3@3?3>3B4D6G5B/<);(<(:(6&3(979=7>7<^@aCf@f?e?g?hCmErIsOuQuUvSqTnaxfvWb}15j0/X1*P8,G>/>A.;D/?G/PK._T8g`CokN||`rv}qzq|s|szozm}ouzsqh|c]tXSlNPdHRZCWYDYZH671671782893:;5<=7?>9@?:BA/K?1M@0M@0NA0O?/O?0O?2N=3N=3J<1I;0G;/D:0D:0D<1D<1B;1@<1A=2A?3B?6K=4\5.w32LS]iM_@Q6E&+1)7(:&<)@3D=>?;;?5B4@2?2@5C9H;J<>/?/=+;)9):,;/<1FADA>?797KCTLSMKJ?B5>274.7.1+:484@9[PUC{N9bIkP`F[FfTrdmhEK:D9C=8@?:@?:C@;DAGB>GD=GD=HC=ID>IE2I=1G=1G=1F<0F<0E;1E;1D;2C:1A:0A:0@91@91=82<71;60;60;7.;7.;7,<8-?9-A;/D0L?/M@0NA0NA0O?/O?/O?2N=3M<2L;1I;0G;/F90C9/C;0B<0B;1@<1@>2A?3B?6N;4m84FEY_WbCQ8F3;++1'8%:!9 ;&>.:2717,:-9-7,:1B8E;E:>2?0<,6'6)>0D;G=8-@6D?BB=A9>27.075GBSLNG=910/2671(A>GBOMWWNRDM:G5F2F.D1G7N8S8T8V9W;\>aAeCk;ej?m>n>o=m:jHr;a?dKnKnNmUoZnrajILt:8\6-P9+PC2UM:^QAreU|nʿ~m~k`t[WnRVjNS`FV`EX`H560560560560671893:94;:5=<7>=8A>9C@;DAHC?HC?GD=HE>ID>ID>JF=JF=MF2@@4P91r1/JKSV>D0603//1)1!9#=!;< =#;%6%6)8-6,4,81@:C<@6B7A4->-5+*&"%%+*1.4)*.+3,4,3,2,0-2+2%6&2&7,6.>7`UqeSVBM:WIf[d_RTCIFM@D??@<@8@7FAMLJN@K9H7H5H3E6G;M8P7R6R6U6X9];ak?m@qBtBuBuBtBpFmAaEeKjKkVt_z]tj~p~ow^aCAg6/hB7sUJye\}vŽ˺tqexb\sW[oS[jM\iK]gL561561561560561671872983<;6=<7@=8B?:DAHE>HE>HE2G=1E=2D;2C:1C:3A:2A:4@93?74<73<71>7/>7/<8/=90>:1A:2C<2D=3H@5I?3L@2MA1NA0P@0O@-O@-L?/L>1M=0L;1J91I81E80C90@9/>:/;;/<<0=>0>?1A?0S8-<7\[ZY86.*1+.%2#9&B*F,D'A&A&<#9#9*;0:07.<4CD;=<<@9>48,6.94HH@E;D:H:I8G;I?NAU?Vi>l>o>p>q@r@tAqCjMmSsJh@`Tsge]w_xh{p}qxgg^X{ZQ~wļ«zxl{hbu_`rXbpVboScmT21/320431651875984984984;:5<;6==5??7AA9CC9EE;EE;HH@HH>HHLC4J@4KA5MC9LB8F=4B90E<5C:5@93?74@85?75<74<42C:5B94A96>95?:7>:7?;8@<9B?:D@7G@6J@4L@0O@-O@+L?,G@.F?/I;0K81M53K65J88F;9B?:6904,=,<,=/C4F8>12&9+8*8+8-7-5.3/1-.,.-0,1,5*7):):(9&33 8'7'6(B5SINCSK\W]ZPR>C9??GAFCDAA?9<3;/?HH>HH9H?:F=8B;5D:8A96?74?74@85@85=85;62=4/=4/=52<74=96>:9=<:>=9B?:D?9G@6J@4M@0O@-P?+L@*B?,B?.F<0H:1J65I56F35@65@<9:=6;>5@@4E<-J9)^B4L>QB;-2#6&:'7$9%>*;%<(?+@-=,9*6(7)9):*9);+>.A1B/@.?,:(<+E6H9?18+6)7+7,9.;-8;1:-<-=.E5L?NEGC?>?B?F@JCJCLDPFTBS>S>XBaFhCi?i@jBpFvJzK{JzHtKpQs\z_{XwNqEkDlEiKg_pnukLI~t̲ų~/.,0/-10.21/43/540762761:94::2<<4>>6@@6BB8CC9DD:IF=IG;JH;LI8MJ7NL7NL7OL9KI:NKBTRS_^fihxmmlkkh`YiYQ\OGRH@KH>GG=EE93>:1=9083-94.;60<92=:3>;4?<5@<3E>4G?4I?3L@0O?0P?/P?-L?,<;&:=(?<+A;-B71A62>42;30=84B;5H94N2.Y,)l/.;=FE;02$1 9'<)7$8"<&;&=)A-A/>.<-:-->-<,?-8(>.L=G:6*2&9.6,6+8,:.:/8.6/3,0-.+.+1)2'6&8"7!8$5#9'>/=.6)9,A7<5>8EAKIJJCC?ACCCAD?B==4:.8*:*;+8)D8NEIE@@>ABIHPAG@ICOGTEU@U?XA_DfCiCkFpIwK{L|JzFxHwKtNtZ|aUvCdIkTv?\I`{||aC;|nճξ/.,/.,0/-10,21-32.54/650880991;;3==5??5AA7BB8CC9HEQPL^]bmlzzz{urke_{YSmTLdMEZG@PB;2?=1@<1?;/A;-F?/H?.K?/M@/O?0O?/P>0L?/@=*?>,@=.?;/?;2>93=:5:94<94D95M51V-+j)-288C>C7.7(:(?-?,9&8#;&:&<)>,@/>/=0=1>2?3=29.8*9+:,:,9*;,;-B4E9>31'2(9/5+4*6-7-7.6,3,1*0,.+/)0(2&4$6 5204$<.=/9.=2D:5-60;5D@MIKIC?=8@9A8>4Vdtӏd92lJ>ynХ10,10,0/+0/+10,21,43.54/77/880991;;3==3??5AA7DA8IE:LF:NH:PJ:RK9RM:SL:QK=OJDVTUfdqwxÏƎ{wpmid_[~UPnNJaKGXEBM?=B;7895296/85,85,671783891;;1>5L?6K>5F<3B92=82:946;47<59<5>:1H4-Y2-w78?D>E9<;0<+@.A/@-<);'>*8$:'<+=.<-;.<0=3?6>3:/7,7,8+8+8+7+A5C88.1&3)7-5+4+3)4-6,5,5+1*/*/,/*/)0'2#4!541/2"6)9-:0?6E=F>@7<5@9KDNGE>;1=1<0CBLIUJYFXCYC]@_BdElJsNzO|LyIvJwTT}JqImStVtNiD^F]Xk󝞎HFk.)kc͖ɿȾȿ65143.32.10+10+21,32-43.66.77/880::2<<2>>4@@6B@4JD8ME8OH8RK;TK:TM;SL*F@*G?*H@+IA,IB0IA4HB6HA9G@:K=?51;/<+?-?->,>*?+?-8%9(:+9-9,:.:0<4>5;4918.8.9/8.6,7-C9@70&,#7/<42*3,2(2+3*3+2+/*-*/*.)0)1(4$5"6 57#3#3$3&5)8,<1?6YQRJHAC;E1:*;(:*:):(:+>0A3A6<3<6A=EEGHIMLPBF@CCIKTNYJZF\F_A_BaEiJpNwOzNxLvQ{RyOvOtVy]{SoD^TlQddt`dMMjgΏX<94;8185052+41*41*52+63,74-85.96/;81=:1?<3A>5C?4JB7MC7PG8SJ;WK;UL=UK?SJCSJK]WcnlŚڟꢩ뙛啘ݔ֐ʉzyrqfc~XVkPN\IGRFCLCBJ??K==G;:@;9:<94?;/C=-E@,F@*FA+EB/EC4CC7BC;AC>@ACBLCANEEOCHNAIL>HI>GDCHAA=2L:.gF7OAI/>,>*?+@,@-?-<*8'8)9*9,8-8.91;5:4:3818192:2706/<5>5912(4*;2<33*1*1'1*2)1)/)-(,(-)/)1)3(5'6%7!7 9%8%6%4%4(7+8.7/NGXPZSQIG>D9@7>/<*<&<(:'9(;*>0A4D;@7@:FCIHHGGJIKFHBDDILSQZO]L]K`D^DaFfIlNuOxOxPwVxUvTvYx]{ZwQkI`WkUgM^^mKZTaTaXaefȃ~嫧@=6=:3:7074-52+52+52+63,74-74-96/;81=:1?<3@=4B>3JB7MC7RF8VJ:WK;XL?:6@<1A>/C@/CB0BC3BD7?D=>D@CVCIaLRhU\o\br`dobbjd`afXWaJDlG>SEXFJ7@+>+A.@/A-@-A.A/=+7&7(8+8+8-6-7/81;4727272829494836/A:8/3*8/=5=5915,2)0'0(0)/)-),(,(-)/)2)4)5'7&7$8#7"8%7$6&7)9+7+4*4+NGd\`YOFA7;29->)>'<&;%9&9*2D9A9E?KHLIGDEEHGIICDEHMSSZR\O^OaH^G`GdIiNrQxRyTzUuZw^}^|UpMgOiYn[mctM^TeO`UgL_R_^_vqלB>5A=4@<3>:1<8/:6-84+73*62)62)73*84+;60>93A<6E>6I@7MC7RF8UI9WJ:XK;ZLA[NHTIMXR`gd|~ʗ㞪쩫蟡ڙҍtrhe]ZXR~XQzYQvVOnMH_C?M?:@?;:B?8>>4@B5BE:?D=:CB>FH?LUDVnQfaristvxo^l[cWYWUVMM?@.9$:$<(=*?,@.@-?-=,;,6'6(6*7-7-8/91838495:693616183:3C<=670@7[Rlc]T?63)2)2*/)*&(%(&+(-+0,2+1'0#1"4$:(;&<(<)<*:,9+8,7-@881GAc^XQB<@;4*:&<$<&<&:(:+<0>2>4C;PJXROJ?:?:HDHGGEJKPTRWNVKXL\RfOfKeJfMlQsRvRvWvXuXu[w\xZsWnVkbuVg\m[lFXDXQeVefgieʏ網C?6B>3A=4?;2=90;7.:6-95,73*73*73*84+:5/=82@;5D=5H?6LB6QE7TH8VI8WJ9YK>ZMEUJNWQ_eby{ɔ⛦뢣㘘،ɀuqiec^`W`V]TVPtMIbFCTBAIAAC<<:AB=FEACD?A?@DBEOMRWVdchqu}}}{p`uYiVaQUHF@4;)<&='8$7%8&9(8'9(7(6(3%4(7-:2<3=5<5<5>9<7<7>9B=C=B[O@66,+#)#-)/-,+((0.4/616.3)2&2%6&:';'<(:(9*7)5)4(9/5-=6PJTQLHB?1(;(=&<';'9(8(:,:/>4B8OFWPRID=C;HCLHJFMLSRTWPVNVOZVfUhSiRkRmSqStRuMmUt\z_{\vUoRiReUfRbZhZhN^ScYiS^`_^W}٩EA6EA5C?4A=2?;0=9.<8-;7,84+84+73*84+:5/=82?:4C<4G>5JB7ND8RF6TG6WG7YIBZEJpW]csrz{vpcTnG\K\HP<<5.9*<'<%;';):);*<,<-<-<.6*8.<1?5A8>7<3:4714.3-93A;E?B<=5<44,4+7-2', 6*G:K>@64--),*,,,,*,*)/+2.5.4+1(1'3'7(:):(:);*:*8+8,4+<4:5<7ONYWEE3/;,<(;*:)9)8(8*8,=3A6JAUKRGG>D:G>KDICLISPSTPSMSNWXdZh[pZrVnRlQlQpGmPvZ}[{VrTkWk\mYhZham`k]gfnfm\_]W{OFmfݺIE9HD8FB6D@4B>3@<1?;0>:/:6-95,95,95,:5/<71>93@;5E>6I@7LD7OF5RE4UE5WG8WI>XMKXNW^Zqppԕ革ꗖ⌋ׂ}yumpgf`_ZYXQQuGGcA>Q=5DH8BT=C`@EnCJOU]dfxknoi`WxIg;U2HAPEM;<71?0@,:$6"5$5$5&7(8+;-/?0@3@36*LBJE50GFZ\IKA?2F9OBPDH7/=6.=6.=60>71@93?:4C>8EA8KC8NE6QD3RE2VF6VH;ZMGVMR[Whlk~Β㚦铕⊌نу{umkde_aY[RQsNHbWFY_CQmBLEMMTU][bZhRpRuTuPlJbBW8J.?8ECKGK>>>6F:H6?+>-=-<->/?0B4D7E:E9B7>5;26-5,3+3*1*4-7.90807/6.5,/&5+7+2#1"9)>-;)<-D7JAD?64*-*-/26755301,0*/,0-0+8191:1;2<0=0?0>17+WLaZ;6;:PQFHPQ<4:/8,9,:-<.;-;,:-<.A3H9I;D6@2>0F1E6E6F7E8F8G:G3;18/4,3*4+4,6-81<4=4<3905-5,7-.$;0=.1"-7&=):&9'8):/=9@@<>37,/,.+**)+(/,448899757473717-6*5(5&5(PEmcHA42CC>BVVA<>48.6+:-/=.9+<-?0A2A2@.=.<-C6D9H?PGRLOINLON^cagitnzduVjQiUoWvVtXp^pnywksXa`m`mbos}숊́|thyjskXON:_VGqgSM=RL4D=3B;3A:2@93A:4A96@;7A@;CC;IE9MG7OG2RF0UF1UH5WK?RHFXR^jg}Ēژ礧흤蛢晞⒚ۋ҆ʃ„ymczXiQ_MYIRAI=A=;>8C9H:I8F3C0@1TIG?;76488:;9874:/<.;.:.8+7*4'2&4*3*3(3)3*5,6.8/=3=2;18/7-6,4*3)3&3%4%6&=)>*9$2:&4%1'51<<=@7=37-1-.--/.439:;=9=2603011/1*2(1%3$1$=1j_TL95@?:=RSJHC=:36.8.;0<0=/;*?-@.?-;*;(;+<,>0>2D8LBPHNFLINLaeafhro{hxZkUjZrYs]tarjt}wy_dgtm|eulw좟Ĕ|hjUHQSK>PJF>DF@D8=65B;D8C8A5>29,6)2'2(3(4*5,5.4.4.4,B7=17,6,9-9-5)1%8(2 1!9(8'4"7%C07&8*6,5.3/53:9?>LKHFBB>=<=7:26,1+1)/,./.1+4*5)7(0!.dY]S@:DC;;MMRQHE;66/8.9/;-:+<,@-A.<)8%9&<)?.7)7+>1G:K@IAIBJEa_^`djnwku]iXe]m^sbtdolr~qsryyaqXfЮ]jPDR9QT?jbUXO@WP@WN?UN>TK2G?2H>2F@4GC:GE9JG8NI6RJ5UJ4UJ4VK9XNDULMZTbkh{~Ñט磤쥨ﭩ▟֦ζgzL]ER>M;G?<=EB:4D9F:1)JEJICE>B;?<=<;B;?7D;MAK>=06)9,7+6,5-2*/*/+2/5.A59+1$3&9+;-8&2245!4"4"4%5'5)0&2)5)6*4(3&3'4)2)3.5233/2-2-4.5-3+/+,/-5.9,7(4%-3"XHYN;3NI41HHOPJJC@;6808,9+<+<*;(9&;(<)=)=+<,8,;0=1?3?3@4@5A7japic_mjqqadgmpylzhxdobidjlnqoqoy{}Zlcwbp}u]rQJY:LR8snZ˷YPAXO@XO@VM>UL=TKLAC5:,9+7*7+6-4-2.3/5384>2;-6)5&5'5'5"49$9"9%:&<+<,8,4*3.5-7+7)6&4"4!4"2$2&0+.,,-,/-2.3+.,-0.2.4*5'8'9'?.*D5>1F>VPB?BAUVRRKHC>=59.9+8(;*;(:'<)>+?-@/>.:,;0=0>1?0?1B3C5i\mdb[kfolbakltxq~o|ir]fY`bfqpzxvwx~Rd[p]njkZtON_;SZ;us\ĸ\PB[OA[OAYM?XL>WK=VJD=?==A>CB;?9<686696;6HA;15+A5K>H:=/8)6)7)7,6.507195=93*5*6*6*5*7):*>,4!44!6"8)8)3(-%@;>8=3<.9)7$7"7#7%3$/&.'.*.-//./,)0+5-5,3&4%9&>*A/1 SE;0A;C?JITUUTSQOMJCC;<28+6&7&7%7&:'<*>-=,=,:,;/<.=/=.?0C4E7\Qg]aYlgpma`fgjqR^^khqem`geiqqxwtunuJ]Rh[m񜡣a`UoHOd=W`Aww]\PB\PB[OAZN@YM?YM?XL>XL>UI;TH:SG9RF8RF8RF8RF8PF:LE;KGE=F?F:>?@EDA<61>:ZYAB@C=@:=8997<8A8E;:.2(/9(8)9)8.:/8091;7>81+2*3,5,5-7.9.=/7(:)<+<,;.;0<695C@@<@7=19*9%:&;%<(7'1%1%1(3,1,/*2*5,7+7)5'7%;(>*;(<,^PF<3/.,@@WXusrojg^YPGA75(. 8'8(8&;)<,=-=,<-;.<..B3F7MA`Wa[pltr`a]a]dHTYegrgoelkpsvvvpsenDXKbXk뒖_zYQlCSh?\gEy|_\PB\PB[OA[OAZN@YM?YM?YM?WK=VJ@@?IE>82,C??=@1;-8'7%9'<)<):(>-:*>2C:/-::245653;6C>KCQISHTHUG?0?.<,=->-?.?/>0<.<.<.=,<,=.A3D6LAbXc]nlrr`c`e`gkvozkv`h_flqx{y|ms^jAWC]Uh懍g]YtI^uIhwPfǻ伺޺޼[OA[OA[OAZN@ZN@YM?YM?YM?XL>XL>WK=VJQI>QI>SK>UL;XM9XM7YL9XM;WK?ULGYSWe^nnjut~}ȍώԏՏӐӋʃ|u|ovioljlcyYvPoBd7V4L8H@EFBJCJEGGCJ=N>LCICCA>ID;44,I@LFBA?=;;<;@=E?G2A5A5A6G8A1;(9&<)=*<*8&:+7)0'C<2/?A/2*,1/5.81908.5*2&1#E5A2=.:*9)9+:,:,;/=0>/<.<+<,>/A2SGg^c_jinochjqoxq{t~mubkdnrzx~quipWfAY@[Qf~ykm]oZy`r֭ӦЧӫԮֱں[N>[N>[N>[N>ZM=ZM=ZM=ZM=YLUL=XLNAEFDA=HB:/7,OFB<=8641051>8E;F9D59(:(:*:'8%9&:':&9&:):,9+7+5+3+3-*+*--3/4173738588;8<9>9A9D7F6H5E+5-2124/6-8*;+=,5&8*;/=2>4=4>5A6J0/..46663-7.90:1;1;0:0;/L?F:@19*6)6(7*8*;-=/>0=/<+<+<.=0KAdZc^kiosinrzvfpoyryjslvwv}hocnRbB[ZM=ZM=ZM=ZM=ZM=YLVJ>XL>YN583/,*&/*:3C9C6>/;*;)<):';(<);'8%5$7%8)7*5*3*3)2*33588<4:-2(-(-+1-3)0&1)6,?*A 9/"0(.,10/1,3+5)6*6+90=6>7:4715092H=KYM=WMCWLHXNOZPX]Ub`Yia\rjfokspvq{u~ɊLj~yrrtl\HLB9A:C@@?:;<>DE><=<>=@ABICMANAL>>@9?6>3,7%:'<);(9%9&:':(:'9(6(2$."/%7.=582400-**&(%'%'%'&*!)".'7(>!;61'8#,#++---+(-)416264666512./,,/,92:191SK"+#F>.&.(<7E@:7/*.*51<7>4<.5)3&5*;.;08.bXZOC:6,:/8-3'6*0%2&2&4%6':*<.=1:0C;\Wppsvx|yq||wt}s{r~r}mxgs`nI\>\>[AVekzm}f~cjw|vzqyo|rvuwy§̹Կ̺ZM=ZM=ZM=ZM=ZM=ZM=ZM=ZM=XK;XK;XK;YL]P@[OC[NFYNJZPQ\SX_U^_Wfd\tibngqjxpyĊď~tnqujW{=A5+5+<3@8>8?:A==;;<;@>B@IAI@KAF<9=4<1;/:,:+A5JAG@A=6351@9C89+5#8';(=*=*;(;(:(9(9(6&2%2%5*8.80911&/%.%,&+'+),+-.*-%+$.'7$;7300.93<*1(,.002+.:>7=4:26/40325872-;582E?E?/+2."51?:E@=83-2,60:1:.9*5'5(9+<0<29/cYXN@84+91:06,9/5+4*4*5)6)5(6(6);0B9YTljqtx||v|yv~usp}kwdq_nI]>\>\CYehwozbu\x]ckppmp]l]h\g^k_qeyizktv|}ƷǿϼƷ\L<\L<\L<\L<\L<\L<\L<\L:A=E@GAH@E@B;6909+9*8(9*?3F9674;7C=OEH<3#9(:';)=+=,<+:)9)7)2#/#4*=3?6914+4&5&2%/$,$+%+(+(+-(+&/(6%:733%70;5A8C;D,626;3=6=8<7=6<2;19.6*6);/@6TMgeorz~||yxwsn}gv`p[mG^\FZ`a~evZiQhOmRtX{]}^x\qX`zM_PaUeYn`ug}j~mrtxyyz~ǹ˸ȶ[K;[K;[K;[K;[K;[K;[K;[K;ZJ:ZJ:ZJ:[K;[K;\L<\L<\L<]K=]K=]L<^M=^M;^O<^O<^O<^Q@^Q@]OB[OC\NE[NF\OI]OO^P_bTmdY{i^pg|t{{zxucMlFRA@A=E;H;G;E9A:@A0D:<731;9A?D?SLUJ:+9)7$7%;)=,=,9*8)4&2&2)9/>7>65./&6)6)4*1'.)-)*(**),','1)9&;GD=:<9:5807-6*4&3#5#6$8&;,9=9?9@8?5<2:.9-9,=1NHc_no|~yyyxtn}et^nVhE\8V^N>\O?^NA]OB^PE^OJbNYbQdcTqdZ}lexrwv}‰΂wlXwD_BTDPJPIHE>EBB@C@GBHDGCDA=?7@7=/:+:*9)8*;.?6FA=;BBAA;6JBXLK>@28(3#8(<-:*7)8+0%3)8/;4:5600+,'0,1-10312537486;-5,6.=0C-F)G+N3R9L3?@M_llzWfCS>P3D3A3>6<99834*/$2*.(72YT\ZXVA?HFB@<7706-8-9+7'5#8#9$:(=-;,6)7.=5NGEA501->9@:815120215283:2:/9.:.6*8+IB_Ynl}v}w~yxsk}dv^pSeF]8V=ZL]TRz_BWhC?EBEFBDAECFDEEAB:?4?3;-8(9(9)8*:-;3IE??=>782/A:ZPh[PCA35%6'9+9+7+8,0&6-;4;440/,-+--493;3=3=1>0=1=1>0A1B4K5N0N-O1X>_3HO\an_nWfP`DX8JAQ:G2:/22-8-;+:*:/2(JBkcLGPK;9;9LJ@<707--9)3':/D;GAC=722.;7:62.2-,-,,./3171:1<1>26)4)B:XRjh|}v}xzxqi{bt]oQcI`:X?[O_QNqX:Sf8]uEa|InSvY{]~`gll}m|o}ponllqqrroprtvtwï̫̾ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8ZK8[L9[L9\M:\M:]L:^K<`J<^K<_L=^M;_N<^O<^O<^O:_P;`O;aP>aP>aP>aP@8>3>19+7':)<*<,=1?7=:9903/24294MElah[QCD>63;7UQF@918-:,9(9(=)?'<&;&=*7(3(=4LFGAE@963073510+1-,/+-./1/4/81;1>29.3(;2NHa^yzz|{xn~ew^pZlL`Ia9W=YM]JGhQ1Qd6\tDf~Nu[chjnsttr}pnmllnnoolknrttwƯν̻ʤ[J8ZK8[J8ZK8[J8ZK8[J8ZK8[J8ZK8[J8[L9\K9\M:]L:]L:^K<^K<^K<^M=^M=^O<^O<\O<`Q>aR=aR?bQ?bQ?aP>aO;bL>hOKgNRbP\cWkjfuv}|xzƄ}uzlmY[DL/I5R4=0?1;+8(<,?.@1A7C=7485..30:60'5)UGwj[PC7<0;07*6+:0708263320112364<%6#9"9"9!865629%B(G&J'M3\Ehbu`lWcQ]P]MZ@M2==F7;/./(5';(?&>%9'8+VJ;2?8412/C@WSHA916*6(5%5$:(<(:&7%9*4&1%?5RJIAHB;62.411/-+22,/+.+-++-*1*4,8,=12(7.IB\Xww}vj|_sXlTiD\D^6U:VLZHC^K-Mc5Uo?b}Jt\glnrvzwr~m|i}ggikmmlh~ijosrxũʵ¶Ş]K7\K7]K7\K7]K7\K7]K7\K7^L8]L8^L8]L8^L8]L8^L8]L:]J<]K=^L>\L<\L<[N=]P?^SA`SB_R?`P@bQAcRBdQBdNAdLBjMIhKMdPYf[lnkw{Ђy~sqjba^JW>Q:L?NCQ@KF9=4;0:,6&A0<,6(A5F==57285715.6-8*<*:'6%;0SLZOE98*>.B3:-3+GB//5:6=,7BM'3&2)2(2'"*'/'/&)+7 .&7-A#;Xr-D]l_iZcU\PWHM?@84>7A7?17&2!6#;'<)8-7/E?;7316454DCLHKED;:04)5(4)5*1=3_Ysqxh}_w[uUoLfEc:Y;[?Y]i@;VF-L^6YuBgMw]}cgjnonm~l}i|h}feflmlk~gfgimrv|z]K7]K7]K7]K7]K7]K7]K7]K7^L8^L8^L8^L8^L8^L8^L8^K:\K;^L>_M?^N>[N=[N=\Q?^RB_SC]QA]OB_OB`NDbPFcOHeNHiMJgNQeS_g_tnny~ʣxy|{vji`]aOZFRHSIVEP?J;E9?:<::=8?7>4/8(8);.;4JF016;6A.<@N'4$,%(),+,*+((((+,$'%(%,;D'4CAR&6jubjZaW]OSBC<8>68,D5H6>,/)((-%:6TPHG5445==WUGBG?A99/3)6,7/70=3915.2-4.83?9E=J@A86-0*0,210303021201/00.1-4-9-=13$aP@`P@]P?\O>[O?[RC[QE[QG\OG\OI_PMcQOfTTgUUgUUgV\h]nlisv|ˊԘנʪ}π䄆vsjegS\GQFOHREQAK=E7=7:99<7@7A4?0>->-<+:,B6H?;20):26/6.7,8,7(8&9&:*4-4.A9OCH:5%2#@2>5HD135;7@4@ES2?)0#&$'13-/''&%12)*8:+1)13=R^=K[g^fV\OTMREI:;74?96,?2B5=17-3),#' %/*EC::,,35AB^]?:C;A9=39/=4@8@;@<=;>;A?>>::?=IDB9<45,2+1-311202020201/00.1-4-9->24%8+;0[Tzw~rdy[tTqNmFg=_=\EbTgAHp;3SH2Qa<]xEfNrZu^t_xc{g{gyfyfycxbybya|bzczf{h{h{e{a{`}``jnstwuynolSeYAPM2A>^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^M9^L8`N:aP<`Q>]P?ZN>YOCXPEXOH[QO_UTbXYeX_iYcl\fk^glaildqokrty~ʅڌᎇןӭijy{ށzwsrcgU\MTGPCM>G-=0F:RGH?5.1)9181;0=1;-6'6&8+5-2+=4NBK=:,8*B67.>:/0164<8BNZLU>E38$&/1,,22**/.::37,29@EMXcMW=CADBF>A9=8988978391:2A:NHVSNNC@7295KIMLQRYZRQYV51>6B9@7?5B9C<@;?@8=9=?C:?58>=MJ93603+3,4.30210102/201/0/.0-4-8-?36'5(9.VO|yzocwXqOlFh@c9\?^KdZh35g;0WO8WgCa{KjPsYt\u^wbyezfwdvawav`x`x`{azczfzgzfzbz`z]|]~_gntsuqtiidQcUDSL8G@^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M;^M9]K5_M5`P9_P;\O>ZN@XOFXQKYPQ`W\g`hnfsshysg{sg}qh}ol}pqrwv}z҄响㝌ڠulnqvlvismllgi^`RWFM3=16*4'6*3,70=5E9F9B3A2>20&720/.1.47?PX]dZ_OS.103,-EE66,,-.>@2537bh=B*2-4&*;=@E6:379=7;/043;;GFRS`cilek^a@>E@^[hgopjjKK=;40>7D5<4:1415;-7,6.8,4,39b:_6\AaNeWap/+_?0[W>^lIe}MkSt\u_v_xcycxbu`u`u_v_w_x`{azbzd{e|d|`y^yZ{\}^agmpsr{nrjexe[k^RbU_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N<_N:^L4_N4`N8^O:[N>YOEZSMZTT_Zahbprmzu{u{qzpvpqtrxt}wz~τڋޖܙ͛~yl[Q>MBQIWRWUSRKM>C4:9<9;;9=8@8B6A0?/9,A65+.$I?g\dZUI<26)3):0;06,3)6-1*71;29/>0F5B39+1(4-31-.*.17EJV[]b\a9<9<+,JK89//57()'+XZ>B9=6:#(+<>AE49,21705(.37KNaehncl`i`lbkLLNJ\ZVTMMHF423/ACJJ1.3,3,5,4-4/4/3/02/2.1-0../-2-7-=1;-1$7,C=yv|qhx_rRlDc9^6]6\FcN`IMe5+VD0[Y@^lIe|NkRt[w_x`{dzcv`s]r\s\t]v^w_{azbybzb|b{_x[xYzY{Z~_ekmsus|rupnlfwe_P=_P=_P=_P=_P=_P=_P=_P=^O<^O<^O<^O<^O<^O<^O<_N:aP6aP6aO9^O<[OA[RK\VV_Zakgvso}z~|}w{uxvsys}x{~ĄɍΔ͚ǠɭŦmfJE2A4@4B9HDNNJK?C=?;=<;=:@8@5>1=0:0?64,1'I?cVh[eWOB>24)7,905,2+600,4/7/7.>1C4>04%4*0+3/..-.1478BEMRY^FKQW37FJ80=*7.:;ECHAB1/4-4-5,4-3,4/4002/2.1-0../-2-7-:/>01%7,;5sqvi}at[pPjCb7`7a;_LfO[~86]=0NF1VX@ZeEcxMjRr[v^ya{dxas]pYpWqXqXt\u]y_x`x_y^z^y\xYxWyV{X_dhloqmxjqij~cbv]_P=_P=_P=_P=_P=_P=_P=_P=^O<^O<^O<^O<^O<^O<^O<_N:cQ9cQ9aP<]P@ZPG\TR_Zaa_mtryx~~yyyuwww|x}ĂąȸоѻЬoT\GG5>0G?WQWVNO@C=?<==;=:=5:19080<5:3=5OEXM]OeXcUL>:-8.914-2,60402-5.<3C7C4:-3%5,.&0-/,3154-.24BFX]W\ouDJHM@02:=HK9>7?=F7B-8>J]gmwjrcn]g^kao]nYe\]PIJG74/0540.95D?JDIA@86/4/7166'/0<2=+60:>E?A443.5.6-4,3*3,4/4101/2.1-0../-2-7-9.?20%6,61popcx\pXnOiBb9a`P@`P@_O?_O?_O?aQAbRB_O?]M=]M=aQAcSCbRB`Q>dS?aP>]P@^QI[QPZSZeapsqyxz|~}xzrslotwv{̀ʋƖäƳ̰ϬϧϣУ˜˜Ѩg^FzgueH?QNccKL?A89:::97561;6815.B;<3I?XKOAdVcTXIG9:/6-7/6/4/0-2,70=4<07)5(7,/$/&/)1-2040516479JNY]NS8=6+90>=HS_`igrepbmcn`o]gSSF@854111/.3194D=B:?7<4908193667<4;4;4<6;59331/3,5.7.5+3+2,2,201203/2.1//0.3.7.?58,6,/&;7XW{me|\rPhGeCe;d9`NlRd=?P, C;&CG.KM5Y_CZjEcxMqZxbx`t\rYqYlSmRnSoTrXtZu]u[tXtWvXwWvWvUuTtS{[{]z^u[mUb~MXrCSj>AW0?U/`P@`P@`P@_O?`P@aQAbRB`P@_O?`P@bRBcSCbRB`P@fVG_QF\OG^TSaZad`omkvwwy{}}x|qukplonquv|~ՉӘΨǸźαתۥޥݢۤأѠǛӼ}dŋw}mVJa[rpZ[KL?@=>>@;;6664=883?86.>3K@H;]Mo``QH:5)0&6-5-0)5195=7<38.5)4*5*7.5+2+0+0,2,4.5287>@JLW[^b\d]eaiS[NVQY_gjqflZ`NT4:,5*6-9'5!-'67CPZZdbldmencm[hQZEE<7646355302/62>9>7;4:3818295:69;7:7:797965312,3,6-7,6,2+1,1,201203/2.1//0.3.7.<3=28.1*74Z[s}fz^vWoOiFf?b^QA^QA^QA^QA_RB`SCaTD`SC_RB`SCaTDaTD`SC^PCbUM\QM[QRcYbkdtqmvuy{y{y~x|nsei`gjnru}}ׇݗ۩ػؿۧϡÜkpo`RG]Umiuu__JL@DAD>@8:66=:;6A:707,>3=/F8j\i[[MB62(4+6-2,52A>GC=62)1'2'0%4*1).)/)2,7/=4B9-(43DCVX^bZaS[Q[FQHSOY\fmvntY_>D.5-42<2>+9'46EKWISPWW_^fck`iRYBI977175<8;;955160:3;290907183:6<8999997988874402+6-7-8,6,2)0)0,10121302/1//0.3.6.90D9804./._blwbxWsPmLlCf:];_IfSgDJl;4O>,=<':?(ED/FH0Q\U'B\/E_2Ic6WJ:ZM=\O?^QA]P@^QA_RBaTD`SC`SC`SCaTDaTD`SC_RB\PDZOMZQVbXcjcsqmvuxzz|w|symrbi]daglrx{ʉߕ夡䶵۪ө¡vqrcbWi`rmut[]LNCG@D@?=;957282918080717396:7:7;9:7:8:6845.3+6,7-8,6,2)0)/+0/222312010/0.3.6.8/F<913.,,fjygtbyTqKkGj>c6Y=^QhXeBBgC7[N;GF1AC-JH3EE-LU6Sc>btLlUpXnRkPiKgIhJhKjMkPmToWpVtXsUqSoPjMgJeHdG`D]AWy=Rq8Mi6Lf6Ne7Of8Lf7Oi9Sm>UH8WJ:[N>\O?]P@]P@_RBaTD_RB`SCaTDaTD`SC_RB_RB^QIVMR_Xhnf{tpxtxwxzy{syjr`g[c_gjrv|ƀΓ䭮绽߹׶еƱy|qvksimeoi扄~sredWYMNDE@@:7;7B=E?<3=3B51#0"I;XKN@=/8*6*3*42UUkh]XD>;3;2804-2,1+0)0'/$/$0#9,4'3):5CAEGBG@HDOOZVaVa^igoYaBG:<5738283=9CHSV_6?4;6;ADJOIM;A135195<8<9;9:77370;2;1:09082736475:8;8:8:9;7956/3,7-8.9-7*3)1)0)1-323322011/0.3.6.7/C:701-13jpqzft]tPmCf=d9c8^EdZmV[wE>dJ=aYFTO;KI4PI6GE.GP3L\8ZlFf|NmSmRlMhJfHgHgIiLjOlSnVoUtVsUnRjLfKcHaF_FZBX|?St;Pn8Ok:Rl=Wn@ZqCUo?Vq>WqARE5UH8XK;ZM=[N>\O?^QA`SC`SCaTDaTDaTD`SC`SCbUEaVP^Vcje|yu}yzyxyvyswjrcj[c]ehpv~ǁшәݣ௳㻿þŹx{tyvquleleoga[`[smyu{|yrpccSTHGC?>:<6A;:1C:TJ>26)9,=.?/B1C5@17-2/LM_]WSD?:48170939292:19/9,8+8)(3"@2I>D@;:7;:@7AHRV_Yb^g`iU[AE@>?;ACGJLTQYT]V^4:/5/37:=A;?4812429586422020404.<4=4<3;2837343438898889997755/3,7-8,:+7*2(0(0(1,424332111/1.3.6.91<3710-@CnukubqRiHf;a4^6b>dNi\iGFjF:]L<]VCXQ>RJ7OG4ID.DJ.GU2Sc>^sHgMjOjKgGgFfGfHgJiNkRmUmUqUoQjNgKcH`E_F^G\E[~DWxAVr?Uo@YpB]rG^uG[sCYtAXs@NB2QE5UI9WK;XL\P@^RBaUEbVFbVFaUE_SCaUEfZJh]Yngwup|x{ywxvwpujoah^f_gempx}͉؏ؙ֪֡۴ߺɼĻqqqtpopfewhenj_Yd_ZTf`snzv{wwshfZWRNHB=6D=;4G=\R;0<07+6(>.D3B3A1A386>>CCB@=7817/7/:393:3;3>5A5E8G6-;%J8L==50+009>AJKTU`Ze]eYaLR>@4/7/;9@@CHDJBI?F5;26368<7914/2142095740.,*0,3.3,=5=4=4<3:59565655757576866542.1+7.9-:+7*4&1&1(1,425342211/1.3.6.;34+:520UXpxcnZiI`Ef8b/]5bBhLePYj5/^G7XK:UN;[P>VI8M@0JC0@F,AO.K[6Xj@bxGfJhIfFeDcBcEeHgLhOiRkSnRlPhNdJaH_F_H_H_H_H]~G]yF]wH`wKcxOczN]uC[vAZu@JC3MF6QH9TK.E6>-2"7'E7E?973.50;5=5<4=4;4925.4+5)8+<,?-S>G2<):-=2;57443KNMRPUTYY]VXMOD@5+7+7/52242618.64>3;5?9B4>+5(3/9-35759./*+0.515/<4=4=4=4;6:676664635253455411-0(8,:+:+8(4&3$3&4*5052423/2/2,4,6.=4/&>935bgoy[iNcC]Eh:e0]6aGhJ]CFR,#VI8SL:OH6[O?UI9F?-HF1>B'@J(IU1Sd:_rEe}IgJeHcCaBbCcEeHfMhPiQlPkMfJcIaG`F`H`I^G^F_}G`|Ia{Kd{Mf|Nf~N]xC]z@^{CDB6FD8JF;PG>RH>WI>]M>_O?`Q>aR?`SB_VGbYRgb_ojnso~wqzt|yywppgg`a\_`bfhopyz̄֍ߖ眙栞ݡף٤ڦإץԤӥѣ͢ɢȟÙ|rn}igld^`fZZkYUrWP}WNWORIZPXPZSkdyr|uqus_]PLEAZT712*6*7(7'7&9(;+<.?18.<2?4;05(3':/@590907.7+7):*?,A/=.@4E:G+?*?)?(?&?$<$<$8'9+<,9+5.545;984:3;4;5:595735435465454535/5,5)8,9*9(9&8&7%6%4&5-4/504.5,5+5*7,907/:6?BmwbsSjIcKj6[6_cNjIV^$"D, ?:'HE4PMC/?G/BH&EK%KS.S]8[kDavKd~NdJbF`Ba@cBeFhJlPmQlLiHgGfHfJeIcHaGdJdIbGc~GdJdHe~Ga}C[{<\=_B=?4?A6FC[K>]M=`O;`Q<^SA^VIc[Xhcinlysotpvptppmgfaa]^\\edkjtr}{φٍ易囖ٜ՝֞מ֝՜ԛўќ͜ʛǚēxtk|mdif]^f[YiZSoWM{UJVKVK\RYRXRfaqjvo~wusgdUSZU2,/%7)7&7%8&8';*;-=/9,9,:,:,9+9+8+8,;1908.8,9*9(:&9&6*80=5@8A9?7<4914->6H@OGQINFC;7*7%8$7)4,//+3)7(:+@*A)A&A#@!<=:: 9%;);-9197:;;94:5;4;5:595735235465464716/5,5)9*9*9(9&9&8%8%6%5+3+4,5*5*6(7)7*;14,54TYes[pGbIhAd;`3[;aMmLb8?S*$A5'69(;<,B@1DA0@?-=B.>G,=CKP'\b_?bB69.:<1??7DA:KB;OE/>/6(/":.8-7,8,:+:)9&7$5)6,8.:0=3@6A7B8:1@6E;FG=@67+6%6&7,4/03-5+9*<';'=%=#;!:77686$8*;2<6=8;::94:5;4;59585735236475565616/5,4(8)9)9'8%8%7$7$6%5'4)5*6(6(7(6)7+<21+88kr]nPi<[Hl7]>e5[>bVq?Qa#(L/);7+07'37&9<)@=*A<(@>)BB&?FXa4s~Tdw`hSa}LaG`C`?a@c@hEjJkMlNnMkHhHgGhKhKfLdJeKdJcFdGfHfGeFbBcDeEhH25*58-;<4A>7G@:KB;RE.>.8(/!6)5)4(6)9+<+=*;):-:/909/:1;1<3=3D9?8:8794:5;4;59585735447476665726/5,5*8*8(8(8&7&7$6$6$5%6(7'9(9(:(9):+:13.HKoyVjD_<_Ag3\8b>cMlOe0=J C1-11'.6'4=,=B.B@+B<$E>$HE$U\0p~Mr|mjW_{J]~E_Ca@bAfCkJlLmOmOoNlIiIhHiLiLhNgMfLdJdGeHgHhIfGdDgHiIlL-3'36+891<;6B=9G@:MD=QG=SI=SK>UNDZUQa^eigumklkjhb`XVPPQQXY`cfjorux|Ђֆه؊ً֋ϋ͉̊ЉшъщЌϋȍ~wmYjSZnVTc\RZaOZ_HeZDxUBLDTRSWRY^dejkluqunoh~v{~l`?28(;(='='<';':'8(7):/8.8,9+:+:*9)7(9+7+8,7+7*8*<,>-<0=0<2;/:08,7-5*@7@5=49.80;1:25,/%0)2025/8-9+;,<-?.?/@/@/A/?-?.@)9)8+70:6=8=774394:5;6:79585654448485676726/6,5*8*9(9(9&9&8&7&8&8%:&;'=(=(=*=,<.7/;8^eaqPi<[Ai4_4`1YKlYq>NZ%-C),:2/-0)08+7@/:B+<<"A<UH(`[5{Slwo[aK^F`DcBeDjGoNpPoSoSoNlIiIgGiLiLiOhNfJeIdHeIgIhHgGeDiIiKlN+1%.4*470893>:7B=:HA;KD18*4&8)<,:,:,;/;-:/9+5+5(6,;/>4?3?6>37.,#+%-*02391;0<0?0?0@1@1@0=/<-9,9*7/8IE4>1>0@/?.$?%@(@*=-;196U\^qGc?a:a7g3b8`FdNa@IS12A64@:<:46?56<7179+4="9CSZ.PqŊˎ̒Í}{egQ_E^@c@iDoJsPsSqUoSnNkJgGeEgJhKiNiNfKdIdIeHgJhIiHfEjLlNoQ&.!(0%-2+13.331764:95<;6GD=DD*;'7$4#B2OAN@B47)7)>/;+:*8(7'6'6(8*8+;.;/9-6*7,<1<271888=:A9B4A/<,;,:/;19384857563657376;9<69453376;9869796:7877767465:5:7:8995827/7+8+:*9+;*:*:(:*;(9":"=$>%?(?+<.81<89?48E26C41=:)>E&FU*bs?aˌɋËz{efPZ|@^?a>hCoJrOrRpTnRnNjIfFdDfIhKiNiNfKeJdGeFgHhGhGeDkLmOpR(0!'/"(-&).(.0-3317839:4==5?@8DE@JLKORYVXeZ\s]^}YX[Y^]eennwx؄⌌솇䂂܀ւӃ΀ȁǃ˄ΆЈӋҌϊŊ}xwozkegf]Xm[Qm[Mi\Lf^Kd_IeaHhaGo_FoP;UA]OaYYXQTS[\`heYPD<707/:1=/;+9(:&9(:)8)8*5,5,/%3)8,>/@/@-=*9'9)0"WJK?/#=12<07,8->4C5;687899:97877;=<<::8785747575979899::9;9<9<8<7;6:8:9:;9;5907,8+9)9+:):):(;*<)9#=':#49%D3?61,^eVgIb<\1X0Y6cBiYoFQo33N3,B?6>C<@78@-1L/3K2.A9&DJ(Zn=~_włʌ~nfRXvBY{?]>cAiDnImLlNkOlNiIfDcBcBfIhKfLdJgMhNgKfHeEfEjIkJqQrStU*0")/#).').(-/,130561782;<4>?7AD=HJGOPTSUaXYkZ\u\Z^]dbkjut~·ߋ鍍년 ؀~Ҁς̅Ɇȇˉ΋ό΍̎Ȋ|x{stknlb`e]Re`Me^Kf^Kh]Ki\Ij^Hk_Gn^Ew_G[CYFZLVPRSQXX_USLE>9606/909,9(8&8&8(8)7)6*4,5,0'5)9+=-A/@-<*9(8)<.REH<4(:-:,4&=,<+;*;*:)9)8)6(7*8,7,3)1'1(7.<5DG8>/9/:0=.;1<6?5:3622:8EBIFDC?>:7989796858598988788999:9;9<9<7;6:596888;8:59/7+8*:*:*;*;*<)<+<)9$?):%5:';/:2<=^gPdA[8W6[;`>dIe?L?>_:2G;/:>08>2F<:R>=N0.S8/VK5ciEx[p}Ɓ}xr^YuETp=\{B_@b@iCmHlKkLiMiMgGeCcBcDgJiLhNgMiOiMiKgGgFfElImLpQoRtU-1"-1#,/&,.)//-11/34/45-9;0<>1@B7EHAKMLQRWUUaVWi\Yt^]fdpnzx΍ߐꐎ튉燄߁|}ȀÆLjƊʌɌɌŌ|v{pujpndbi_Vc]M_aL_aKc^Jg\Jl[In\Ho]Gq]EwaIxX?S=VDXOUSOTMS><<784716/6.7+7(7&8$8&8'6)5*3,5,3(6(9)<+?-?-<+8(5'J=F:A584627272728596;8;877888:8;8<8<8<8;58475777:7:48/7,8+:+;+<+<+<)<+<)9&@*9$6$;+0'40PT[iJ`:U7V@]HfHdNa89e?6R@2DA09=,57)>6+K9/E-#R=,g]B_t{z{xm\uKHb5Nh8[xB_}?c@hDlGjIhJgLfKdDdCcDeFhKkNkOjNiOiOiMhJgHhHlKoMsVsWvY24&04&01)01+12-23.34.46+9;-;>-?A3DF9IJDMONRQWSS]XVd\Zoda~nlzwÌ֑㔑ꓐ뎋≅ق||~Ë}{vyn~rgmmaak^Vi[Pc\J]`K]aJc^Jh[JmZKqZJtZIv[FsWAxR;Q=YF[PTPFI>A2/5/51605.5+6)8)7$8$8&9'6)6*3,6-6)8'7&:(>+?-;+8)4'UI<18,B45%=+=+8(8'9(:)9)7)6(3'6*3)2)4,:3>7?9=:45596;5;2:397=<@UVbbmjidVQA<634/61717182859697:878898;9<8<8<8<7<5:686797<7<49/9,9*;*;)<)<+=);*<(:'@,8&8';-+"54`gTdG\-=@-@C.DG4IK>MNFQPNRRRVUSYX]a_lkius}njӕᔑ␍܋ӄā}||~zxsznzrfjm_^j[Ti[PjZKfZJb_Lb_Le^Li\Kn[Lr[Kw\K{ZG~UAR=RAVFRHG@88331-3/5/5.3,3)5(9(8$9$:&:'8)7*5,7-;+:)6%8';+=.;.7,90\T=55+A53$:(?+:):*:+:,;-:-8-7-3*1)1+71<7>:;77475;<8>7=7;7;797:::=:=7;2;/8*:*;*<)<*<(;););(=*8'9*8-/)@ChrM^H[DYH[O^T]TWXUdM?OL9LG4JE1FD-?B'=D#>H#KV.\g.==1==3==5;<4;=2;=/?B/@D-CG.FJ3KL:NOAQQIRRHYWJZZN_^\gerqn{yďяӍϊǃ~yzwyv{v|y|}}x|tzrvksrffm_\j\Sk[NlZLl[Kk[Ki]Mg^Mi]Mj]Mn]Ms^Mz]MZI`OVGN@J=@76.1+1+516/5.4-2)4'6&;(9$;$;&;':)9*7,9->,;(5#5#9)<.;/7-?7[TIA:0@36&3 <)9'7'7'7(7)7*7,7-<3:293<7>:=9854196<9::8:>@PPbcppheTP=61+40;7=:;7;5:294837373556669697;8<8>7=7=6:8<898:;:>:>7<28TXepK\I]J\M[QZVVZR`RPI7HM9NI5H@+;567>O%Lf6lTw\edfkt|mn}\Q`Cg{HiFlGmGjGfGbGcGhJlMoPnPlMiKjJjLsTsUsSrQrOsRwUzZvZu[sYRK;RK;RJ=RJ=RJ=RJ=RJ=RK;UNXQ?YR@[TD\UE\UEb[HaZHaYLbYRe][kaiqftuj{zn|pss|puj{mbre]jc`k`_g_\c_Z^^ZY^YUaZRbZOe[Og[Ki\Kk\Ik\Gm]Fm]Fj^HicMqfTqZJuOBWJ\PYLZLN=E4<,7(8-80411-6/7.7.7.7.7+6)7)8)8)9)9)9+9+8+;,;+>-9(1 2!9*H9=,2#PFJ@F<:7487::::776493=7F>B9:/4(1&5);/?3:0<3?7?:=;;9899:7:8:8:999797959540516576899:9:9;;>9;99=:A=B;A6?1:)<+=*<(:&:%8&8&A0<-/#/&LJmoloVZLNNOQMUOXO]RaTjSWZ/:M7FTa)~Poyxs~ahL\mCYdBT]BHP9?D0:=,@C2<@1:>0]sBgHpKoKlGjIiKgJlPmSoSlPmMkJmJmIqLqMrNrPtRvUyYz^ycmZbOWN?WN?WN?WN?WN?WN?WN?WN?XO@YPAYPA[RC\SD]TE^UF_VGd[JcZIcYMcYOf[Uj_]nbdpdhreltgpvirvirsfmm`gg[_bXY^[VZZRYVOWTKXTIXTH\VH^WGcZKcZIf[Ig\Hi]Gj^Fk_Gh`IcbMngTv\MSFVMVORJQEH9C0=,9)8,8062406.8.8.8.7-8-7,7+7+7+7+7+8+8+8+:,<.>.9(1 2 :)>.<.:-4*4);0E:OBQCOCF?@;<5;4=7=88633777879787797=9B:A7?4:,6'5&8)=-@1A4@6@7=8:777567:6:6<7:89879595:592:3:5;6;8;89999:;;;<=?=A;?6=2;-;+=*=+<);(:&8%:%9'8)5*<5QPee^aMMNLTMYP\Q^S^S_VfQ`_/Sg*^r3zOn|pbjHauBTe;JX7FP7?H59?158-:^tEgHqMpLnHkHkLhKmQnTmSmQkLkHlHmHpJpJpLsQuTxXxXx^mXbQYH]TE]TE]TE]TE]TE]TE]TE]TE[RC\SD]TE^UF_VG`WHaXIaXGe]Je]Hd[Jd[Le[Qf[Uh]Yh][i]]j^^k__k__i^\f[YbWS_VQZVMWTKUQHRNCQMBSOCWQCXRB^WG^WEaYFc[Fg\Hi^Hk`JhbLbaMngUy_PXN[UVQIEE@@7>1;/8+8+9,;/:/8.7-7-9.8-7,7,7+7+7+7+8+8+8+9+;,>0>.:(2 3:&>,>.?08+2(4*<0F9M?ND:643204297=<<<;<9<5:27265899<:@:8-:+6'4%5%8(<+=.D5C6B8=79464557969696977779595:3:3;4;6<6;8:999889:<<@>B=?9:17+7(;,<+<+;):(9&7%9&z6#y6%9,F=SOWTPOIFMHSLYP^SaWaW_VePsrFzVn{|[[oaXIaXIaXIaXIaXIaXIaXIaXI_VG`WH`WHaXIbYJcZKd[Ld[Je]Hf^Gf^Ig_Lg^Of\Pf\Rf\Sh]Wh]Wh]Wh^Ug]Te[QdZPc[N]YMZVJVRFRNBPL@PM>TN@UO?WQAYTA[VC]XDaZGd]Jf_LfaMdcQleUv\O[Qb\ZXFD<:<8;6:08-8):*?.?/9-7,8-9-8-8,8,7+7+8+8+8+8+8+9+;,?1>.9'3 38"=)@.?-:+7*5*7+:.7<380625587765615(7'6&7&7&9(:):*A1B4A7?8;5957687687878868694:4;492:2:4;7:8:89799<:@3B%:F.=F3;A3:=2:=4<=599-?@2<>39<1<@29B/?L2PbNK:NK:NK:PMTQ@VS@XWC[ZF]\H^]Kb`Qf^QmWJ[Ricc`MMBC;=8984709+=)C+B+;+7)8*:+9+9*9*8)8)8)8)9)9)9)9);,?1>0:(6"47 =&B-;*;,:,9-8.:0<0:49<4<3928384838256<494:7:9<76210(6(:(:(:(:(:(9&7&:+;/>3?7=8;896876666667484:3:3<3:2;2<5=7=:><=;>=@?1;=28;0;?18A.>K1Pb8770;.?+C*A(;*7(8)9*9*9*9*8)8)9)9)9)9)9)9);,?1=/<)9$65;"A*B.@/;,7*2(4+;0=85:3<6=8>:>;>:=9<587:9>=>=>962/0'9+>*>*>*=)<(:'8%6%7);0=3<5<7;8;787757585:4;4<4=4>5?7A:A;A>A?@=B??:@8=38-5(5'8(<*<(<)<(:&9'7%6$6%}:)t3!~9*OAYNRGOEVJYN[MZM[M\Q_T`WgW~xXy^r|ZU`B;E,/;%0;*0<.3=24<16<2?1:<17:/:>07@-=J0Oa;bxIkLuQuQtNqNrSpRrQsPrOpKnJpLsOvRyX{Zz]x]qWgO]EXB`NYISzCg^Og^Og^Og^Og^Og^Og^Og^Og^Og^Og^Oh_Ph_Ph_Ph_Pi`OjaPjbOjbOjbOi`Oi`OiaNiaNiaNh`Kh`Kh`Ih`IhaGhaGhaGf_Le^Kb[I\WDWR?PM:LI8IH6IH6GH6GJ9GK:HL;IM;A@CAEBC@A??1266:<=;;9714.4)<->+>+@,>+>(;':'7%7'8+8.7094=9>;:79595:4;4;4=4>4B7C9C9<3:/8+6(7'8):):(=)<*<):'9(7&6%}6$x3#x5%B2UEWKPCPDZLYMZN\Q\Q[T\U[VbUkbEV`=JS4=G,6?*2=,4>35?66=68?8=B;CF=EG/;9*78*=>0:<17:/:>06?,=J0N`:awHkLuQuQtNrOrSpPqOrNqMpLoKrNuTyX`~az]qUfL_G]E^IbPYISzCh_Ph_Ph_Ph_Ph_Ph_Ph_Ph_Pg^Oh_Ph_Ph_Ph_Ph_Pi`Qi`QmdUlcTjaRi`Qh_Pg^Og^Mh`MiaNiaLiaLiaLh`Ih`IhaGh`IgaKf_Le^Kb[H\WDUR?PMSQDSPAXLYSRODE::75;3>/=)8":)8'9(;*;*;*;*;*:):):):):):):);,;0:.<,>+9#37?'9#;)>0<18.7/<5?==B?DCEDC@?;7501./,51:6<6:28.8,:+=->+?,@-@-A+>*=*;*:(7(5)5+90?9C>=7;5;5<4<5=4>5@5D9D:C;A9?:;685937-8(5'6':)<*:)8&=*<+<*<)~:'|8%{6&{6&y1#8*G8SCPBL=RE_SWLYN[R]T]V\VYT^QaX;EM(6@8A&>G26BE*;:&78(=>09;069.:>06?,F7GK=IK=AE4KJ6\Q;aE/J9j]g`USFEA@A=>5=0=-4%5&6'7(7(8);,=.<-<-<-<-;,;,;,<-2(7.;/:)7"579"A-;+6)4*6/<7C?HEDEEHCC:661808.4+9/9.8.8-9,:+<+<+=+=*>+?,@-A,A-@-;*:(7(6)6+8-;3<4=6=6?8A7A9B6@6@5H=E;A8;25/3-1*2+9-;*9+:*:););+<+9'}8(|9(|9(|9({8'y6&x3$w- A4OCMAL@QEUJRG\R\RUMTLZUXSWTgZ]T5IQ*AK(BK,>H/7@+2=-4?14<1HPCZ^PW[JMO:DF.AA'==%:;)>?1;=2:=2;?14=*;H.PbF7>F7=E6@F8>E5>F1HL5MI0U?'Q:sbcX_ZUTGG@>A=?9:09+=,=.>-;-;+9+:*:,:+:,:+:,:+:,;.?5B:B7=/6#1125#6(;/A8E?IDJFKHCAEDB><39/=0?1=0?1>2>0>/=/>.@.?,=*;*<+=,?+>+>,>,@.=-:,8,8+8-:09/<2<2?5A7C9C9D9E8B6A4=3:06/5.4,7,:.=,;,;+:*;*<*<,~;*|;){9)y:)x9(w8'u6'w4$4'D7NCK?J>QDTIRGSJXOUOVP]XWRSOcT]W5Xc9_jBZfBIT66C)4@*0:<19<1<@25>+;H.PbMKD63?3A4A3A4;,:,8-7+6+6,7.:/;/<,;-;,:+;+;+<,};+z;*z;,w9*v8)u7(t6)v4&;1FEI0?C(=@#:<$89';<.8:/9<1=A36?,MK4>4>4>4?5?5?5>7?;B>D>F=FM@PDSHPGMGIEGBC?A=B=FBD??7=0>.C0G3I6F4E3C3B1A0}@.zA.|?-:,8,9+:,:,;-;+;+:+:)8)8*9,;/=/<0:/8.9/:.:.:,9+8*7)7(6)6*7+8-9/<0<.<-;,9*:*~9*}:*};+|:,z;,y;,w9*s8*q6(r7)u5)D8H=K?H:IB)=A(;='78(:;-79.9<1=A37@-NKB1=I1?G/LG1S>+g=-ZL_S>43+?9XUigdeRUJNNPIAF<@6>4@6D:G=G>JAJAJBJBKCKCKDKESRTTSRROSLSLULUNLHIFEBC@B@C@EBFDJFE@>7=2?2B1E3G4E3C3B3@0?1~?0z?/|>/:.9.9.9.;-;-;-;-9*9*9+:*:+;-<.;/;/9-9-:,9,8+8*8*8)8)8(8)9*:,:-;-:-:,9+8*}8)}7+|8+{9+z8,y9-x:-v8+q5*o5)q7+t9+H;IC-B47@-;H.L^8_uFiJtPtPtNrOsTpQnMmLpPwY|az`rXiQZA\EaIeMgMgKhJfLcPY{IRtBi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QkbSkbSkbSkbSkbSkbSkbSkaUlbYlbYlbYlbVlbVlcRlcRldQldQldQlcRlcTlbVlbXlbXlbXocUnbRkbQlcRlcRkbQg`Pd]M^WGYSCSM?MJ;KH9GE6EB3?B/;H.?H-OC-a=-E:XRNJ,+:9=;SRpnvvehX^^_UQPFG@C:D=G>GAG?HCJBHDJCJFKDKGKGHHGIHHGGHDHDGBFBBAABBABBCBB@A>A?JGC?<6>3@3A0A0C3A2@1?1=1<0<1=1=1;1;1:3;1;1.9)9(:*:+;,;+;,:+:,9+7)~6({5){5){5)z6)x6*x8,w9,s8*p4)o5)r:-v<0M@KN)?O(J\2_rEk~QexKXj@M_7@Q-6E&7D*=F1=D4:>07;-8:,:;-68-8;0>B47@-9F,I[5[qBeFrNsOsMrOsTpQmLoOsUx\z`s[iQ`HYB^GeMgMfJeGgGhLaNXzHQsAi`Qi`Qi`Qi`Qi`Qi`Qi`Qi`QkbSkbSkbSkbSkbSkbSkbSkbSlbXlbVlbVlcRlcRldOldOldMldMldMldOldQlcRlcTlbVlbVocUmaSkbSlcTmdUlcTi`Qf_Ob[K^WGXQARLB>@9C?C=C@D?CAD@ECDCADADDFGHIHJIIIGHACADBEBEAA@>=:=:FF=<83;2@4?1>0@1G]/AV-7H$1@!6B*=F5PK8MH5ID1DC.@F*DD([B,TG\X>A/3IN?E;>;FBFBB>>7D=D=D@EAEBECDEDF?C@DBEEEGGFFBC>?BD@C>A=>>>A?C@ECBB9850;4?6>3=/?2)=C5?>@=@=C?B?>:9370:0=2>3>2?2?3=2;393938192;0<.<.;-;/:.:.:.~:-~:-~:-~:-};/};/};/};/}90}90~80~8.7.7.7.~8,8,~8,}9,|8-{9-z8,x8,x8,x8.x8.w7-v8-v6,t6+s5*q5+m1'r6,n4)m3(o6+m4)q8-I=SHSJRGRHPHQJQKRLTMTK[NcQo_HYU:MV7O_;j~YbxQYoHUjCRg@Mb;IY5CR17D&4>#2:#6;'<>0@B5@@6<>358-39-4:.7:/9=/;?.=B,%Q?)kP=XGNBE=D?WVTTQQPONMMMLJKJTTHG=>=:B@EAB;>4D9E9F=G>FBDDAEAEBFCDCDDEDCFDFDFDEAD@B?A>A=A=A=C?E?C<>6:090:/<0<0A2~@3~>4<3:3918190;.<-;,;,;-:,:,:,9-9-9-9-~:/~:/~:/~:/}90}90}90}90}90}90|90|90|90z:0z:0y9/y9/y9/w9.w9.w8/w8/t8.s7-r6,r6,p6+p6+k1&q7,m4)l3(o6+l3(p7,~H>RISLQJPJQLPMQNSOOGSH[K{ePsiPhkLfqQgxT^tMXnGPf?La:K_:K\:GV7CP4>2;=04:03;05;16<0:A,>D*Q[9^mDkRpRpSqRsSsVx^|exakT`I]F]F\E`IaJcLeNdMbK`I^I]LRtBIk9i`Qi`Qi`QjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTnbTqdTo_Pm]Pm_RqeYog\ldYhbVfbWpl`{xi~{jyizubpiVe`JTT(MB.S@/U8(]7*l=3n70u91~;5@:IBPJXPZR^YSNGEB?DBFCD@@:A;CG@GCFFEFDFCDCDCDCDDEEEECECDBDBD?C>C=C=C=C>E@E?B<>5:18-9,;-@2@1~>2=1:19181:0;.;,;,;,:,:,:.:.9-9-~:/~:/~:/~:/~:/~:/}90}90}90}90|90{8/{8/{8/{;1{;1z:0y;0x:/x:/x:/x:/t8.t8.s7-s7-r6,q5+o5*o5*j1&o6+m4)k2'l6*i3'm7+}G=PIPIPJQLRMSNUPVPWO[P~^OtbNoiQorUlwYfwUQeBK_:EY6DU3EV6GV9GT8ER8?I0*7;*:<.<>0;=/9;.6<25=26<26<0:0=@-=C)MW5Zi@f|MlNnQqRuUtWz`w`nWcL\E\E\EZC_HaJbKdMcLaJ_H]H[}JPr@Gi7i`Qi`Qi`QjaRjaRkbSkbSkbSjaRjaRjaRjaRjaRjaRjaRjaRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTnbTrdWoaTm_Rk_SkaWlcZle[jf]jf]xtix~r}zg`cNOT>DG2FE1HC0F=,L<,VC4P9+R6*V4*Y5)\6+a9/e=1m=1KBSJUONKFDABDCFF@>A?B>E@ECFDEDEDDDCDCDDDDDEDEBFCFBEAD>E>DDA8;18,9+<-@0@1~?0=/:1:/9/:.:-;,;,:+:,:,9-9-9-9-~:/~:/~:/~:/~:/~:/}90|90}90{8/{8/{8/{8/x8.{;1y;0y;0y;0x:/x:/x:/v:/s7-s7-s7-r6,q5+o5*o5*m4)j1&o6+l3(h2&k5)h2&l6*|FG2:A/9=,9=.9=.8<-7;-7=36=56;46<2:<1;=/bxIjLnQsTwWxZ{ar[eN\EZC\E\EZC_H`IaJbKaJ`I^G]HY{HNp>Eg5haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTrfXth\sg[mcYjaXle]snhzwp~wz{kcfSOR?GJ7EH5BE2BE2EH5KL0A9,A7+@6*F4(S5*qB8PHPKIGGIEIBE@B@BBACBEAEADADADDDFDFDFDDEDEDDCFBFAF>E=E=F=E=F>A:C;E=B9>39-;..=-;/:-:-;.:-;-:,:,:,9+9-9-~:/~:/~:/~:/}:1}:1}:1}:1|91z:1|91y90y90x8/x8/v7.y:1y:1x90v:0v:0u9/u9/t:/r7/q6.q6.p5-o4,n3+n3+m4+j1(m7-j4*h2(j4*f2'j6+}D;NGNHQJTLUOWPYR[Q{YMv\OkZJ]UBYXDY^HOYA?K3:H/7E.4B+5A+8D.=I3CL7EN9BK6?H5.5<,4:,5<45<56;56;49;0:-;@)GP1Ra:`vGiKoRuVyYy[x`nW`IZ}C[~D^G^G]F`IaJbKbKaJ`I_H^IW|ILp@Bf6haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlcTkaUndZpf\lcZkd\rmg|ľrfcTPQ?FI8>E3;D1:F28E38E38C2:B34(P:/e?6EAPOX[QVCIFJEFFFEDEBDBD?CADDDFDFDFDCDCDCDCEAFAF@F=E/?/>.=-<-;-:-;.:,:,:,:,9+:+9-~8,~:/~:/~:/~:/}:1}:1}:1}:1z:1z:1y90y90x8/v7.v7.t8.w8/u9/u9/s9.t8.s9.r8-r8-q6.q6.p5-o4,n3+m4+l3*j4*h2(l6,i3)f2'h4)e1&i5*{B9MGMHPJTLVOXNYO|\Qs\Nk[L`WFVSBPSBJQ?@I64@,3<+2;*09(09(2;*5>-9B1G4:F2:C25@/3>-1<,3:33954954928919;.;>-;@*CL/O^7]sDiMpSwYyYwYqYfOZ}CX{A\E]F]F^G`I`I`I`I`I_H^G]JV{HJn@Ae7haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlbVj`VjaXkdZkg^upjμzym]_YIKL:@E1;D/>J6=H7=F5;C4;>5:;3983880==3C<2N71a84HH]_`dWZQSNOMKKJHGFDDABBCDDFDFCECEBDBBCBDCD@D?F?E.>-=,<,;,;,<-:,:,:,9+9-9-~8.}9.~:/~:/}:1}:1}:1}:1}:1}:1z:1y:1x90x90w8/t8.s7-r8-t8.s9.r8-q8-r8-p7,p7,p7,o6-o6-n5,n5,m4+l3*k2)i3)g1'k7,h4)e1&h4)b0%f4)zA8MGMHPJULXNYOxZOr\Nk^N^WGRPAKN=CJ:9B12:+08)17+17-06,/5+/5)08+2:+4<-9D4;F5=H7-.800621622717829;0:<.:?)?H+KY5[qChLqVw[wYsVgP^IUx@WzB[~F[~F[~F]H_J_J_J_J^I^I]H]JUvIJk@@a6haQhaQhaQibRibRjcSjcSjcSibRibRibRibRibRibRibRibRkbSkbSkbSkbSkbSkbSkbSkbSlcTlcTlcTlcTlcTlcTlcTlbVpg^ng_lgatqj}ub^\GKM7CH2AI2AI4@G5BD7AA7B=9C97?:69<5>?7B71J.+d66QRginm\\ZWVSQNLKHHCDBCCFDFDFCECEBDBBBBDCCBC?D>E>FD69A208+/7*6<247058157247025.06,08-19,6A3:E5=J9>K9-,6..400511606718:/:<.:?+WzB[~FY|DY|D\G_J_J^I^I^I]H]H]LStIHhA?]7icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSjcSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUmdUmdUmdUmdUldWibZgd]vsnʵƶibbFEH-DH/CG0FE1GD5F<3C60F42H:9>=9>?:B:7I75cGFjjœ譩ҋtn]XSPONJLFKFKEGIKDF;>>@GIDG:=@@@@A@B>C>BA9@9A9B8@5:.8*=0>/>.>-=,<+=*<,:+9-9-~8,~8.|8-|8-|8-|90|90|90|90z:1z:1z:1z:1y=5w<4w;3u:2t91q8/p7.p7.o6-m7-m7-l8-m7-l8-m7-m7-i2+m6/p92o81k4-g2*g2*h3+e0(i7.d2)]-#`0&_/%b2(s>6OJPKQJRJ}YMv_QfYITN>DE5>E5:C25@04&DR1WlChRs]w_rWkR[~DXyDTu@Tu@WxCZ{F[|GZ{F^JbNbN^J\}H_K`L^~MTsJFd@2I:3L95K<9?:7BA?MHE]RPyjgβſ쳪͂|c^VVRSHMADDEEEHHJKEF<><>AC????A@A@B>B=A<@9A<@;@9B:C;A6;18-=0>/>.>-=,<+<,<,:+9-9-~8,}9.|8-|8-|8-|90|90|90|90z:1{;2{;2z;2w<4u<3u:2s:1r90n8.o6-m7-m7-l8-l8-l8-l8-j8-l8-l8-k6.n70o81n91l7/i4,g2*e3*c1(d4*_/%^.$b2(^.$`0&p>5JERLXR~XOrVKdRDQJ:>?/:A16A05@03>04<14<15;17:379477577557246116//6./7,.9+1<.4A08E49H58G44E24B1.8/.5..3--2+23+46+8:-9=,7?(DQ3WlEhUt`wbpYgPY|DWxCTu@Tu@VwBYzEYzEYzE[|G_K_K\}H[|G^J^J^{MSnKF_A9R4icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSkbSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUmdUmdUneVneVlfZed_y{xشğl`gEQX7DG,DC.JD4LD7KA8I>:C;9SJKia_wvecBEDIRVUTMKDACAFEEFDDCD=?>@@?@?B@B?B=A:@:@:B:E/>.=-~<,=-=-9-9-~:/}9.}9.|8-{8/{8/}:1}:1{;2{;2{;2{;2z;4x<4t;2q;1r90o9/n8.l8-l6,k7,l8-j8-j8-j8-j8-i9-j8-j8-n91m80m80m80m80i7.f4+c1(d2)a1']-#_0&c4*\-#_0&sD<}PJVP~YQpTI^J?OC7?<-46(2;*0;+1<.2=/4<14<15;17:379479668357257227007/08-.9+0;-2?.6C27E48G48G49F54>33:2/4-,2(/0(13(57*6:)6>'DQ5YmJkZwfwflZ_KWxCWuCTr@Tr@VtBXvDYwEYwEZxF]{I_}K]{I]{I_}K^|JZwKPgJAW@3I2icSicSicSicSicSicSicSicSicSicSicSicSicSicSicSicSjcSkbSkbSlcTlcTmdUmdUmdUmdUmdUmdUneVneVneVneVmg[jkfڴefmLMQ6FH0HJ5KI:HD9D@7OGDj`_収cd@?PKTMPHF@GBMJKH@?>>???>A?A?B?B=B=>9@:C=E?E>A9=5;2<1=0>/>.=/~<,=-=-9-9-~:/}9.}9.|8-{8/{8/~;2~;2|<3{;2{;2{;2z;4x<4r90o9/o9/m9.l8-k7,j6+h6+i7,i7,i7,h8,h8,h8,h8,h8,m;2l7/j5-i7.j8/j8/f4+a1'e5+a2(].$a2(b3)Y* a2(yNE\VvWRiNGWC:I<3@:.:;-8<.08)/:*3;.4@?A@C?C?C?C=?;A@9>5=3<1<2=1=0=1~<.=/=/~:/~:/~:/}9.|90{8/{8/{8/|<3|<3|<3{;2z;4y:3y:3w;3n70m80l7/l7/k6.h6-h6-h6-i7.h8.h8.g8.g8.g8.g8.h8.k92h6/f4-g5.i70h70e4-b1*c2+b3+_0(]1(]1(V*!b6-{ULtYRaNHN?8A7.=6,;9-9;.9<139-3;.5;/6<06<07:/58-47.69049238139/39/2:/19.19,.9+.9+/:,0;-3>.6C2:E5Qn>Qn>Qn>Qn>Qn>Sp@Sp@WtD[xH]zJ]zJ_|L_|LZwGRlECU?6D7(6)gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSicSjcSkbSkbSlcTlcTmdUmdUmdUmdUmdUneVneVofWpgXpgXng]lnmz׹ĥregOMP;GK:FM=GOBKQG{{sžؓeSJ:TFWIF;@8KEC>C?B?C@C>C>D>B=B6<5/95,;8/8:/57,36+69.5;/7:/69.69.58-57,36+28,19,28.19,19.19,19,19,.9+.9+.9+/:,0;+3>.6A17B2ex\umtlf_RwKBh9KkVsCZwG]zJ^{K_|L_|LVsCNg@D=CUrDYvH[xJ]zL^{M\yKQn@G_;6B4+4/#)%gdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSgdSicSjcSjcSjbUlbVlbVmcWmdUmdUmdUleUmfVngWogZnh\oh^mjekormtzη|ubb_NXZL]cWmwn|}̻pQDSFSHC:J@H@G>F>E=DG>G>C;>5:2:3>6=5=4=5=4<3;0;1;1~:/~:/~:1}90|90{8/{8/{8/z:1z:1x92w81v70u6/u6/q6.m80k90j8/j8/i9/i9/i9/h8.g7-f7-g7-f7-f7-f7-f7-f7-f5.j81m;4k:3j92j:0m>4oC8l@5oD;d<2c=2zVJdZyWMbLA>:13814927<54:0/5+25,9<336+25*24)03(13(25*46+47,.6),7)/7*-8*/7*/7*/7*/7*19,08+08-/7,/7,/7,08-08+7?09B14*00!''heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjdVjdVjdXldYlcZmeZmeXmfVg`NjeRnkXol]he\feasqrԶ|qtY_dMbkXr}lا`XD=NEMCF3<2:1919191~:1|91{80z7/z7/w7.v6-w7.w7.w8/w8/v7.u6-q5+n3+l7/i81i81h70h70g6/g6/g6/f5.g6/i70i81h70g6/e4-e3,h3-j5/m80k90j:0i;.i=0kA3gB2jI:dH:v_O~k\xjoRJ=79.4:04:039/39/39/28.28.17-17-36-06,25,/5+14+/5+/4-.5-/4-.5-/4-/4-/4-/4-05./4-/4-.3,.3,/4-/4-/6.1;23=26@58B79D67B45@03>-4?.DQ=WeN[kQPbHEX<@T8BW6Ic>Ke>Kf=Kf=JeOj?UpGYtK\vO]wP]wRWqNHb?;O6&1+&+.$),heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZmfVidQjhSmjWjk[gg_lll~ЯvkqUYaI_kUto~uKAM@K>L@K>E9=4?6E9F7J7L:J7F6C2C6E7C7B8A7>5<4:39193~92}:2z:1z:1y90x8/v7.v7.u6-v7.t8.t8.t8.r6,o5*m4+l7/i81j81h70i70h70g6/g6/e3,e3,g5.h6/j81j81j81k92k60l71k90k;1k;/j>1j@0iD2gH6kP=gRAufSuesrKL<69.39/39/39/28.28.28.17-17-17-17-06,06,/5+/5+/5+/4./4./4./4./4./4./4./4.05//4..3-.3-.3-.3-/4./6/.80/:21=34@66B66B66B45B16C1CP>P]IR`IIW@AO6BP7EU:Jb@Jd?Ke@Ke>Ic6I5&1-',0$)-heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZmfVmhUkiTmjWjk[kkcwwwۿʫyuy`kpZt{i؞L=RBL;@1G;YMUJ@4D7H:K=I;B7?3@7E;@9A9A8?6~>5}=4<4}=4z;4x<4w;3w;3u:2t91t91t91r90r90r90r90o9/n8.l6,k5+l7/j81l71j81k60i70i70h6/g5.g5.f5.g6/h70i81k:3k:3l;4j;3i:0h<1k?2jC4iD2fE2fI7lVAjYGujVm{mEF658-28.28.28.17-17-17-06,17-17-17-06,06,/5+/5+/5+/4./4./4./4./4./4./4./4./4./4..3--2,-2,.3-/4..5.+5-+6.-9//;12>24@46B47D38E3?L:ER>CQ:;I28F->L3DT9J_@Jb@LdBKc?Ia=G`9F_8G`9RkDXpL]uS^vVZqTPgK=T8.A.&1-',0%*.heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZmfVniVljUlkWlm]pqiؼǫ}ſñpP@O?XJM?E9G4e=1f>2hC3iE5fG3cG2cJ6hV@i\IskVozpq_9=,47,28.17-17-17-06,06,06,17-17-17-06,06,/5+/5+/5+.3-.3-.3-.3-.3-.3-.3-.3-.3-.3--2,-2,-2,-2,.3--4-*4,)4,*6,+7-.:.1=14@25A36C2:G5N4DX@7C;F?D=>;:7:8>;=;?<@=}@=xA6s>6r=5r=5r=5p>5o=4n>4m=3l<2k;1j;1i:0i:0j:0n72p62p62m61m61l71i70i70l;4k:3h91e90e90e90e:1d<2fB6cA5cC4dD5dG5dI6bI3_I2^L6eV?jbMrmWor[`L3:(28,28.17-17-17-06,06,06,17-17-17-06,06,/5+/5+/5+.3-.3-.3-.3-.3-.3-.3-.3--2,-2,,1+,1+,1+,1+-2,,3,,6.+5-*4+*4++5,.8-0;-2=/2=-5@/6A05A-1=)1=)5A-8F/=O5@T8FY=H\@J]?I^=K^>K`?TgG[pQcvZauZYkSJ]G6G4&4%$-*$),"'*heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjcYkdZlc\md[meZlfVjgTkjUlnYorasvmθκƶøͧkX[GWEL;D:DE?A>=::9;9=5o?5o?5o@6n?5m>4k<2h<1h<1h<1l<2o83q62p62p62m61l71j81i81h70g80e90e:1d<2e?4f@5dB6^B4aG8cL:dM;cM8`K6]K3]M4]Q9bX?mhRss[nv{eFO:4=*39-28.28.28.17-17-17-06,17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,-2,,1++0*+0*+0*+0*,1+,3,.5.,6.*4+*4+*4++5,-7,.9+-8*0;+4?/5@/4?.3?+3>-3@,7F/9K3@O8BT:GWJ=I>I@G@D>=::7=9>:?9A:xA:tD:pF:pE5j>5n=6o83r73p62p62n72l71j81i81d8/d90c;1d>3d@4cA5cA5_C5ZE4_NnlUtv^|kcmU2>(6B.3;.39/39/39/28.28.28.17-17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,,1+,1++0**/)*/)+0*,1++2+-4-+5-*4,*4,+5,+5,,6+-7,,6+/:,2=/6A17B27B15@04?.2?-4C.:G3=L5AO8DT:JX?L\BTbI\kTcqZ^mXUbPDRA2>0#/%&/,&,,$**heVheVheVheVheVheVheVheVheVheVheVheVheVheVheVheVjdVjdVjcYkdZlc\md[lfZlfVolYmlWjlWgkZflbr{x׭oYWDQ@O>OAOBK@C<<5>7?6?8A7{B7uD6qE8qE8p?8q?8s>8q?8q?8q?8q?8p?8sB;qB:o@8m>6l=5j>5m>6o>7o83q73o83m82m82i81h91f:1f;2d>3d@4bB5`C5]A3\@2WB1TG4[S>f^Gi^HbX?ZS9ZS7\W:ZV;XW;kmUsw^u}fUaI&28D03;.4:04:039/39/39/28.28.17-17-17-06,06,/5+/5+/5+-2,-2,-2,-2,-2,-2,-2,-2,,1++0*+0**/)*/)+0*+0*,1++2+)3+*4,+5-+5,,6--7.-7,,6+.8-2<16A39D69D47B46A10;+2?-5B09F22=/x=/t?/sB3tD6r=5r=7t=8s>8u@:u@:t?9q?8sA:q@9q@9q@9p?8n?7o>7o>7k92m82l:3l;4l;4h<3g<3c=2c?3^>1dG9cG9T=-N9(M8'@1WQ;PN7KI0OK2]Y>ieJeaDVU7XX<]`CosZzfdlU=I1-9#2>*4-1=)2>*9E/BN8IU?O[GVbN]hWYdTLWI/u@8s>8u>9u@:t?9o=6p>7sA:q?8p?8p?8n?7o>7m>6n=6m>6k<4l=5m>6k?6j?6gA6eA5bB5dG9[A2^G7^I8N=+F7$G8%>6!LL4GK2DG,DD*MM1\[?baC`aBYY=dgJsw^sy_X`I:D,/;%7C/6>16<26<26<25;15;15;15;15;15;15;14:04:039/39/39/27127127116016016005/05/.3-.3--2,-2,,1+,1++0*+0**1**1*)0))0))0)*1*+2*,3+.5--4,.5-07/4;39A6?F>BJ?;F8:E57B14?.3?+6B.)r>)s@+tD0vE4q?4n<3q<4tB9sA8o?5qA7xH>n>4m>4m>4k?4l=3j>3l=3j>3g?5gA6gA6gC7eC7cC6`C5^D5bK;UB1ZI7`S@RG3C;&E=(FA+AE,BH.AE*<@%?B%NN2_`AijKaaEnqTvzagmSJO94<%4=(=F38>28>48>48>47=37=37=36<28>48>47=37=37=36<26<26<25:449349349338238238227105/05//4..3--2,,1++0*+0*).().().().().(*/)+0*,1+160/4.,1+,1+/4.6;4=BK:4.8/-4--4-,3,gdUgdUheVheVheVheVifWifWifWifWifWifWifWifWifWifWkeWkeWlcZmd[md]mf\mg[jiWkmXimVjoYjs`hthm|wڻּҽz{R>tJ4uH3vI4zM8}P;yL7nA.e7'{M@sD:qB8sD:oC8g;0d8-g=1i?3i?3i?3g?3f>2f>2f>2e?2b@4bB5`C5_C5_C5[D4ZE4WD3XI6OB/\T?oiSc^HMK4IG0IK3>D*?H-@F*48>47=37=37=39?58>48>48>48>48>48>48>47<67<67<66;56;56;55:45:438238216005//4.-2,,1+,1++0*+0**/)*/)+0*,1+-2,-2,05/.3-+0*+0*-2.2718=9;B:@K=@M;@M;=J68E13@,1?(0>'4.:0,6..5.-4-gdUgdUgdUheVheVifWifWifWifWifWifWifWifWifWifWifWkeWldWlcZmd[md]mf\mg[jiWkmXinWiqZgs_drejytܿչйѾϴuawVCjI6lI6rM;uP>mF7iB3gB2jE5nI9nJ:oK;oK;eA1cB1cB1cB1cB1cB1bC1`C3]F6\G6\G6ZG6ZG6WH5TG4RG3PH3NH2fdM~~frrZVX@JL4GM3A.:>-;>39?59?58>48>47=37=37=38>48>48>48>48>48>48>48>49>89>89>88=78=78=77<67<66;55:449338227105//4./4.-2.-2.,1-+0,+0,,1--2.-2.,1-,1-,1-,1-.210513764;4;G9=L9@O<@O:8F71?2-9-,6--4,,3+fcTfcTgdUheVheVifWjgXjgXifWifWifWifWifWifWifWifWldWldWlcZmd[md]mf\mg[jiWkmXinWiqZgs_bpcgxrڽѵ˴˺ҿһsrb|]K}^LtUCaD2W:(Y<*[>,X=*`E2`E2`E2_F2`G3`G3`G3]H3\K7\M:\M:YL9XM9UM8RL6QL6NL5QQ9ikS|gmqXSY?FL2>G,48>48>48>47=37=38>48>48>48>49?59?5:?9:?9:?9:?99>89>89>88=78=78=77<66;55:4493382382/40.3/-2.,1-+0,+0,+0,+0,+0,,1--10.21/32/32/32-4-3?17F3=L7@O:?N7M:MJ9BC3=@5;A7;A7;A7:@6:@6:@69?58>48>48>49?59?5:@6:@6:@6;@:;@:;@::?9:?99>89>89>8:?9:?99>89>88=78=77<67<6495273162/40-2.,1-+/.+/.,0/,0/-10.21.23.23-12+1-+9*/@-6H2;M7=O7A6>A6>A6=@7=@79?59?59?5:@6:@6:B7:B7:B7;@9;@9;@::?8:?99>79>89>7;@:;@9;@:;@9:?9:?8:?9:?98?87=94;4382160/4..3/.3/.21.21,2.,2.+2++2*,4))6%$6)=!2F+8L1;O6;M5;M5;M58J29K3;M5H&DK*FM+EL*PV4PT3KN/HK,TT8bbFccIZZ@[Y@\ZA][B][B[Y@XV=US:SQ8HF1GD1DA0A?0@>1>>2??5>@5;>59?59?59A69A48C58C58C5:B79A69@88@58?79A69@8:B7:A9:B79@8:B7;B:E=8B:8B:7A88@56>14O<>P::L6@R8EW=FY=DX=@T;5H2+<),6+,3++2*ZgM[hN\hP]iQbjSckTglXhkXghVghVifWifWkeWlfXmeZmgYmgYkhYkg[kg\jf]jf[hfZefVhiWglVfo\erajwnz˹ʿNjlRM0SN0QK+QK+UO/UO/TO1TO1SO2SO2QP4QP4QM2PO3PN5NQ6MO7JP6HM6EM5HQ6EN1BK.?I'BI(FM+JP,KQ-NR/PT1VZ7^bA_bCY\?TWWU>XV=YW>XV=XW;WV:XT9QK3OI3LG4ID1DA2B@3A?3>@5<=59?59?59A67B48C57D37D3:B79A69A68@58@59A69A6:B7:B7:B7:B7:B7;C874>63=40>-3C)9M*BY/Ga1Op;Ln;Li=Fa>BY?F;J@?I>>I9?G8>F7>D8=B;>E>9C;6@74B19I/BV3Pg=XrB^J[}JXuIMhECZ@9O:6G54E2XR6:@6:@69A67B47B46C26C2;C8:B79A69A69A69A6:B7;C8;C8:B7:B7;C8;C8=E:>F;=G<=G?>H=>I9?G8>F7>D8=B;=D=9C;6@74B19I/DX5Ri?[uEZ{FWyFTqEIdA=T:2H3/@.->+6H2@R8L_CReGSgKOcG@W=6I30:/07/-4,YgMZhN\hP^jRblTemVinZjo[mn\lm[mk\mj[nhZnhZoi]oi[liZkhYjfZieZie\ieZig[ghXghVchRajWerao|s{ѿɶıþʾŸ̌oRL2TO2TM0UN1TN.UO/VQ3VQ3UQ4SO2ON2NM1PL1NM1NL3KN3LN6KQ7KP9JR:LU:IR5JS6OY7SZ9T[9]c?fnGcszpr{\\bFLP7KM5LK6KI4LJ5PK5TN8VP:WQ;VP:SN;QL9LI:IG:GE9CE:=>6:@6:@69A67B47B46C26C2;C8;C8:B79A69A6:B7;C8;C8;C8;C8;C8;C8F;=G<=G?=G<=H8>F7=E6=C7=B;:A:7A95?64B19I/BV3Ne;Uo?Tu@RtAPmAE`=9P6-C.+<*+<)1C-$2 netpbm-free-10.0-1/buildtools/depend.pl0100755004714500471450000001101507732352703020304 0ustar aba-guestaba-guest#! /usr/bin/perl -w @pbm=@ppm=@pgm=@pnm=(); @ppm = ("libppm1", "libppm2", "libppmcmap", "libppm4", "libppm5", "libppmfloyd"); @pbm = ("libpm", "libpbm1", "libpbm2", "libpbm3", "libpbm4", "libpbm5", "bitio"); @pgm = ("libpgm1", "libpgm2"); @pnm = ("libpnm1", "libpnm2", "libpnm3", "libpnm4", "libpam", "libpammap"); %min = ('pbm' => 25, 'pgm' => 19, 'pnm' => 25, 'ppm' => 25); %extradep = ('pbm' => '', 'pgm' => 'lib/shared/libpbm.so', 'pnm' => 'lib/shared/libppm.so', 'ppm' => 'lib/shared/libpgm.so'); %extra = ('pbm' => '', 'pgm' => '-lpbm', 'pnm' => '-lppm -lpgm -lpbm', 'ppm' => '-lpbm -lpgm'); foreach $i ('ppm', 'pbm', 'pgm', 'pnm') { foreach $j (@$i) { # foreach $l ('shared', 'static') { # print "lib/shared/$j.o: lib/shared\n"; print "lib/shared/$j.o: $i/$j.c\n"; print "\t\$(CC) -c \$(INCLUDE) -I \$(SRCDIR)/include/ ". "-I \$(SRCDIR)/shhopt/ ". "\$(CFLAGS) -fPIC -D_REENTRANT \$(CDEBUG) -o \$@ \$<\n\n"; # print "lib/static/$j.o: lib/static\n"; print "lib/static/$j.o: $i/$j.c\n"; print "\t\$(CC) -c \$(INCLUDE) -I \$(SRCDIR)/include/ ". "-I \$(SRCDIR)/shhopt/ ". "\$(CFLAGS) -D_REENTRANT \$(CDEBUG) -o \$@ \$<\n\n"; # } print "lib/static/lib$i.a: lib/static/$j.o\n"; print "lib/static/libnetpbm.a: lib/static/$j.o\n"; print "lib/shared/lib$i.so.9.$min{$i}: lib/shared/$j.o\n"; print "lib/shared/libnetpbm.so.10.0: lib/shared/$j.o\n"; } } print "lib/static/libpbm.a: lib/static/shhopt.o\n"; print "lib/static/libnetpbm.a: lib/static/shhopt.o\n"; print "lib/shared/libpbm.so.9.$min{'pbm'}: lib/shared/shhopt.o\n"; print "lib/shared/libnetpbm.so.10.0: lib/shared/shhopt.o\n"; print "lib/shared/shhopt.o: shhopt/shhopt.c\n"; print "\t\$(CC) -c \$(INCLUDE) -I \$(SRCDIR)/include/ ". "-I \$(SRCDIR)/shhopt/ ". "\$(CFLAGS) -fPIC -D_REENTRANT \$(CDEBUG) -o \$@ \$<\n\n"; print "lib/static/shhopt.o: shhopt/shhopt.c\n"; print "\t\$(CC) -c \$(INCLUDE) -I \$(SRCDIR)/include/ ". "-I \$(SRCDIR)/shhopt/ ". "\$(CFLAGS) -D_REENTRANT \$(CDEBUG) -o \$@ \$<\n\n"; print "lib/static/libpbmvms.o: pbm/libpbmvms.c\n"; print "\t\$(CC) -c \$(INCLUDE) \$(CFLAGS) \$(CDEBUG) -o \$@ \$<\n\n"; print "lib/shared/libpbmvms.o: pbm/libpbmvms.c\n"; print "\t\$(CC) -c \$(INCLUDE) \$(CFLAGS) \$(CDEBUG) -o \$@ \$<\n\n"; foreach $i ('ppm', 'pbm', 'pgm', 'pnm') { print "LIBOBJECT_$i := ".join('.o ', @$i).".o\n"; } print "ifneq (\${VMS}x,x)\nLIBOBJECT_pbm += libpbmvms.o\n". "\nlib/static/libpbm.a: lib/static/libpbmvms.o\n". "\nlib/shared/libpbm.a: lib/shared/libpbmvms.o\n". "\nendif\n\n"; print "lib/static/lib%.a:\n". "\tar cq \$@ \$+\n\tranlib \$@\n\n"; print "lib/static/libnetpbm.a:\n". "\tar cq \$@ \$+\n\tranlib \$@\n\n"; foreach $i ('ppm', 'pbm', 'pgm', 'pnm') { print "lib/shared/lib$i.so.9.$min{$i}: $extradep{$i}\n\n"; print "lib/shared/lib$i.so.9.$min{$i}:\n". "\t\$(LD) \$(LDSHLIB) -Llib/shared -o \$@ \$+ $extra{$i} -lc \$(CDEBUG)\n\n"; print "lib/shared/lib$i.so.9.$min{$i}: SONAME := lib$i.so.9\n"; print "lib/shared/lib$i.so.9: lib/shared/lib$i.so.9.$min{$i}\n". "\tln -sf \$\$(basename \$+) \$@\n\n"; print "lib/shared/lib$i.so: lib/shared/lib$i.so.9\n". "\tln -sf \$\$(basename \$+) \$@\n\n"; print "install.lib.old-shared.lib:: lib/shared/lib$i.so.9.$min{$i}\n". "\t\$(INSTALL) -c -m \$(INSTALL_PERM_LIBS) \$<". " \$(INSTALLSTATICLIBS)/lib$i.so.9.$min{$i}\n"; print "install.lib.old-shared.lib::\n". "\t\$(SYMLINK) lib$i.so.9.$min{$i} \$(INSTALLSTATICLIBS)/lib$i.so.9\n"; print "install.lib.old-shared.devel::\n". "\t\$(SYMLINK) lib$i.so.9 \$(INSTALLSTATICLIBS)/lib$i.so\n"; print "install.lib.old-static:: lib/static/lib$i.a\n". "\t\$(INSTALL) -c -m \$(INSTALL_PERM_LIBS) \$<". " \$(INSTALLSTATICLIBS)/lib$i.a\n"; } print "lib/shared/libnetpbm.so.10.0: SONAME := libnetpbm.so.10\n"; print "lib/shared/libnetpbm.so.10.0:\n". "\t\$(LD) \$(LDSHLIB) -o \$@ \$+ -lc \$(CDEBUG)\n\n"; print "lib/shared/libnetpbm.so.10: lib/shared/libnetpbm.so.10.0\n". "\tln -sf \$\$(basename \$+) \$@\n\n"; print "lib/shared/libnetpbm.so: lib/shared/libnetpbm.so.10\n". "\tln -sf \$\$(basename \$+) \$@\n\n"; print "install.lib.shared.lib:: lib/shared/libnetpbm.so.10.0\n". "\t\$(INSTALL) -c -m \$(INSTALL_PERM_LIBS) \$<". " \$(INSTALLSTATICLIBS)/libnetpbm.so.10.0\n"; print "install.lib.shared.lib::\n". "\t\$(SYMLINK) libnetpbm.so.10.0 \$(INSTALLSTATICLIBS)/libnetpbm.so.10\n"; print "install.lib.shared.devel::\n". "\t\$(SYMLINK) libnetpbm.so.10 \$(INSTALLSTATICLIBS)/libnetpbm.so\n"; print "install.lib.static:: lib/static/libnetpbm.a\n". "\t\$(INSTALL) -c -m \$(INSTALL_PERM_LIBS) \$<". " \$(INSTALLSTATICLIBS)/libnetpbm.a"; netpbm-free-10.0-1/buildtools/install.sh0100644004714500471450000001256207716762513020525 0ustar aba-guestaba-guest#! /bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. # # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 netpbm-free-10.0-1/buildtools/installosf0100644004714500471450000000142307716762513020616 0ustar aba-guestaba-guest#!/bin/sh # This program takes parameters as a Netpbm make file might pass to # its $(INSTALL) program and invokes OSF1 Install with the proper # parameters to effect what the make file wants. If your system has # OSF1 Install on it, you can just set the INSTALL variable in # Makefile.config to "installosf" and 'make install' will work for # you. # Of course, you could also just install Ginstall and forget about this # program. PERMISSIONS=444 while [ $# -gt 0 ]; do if [ "$1" = "-c" ]; then x=x; elif [ "$1" = "-s" ]; then x=x; elif [ "$1" = "-m" ]; then shift PERMISSIONS=$1 elif [ ${SOURCE_FILE}x == x ]; then SOURCE_FILE=$1 else TARGET_DIR=$1 fi shift; done install -f $TARGET_DIR -m $PERMISSIONS $SOURCE_FILE netpbm-free-10.0-1/buildtools/libopt.c0100644004714500471450000003452207716762513020160 0ustar aba-guestaba-guest/*---------------------------------------------------------------------------- libopt ------------------------------------------------------------------------------ This is a program to convert link library filepaths to linker options that select them. E.g. ../pbm/libpbm.so becomes -L../pbm -lpbm . Each argument is a library filepath. The option string to identify all of those library filepaths goes to Standard Output. If an argument doesn't make sense as a library filespec, it is copied verbatim, blank delimited, to the output string. The "lib" part of the library name, which we call the prefix, may be other than "lib". The list of recognized values is compiled in as the macro SHLIBPREFIXLIST (see below). There is no newline or null character or anything after the output. ------------------------------------------------------------------------------ Why would you want to use this? On some systems, the -L/-l output of this program has exactly the same effect as the filepath input when used in the arguments to a link command. A GNU/Linux system, for example. On others (Solaris, for example), if you include /tmp/lib/libpbm.so in the link as a link object, the executable gets built in such a way that the system accesses the shared library /tmp/lib/libpbm.so at run time. On the other hand, if you instead put the options -L/tmp/lib -lpbm on the link command, the executable gets built so that the system accesses libpbm.so in its actual installed directory at runtime (that location might be determined by a --rpath linker option or a LD_LIBRARY_PATH environment variable at run time). In a make file, it is nice to use the same variable as the dependency of rule that builds an executable and as the thing that the rule's command uses to identify its input. Here is an example of using libopt for that: PBMLIB=../pbm/libpbm.so ... pbmmake: pbmmake.o $(PBMLIB) ld -o pbmmake pbmmake.o `libopt $(PBMLIB)` --rpath=/lib/netpbm Caveat: "-L../pbm -lpbm" is NOT exactly the same as "../pbm/libpbm.so" on any system. All of the -l libraries are searched for in all of the -L directories. So you just might get a different library with the -L/-l version than if you specify the library file explicitly. -----------------------------------------------------------------------------*/ #define _BSD_SOURCE 1 /* Make sure strdup() is in stdio.h */ #define MAX_PREFIXES 10 /* Here's how to use SHLIBPREFIXLIST: Use a -D compile option to pass in a value appropriate for the platform on which you are linking libraries. It's a blank-delimited list of prefixes that library names might have. "lib" is traditionally the only prefix, as in libc or libpbm. However, on Windows there is a convention of using different prefixes to distinguish different co-existent versions of the same library (kind of like a major number in some unices). E.g. the value "cyg lib" is appropriate for a Cygwin system. */ #ifndef SHLIBPREFIXLIST # define SHLIBPREFIXLIST "lib" #endif #include #include #include typedef unsigned char bool; #define true (1) #define false (0) static void parse_prefixlist(const char * const prefixlist, char * parsed_prefixes[MAX_PREFIXES+1], bool * const errorP) { /*---------------------------------------------------------------------------- Given a space-separated list of tokens (suffixes), return an argv-style array of pointers, each to a newly malloc'ed storage area the prefix as a null-terminated string. Return a null string for the unused entries at the end of the array We never return more than MAX_PREFIXES prefixes from the input, so there is guaranteed always to be one null string at the end of the array. In case of error, return *errorP == true and don't allocate any storage. Otherwise, return *errorP = false. -----------------------------------------------------------------------------*/ char * prlist; prlist = strdup(prefixlist); if (prlist == NULL) *errorP = true; else { if (strlen(prlist) <= 0) *errorP = true; else { /* NOTE: Mac OS X, at least, does not have strtok_r(). 2001.09.24 */ char * token; int num_tokens; int i; for (i=0; i < MAX_PREFIXES + 1; i++) { parsed_prefixes[i] = NULL; } num_tokens = 0; token = strtok(prlist, " "); *errorP = false; /* initial value */ while (token != NULL && num_tokens < MAX_PREFIXES && !*errorP) { parsed_prefixes[num_tokens] = strdup (token); if (parsed_prefixes[num_tokens] == NULL) *errorP = true; num_tokens++; token = strtok(NULL, " "); } for (i = num_tokens; i < MAX_PREFIXES + 1 && !*errorP; i++) { parsed_prefixes[i] = strdup(""); if (parsed_prefixes[i] == NULL) *errorP = true; } } if (*errorP) { /* Deallocate any array entries we successfully did */ int i; for (i = 0; i < MAX_PREFIXES + 1; i++) if (parsed_prefixes[i]) free(parsed_prefixes[i]); } free(prlist); } } static void parse_prefix(const char * const filename, bool * const prefix_good_p, unsigned int * const prefix_length_p, bool * const error_p) { /*---------------------------------------------------------------------------- Find the library name prefix (e.g. "lib") in the library filename 'filename'. Return the length of the prefix, in characters, as *prefix_length_p. (The prefix always starts at the beginning of the filename). Iff we don't find a valid library name prefix, return *prefix_good_p == false. The list of valid prefixes is compiled in as the blank-delimited string which is the value of the SHLIBPREFIXLIST macro. -----------------------------------------------------------------------------*/ char * shlibprefixlist[MAX_PREFIXES+1]; /* An argv-style array of prefix strings in the first entries, null strings in the later entries. At most MAX_PREFIXES prefixes, so at least one null string. */ char * prefix; /* The prefix that the filename actually uses. e.g. if shlibprefixlist = { "lib", "cyg", "", ... } and the filename is "path/to/cyg.", then prefix = "cyg". String is in the same storage as pointed to by shlibprefixlist (shlibprefixlist[1] in this example). */ bool prefix_good; /* The first part of the filename matched one of the prefixes in shlibprefixlist[]. */ int prefix_length; int i; parse_prefixlist(SHLIBPREFIXLIST , shlibprefixlist, error_p); if (!*error_p) { if (strcmp(shlibprefixlist[0], "") == 0) { fprintf(stderr, "libopt was compiled with an invalid value " "of the SHLIBPREFIX macro. It seems to have no " "tokens. SHLIBPREFIX = '%s'", SHLIBPREFIXLIST); exit(100); } i = 0; /* start with the first entry in shlibprefixlist[] */ prefix_length = 0; /* initial value */ prefix = shlibprefixlist[i]; prefix_good = false; /* initial value */ while ( (*prefix != '\0' ) && !prefix_good ) { /* stop condition: shlibprefixlist has MAX_PREFIXES+1 entries. * we only ever put tokens in the 0..MAX_PREFIXES-1 positions. * Then, we fill DOWN from the MAX_PREFIXES position with '\0' * so we insure that the shlibprefixlist array contains at * least one final '\0' string, but probably many '\0' * strings (depending on how many tokens there were). */ prefix_length = strlen(prefix); if (strncmp(filename, prefix, prefix_length) == 0) { prefix_good = true; /* at this point, prefix is pointing to the correct * entry, and prefix_length has the correct value. * When we bail out of the while loop because of the * !prefix_good clause, we can then use these * vars (prefix, prefix_length) */ } else { prefix = shlibprefixlist[++i]; } } *prefix_length_p = prefix_length; *prefix_good_p = prefix_good; { int i; for (i=0; i < MAX_PREFIXES + 1; i++) free (shlibprefixlist[i]); } } } static void parse_filename(const char * const filename, char ** const libname_p, bool * const valid_library_p, bool * const error_p) { /*---------------------------------------------------------------------------- Extract the library name root component of the filename 'filename'. This is just a filename, not a whole pathname. Return it in newly malloc'ed storage pointed to by '*libname_p'. E.g. for "libxyz.so", return "xyz". return *valid_library == true iff 'filename' validly names a library that can be expressed in a -l linker option. return *error_p == true iff some error such as out of memory prevents parsing. Do not allocate any memory if *error_p == true or *valid_library == false. -----------------------------------------------------------------------------*/ char *lastdot; /* Pointer to last period in 'filename'. Null if none */ /* We accept any period-delimited suffix as a library type suffix. It's probably .so or .a, but is could be .kalamazoo for all we care. (HOWEVER, the double-suffixed import lib used on cygwin (.dll.a) is NOT understood). */ lastdot = strrchr(filename, '.'); if (lastdot == NULL) { /* This filename doesn't have any suffix, so we don't understand it as a library filename. */ *valid_library_p = false; *error_p = false; } else { unsigned int prefix_length; bool prefix_good; parse_prefix(filename, &prefix_good, &prefix_length, error_p); if (!*error_p) { if (!prefix_good) { *valid_library_p = false; } else { /* Extract everything between and "." as the library name root. */ *libname_p = strdup(filename + prefix_length); if (*libname_p == NULL) *error_p = true; else { (*libname_p)[lastdot - filename - prefix_length] = '\0'; if (strlen(*libname_p) == 0) { *valid_library_p = false; free(*libname_p); } else *valid_library_p = true; } } } } } static void parse_filepath(const char * const filepath, char ** const directory_p, char ** const filename_p, bool * const error_p) { /*---------------------------------------------------------------------------- Extract the directory and filename components of the filepath 'filepath' and return them in newly malloc'ed storage pointed to by '*directory_p' and '*filename_p'. -----------------------------------------------------------------------------*/ char *lastslash; /* Pointer to last slash in 'filepath', or null if none */ lastslash = strrchr(filepath, '/'); if (lastslash == NULL) { /* There's no directory component; the filename starts at the beginning of the filepath */ *filename_p = strdup(filepath); if (*filename_p == NULL) *error_p = true; else { *directory_p = strdup(""); if (*directory_p == NULL) { *error_p = true; free(*filename_p); } else *error_p = false; } } else { /* Split the string at the slash we just found, into filename and directory */ *filename_p = strdup(lastslash+1); if (*filename_p == NULL) *error_p = true; else { *directory_p = strdup(filepath); if (*directory_p == NULL) { *error_p = true; free(*filename_p); } else { *error_p = false; (*directory_p)[lastslash - filepath] = '\0'; } } } } int main(int argc, char **argv) { bool error; int retval; unsigned int arg; /* Index into argv[] of argument we're processing */ error = false; /* no error yet */ for (arg = 1; arg < argc && !error; arg++) { const char *filepath; /* The argument we're processing */ bool valid_library; /* Our argument is a valid library filepath that can be converted to -l/-L notation. */ char *directory = NULL; /* Directory component of 'filepath' */ char *filename = NULL; /* Filename component of 'filepath' */ char *libname = NULL; /* Library name component of 'filename'. e.g. xyz in libxyz.so */ filepath = argv[arg]; parse_filepath(filepath, &directory, &filename, &error); if (!error) { parse_filename(filename, &libname, &valid_library, &error); if (!error) { if (valid_library) { if (strlen(directory) == 0) fprintf(stdout, "-L. -l%s ", libname); else fprintf(stdout, "-L%s -l%s ", directory, libname); free(libname); } else fprintf(stdout, "%s ", filepath); } free(directory); free(filename); } } if (error) { fprintf(stderr, "serious libopt error prevented parsing library " "names. Invalid input to libopt is NOT the problem.\n"); retval = 10; } else retval = 0; return retval; } netpbm-free-10.0-1/buildtools/make_merge.sh0100644004714500471450000000066507716762513021154 0ustar aba-guestaba-guest#!/bin/sh # This program is called by the make files. It creates the merge.h # file which is included by pbmmerge.c, etc. echo "/* File generated by make_merge.sh */" >merge.h echo "" >>merge.h echo "#define TRY(s,m) \\" >>merge.h echo " { if ( strcmp( cp, s ) == 0 ) exit( m( argc, argv ) ); }" >>merge.h echo "" >>merge.h for MERGE_BINARY in $*; do echo "TRY( \"${MERGE_BINARY}\", main_${MERGE_BINARY} );" >>merge.h done netpbm-free-10.0-1/buildtools/mantocat0100644004714500471450000000062607716762513020252 0ustar aba-guestaba-guest#!/bin/sh # # Convert a man page in nroff format to formatted (cat-able) format. # This can be used a "mancp" program. I.e. set the make file variable # MANCP to the name of this program. # # Note that the arguments of a "mancp" program are as if the program is 'cp'. # # Oliver Trepte, 93-07-05 TMPDIR=${TMPDIR:-/tmp} TMP=${TMPDIR}/mancp$$ nroff -man $1 > $TMP cp $TMP $2 rm -f $TMP echo "Done with $2" netpbm-free-10.0-1/buildtools/mantocatgz0100644004714500471450000000073107716762513020610 0ustar aba-guestaba-guest#!/bin/sh # # Convert a man page in nroff format to formatted (cat-able) and gzipped # format. # This can be used a "mancp" program. I.e. set the make file variable # MANCP to the name of this program. # # Note that the arguments of a "mancp" program are as if the program is 'cp'. # # Oliver Trepte, 93-07-05 TMPDIR=${TMPDIR:-/tmp} TMP=${TMPDIR}/mancp$$ nroff -man $1 > $TMP gzip $TMP --no-name --to-stdout >$TMP.gz cp $TMP.gz $2 rm -f $TMP $TMP.gz echo "Done with $2" netpbm-free-10.0-1/buildtools/mkinstalldirs0100644004714500471450000000150607716762513021322 0ustar aba-guestaba-guest#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # This program is important because some systems don't have an 'install' # program that has the -d option to create directories. errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr else chmod 755 "$pathcomp" fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here netpbm-free-10.0-1/buildtools/stamp-date0100644004714500471450000000175007716762513020502 0ustar aba-guestaba-guest#!/bin/sh # # Copyright (C) 1993 by Oliver Trepte. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, provided # that the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. This software is provided "as is" without express or # implied warranty. # # This shell script creates a file called "compile_time.h" which holds # a define stating the compilation time. This is used for the -version # flag. # OUTFILE=compile.h DATE=`date` LOGNAME=${LOGNAME:-UNKNOWN} USER=${USER:-$LOGNAME} if [ $USER = "UNKNOWN" ]; then USER=`whoami` fi echo "/* compile_time.h This file tells the package when it was compiled */" > $OUTFILE echo "/* DO NOT EDIT - THIS FILE IS MAINTAINED AUTOMATICALLY */" >> $OUTFILE echo "#define COMPILE_TIME \"$DATE\"" >> $OUTFILE echo "#define COMPILED_BY \"$USER\"" >> $OUTFILE netpbm-free-10.0-1/buildtools/try_ldconfig0100644004714500471450000000165307716762513021130 0ustar aba-guestaba-guest#/bin/sh # Run Ldconfig if possible. # # If there's no such command, just assume this system doesn't need it. # # If it fails for any other reason (typically lack of permission), tell user to do it manually later. # # This is intended to be used in a make file that runs on lots of different kinds of systems. ldconfig 2>/dev/null rc=$? if [ $rc -ne 127 ]; then if [ $rc -ne 0 ]; then echo "===================================================================" echo "To complete installation of your shared liraries, you need to run " echo "'ldconfig'. When I tried, it failed. Maybe you don't have the " echo "necessary permissions. Be sure you run 'ldconfig' successfully " echo "before you try to run any Netpbm programs." echo "===================================================================" echo echo "Enter anything to continue the install." read; fi fi netpbm-free-10.0-1/debian/0040755004714500471450000000000007776237751015571 5ustar aba-guestaba-guestnetpbm-free-10.0-1/debian/README.Debian0100644004714500471450000000420007752022373017605 0ustar aba-guestaba-guestThis package has a rather strange relation to upstream: * Upstreams and debian goals differ in some aspects too much to build the package on upstream versions as in a normal package. * Because of this the version numbers of the debian package are just clues of the aequivalent upstream version. Sometimes in a source file the last incorporated upstream version may be given. * Also the package is treated as a native debian package. Speaking about source, we consider http://netpbm.alioth.debian.org/ the technical upstream, and this release can be exported out of alioth by cvs -z3 -d:pserver:anonymous@cvs.alioth.debian.org:/cvsroot/netpbm export \ -r debian-9-25-8 netpbm On alioth the source of Debian's netpbm-free 9.20-10 was imported and then updated. netpbm-free 9.20-10 is successor of the first debian packages by Steve, source-equivalent to the version in woody r2, and the last with another technical upstream. This upstream was http://netpbm.sourceforge.net/ and the source file could have been downloaded from http://download.sourceforge.net/netpbm/netpbm-9.20.tgz Packaging was not a simple job, as the licensing is complicated upstream. The upstream source is split into two to allow Debian packaging - some of it is free and some goes into non-free. Some of the upstream source files cannot be redistributed at all, as there is no license associated with them. These cases are tried to be handled on a case-by-case basis. In creating the Debian "upstream" source packages, Steve has removed the references to the non-free and non-distributable files. This package was debianised by Steve McIntyre , finishing on Sun 7th October 2001. The maintainership was transfered in August 2003 to Andreas Barth , first as cooperative maintainership and sponsored by Steve. The last package used for updating the cvs-version can be downloaded from http://download.sourceforge.net/netpbm/netpbm-9.25.tgz Relating security: In README.Security the incorporated advisories are given; however, this list is only complete for advisories starting in August 2003. Andreas Barth netpbm-free-10.0-1/debian/README.Security0100644004714500471450000000100207752267346020242 0ustar aba-guestaba-guestnetpbm is one of the oldest pieces of software still in use. Therefore it has also a history of security announcements. In this file we annote the advisories that are integrated in this version of netpbm. This list is only exhaustive since August 2003 where we started tracking in this file. The older security advisories are (hopefully ;) also applied. Andreas Barth - debian Maintainer of netpbm - CVE dictionary: CAN-2003-0146 CAN-2003-0924 (with 2:9.25-8) CERT: VU#630433 VU#378049 netpbm-free-10.0-1/debian/changelog0100644004714500471450000003756707776237374017463 0ustar aba-guestaba-guestnetpbm-free (2:10.0-1) unstable; urgency=low * ppmtompeg cares about buffering now. Closes: #218295 * catch up with netpbm.sf.net 10.0 - pnmtops: No setpagedevice by default - added pbmtextps - minor changes in HISTORY * Included st4topgm. Closes: #223506 * renamed optParseOptions* to pm_* * started reworking of documentation, and added README.1st -- Andreas Barth Sun, 4 Jan 2004 19:55:15 +0100 netpbm-free (2:9.25-9) unstable; urgency=high * There are more bugs. Some are critical and fixed into this release; the others are more aesthetical, and mentioned in TODO. -- Andreas Barth Mon, 10 Nov 2003 22:10:37 +0100 netpbm-free (2:9.25-8) unstable; urgency=high * Next round in fixing security bugs; also repaired pamstretch-gen. -- Andreas Barth Tue, 4 Nov 2003 22:53:21 +0100 netpbm-free (2:9.25-7) unstable; urgency=high * Fixed security bug (insecure tmpfile-handling) in anytopnm, pnminterp-gen and others. Closes: #219019 -- Andreas Barth Tue, 4 Nov 2003 08:35:01 +0100 netpbm-free (2:9.25-6) unstable; urgency=low * Fixed bug in pnmnorm. Closes: #213366 * added a space in debian/control. * polished the docu a bit. -- Andreas Barth Sat, 4 Oct 2003 10:56:50 +0200 netpbm-free (2:9.25-5) unstable; urgency=low * Should really work on hppa this time. Closes: #211271 -- Andreas Barth Thu, 18 Sep 2003 17:44:15 +0200 netpbm-free (2:9.25-4) unstable; urgency=low * changed wrong builded libary file, FTBFS. Closes: #211271 * corrected spelling error -- Andreas Barth Wed, 17 Sep 2003 12:26:14 +0200 netpbm-free (2:9.25-3) unstable; urgency=low * autosizing of rawtopgm works. Closes: #199053 * ppmcie use lower case x and y for chromaticities. Closes: #176313 * libraries are compiled correct now: with -D_REENTRANT and if (and only if) shared, also with -fPIC. * created unified libs in libnetpbm10-*, and set libnetpbm9-* to deprecated (but still produce them). * using debhelper V4 commands and reworked debian/rules and Makefiles. -- Andreas Barth Tue, 02 Sep 2003 10:44:50 +0200 netpbm-free (2:9.25-2) unstable; urgency=low * "brown paperbag release": Building works, and libpng12 is used. Closes: #207451 * twisted the uploader field a bit to get correct closing of bug reports * updated to standard 3.6.1.0; moved libnetpbm9-dev to libdevel * made package linda/lintian clean (except where I'm sure that I'm right) * updated copyright and README.Debian * added pnmnorm (must be slipped through). Closes: #207483 -- Andreas Barth Wed, 27 Aug 2003 16:29:18 +0200 netpbm-free (2:9.25-1) unstable; urgency=low * moved to alioth, new maintainer, and found a way to handle upstream (this means that from now on we're treating netpbm-free as a native package) * pnmnorm replaces pgmnorm, pamoil replaces pgmoil * Uses POSIX-compatible commands. Closes: #204890 * Documentation bug. Closes: #199047, #206162 * Defaults to a fillorder at tifftopnm. Closes: #150815 * Build-dep libpng10. Closes: #196852 (for woody: change this yourself back) * Speed up pnmscale with <=256 colors. Closes: #187395 * Rewrote upstream Makefiles in a a bit more sensible way. * removed jbig support due to patent issues. -- Andreas Barth Thu, 21 Aug 2003 17:25:56 +0200 netpbm-free (2:9.20-10) unstable; urgency=medium * Rebuilt -9 on a clean sid system to ensure libpng consistency. Closes: #185384, #185480. -- Steve McIntyre <93sam@debian.org> Wed, 19 Mar 2003 20:50:42 +0000 netpbm-free (2:9.20-9) unstable; urgency=high * sid release using the woody fixes in -8.1 and -8.2. -- Steve McIntyre <93sam@debian.org> Sat, 15 Mar 2003 02:11:07 +0000 netpbm-free (2:9.20-8.2) stable-security; urgency=high * Non-maintainer upload by the Security Team * Applied another patch by Alan Cox -- Martin Schulze Fri, 28 Feb 2003 16:07:29 +0100 netpbm-free (2:9.20-8.1) stable-security; urgency=high * Non-maintainer upload by the Security Team * Applied patch from Alan Cox plus corrections to fix multiple vulnerabilities (VU#378049, VU#630433) -- Martin Schulze Fri, 28 Feb 2003 12:21:40 +0100 netpbm-free (2:9.20-8) unstable; urgency=low * Dropped Depends: on gs to Recommends after user requests. Closes: #138864. * Make sure that we clean up the netpbm-shhopt.h symlink properly. Closes: #140653 -- Steve McIntyre <93sam@debian.org> Mon, 01 Apr 2002 18:57:38 +0100 netpbm-free (2:9.20-7) unstable; urgency=high * Fixed Conflicts: on netpbm against netpbm-dev more explicitly. Closes: #138968 -- Steve McIntyre <93sam@debian.org> Sun, 17 Mar 2002 08:27:22 +0000 netpbm-free (2:9.20-6) unstable; urgency=high * Added Provides: netpbm-dev to help upgrades. * Specify Depends: on libnetpbm9 more explicitly. Closes: #137077 (grave bug) -- Steve McIntyre <93sam@debian.org> Tue, 12 Mar 2002 22:26:20 +0000 netpbm-free (2:9.20-5) unstable; urgency=low * Added dependency on gs | gs-aladdin. Closes: #135464. * Updated Standards-Version. -- Steve McIntyre <93sam@debian.org> Sun, 03 Mar 2002 18:47:15 +0000 netpbm-free (2:9.20-4) unstable; urgency=low * Add missing symbols to libnetpbm.a. Closes: #122169 -- Steve McIntyre <93sam@debian.org> Wed, 19 Dec 2001 16:49:15 +0000 netpbm-free (2:9.20-3) unstable; urgency=low * Patch from upstream to fix seg-fault. Closes: #114022 -- Steve McIntyre <93sam@debian.org> Mon, 05 Nov 2001 23:45:15 +0000 netpbm-free (2:9.20-2) unstable; urgency=low * Re-added ppmquantall script. Closes: #117001. * Modified postinst to be safer with ldconfig, as per lintian. -- Steve McIntyre <93sam@debian.org> Sun, 04 Nov 2001 17:24:15 +0000 netpbm-free (2:9.20-1) unstable; urgency=low * New upstream release. * Upstream change: photometric interpretation fixed. Closes: #110314 * Upstream change: "bool" type removed from interface headers. Closes: #113929 -- Steve McIntyre <93sam@debian.org> Sun, 07 Oct 2001 22:29:27 +0100 netpbm-free (2:9.16-3) unstable; urgency=low * Added Build-Depends: flex. Closes: #108349 -- Steve McIntyre <93sam@debian.org> Sat, 11 Aug 2001 09:29:51 +0100 netpbm-free (2:9.16-2) unstable; urgency=low * pm.h now includes "netpbm-shhopt.h" rather than "shhopt.h". Closes: #108183 -- Steve McIntyre <93sam@debian.org> Fri, 10 Aug 2001 00:30:51 +0100 netpbm-free (2:9.16-1) unstable; urgency=low * New upstream release. * New upstream *finally* contains new ppmtoilbm. Closes: #31971 * pnm(5) man page has been included for a long time. Closes: #91770 * Upstream changes should reduce memory usage drastically in pnmtopng. Closes: #92146 * Added new utilities for Atari Neochrome files - patch from Teemu Hukkanen. Closes: #95089 * New build fixes png symbols problem. CLoses: #101857 * Fixed LD_LIBRARY_PATH for fakeroot so the package builds OK. Closes: #101858 * Include pam.h in the -dev package. Closes: #102245 * Added "Replaces: netpbm-nonfree (<= 19940301.1-5)" to fix conflict. Closes: #102392 -- Steve McIntyre <93sam@debian.org> Mon, 06 Aug 2001 08:13:51 +0100 netpbm-free (2:9.10-4) unstable; urgency=low * Updated sh versions of pnmindex and ppmquantall to include new functionality in upstream csh versions. Sent upstream - next upstream release should hopefully not depend on csh any more. * Fixed unsafe temp file use in anytopnm. Closes: #92152. Thanks to Matt Zimmerman for the patch. I'm currently auditing for any other potential holes. * Fixed formatting of ppmtompeg man page. Closes: #90288. Thanks to Colin Watson for the patch. -- Steve McIntyre <93sam@debian.org> Mon, 16 Apr 2001 16:46:00 +0100 netpbm-free (2:9.10-3) unstable; urgency=low * Conflicts/Replaces/Provides added for pbmwbmp - now folded into netpbm. Closes: #88869. * Moved Build-Depends-Indep to Build-Depends. Closes: #88250. * Package includes forked new version of shhopt.h, now installed as netpbm-shhopt.h. Closes: #87944, #87984. * Removed call to dh_suidregister from rules file. * Set pnmscale to default to non-verbose operation. Closes: #88467. * Replaced csh scripts with sh scripts from older netpbm package and removed csh dependency. Closes: #87933. * Still not closing ucbmpeg conflicts bugs yet - no response from ucbmpeg maintainer. -- Steve McIntyre <93sam@debian.org> Fri, 09 Mar 2001 20:27:42 +0000 netpbm-free (2:9.10-2) unstable; urgency=low * New maintainer address. * Make sure ppmtomap is linked with libm. Closes: #87969, #87952. * Added Conflicts: ucbmpeg over /usr/bin/eyuvtoppm. Not closing yet - dialogue with ucbmpeg maintainer. -- Steve McIntyre <93sam@debian.org> Thu, 01 Mar 2001 01:29:00 +0000 netpbm-free (2:9.10-1) unstable; urgency=medium * New upstream release; completely repackaged from scratch. Closes: #61908 * Updated Standards-Version. * New anytopnm now handles JPEG files. Closes: #79480 * New pbmtext has buffer overflow fix. Closes: #77681 * New upstream version of pstopnm, written in C. Closes: #64250, #84679 * Format description manpages from section 5 moved from -dev package to netpbm. Closes: #63659 * Undid the previous merge of the 4 libraries into 1 large one. * Library/dev package renamed. Closes: #66187 * Conflicts/Replaces/Provides added for pnmtopng - now folded into netpbm. -- Steve McIntyre Sun, 25 Feb 2001 02:37:21 +0000 netpbm-free (1:19940301.2-13) frozen unstable; urgency=low * Move changelog to /usr/share/doc for FHS. Fixes Bug #51025, #47877. * Applied patch to fix xwdtopnm 16-bit bug. Thanks to Tomasz Motylewski . Fixes Bug #47109. * Fixed thinko in man page for pbmtog3. Fixes Bug #52950. * Changed csh scripts to use sh. Thanks to adrian.bridgett@iname.com for the patch. Fixes Bugs #57285, #20121. * pbmtog3 now seems to work fine. Closing Bug #21020. * Updated Standards-Version. -- Steve McIntyre Sun, 13 Feb 2000 15:58:50 +0000 netpbm-free (1:19940301.2-12) unstable; urgency=low * Removed use of /tmp in pnmindex and anytopnm. Fixes Bug #43684. -- Steve McIntyre Wed, 22 Sep 1999 00:04:50 +0100 netpbm-free (1:19940301.2-11) unstable; urgency=low * Added a Conflicts: line against old versions of netpbm-nonfree. Fixes Bugs #40948, #41376, #37565. -- Steve McIntyre Wed, 21 Jul 1999 23:39:40 +0100 netpbm-free (1:19940301.2-10) unstable; urgency=low * Fixed warning in ppmtogif from comments in rgb.txt. Fixes Bug#33627. * Moved ppmtomap here from netpbm-nonfree, as it _is_ free. * Added papersize handling to pnmtops, using libpaper. Thanks to Brian May for the patch. Fixes Bug#34254. * Compiled using RAWBITS option; fixes Bug#35815 -- Steve McIntyre Tue, 27 Apr 1999 22:31:16 +0100 netpbm-free (1:19940301.2-9) unstable; urgency=low * Fixed logic hole in pnmtops - flip the Y co-ords if -nocenter is used, closes: bug #30697. * ppmquantall now copes with comments (e.g. created by gimp), -ext option added, closes: bug #30905. -- Steve McIntyre Sun, 14 Feb 1999 20:23:37 +0000 netpbm-free (1:19940301.2-8) frozen unstable; urgency=low * Added more debug for file I/O errors; hopefully should help to diagnose/fix Bug#28706 * Changed sections to remove "main/" - lintian complaints... -- Steve McIntyre Tue, 03 Nov 1998 00:35:48 +0000 netpbm-free (1:19940301.2-7) frozen unstable; urgency=low * Include non-maintainer diff from -6.1. Fixes Bug#28396. -- Steve McIntyre Sat, 24 Oct 1998 12:45:59 +0100 netpbm-free (1:19940301.2-6.1) unstable; urgency=low * non-maintainer (binary-only) upload for Alpha * "linux" is not defined by egcs on Alpha, so pbmplus.h did the wrong thing. Added a test for __linux. -- Paul Slootman Thu, 22 Oct 1998 18:08:23 +0200 netpbm-free (1:19940301.2-6) frozen unstable; urgency=low * libtiff3g now fixed (links -lm properly), so removing it from the pnm Imakefile here. Fixes Bug#22181. -- Steve McIntyre Sun, 18 Oct 1998 13:40:12 +0100 netpbm-free (1:19940301.2-5) unstable; urgency=low * Fixed Depends: line as per policy: must specify a real package with a virtual package. Fixes Bug#27917 * Renamed netpbm upstream changelog to changelog.gz as required by policy. * Call ldconfig for netpbm1 in postinst. -- Steve McIntyre Wed, 14 Oct 1998 21:00:12 +0100 netpbm-free (1:19940301.2-4) frozen unstable; urgency=high * Make sure Alpha NMU stuff makes it in for hamm - apparently the -lm flag needed for m68k too and the m68k package just won't work without it. -- Steve McIntyre Mon, 28 Jun 1998 23:16:22 +0100 netpbm-free (1:19940301.2-3) unstable; urgency=low * New maintainer. -- Steve McIntyre Wed, 10 Jun 1998 23:21:26 +0100 netpbm-free (1:19940301.2-2.1) frozen unstable; urgency=low * non-maintainer upload for Alpha. * declaration of write() in pbmplus.h conflicted with declaration. * -lm needed when linking fitstopnm (libtiff3g doesn't link libm implicitly). -- Paul Slootman Wed, 6 May 1998 21:28:26 +0200 netpbm-free (1:19940301.2-2) unstable; urgency=low * Removed dh_du call. * Use tempfile (fixes #19803). -- Herbert Xu Tue, 17 Mar 1998 21:34:03 +1100 netpbm-free (1:19940301.2-1) unstable; urgency=low * Modified pbmplus.h for linux (fixes #13372). Actually, this has been fixed for a while. * Added Yoshiyuki Okada's patch (fixes #16903). -- Herbert Xu Fri, 27 Feb 1998 15:46:00 +1100 netpbm-free (1:19940301.1-1) unstable; urgency=low * Split packages into free and nonfree. * Adjusted priority to optional. * Updated to Standard 2.4.0.0. * Renamed netpbm1-dev to netpbm-dev. -- Herbert Xu Thu, 19 Feb 1998 10:46:38 +1100 netpbm (1:19940301-1) unstable; urgency=low * New maintainer. * Rebuilt from scratch. * New packaging format (fixes #3975). * Shared libraries. * Converted to debhelper (fixes #11925, #14515, #14928). * Added missing files (fixes #10478, #10951). * Corrected typo in anytopnm (fixes #11933). * Nonexistant bugs (fixes #4300, #9677, #11930, #16047). * Upgraded Suggests:cshell to Depends. * Depend on bc (#13905). -- Herbert Xu Wed, 11 Feb 1998 22:42:50 +1100 netpbm (1994.03.01p1-6.2) unstable; urgency=low * Non-maintainer release * Switch to libc6 / glibc2 -- Wichert Akkerman Sat, 27 Dec 1997 12:41:29 +0100 netpbm (1994.03.01p1-6.1) unstable; urgency=low * Non-maintainer release * Fixes for packaging "out of the box" in debian/rules (running dpkg-buildpackage should work OK now) * Successful packaging of netpbm-dev requires a fix to debstd (the strip line for static libraries must have --strip-debug or no symbols will be exported) * Added ppmcmap.h and ppmdraw.h, because some apps need these headers for functions in libppm.a -- Chris Lawrence Fri, 21 Mar 1997 13:01:15 -0600 netpbm (1994.03.01p1-6) unstable; urgency=low * Added Suggests: csh|tcsh; clears Bug #6411 * All man pages are compressed; clears Bug #6701 * Included g3topbm and pbmtog3 binaries; clears Bug #6818 * Added pbmplus.h to the netpbm-dev package; clears Bug #7350 * New maintainer * New source package format. -- Susan G. Kleinmann Sat, 15 Feb 1997 21:10:35 -0500 Local variables: mode: debian-changelog End: netpbm-free-10.0-1/debian/compat0100644004714500471450000000000207723461056016751 0ustar aba-guestaba-guest4 netpbm-free-10.0-1/debian/control0100644004714500471450000000435707764460402017166 0ustar aba-guestaba-guestSource: netpbm-free Section: graphics Priority: optional Maintainer: A. Barth (sponsored by Steve McIntyre) <93sam-sponsoring-aba@klecker.debian.org> Uploaders: Steve McIntyre <93sam@debian.org>, Andreas Barth Standards-Version: 3.6.1.0 Build-Depends: libtiff3g-dev, libjpeg62-dev, debhelper (>= 4), libpng12-dev, zlib1g-dev, flex, sed Package: netpbm Architecture: any Depends: bc, libnetpbm10 (>= ${Source-Version}), ${shlibs:Depends} Recommends: gs | gs-aladdin Conflicts: netpbm-nonfree (<= 1:19940301.1-3), pnmtopng, pbmwbmp, netpbm-dev (<= 2:9.10), ucbmpeg (<= 1r2-6) Replaces: pnmtopng, pbmwbmp, netpbm-dev, netpbm-nonfree (<= 19940301.1-5) Provides: pnmtopng, pbmwbmp Description: Graphics conversion tools Netpbm is a toolkit for manipulation of graphic images, including conversion of images between a variety of different formats. There are over 220 separate tools in the package including converters for more than 80 graphics formats. . Website is http://netpbm.alioth.debian.org/ Section: graphics Package: libnetpbm10 Architecture: any Depends: ${shlibs:Depends} Description: Shared libraries for netpbm This package contains the shared libraries used by netpbm. Section: libs Package: libnetpbm10-dev Architecture: any Depends: libnetpbm10 Conflicts: netpbm-dev,libnetpbm9-dev Replaces: netpbm-dev Provides: netpbm-dev Description: Development libraries and header files This development package contains the library and header files for the pbm, pgm, pnm, and ppm graphics formats. Section: libdevel Package: libnetpbm9 Architecture: any Depends: ${shlibs:Depends} Description: Shared libraries for netpbm This package contains shared libraries used to be used by netpbm. Now we've switched to a single shared library, look out for libnetpbm10. This package is provided for backward compatibility. Section: libs Package: libnetpbm9-dev Architecture: any Depends: libnetpbm9 Conflicts: netpbm-dev Replaces: netpbm-dev Provides: netpbm-dev Description: Development libraries and header files This development package contains the library and header files for the pbm, pgm, pnm, and ppm graphics formats, if the split and now deprecated libraries are used. . This package is provided for backward compatibility. Section: libdevel netpbm-free-10.0-1/debian/copyright0100644004714500471450000005142307776237374017527 0ustar aba-guestaba-guestThis package was debianised by Steve McIntyre , finishing on Sun 7th October 2001. The maintainership was transfered in August 2003 to Andreas Barth , first as cooperative maintainership and sponsored by Steve. Packaging and keeping the package current is not simple, for details see README.Debian. We consider http://netpbm.alioth.debian.org/ the technical upstream, and this release can be exported out of alioth by cvs -z3 -d:pserver:anonymous@cvs.alioth.debian.org:/cvsroot/netpbm export \ -r debian-9-25-2 netpbm Copyright: ========== Netpbm has a very complicated licensing setup, as it is a collection of hundreds of small utility programs, each with an individual copyright/license. From inspection of the source and documentation in the package, I believe the following programs are DFSG-free. They have a variety of licenses, which I have summarised below for convenience. A: The most common netpbm license - clearly the original from Jef Poskanzer: Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is" without express or implied warranty. The core libp[gbnp]m library code all also seems to follow this license. B: The standard BSD license. See /usr/share/common-licenses/BSD C: GNU General Public License v2. See /usr/share/common-licenses/GPL. D: The Independent JPEG Group license: Permission is hereby granted to use, copy, modify, and distribute this software (or portions thereof) for any purpose, without fee, subject to these conditions: (1) If any part of the source code for this software is distributed, then this README file must be included, with this copyright and no-warranty notice unaltered; and any additions, deletions, or changes to the original files must be clearly indicated in accompanying documentation. (2) If only executable code is distributed, then the accompanying documentation must state that "this software is based in part on the work of the Independent JPEG Group". (3) Permission for use of this software is granted only if the user accepts full responsibility for any undesirable consequences; the authors accept NO LIABILITY for damages of any kind. These conditions apply to any software derived from or based on the IJG code, not just to the unmodified library. If you use our work, you ought to acknowledge us. Permission is NOT granted for the use of any IJG author's name or company name in advertising or publicity relating to this software or products derived from it. This software may be referred to only as "the Independent JPEG Group's software". We specifically permit and encourage the use of this software as the basis of commercial products, provided that all warranty or liability claims are assumed by the product vendor. E: This software is copyrighted as noted below. It may be freely copied, modified, and redistributed, provided that the copyright notice is preserved on all copies. There is no warranty or other guarantee of fitness for this software, it is provided solely "as is". Bug reports or fixes may be sent to the author, who may or may not act on them as he desires. You may not include this software in a program or other software product without supplying the source, or without informing the end-user that the source is available for no extra charge. If you modify this software, you should include a notice giving the name of the person performing the modification, the date of modification, and the reason for such modification. F: The program and documentation may be freely distributed by anyone in source or binary format. Please clearly note any changes. G: Public domain: This software is in the public domain. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, without any conditions or restrictions. H: Public domain, slightly different wording: Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, without any conditions or restrictions. This software is provided "as is" without express or implied warranty. H1: Public domain, even another wording: Contributed to the public domain. H2: Public domain, even another wording: Contributed to the public domain. This software is provided in the hope that it will be useful, but without warranty. I: A variation on the BSD license Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of the Smithsonian Astrophysical Observatory not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. The Smithsonian Astrophysical Observatory makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. THE SMITHSONIAN ASTROPHYSICAL OBSERVATORY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE SMITHSONIAN ASTROPHYSICAL OBSERVATORY BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Programs actually included in this package: 411toppm: (B) 2001 Steve Allen anytopnm: (A) 1991 Jef Poskanzer asciitopgm: (A) 1989 Wilson H. Bent, Jr atktopbm: (A) 1991 Bill Janssen bioradtopgm: (A) 1993 Oliver Trepte bmptopnm: (A) 1992 David W. Sanderson (as bmptoppm) brushtopbm: (A) 1988 Jef Poskanzer cmuwmtopbm: (A) 1989 Jef Poskanzer eyuvtoppm: (B) 1995 The Regents of the University of California fiascotopnm: (C) 1994-2000 Ullrich Hafner fitstopnm: (A) 1989 Jef Poskanzer fstopgm: (A) 1989 Jef Poskanzer g3topbm: (A) 1989 Paul Haeberli gemtopnm: (A) 1988 Diomidis D. Spinellis giftopnm: (A) 1990-1993 David Koblas gouldtoppm: (A) 1990 Stephen P. Lesniewski hipstopgm: (A) 1989 Jef Poskanzer icontopbm: (A) 1988 Jef Poskanzer ilbmtoppm: (A) 1989 Jef Poskanzer imgtoppm: (A) 1989 Jef Poskanzer jpegtopnm: (D) 1991-2000 Thomas G. Lane, Bryan Henderson leaftoppm: (A) 1994 Bill O'Donnell lispmtopgm: (A) 1988 Jef Poskanzer, Jamie Zawinski macptopbm: (A) 1988 Jef Poskanzer mdatopbm: (C) 1999 John Elliott mgrtopbm: (A) 1989 Jef Poskanzer mtvtoppm: (A) 1989 Jef Poskanzer neotoppm: (D) 2001 Teemu Hukkanen palmtopnm: (A) 1995-2000 Ian Goldberg, Bill Janssen pamcut: (A) 1989 Jef Poskanzer pamdeinterlace (H1) 2001 Bryan Henderson pamdice (H1) 2001 Bryan Henderson pamfile: (A) 1991 Jef Poskanzer pamoil: (A) 1990 Wilson Bent pamstack (H1) 2002 Bryan Henderson pamstretch (C) 1998,2000 Russell Marks (as pnminterp) pamstretch-gen (H1) 1999 Russell Marks (as pnminterp-gen) pbmclean: (A) 1989-2001 Jef Poskanzer, Angus Duggan, Michael Sternberg pbmlife: (A) 1988-1991 Jef Poskanzer pbmmake: (A) 1988 Jef Poskanzer pbmmask: (A) 1989-1991 Jef Poskanzer pbmpage: (C) 1998 Tim Norman pbmpscale: (A) 1989-1990 Jef Poskanzer, Angus Duggan pbmreduce: (A) 1989 Jef Poskanzer pbmtextps: (A) 2002 James McCann pbmtext: (A) 1991 Jef Poskanzer pbmto10x: (A) 1990-1994 Ken Yap pbmtoascii: (A) 1988-1992 Jef Poskanzer pbmtoatk: (A) 1991 Bill Janssen pbmtobbnbg: (A) 1989 Mike Parker pbmtocmuwm: (A) 1989 Jef Poskanzer pbmtoepsi: (A) 1988 Jef Poskanzer pbmtoepson: (A) 1990 Jef Poskanzer, John Tiller pbmtog3: (A) 1989 Paul Haeberli pbmtogem: (A) 1988 Jef Poskanzer, David Beckemeyer pbmtogo: (A) 1988-1989 Jef Poskanzer, Michael Haberler, Bo Thide' pbmtoicon: (A) 1988 Jef Poskanzer pbmtolj: (A) 1988 Jef Poskanzer, Michael Haberler pbmtomacp: (A) 1988 Douwe vand der Schaaf pbmtomda: (C) 1999 John Elliott pbmtomgr: (A) 1989 Jef Poskanzer pbmtonokia: (A) 2001 OMS Open Media System GmbH, Tim Rhsen pbmtopgm: (A) 1989-1990 Jef Poskanzer, Angus Duggan pbmtopi3: (A) 1988 David Beckemeyer and Jef Poskanzer pbmtoplot: (A) 1990 Arthur David Olson pbmtoppa: (C) 1998 Tim Norman pbmtopsg3: (C) 2001 Kristof Koehler pbmtoptx: (A) 1988 Jef Poskanzer pbmtowbmp: (A) 1999 Terje Sannum pbmtox10bm: (A) 1988 Jef Poskanzer pbmtoxbm: (A) 1988 Jef Poskanzer pbmtoybm: (A) 1991 Jamie Zawinski and Jef Poskanzer pbmtozinc: (A) 1988 James Darrell McCauley , Jef Poskanzer pbmupc: (A) 1988 Jef Poskanzer pcxtoppm: (A) 1990 Michael Davidson pgmbentley: (A) 1990 Wilson Bent pgmcrater: (H) 1989 John Walker pgmedge: (A) 1989 Jef Poskanzer pgmenhance: (A) 1989-1991 Jef Poskanzer pgmhist: (A) 1989 Jef Poskanzer pgmkernel: (A) 1992 Alberto Accomazzi, Smithsonian Astrophysical Observatory pgmnoise: (A) 1993 Frank Neumann pgmramp: (A) 1989 Jef Poskanzer pgmslice: (C) 2000 Jos Dingjan pgmtexture: (A) 1991 Texas Agricultural Experiment Station, James Darrell McCauley pgmtofs: (A) 1991 Jef Poskanzer pgmtolispm: (A) 1991 Jamie Zawinski and Jef Poskanzer pgmtopbm: (A) 1989 Jef Poskanzer pgmtoppm: (A) 1991 Jef Poskanzer pi1toppm: (A) 1991 Steve Belczyk and Jef Poskanzer pi3topbm: (A) 1988 David Beckemeyer and Diomidis D. Spinellis pjtoppm: (A) 1990 Christos Zoulas pngtopnm: (A) 1995-1998 Alexander Lehmann , Willem van Schaik pnmalias: (A) 1992 Alberto Accomazzi, Smithsonian Astrophysical Observatory pnmarith: (A) 1989-1991 Jef Poskanzer pnmcat: (A) 1989-1991 Jef Poskanzer pnmcolormap (A) 1989,1991 Jef Poskanzer (A) 2001 Bryan Henderson pnmcomp: (A) 1992 David Koblas pnmconvol: (A) 1989-1995 Jef Poskanzer, Mike Burns pnmcrop: (A) 1988 Jef Poskanzer pnmcut: (A) 1989 Jef Poskanzer pnmdepth: (A) 1989-1991 Jef Poskanzer pnmenlarge: (A) 1989 Jef Poskanzer pnmfile: (A) 1991 Jef Poskanzer pnmflip: (A) 1989 Jef Poskanzer pnmgamma: (A) 1991 Jef Poskanzer and Bill Davidson pnmhisteq: (H) 1995 John Walker pnmhistmap: (A) 1993 Wilson H. Bent, Jr pnmindex: (A) 1991 Jef Poskanzer pnminvert: (A) 1989 Jef Poskanzer pnmmargin: (A) 1991 Jef Poskanzer pnmmontage: (A) 2000 Ben Olmstead pnmnlfilt: (A) 1993 Graeme W. Gill pnmnorm: (A) 1989,1991 Jef Poskanzer (as pgmnorm) (A) Michael Mauldin (fbnorm-filter in "Fuzzy Pixmap") (A) Wilson H. Bent, Jr. (whb@usc.edu) (as ppmnorm) (A) 2002 Bryan Henderson pnmpad: (A) 1989 Jef Poskanzer (A) 1990 Angus Duggan (A) 2002 Martin van Beilen pnmpaste: (A) 1989 Jef Poskanzer pnmpsnr: (C) 1994-2000 Ullrich Hafner pnmquant (H1) 2002 Bryan Henderson pnmremap (A) 1989,1991 Jef Poskanzer (as ppmquant) (A) 2001 Bryan Henderson pnmrotate: (A) 1989-1991 Jef Poskanzer pnmscale: (A) 1989-1991 Jef Poskanzer pnmscalefixed: (A) 1989-1991 Jef Poskanzer pnmshear: (A) 1989-1991 Jef Poskanzer pnmsmooth: (A) 1984 Mike Burns pnmsplit: (H1) 2000 Bryan Henderson pnmtile: (A) 1989 Jef Poskanzer pnmtoddif: (A) 1992 Digital Equipment Corporation, Burkhard Neidecker-Lutz pnmtofiasco: (C) 1994-2000 Ullrich Hafner pnmtofits: (C) 1989 Wilson H. Bent pnmtojpeg: (D) 1991-2001 Thomas G. Lane, Bryan Henderson pnmtopalm: (A) 1995-2000 Ian Goldberg, Bill Janssen pnmtoplainpnm: (A) 1991 Jef Poskanzer pnmtopng: (A) 1995-1998 Alexander Lehmann , Willem van Schaik pnmtops: (A) 1989 Jef Poskanzer pnmtorast: (A) 1989-1991 Jef Poskanzer pnmtorle: (E) 1994 Minnesota Supercomputer Center, Inc, Wes Barris pnmtosgi: (A) 1994 Ingo Wilken pnmtosir: (A) 1991 Marvin Landis pnmtotiff: (A) 1990 Sun Microsystems, Inc, Jef Poskanzer pnmtotiffcmyk: (C) 1999 Andrew Cooke (Jara Software) pnmtoxwd: (A) 1989-1991 Jef Poskanzer ppm3d: (A) 1989 Jef Poskanzer ppmbrighten: (A) 1989-1990 Jef Poskanzer, Brian Moffet ppmchange: (A) 1991 Wilson H. Bent, Jr ppmcie: (H) 1995 John Walker ppmcolormask: (H1) 2000 Bryan Henderson ppmcolors (H1) 2001 Bryan Henderson ppmdim: (A) 1993 Frank Neumann ppmdist: (A) 1993 Dan Stromberg ppmdither: (A) 1991 Christos Zoulas ppmfade: (?) 1994 Minnesota Supercomputer Center, Inc, Wes Barris ppmflash: (A) 1993 Frank Neumann ppmforge: (H) 1989 John Walker ppmhist: (A) 1989 Jef Poskanzer ppmlabel: (H) 1995 John Walker ppmmake: (A) 1989 Jef Poskanzer ppmmix: (A) 1993 Frank Neumann ppmntsc: (E) 1993 Minnesota Supercomputer Center, Inc, Wes Barris ppmpat: (A) 1989-1991 Jef Poskanzer ppmquant: (A) 1989-1991 Jef Poskanzer ppmquantall: (A) 1991 Jef Poskanzer ppmqvga: (F) 1991-1992 Bill Davidsen, Lyle Rains ppmrainbow: (H2) 2001 Arjen Bax ppmrelief: (A) 1990 Wilson H. Bent, Jr ppmshadow: (G) 1997 John Walker ppmshift: (A) 1993 Frank Neumann ppmspread: (A) 1993 Frank Neumann ppmtoacad: (H) 1991 John Walker ppmtobmp: (A) 1992 David W. Sanderson ppmtoeyuv: (B) 1995 The Regents of the University of California ppmtoicr: (A) 1990 Kanthan Pillay ppmtoilbm: (A) 1989 Jef Poskanzer ppmtoleaf: (A) 1994 Bill O'Donnell ppmtolj: (A) 2000 Jonathan Melvin ppmtomap: (A) 1989 Jef Poskanzer ppmtomitsu: (A) 1992-1993 S.Petra Zeidler ppmtompeg: (B) 1995 The Regents of the University of California ppmtoneo: (D) 2001 Teemu Hukkanen ppmtopcx: (B) 1994 Ingo Wilken ppmtopgm: (A) 1989 Jef Poskanzer ppmtopi1: (A) 1991 Jef Poskanzer and Steve Belczyk ppmtopict: (A) 1990 Ken Yap ppmtopj: (A) 1990 Christos Zoulas ppmtopuzz: (A) 1991 Jef Poskanzer ppmtorgb3: (A) 1991 Jef Poskanzer ppmtosixel: (A) 1991 Rick Vinci ppmtotga: (A) 1989-1991 Mark Shand and Jef Poskanzer ppmtouil: (A) 1990 Mark W. Snitily, Jef Poskanzer ppmtowinicon: (A) 2000 Lee Benfield ppmtoxpm: (A) 1990 Mark W. Snitily ppmtoyuv: (A) 1987-1991 Abekas Video Systems Inc, DHD PostImage Inc ppmtoyuvsplit: (A) 1993 Andre Beck ppmtv: (A) 1993 Frank Neumann psidtopgm: (A) 1989 Jef Poskanzer pstopnm: (I) 1992 Smithsonian Astrophysical Observatory, Alberto Accomazzi qrttoppm: (A) 1989 Jef Poskanzer rasttopnm: (A) 1989-1991 Jef Poskanzer rawtopgm: (A) 1989 Jef Poskanzer rawtoppm: (A) 1991 Jef Poskanzer rgb3toppm: (A) 1991 Jef Poskanzer rletopnm: (E) 1994 Minnesota Supercomputer Center, Inc, Wes Barris sbigtopgm: (A) 1998 John Walker sgitopnm: (A) 1994 Ingo Wilken sirtopnm: (A) 1991 Marvin Landis sldtoppm: (H) 1991 John Walker spctoppm: (A) 1991 Jef Poskanzer and Steve Belczyk sputoppm: (A) 1991 Jef Poskanzer and Steve Belczyk tifftopnm: (A) 1990 Sun Microsystems, Inc, Jef Poskanzer tgatoppm: (A) 1989 Jef Poskanzer thinkjettopbm: (A) 2001 W. Eric Norum wbmptopbm: (A) 1999 Terje Sannum winicontoppm: (A) 2000 Lee Benfield xbmtopbm: (A) 1988 Jef Poskanzer ximtoppm: (A) 1991 Jef Poskanzer xpmtoppm: (A) 1991 Jef Poskanzer xvminitoppm: (A) 1993 Ingo Wilken xwdtopnm: (A) 1989-1991 Jef Poskanzer ybmtopbm: (A) 1988 Jamie Zawinski and Jef Poskanzer yuvsplittoppm: (A) 1993 Marcel Wijkstra yuvtoppm: (A) 1987-1991 Jef Poskanzer, Abekas Video Systems Inc., DHD PostImage Inc. zeisstopnm: (A) 1993 Oliver Trepte The following packages were included in this package, but replaced: [ bmptoppm: (A) 1992 David W. Sanderson ] [ gemtopbm: (A) 1988 Diomidis D. Spinellis ] [ pgmnorm: (A) 1989-1991 Jef Poskanzer ] [ pnminterp: (C) 1998-2000 Russell Marks ] [ pnminterp-gen: (C) 1998-2000 Russell Marks ] [ pnmnoraw: (A) 1991 Jef Poskanzer ] [ picttoppm: (A) 1989-1993 George Phillips [security]] [ ppmnorm: (A) 1989-1991 Jef Poskanzer, Wilson H. Bent, Jr ] [ ppmsvgalib: (H1) 2002 Bryan Henderson [never included in debian]] Not distributed due to patent issues: [ jbigtopnm: (C) 2000 Markus Kuhn ] [ pnmtojbig: (C) 2000 Markus Kuhn ] filter to create GIFs - patent restricted. (http://www.unisys.com/unisys/lzw/ [ ppmtogif: (A) 1989 Jef Poskanzer ] =============================================================================== NON-FREE: The following programs have restrictions on their use or source: hpcdtoppm package: ================== hpcdtoppm pcdindex * Copyright (c) 1992, 1993, 1994 by Hadmut Danisch (danisch@ira.uka.de). * Permission to use and distribute this software and its * documentation for noncommercial use and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation. It is not allowed to sell this software in * any way. This software is not public domain. =================================================================================================== UNKNOWN, SO NOT DISTRIBUTED: The following programs are in the upstream source package, but do not have sufficient copyright and license information to be redistributed: pamchannel: No copyright / license text found pamtopnm: No copyright / license text found pbmto4425: No copyright / license text found pbmtoln03: No copyright / license text found pbmtolps: No copyright / license text found pbmtopk: No copyright / license text found pktopbm: No copyright / license text found ppmtopjxl: No copyright / license text found spottopgm: No copyright / license text found netpbm-free-10.0-1/debian/libnetpbm10-dev.docs0100644004714500471450000000005207725111704021305 0ustar aba-guestaba-guestNetpbm.programming debian/README.Security netpbm-free-10.0-1/debian/libnetpbm9-dev.docs0100644004714500471450000000005207717743212021243 0ustar aba-guestaba-guestNetpbm.programming debian/README.Security netpbm-free-10.0-1/debian/netpbm-dev.dirs0100644004714500471450000000011007716230207020461 0ustar aba-guestaba-guestusr/share/doc usr/include usr/lib usr/share/man/man3 usr/share/man/man5 netpbm-free-10.0-1/debian/netpbm.dirs0100644004714500471450000000006407716230207017715 0ustar aba-guestaba-guestusr/share/doc usr/share/man/man1 usr/share/man/man5 netpbm-free-10.0-1/debian/netpbm.docs0100644004714500471450000000006707717743212017715 0ustar aba-guestaba-guestREADME COPYRIGHT.PATENT HISTORY debian/README.Security netpbm-free-10.0-1/debian/rules0100755004714500471450000000503407725316563016641 0ustar aba-guestaba-guest#!/usr/bin/make -f # Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. # This version is for a hypothetical package that builds an # architecture-dependant package, as well as an architecture-independant # package. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 DEBIAN_DIR = $(shell pwd)/debian build: build-stamp build-stamp: dh_testdir cp -af Makefile.config.in Makefile.config make depend ln -sf shhopt.h shhopt/netpbm-shhopt.h make build touch build-stamp clean: dh_testdir dh_testroot touch Makefile.config .depend rm -f build-stamp make clean dh_clean rm -f shhopt/netpbm-shhopt.h rm -f Makefile.config .depend # Build architecture-independent files here. binary-indep: build # Build architecture-dependent files here. binary-arch: build # dh_testversion dh_testdir dh_testroot dh_clean -k # install netpbm make PREFIX=$(DEBIAN_DIR)/netpbm/usr \ install.bin make PREFIX=$(DEBIAN_DIR)/netpbm/usr/share \ install.man.bin install.man.general dh_installdirs -pnetpbm usr/share/doc/netpbm install -m 644 HISTORY $(DEBIAN_DIR)/netpbm/usr/share/doc/netpbm/changelog # install libnetpbm10 make PREFIX=$(DEBIAN_DIR)/libnetpbm10/usr \ install.lib.shared.lib # install libnetpbm10-dev make PREFIX=$(DEBIAN_DIR)/libnetpbm10-dev/usr/ \ install.lib.hdr install.lib.static install.lib.shared.devel make PREFIX=$(DEBIAN_DIR)/libnetpbm10-dev/usr/share/ \ install.man.lib # install libnetpbm9 make PREFIX=$(DEBIAN_DIR)/libnetpbm9/usr \ install.lib.old-shared.lib # install libnetpbm9-dev make PREFIX=$(DEBIAN_DIR)/libnetpbm9-dev/usr/ \ install.lib.hdr install.lib.old-static install.lib.old-shared.devel make PREFIX=$(DEBIAN_DIR)/libnetpbm9-dev/usr/share/ \ install.man.old-lib dh_makeshlibs dh_installdocs dh_installexamples dh_installmenu dh_installcron dh_installchangelogs dh_strip dh_compress usr/share/doc/netpbm/COPYRIGHT.PATENT dh_fixperms dh_installdeb dh_shlibdeps -L libnetpbm10 -l debian/libnetpbm10/usr/lib -Nlibnetpbm9 -Nlibnetpbm9-dev dh_shlibdeps -L libnetpbm9 -l debian/libnetpbm9/usr/lib -plibnetpbm9 -plibnetpbm9-dev dh_gencontrol cat debian/netpbm/DEBIAN/control | sed 's/libnetpbm10, //g' > debian/netpbm/DEBIAN/control.1 mv -f debian/netpbm/DEBIAN/control.1 debian/netpbm/DEBIAN/control dh_md5sums dh_fixperms dh_builddeb source diff: @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary netpbm-free-10.0-1/deprecated/0040755004714500471450000000000007776237751016447 5ustar aba-guestaba-guestnetpbm-free-10.0-1/deprecated/Makefile0100644004714500471450000000325307724372231020071 0ustar aba-guestaba-guestall: include ../Makefile.config install.hdr install.merge install.man install.lib install.staticlib dep clean: build.bin install.man.bin install.man.general install.man.lib clean: install.man.old-lib: BINS=ppmtomap install.lib.hdr: ln -sf pm_config.h $(INSTALLHDRS)/pbmplus.h install.man.bin: for i in $(BINS); do \ $(MANCP) $$i.1 $(INSTALLMANUALS1)/$$i.$(SUFFIXMANUALS1) ; \ done ln -sf bmptopnm.1.gz $(INSTALLMANUALS1)/bmptoppm.1.gz ln -sf pamstretch.1.gz $(INSTALLMANUALS1)/pnminterp.1.gz ln -sf pamstretch-gen.1.gz $(INSTALLMANUALS1)/pnminterp-gen.1.gz # pnmnorm replace pgmnorm in March 2002. ln -sf pnmnorm.1.gz $(INSTALLMANUALS1)/pgmnorm.1.gz ln -sf pnmnorm.1.gz $(INSTALLMANUALS1)/ppmnorm.1.gz # pamoil replaced pgmoil in June 2001. ln -sf pamoil.1.gz $(INSTALLMANUALS1)/pgmoil.1.gz ln -sf pnmtoplainpnm.1.gz $(INSTALLMANUALS1)/pnmnoraw.1.gz ln -sf gemtopnm.1.gz $(INSTALLMANUALS1)/gemtopbm.1.gz ln -sf pnmtojpeg.1.gz $(INSTALLMANUALS1)/ppmtojpeg.1.gz install.bin: for i in $(BINS); do \ $(INSTALL) -c -m $(INSTALL_PERM_BIN) $$i $(INSTALLBINARIES)/$$i; \ done # In March 2002, bmptopnm replaced bmptoppm ln -sf bmptopnm $(INSTALLBINARIES)/bmptoppm ln -sf pamstretch $(INSTALLBINARIES)/pnminterp ln -sf pamstretch-gen $(INSTALLBINARIES)/pnminterp-gen # pamoil replaced pgmoil in June 2001. ln -sf pamoil $(INSTALLBINARIES)/pgmoil ln -sf pnmtoplainpnm $(INSTALLBINARIES)/pnmnoraw ln -sf gemtopnm $(INSTALLBINARIES)/gemtopbm # In October 2001, pnmtojpeg replaced ppmtojpeg ln -sf pnmtojpeg $(INSTALLBINARIES)/ppmtojpeg # In March 2002, pnmnorm replaced ppmnorm and pgmnorm ln -sf pnmnorm $(INSTALLBINARIES)/ppmnorm ln -sf pnmnorm $(INSTALLBINARIES)/pgmnorm netpbm-free-10.0-1/deprecated/ppmtomap0100644004714500471450000000012107720753156020205 0ustar aba-guestaba-guest#!/bin/sh # This program exists for backward compatibility. pnmcolormap all $@ netpbm-free-10.0-1/deprecated/ppmtomap.10100644004714500471450000000113007717507641020347 0ustar aba-guestaba-guest.TH ppmtomap 1 "06 January 2002" .IX ppmtomap .SH NAME ppmtomap - extract all colors from a portable pixmap .SH DESCRIPTION This program exists only for backward compatibility. Use .BR pnmcolormap , which replaced it in January 2002. One trivial difference between .B ppmtomap and .B pnmcolormap all is that if the input is PBM or PGM, .B ppmtomap would produce PPM output, whereas .B pnmcolormap all produces the same kind of output as the input. This should not be very noticeable, though, as PBM and PGM images are usually usable anywhere a PPM image is. .SH SEE ALSO .BR pnmcolormap (1)netpbm-free-10.0-1/doc/0040755004714500471450000000000007776237751015114 5ustar aba-guestaba-guestnetpbm-free-10.0-1/doc/html/0040755004714500471450000000000007776237751016060 5ustar aba-guestaba-guestnetpbm-free-10.0-1/doc/html/outside-debian.html0100644004714500471450000001210507764461315021626 0ustar aba-guestaba-guest Debian's netpbm

Using netpbm from http://netpbm.alioth.debian.org/ outside Debian

This package is free software, so you can of course also use it outside Debian. We are pleased if you like this package, and are willing to change it to make it fit better. But: We can't do any testing outside of Debian's current releases. And: In the way this package is constructed there are some manifestations of Debian's way of treating code. We try to document them in this file. If you need changes for better inclusion of this package in your favourite OS, please supply us with the details and, if possible, code. We would do what we can, as long as we don't breach Debian's rules or make things to complicated.

Assumptations of installed build helpers:

We assume that you have a working base system, means: All essential and build-essential packages are there. Among these, there are (this are the names used in Debian):

  • libc6-dev
  • gcc
  • make
  • bash
  • bsdutils
  • coreutils
  • diff
  • findutils
  • grep
  • gzip
  • perl-base
  • sed
  • tar
  • util-linux

We also assume that "install" is capable of creating directories and removing files that are at the to-be-installed location. We assume that the Makefiles don't need to handle old versions of files, but we have a package management system that removes them if needed. So we don't provide an uninstall. We assume that the target system is capable of using shared libraries, so we don't need a "merge" target.

If we broke your favourite OS, we're sorry about this. We are willing to add code for unbreaking, but you have to supply details to us. Code would make un-breaking even faster.

Free software and copyright

This package will remain to consist to 100% of free software. Free software is used in Debian consistent to the Debian Free Software Guidlines (DFSG), as defined in http://www.debian.org/social_contract#guidelines. See debian/copyright for a detailed list of copyright attached to each programm.

However, the clause above is only strict valid for version of the cvs branch tagged by us, and only to our best knowledge. Checkout to other times may have also code where we are very confident that it is free, but we don't have all license issues finally settled. (You can assume that we don't like to make the work of adding code, just to remove it later because of failing the DFSG. So be confident that it's normally just a missing e-mail in these cases.) Non-tagged cvs-code can also be failing in every other aspect, be uncompilable or similar things.

And: The clause just says that we are quite confident and we don't know of anything opposing this. But there can always be e.g. a patent unknown to us. If you notice such an error, please alert us (best via the Debian Bug Tracking System, http://bugs.debian.org/). If you notice a violation again the "free software"-clause, a severity of serious is adaequate.

We don't change tagged versions after listing the tag on the web site. So, if we notice an error, we'll correct this in cvs and release (and tag) a new version as soon as possible. So, you should use only the latest tagged version for your own safety.

Bug Tracking

If you notice an error, please check first with your distribution whether this is an distribution-specific problem, and try to check a newer tagged version of the cvs code. If you are sure that you found an error in the cvs version, you can use the Debian Bug Tracking System via http://bugs.debian.org/. Please say in this case that you're using an version exported from the cvs, and give the tag you used to retrive the code to the BTS as version. And pre-check that this bug is not already listed on http://bugs.debian.org/src:netpbm-free.

However, you should assume that only the versions of this package work that are tagged by us and that have their tagged listed on the website. We would look also at other bug reports, but we might just close such a bug with the notice that you should test the newest tagged version.

Changelog

The changes to this package are documented in HISTORY and in debian/changelog. We try to keep common changes in HISTORY, but we don't always achieve this, so you should look at both files.

[2003-11-23]

Valid XHTML 1.1!

netpbm-free-10.0-1/doc/licenses/0040755004714500471450000000000007776237751016721 5ustar aba-guestaba-guestnetpbm-free-10.0-1/doc/licenses/GPL_LICENSE.txt0100644004714500471450000004312707773014773021244 0ustar aba-guestaba-guest GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. netpbm-free-10.0-1/doc/licenses/OPENLICENSE0100644004714500471450000002265007773014773020404 0ustar aba-guestaba-guest The Open Software License v. 1.1 This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following notice immediately following the copyright notice for the Original Work: Licensed under the Open Software License version 1.1 1) Grant of Copyright License. Licensor hereby grants You a world-wide, royalty-free, non-exclusive, perpetual, non-sublicenseable license to do the following: a) to reproduce the Original Work in copies; b) to prepare derivative works ("Derivative Works") based upon the Original Work; c) to distribute copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute shall be licensed under the Open Software License; d) to perform the Original Work publicly; and e) to display the Original Work publicly. 2) Grant of Patent License. Licensor hereby grants You a world-wide, royalty-free, non-exclusive, perpetual, non-sublicenseable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor ("Licensed Claims") to make, use, sell and offer for sale the Original Work. Licensor hereby grants You a world-wide, royalty-free, non-exclusive, perpetual, non-sublicenseable license under the Licensed Claims to make, use, sell and offer for sale Derivative Works. 3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor hereby agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work, and by publishing the address of that information repository in a notice immediately following the copyright notice that applies to the Original Work. 4) Exclusions From License Grant. Nothing in this License shall be deemed to grant any rights to trademarks, copyrights, patents, trade secrets or any other intellectual property of Licensor except as expressly stated herein. No patent license is granted to make, use, sell or offer to sell embodiments of any patent claims other than the Licensed Claims defined in Section 2. No right is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under different terms from this License any Original Work that Licensor otherwise would have a right to license. 5) External Deployment. The term "External Deployment" means the use or distribution of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether the Original Work or Derivative Works are distributed to those persons or made available as an application intended for use over a computer network. As an express condition for the grants of license hereunder, You agree that any External Deployment by You of a Derivative Work shall be deemed a distribution and shall be licensed to all under the terms of this License, as prescribed in section 1(c) herein. 6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. 7) Warranty and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work is owned by the Licensor or that the Original Work is distributed by Licensor under a valid current license from the copyright owner. Except as expressly stated in the immediately proceeding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to Original Work is granted hereunder except under this disclaimer. 8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to any person for any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to liability for death or personal injury resulting from Licensor's negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You. 9) Acceptance and Termination. If You distribute copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express and volitional assent of recipients to the terms of this License. Nothing else but this License (or another written agreement between Licensor and You) grants You permission to create Derivative Works based upon the Original Work or to exercise any of the rights granted in Sections 1 herein, and any attempt to do so except under the terms of this License (or another written agreement between Licensor and You) is expressly prohibited by U.S. copyright law, the equivalent laws of other countries, and by international treaty. Therefore, by exercising any of the rights granted to You in Sections 1 herein, You indicate Your acceptance of this License and all of its terms and conditions. This License shall terminate immediately and you may no longer exercise any of the rights granted to You by this License upon Your failure to honor the proviso in Section 1(c) herein. 10) Mutual Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License if You file a lawsuit in any court alleging that any OSI Certified open source software that is licensed under any license containing this "Mutual Termination for Patent Action" clause infringes any patent claims that are essential to use that software. 11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of the U.S. Copyright Act, 17 U.S.C. 101 et seq., the equivalent laws of other countries, and international treaty. This section shall survive the termination of this License. 12) Attorneys Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. 13) Miscellaneous. This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. 14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. This license is Copyright (C) 2002 Lawrence E. Rosen. All rights reserved. Permission is hereby granted to copy and distribute this license without modification. This license may not be modified without the express written permission of its copyright owner. netpbm-free-10.0-1/doc/licenses/README.JPEG0100644004714500471450000004777507773014773020340 0ustar aba-guestaba-guestTHIS IS THE README FILE FROM THE JPEG LIBRARY, 2000.03.06. IT IS INCLUDED VERBATIM, INCLUDING ITS COPYRIGHT AND LICENSE NOTICES, IN THE NETPBM PACKAGE AS ONE OF THE TERMS UNDER WHICH THE INDEPENDENT JPEG GROUP GRANTED PERMISSION TO BRYAN HENDERSON TODAY TO DISTRIBUTE THE PPMTOJPEG AND JPEGTOPPM COMPONENTS OF NETPBM, WHICH ARE DERIVED FROM THE CJPEG AND DJPEG PROGRAMS IN THE JPEG LIBRARY PACKAGE. AS PROVIDED BY THE LICENSE GIVEN TO BRYAN, BRYAN PROPAGATES THE SAME LICENSE TO YOU, WITH RESPECT TO PPMTOJPEG AND JPEGTOPPM. The Independent JPEG Group's JPEG software ========================================== README for release 6b of 27-Mar-1998 ==================================== This distribution contains the sixth public release of the Independent JPEG Group's free JPEG software. You are welcome to redistribute this software and to use it for any purpose, subject to the conditions under LEGAL ISSUES, below. Serious users of this software (particularly those incorporating it into larger programs) should contact IJG at jpeg-info@uunet.uu.net to be added to our electronic mailing list. Mailing list members are notified of updates and have a chance to participate in technical discussions, etc. This software is the work of Tom Lane, Philip Gladstone, Jim Boucher, Lee Crocker, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, Guido Vollbeding, Ge' Weijers, and other members of the Independent JPEG Group. IJG is not affiliated with the official ISO JPEG standards committee. DOCUMENTATION ROADMAP ===================== This file contains the following sections: OVERVIEW General description of JPEG and the IJG software. LEGAL ISSUES Copyright, lack of warranty, terms of distribution. REFERENCES Where to learn more about JPEG. ARCHIVE LOCATIONS Where to find newer versions of this software. RELATED SOFTWARE Other stuff you should get. FILE FORMAT WARS Software *not* to get. TO DO Plans for future IJG releases. Other documentation files in the distribution are: User documentation: install.doc How to configure and install the IJG software. usage.doc Usage instructions for cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom. *.1 Unix-style man pages for programs (same info as usage.doc). wizard.doc Advanced usage instructions for JPEG wizards only. change.log Version-to-version change highlights. Programmer and internal documentation: libjpeg.doc How to use the JPEG library in your own programs. example.c Sample code for calling the JPEG library. structure.doc Overview of the JPEG library's internal structure. filelist.doc Road map of IJG files. coderules.doc Coding style rules --- please read if you contribute code. Please read at least the files install.doc and usage.doc. Useful information can also be found in the JPEG FAQ (Frequently Asked Questions) article. See ARCHIVE LOCATIONS below to find out where to obtain the FAQ article. If you want to understand how the JPEG code works, we suggest reading one or more of the REFERENCES, then looking at the documentation files (in roughly the order listed) before diving into the code. OVERVIEW ======== This package contains C software to implement JPEG image compression and decompression. JPEG (pronounced "jay-peg") is a standardized compression method for full-color and gray-scale images. JPEG is intended for compressing "real-world" scenes; line drawings, cartoons and other non-realistic images are not its strong suit. JPEG is lossy, meaning that the output image is not exactly identical to the input image. Hence you must not use JPEG if you have to have identical output bits. However, on typical photographic images, very good compression levels can be obtained with no visible change, and remarkably high compression levels are possible if you can tolerate a low-quality image. For more details, see the references, or just experiment with various compression settings. This software implements JPEG baseline, extended-sequential, and progressive compression processes. Provision is made for supporting all variants of these processes, although some uncommon parameter settings aren't implemented yet. For legal reasons, we are not distributing code for the arithmetic-coding variants of JPEG; see LEGAL ISSUES. We have made no provision for supporting the hierarchical or lossless processes defined in the standard. We provide a set of library routines for reading and writing JPEG image files, plus two sample applications "cjpeg" and "djpeg", which use the library to perform conversion between JPEG and some other popular image file formats. The library is intended to be reused in other applications. In order to support file conversion and viewing software, we have included considerable functionality beyond the bare JPEG coding/decoding capability; for example, the color quantization modules are not strictly part of JPEG decoding, but they are essential for output to colormapped file formats or colormapped displays. These extra functions can be compiled out of the library if not required for a particular application. We have also included "jpegtran", a utility for lossless transcoding between different JPEG processes, and "rdjpgcom" and "wrjpgcom", two simple applications for inserting and extracting textual comments in JFIF files. The emphasis in designing this software has been on achieving portability and flexibility, while also making it fast enough to be useful. In particular, the software is not intended to be read as a tutorial on JPEG. (See the REFERENCES section for introductory material.) Rather, it is intended to be reliable, portable, industrial-strength code. We do not claim to have achieved that goal in every aspect of the software, but we strive for it. We welcome the use of this software as a component of commercial products. No royalty is required, but we do ask for an acknowledgement in product documentation, as described under LEGAL ISSUES. LEGAL ISSUES ============ In plain English: 1. We don't promise that this software works. (But if you find any bugs, please let us know!) 2. You can use this software for whatever you want. You don't have to pay us. 3. You may not pretend that you wrote this software. If you use it in a program, you must acknowledge somewhere in your documentation that you've used the IJG code. In legalese: The authors make NO WARRANTY or representation, either express or implied, with respect to this software, its quality, accuracy, merchantability, or fitness for a particular purpose. This software is provided "AS IS", and you, its user, assume the entire risk as to its quality and accuracy. This software is copyright (C) 1991-1998, Thomas G. Lane. All Rights Reserved except as specified below. Permission is hereby granted to use, copy, modify, and distribute this software (or portions thereof) for any purpose, without fee, subject to these conditions: (1) If any part of the source code for this software is distributed, then this README file must be included, with this copyright and no-warranty notice unaltered; and any additions, deletions, or changes to the original files must be clearly indicated in accompanying documentation. (2) If only executable code is distributed, then the accompanying documentation must state that "this software is based in part on the work of the Independent JPEG Group". (3) Permission for use of this software is granted only if the user accepts full responsibility for any undesirable consequences; the authors accept NO LIABILITY for damages of any kind. These conditions apply to any software derived from or based on the IJG code, not just to the unmodified library. If you use our work, you ought to acknowledge us. Permission is NOT granted for the use of any IJG author's name or company name in advertising or publicity relating to this software or products derived from it. This software may be referred to only as "the Independent JPEG Group's software". We specifically permit and encourage the use of this software as the basis of commercial products, provided that all warranty or liability claims are assumed by the product vendor. ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA. ansi2knr.c is NOT covered by the above copyright and conditions, but instead by the usual distribution terms of the Free Software Foundation; principally, that you must include source code if you redistribute it. (See the file ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part of any program generated from the IJG code, this does not limit you more than the foregoing paragraphs do. The Unix configuration script "configure" was produced with GNU Autoconf. It is copyright by the Free Software Foundation but is freely distributable. The same holds for its supporting scripts (config.guess, config.sub, ltconfig, ltmain.sh). Another support script, install-sh, is copyright by M.I.T. but is also freely distributable. It appears that the arithmetic coding option of the JPEG spec is covered by patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot legally be used without obtaining one or more licenses. For this reason, support for arithmetic coding has been removed from the free JPEG software. (Since arithmetic coding provides only a marginal gain over the unpatented Huffman mode, it is unlikely that very many implementations will support it.) So far as we are aware, there are no patent restrictions on the remaining code. The IJG distribution formerly included code to read and write GIF files. To avoid entanglement with the Unisys LZW patent, GIF reading support has been removed altogether, and the GIF writer has been simplified to produce "uncompressed GIFs". This technique does not use the LZW algorithm; the resulting GIF files are larger than usual, but are readable by all standard GIF decoders. We are required to state that "The Graphics Interchange Format(c) is the Copyright property of CompuServe Incorporated. GIF(sm) is a Service Mark property of CompuServe Incorporated." REFERENCES ========== We highly recommend reading one or more of these references before trying to understand the innards of the JPEG software. The best short technical introduction to the JPEG compression algorithm is Wallace, Gregory K. "The JPEG Still Picture Compression Standard", Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44. (Adjacent articles in that issue discuss MPEG motion picture compression, applications of JPEG, and related topics.) If you don't have the CACM issue handy, a PostScript file containing a revised version of Wallace's article is available at ftp://ftp.uu.net/graphics/jpeg/wallace.ps.gz. The file (actually a preprint for an article that appeared in IEEE Trans. Consumer Electronics) omits the sample images that appeared in CACM, but it includes corrections and some added material. Note: the Wallace article is copyright ACM and IEEE, and it may not be used for commercial purposes. A somewhat less technical, more leisurely introduction to JPEG can be found in "The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides good explanations and example C code for a multitude of compression methods including JPEG. It is an excellent source if you are comfortable reading C code but don't know much about data compression in general. The book's JPEG sample code is far from industrial-strength, but when you are ready to look at a full implementation, you've got one here... The best full description of JPEG is the textbook "JPEG Still Image Data Compression Standard" by William B. Pennebaker and Joan L. Mitchell, published by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. Price US$59.95, 638 pp. The book includes the complete text of the ISO JPEG standards (DIS 10918-1 and draft DIS 10918-2). This is by far the most complete exposition of JPEG in existence, and we highly recommend it. The JPEG standard itself is not available electronically; you must order a paper copy through ISO or ITU. (Unless you feel a need to own a certified official copy, we recommend buying the Pennebaker and Mitchell book instead; it's much cheaper and includes a great deal of useful explanatory material.) In the USA, copies of the standard may be ordered from ANSI Sales at (212) 642-4900, or from Global Engineering Documents at (800) 854-7179. (ANSI doesn't take credit card orders, but Global does.) It's not cheap: as of 1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7% shipping/handling. The standard is divided into two parts, Part 1 being the actual specification, while Part 2 covers compliance testing methods. Part 1 is titled "Digital Compression and Coding of Continuous-tone Still Images, Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS 10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of Continuous-tone Still Images, Part 2: Compliance testing" and has document numbers ISO/IEC IS 10918-2, ITU-T T.83. Some extensions to the original JPEG standard are defined in JPEG Part 3, a newer ISO standard numbered ISO/IEC IS 10918-3 and ITU-T T.84. IJG currently does not support any Part 3 extensions. The JPEG standard does not specify all details of an interchangeable file format. For the omitted details we follow the "JFIF" conventions, revision 1.02. A copy of the JFIF spec is available from: Literature Department C-Cube Microsystems, Inc. 1778 McCarthy Blvd. Milpitas, CA 95035 phone (408) 944-6300, fax (408) 944-6314 A PostScript version of this document is available by FTP at ftp://ftp.uu.net/graphics/jpeg/jfif.ps.gz. There is also a plain text version at ftp://ftp.uu.net/graphics/jpeg/jfif.txt.gz, but it is missing the figures. The TIFF 6.0 file format specification can be obtained by FTP from ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems. IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6). Instead, we recommend the JPEG design proposed by TIFF Technical Note #2 (Compression tag 7). Copies of this Note can be obtained from ftp.sgi.com or from ftp://ftp.uu.net/graphics/jpeg/. It is expected that the next revision of the TIFF spec will replace the 6.0 JPEG design with the Note's design. Although IJG's own code does not support TIFF/JPEG, the free libtiff library uses our library to implement TIFF/JPEG per the Note. libtiff is available from ftp://ftp.sgi.com/graphics/tiff/. ARCHIVE LOCATIONS ================= The "official" archive site for this software is ftp.uu.net (Internet address 192.48.96.9). The most recent released version can always be found there in directory graphics/jpeg. This particular version will be archived as ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz. If you don't have direct Internet access, UUNET's archives are also available via UUCP; contact help@uunet.uu.net for information on retrieving files that way. Numerous Internet sites maintain copies of the UUNET files. However, only ftp.uu.net is guaranteed to have the latest official version. You can also obtain this software in DOS-compatible "zip" archive format from the SimTel archives (ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/), or on CompuServe in the Graphics Support forum (GO CIS:GRAPHSUP), library 12 "JPEG Tools". Again, these versions may sometimes lag behind the ftp.uu.net release. The JPEG FAQ (Frequently Asked Questions) article is a useful source of general information about JPEG. It is updated constantly and therefore is not included in this distribution. The FAQ is posted every two weeks to Usenet newsgroups comp.graphics.misc, news.answers, and other groups. It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/ and other news.answers archive sites, including the official news.answers archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/. If you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu with body send usenet/news.answers/jpeg-faq/part1 send usenet/news.answers/jpeg-faq/part2 RELATED SOFTWARE ================ Numerous viewing and image manipulation programs now support JPEG. (Quite a few of them use this library to do so.) The JPEG FAQ described above lists some of the more popular free and shareware viewers, and tells where to obtain them on Internet. If you are on a Unix machine, we highly recommend Jef Poskanzer's free PBMPLUS software, which provides many useful operations on PPM-format image files. In particular, it can convert PPM images to and from a wide range of other formats, thus making cjpeg/djpeg considerably more useful. The latest version is distributed by the NetPBM group, and is available from numerous sites, notably ftp://wuarchive.wustl.edu/graphics/graphics/packages/NetPBM/. Unfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software is; you are likely to have difficulty making it work on any non-Unix machine. A different free JPEG implementation, written by the PVRG group at Stanford, is available from ftp://havefun.stanford.edu/pub/jpeg/. This program is designed for research and experimentation rather than production use; it is slower, harder to use, and less portable than the IJG code, but it is easier to read and modify. Also, the PVRG code supports lossless JPEG, which we do not. (On the other hand, it doesn't do progressive JPEG.) FILE FORMAT WARS ================ Some JPEG programs produce files that are not compatible with our library. The root of the problem is that the ISO JPEG committee failed to specify a concrete file format. Some vendors "filled in the blanks" on their own, creating proprietary formats that no one else could read. (For example, none of the early commercial JPEG implementations for the Macintosh were able to exchange compressed files.) The file format we have adopted is called JFIF (see REFERENCES). This format has been agreed to by a number of major commercial JPEG vendors, and it has become the de facto standard. JFIF is a minimal or "low end" representation. We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF Technical Note #2) for "high end" applications that need to record a lot of additional data about an image. TIFF/JPEG is fairly new and not yet widely supported, unfortunately. The upcoming JPEG Part 3 standard defines a file format called SPIFF. SPIFF is interoperable with JFIF, in the sense that most JFIF decoders should be able to read the most common variant of SPIFF. SPIFF has some technical advantages over JFIF, but its major claim to fame is simply that it is an official standard rather than an informal one. At this point it is unclear whether SPIFF will supersede JFIF or whether JFIF will remain the de-facto standard. IJG intends to support SPIFF once the standard is frozen, but we have not decided whether it should become our default output format or not. (In any case, our decoder will remain capable of reading JFIF indefinitely.) Various proprietary file formats incorporating JPEG compression also exist. We have little or no sympathy for the existence of these formats. Indeed, one of the original reasons for developing this free software was to help force convergence on common, open format standards for JPEG files. Don't use a proprietary file format! TO DO ===== The major thrust for v7 will probably be improvement of visual quality. The current method for scaling the quantization tables is known not to be very good at low Q values. We also intend to investigate block boundary smoothing, "poor man's variable quantization", and other means of improving quality-vs-file-size performance without sacrificing compatibility. In future versions, we are considering supporting some of the upcoming JPEG Part 3 extensions --- principally, variable quantization and the SPIFF file format. As always, speeding things up is of great interest. Please send bug reports, offers of help, etc. to jpeg-info@uunet.uu.net. netpbm-free-10.0-1/include/0040755004714500471450000000000007776237751015772 5ustar aba-guestaba-guestnetpbm-free-10.0-1/include/Makefile0100644004714500471450000000072607724372231017416 0ustar aba-guestaba-guest all: # HEADERS=netpbm-shhopt.h pam.h HEADERS=pam.h \ libpbm.h libpgm.h libppm.h \ pam.h pbm.h pgm.h \ pm.h pm_config.h \ pnm.h ppm.h ppmcmap.h include ../Makefile.config install.lib.hdr: for i in $(HEADERS); do \ $(INSTALL) -m $(INSTALL_PERM_HDR) $$i $(INSTALLHDRS)/$$i; done install.hdr install.merge install.man install.lib install.staticlib dep clean: build.bin install.man.bin install.man.general install.man.lib clean: install.bin: install.man.old-lib: netpbm-free-10.0-1/include/bitio.h0100644004714500471450000000413307717675121017237 0ustar aba-guestaba-guest/*\ * $Id: bitio.h,v 1.1 2003/08/17 12:51:29 aba-guest Exp $ * * bitio.h - bitstream I/O * * Works for (sizeof(unsigned long)-1)*8 bits. * * Copyright (C) 1992 by David W. Sanderson. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. This software is provided "as is" * without express or implied warranty. * * $Log: bitio.h,v $ * Revision 1.1 2003/08/17 12:51:29 aba-guest * moved bitio.h to include/ * * Revision 1.2 2003/08/14 19:38:51 aba-guest * First part to 9.25 update; could now be really broken * * Revision 1.1.1.1 2003/08/12 18:23:03 aba-guest * Latest debian release * * Revision 1.4 1992/11/24 19:37:02 dws * Added copyright * * Revision 1.3 1992/11/17 03:37:59 dws * updated comment * * Revision 1.2 1992/11/10 23:10:22 dws * Generalized to handle more than one bitstream at a time. * * Revision 1.1 1992/11/10 18:33:51 dws * Initial revision * \*/ #ifndef _BITIO_H_ #define _BITIO_H_ #include "pm.h" typedef struct bitstream *BITSTREAM; struct bitstream * pm_bitinit(FILE * const f, char * const mode); /* * pm_bitfini() - deallocate the given BITSTREAM. * * You must call this after you are done with the BITSTREAM. * * It may flush some bits left in the buffer. * * Returns the number of bytes written, -1 on error. */ extern int pm_bitfini ARGS((BITSTREAM b)); /* * pm_bitread() - read the next nbits into *val from the given file. * * Returns the number of bytes read, -1 on error. */ extern int pm_bitread ARGS((BITSTREAM b, unsigned long nbits, unsigned long *val)); /* * pm_bitwrite() - write the low nbits of val to the given file. * * The last pm_bitwrite() must be followed by a call to pm_bitflush(). * * Returns the number of bytes written, -1 on error. */ extern int pm_bitwrite ARGS((BITSTREAM b, unsigned long nbits, unsigned long val)); #endif /* _BITIO_H_ */ netpbm-free-10.0-1/include/bmp.h0100644004714500471450000001366507717507641016722 0ustar aba-guestaba-guest/*\ * $Id: bmp.h,v 1.2 2003/08/16 20:10:09 aba-guest Exp $ * * bmp.h - routines to calculate sizes of parts of BMP files * * Some fields in BMP files contain offsets to other parts * of the file. These routines allow us to calculate these * offsets, so that we can read and write BMP files without * the need to fseek(). * * Copyright (C) 1992 by David W. Sanderson. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. This software is provided "as is" * without express or implied warranty. * * $Log: bmp.h,v $ * Revision 1.2 2003/08/16 20:10:09 aba-guest * source should now be 9.25 upstream * * Revision 1.1.1.1 2003/08/12 18:23:03 aba-guest * Latest debian release * * Revision 1.3 1992/11/24 19:39:56 dws * Added copyright. * * Revision 1.2 1992/11/17 02:13:37 dws * Adjusted a string's name. * * Revision 1.1 1992/11/16 19:54:44 dws * Initial revision * \*/ /* There is a specification of the Windows BMP format in (2000.06.08) However, the format we have seen for Windows BMP files with 24 bit truecolor is quite a bit different, and zgv seems to know it too: The raster is 3 bytes per pixel, in the order G, B, R with each row padded out to a multiple of 4 bytes. The above document says it is 4 bytes per pixel, in the order R, G, B, Z (zero). And the colormap format is also different: Each color entry is in the order B, G, R, Z whereas the document says R, G, B, Z. The ColorsImportant field is defined in that spec as "Number of important colors. 0 = all" That is the entire definition. The spec also says the number of entries in the color map is a function of the BitCount field alone. But Marc Moorcroft says (2000.07.23) that he found two BMP files some time ago that had a color map whose number of entries was not as specified and was in fact the value of ColorsImportant. And Bill Janssen actually produced some BMPs in January 2001 that appear to have the size of the colormap determined by ColorsUsed. They have 8 bits per pixel in the raster, but ColorsUsed is 4 and there are in fact 4 entries in the color map. He got these from the Palm emulator for Windows, using the "Save Screen" menu option. Bmptoppm had, for a few releases in 2000, code by Marc to use ColorsImportant as the color map size unless it was zero, in which case it determined color map size as specified. The current thinking is that there are probably more BMPs that need to be interpreted per the spec than that need to be interpreted Marc's way. But in light of Janssen's discovery, we have made the assumption since February 2001 that when ColorsUsed is zero, the colormap size is as specified, and when it is nonzero, the colormap size is given by ColorsUsed. Now we just have to wait for reports of BMPs for which this assumption is not true. */ #ifndef _BMP_H_ #define _BMP_H_ #include "ppm.h" /* For pm_error() */ enum bmpClass {C_WIN=1, C_OS2=2}; static char er_internal[] = "%s: internal error!"; static unsigned int BMPlenfileheader(enum bmpClass const class) { unsigned int retval; switch (class) { case C_WIN: retval = 14; break; case C_OS2: retval = 14; break; } return retval; } static unsigned int BMPleninfoheader(enum bmpClass const class) { unsigned int retval; switch (class) { case C_WIN: retval = 40; break; case C_OS2: retval = 12; break; } return retval; } static unsigned int BMPlencolormap(enum bmpClass const class, unsigned int const bitcount, int const cmapsize) { unsigned int lenrgb; unsigned int lencolormap; if (bitcount < 1) pm_error(er_internal, "BMPlencolormap"); else if (bitcount > 8) lencolormap = 0; else { switch (class) { case C_WIN: lenrgb = 4; break; case C_OS2: lenrgb = 3; break; } if (cmapsize < 0) lencolormap = (1 << bitcount) * lenrgb; else lencolormap = cmapsize * lenrgb; } return lencolormap; } /* * length, in bytes, of a line of the image * * Each row is padded on the right as needed to make it a * multiple of 4 bytes int. This appears to be true of both * OS/2 and Windows BMP files. */ static unsigned int BMPlenline(enum bmpClass const class, unsigned int const bitcount, unsigned int const x) { unsigned int bitsperline; unsigned int retval; bitsperline = x * bitcount; /* * if bitsperline is not a multiple of 32, then round * bitsperline up to the next multiple of 32. */ if ((bitsperline % 32) != 0) bitsperline += (32 - (bitsperline % 32)); if ((bitsperline % 32) != 0) { pm_error(er_internal, "BMPlenline"); retval = 0; } else /* number of bytes per line == bitsperline/8 */ retval = bitsperline >> 3; return retval; } /* return the number of bytes used to store the image bits */ static unsigned int BMPlenbits(enum bmpClass const class, unsigned int const bitcount, unsigned int const x, unsigned int const y) { return y * BMPlenline(class, bitcount, x); } /* return the offset to the BMP image bits */ static unsigned int BMPoffbits(enum bmpClass const class, unsigned int const bitcount, unsigned int const cmapsize) { return BMPlenfileheader(class) + BMPleninfoheader(class) + BMPlencolormap(class, bitcount, cmapsize); } /* return the size of the BMP file in bytes */ static unsigned int BMPlenfile(enum bmpClass const class, unsigned int const bitcount, int const cmapsize, unsigned int const x, unsigned int const y) { return BMPoffbits(class, bitcount, cmapsize) + BMPlenbits(class, bitcount, x, y); } #endif /* _BMP_H_ */ netpbm-free-10.0-1/include/colorname.h0100644004714500471450000000077507776237374020131 0ustar aba-guestaba-guest#include #include #ifndef COLORNAME_H #define COLORNAME_H enum colornameFormat {PAM_COLORNAME_ENGLISH = 0, PAM_COLORNAME_HEXOK = 1}; struct colorfile_entry { long r, g, b; char * colorname; }; void pm_canonstr(char * const str); FILE * pm_openColornameFile(const int must_open); struct colorfile_entry pm_colorget(FILE * const f); long pm_rgbnorm(const long rgb, const long lmaxval, const int n, const char * const colorname); #endif netpbm-free-10.0-1/include/compile.h0100644004714500471450000000000007717657506017555 0ustar aba-guestaba-guestnetpbm-free-10.0-1/include/libpbm.h0100644004714500471450000000066607717167171017406 0ustar aba-guestaba-guest/* libpbm.h - internal header file for libpbm portable bitmap library */ #ifndef _LIBPBM_H_ #define _LIBPBM_H_ /* Here are some routines internal to the pbm library. */ char pbm_getc ARGS(( FILE* file )); unsigned char pbm_getrawbyte ARGS(( FILE* file )); int pbm_getint ARGS(( FILE* file )); int pbm_readmagicnumber ARGS(( FILE* file )); void pbm_readpbminitrest ARGS(( FILE* file, int* colsP, int* rowsP )); #endif /*_LIBPBM_H_*/ netpbm-free-10.0-1/include/libpgm.h0100644004714500471450000000064107717167171017404 0ustar aba-guestaba-guest/* libpgm.h - internal header file for libpgm portable graymap library */ #ifndef _LIBPGM_H_ #define _LIBPGM_H_ /* Here are some routines internal to the pgm, ppm, and pnm libraries. */ void pgm_readpgminitrest(FILE* file, int* colsP, int* rowsP, gray* maxvalP); gray pgm_getrawsample(FILE *file, const gray maxval); void pgm_writerawsample(FILE *file, const gray val, const gray maxval); #endif /*_LIBPGM_H_*/ netpbm-free-10.0-1/include/libppm.h0100644004714500471450000000045707717167171017422 0ustar aba-guestaba-guest/* libppm.h - internal header file for libppm portable pixmap library */ #ifndef _LIBPPM_H_ #define _LIBPPM_H_ #include "libpgm.h" /* Here are some routines internal to the ppm library. */ void ppm_readppminitrest ARGS(( FILE* file, int* colsP, int* rowsP, pixval* maxvalP )); #endif /*_LIBPPM_H_*/ netpbm-free-10.0-1/include/pam.h0100644004714500471450000001506707776237374016727 0ustar aba-guestaba-guest/*---------------------------------------------------------------------------- These are declarations for use with the Portable Arbitrary Map (PAM) format and the Netpbm library functions specific to them. -----------------------------------------------------------------------------*/ #ifndef PAM_H #define PAM_H #include "pnm.h" typedef unsigned long sample; struct pam { /* This structure describes an open PAM image file. It consists entirely of information that belongs in the header of a PAM image and filesystem information. It does not contain any state information about the processing of that image. This is not considered to be an opaque object. The user of Netbpm libraries is free to access and set any of these fields whenever appropriate. The structure exists to make coding of function calls easy. */ /* 'size' and 'len' are necessary in order to provide forward and backward compatibility between library functions and calling programs as this structure grows. */ unsigned int size; /* The storage size of this entire structure, in bytes */ unsigned int len; /* The length, in bytes, of the information in this structure. The information starts in the first byte and is contiguous. This cannot be greater than 'size' */ FILE *file; int format; /* The format code of the raw image. This is PAM_FORMAT unless the PAM image is really a view of a PBM, PGM, or PPM image. Then it's PBM_FORMAT, RPBM_FORMAT, etc. */ unsigned int plainformat; /* Logical: the format above is a plain (text) format as opposed to a raw (binary) format. This is entirely redundant with the 'format' member and exists as a separate member only for computational speed. */ int height; /* Height of image in rows */ int width; /* Width of image in number of columns (tuples per row) */ unsigned int depth; /* Depth of image (number of samples in each tuple). */ sample maxval; /* Maximum defined value for a sample */ unsigned int bytes_per_sample; /* Number of bytes used to represent each sample in the image file. Note that this is strictly a function of 'maxval'. It is in a a separate member for computational speed. */ char tuple_type[256]; /* The tuple type string from the image header. Netpbm does not define any values for this except the following, which are used for a PAM image which is really a view of a PBM, PGM, or PPM image: PAM_PBM_TUPLETYPE, PAM_PGM_TUPLETYPE, PAM_PPM_TUPLETYPE. */ }; #define PAM_PBM_TUPLETYPE "BLACKANDWHITE" #define PAM_PGM_TUPLETYPE "GRAYSCALE" #define PAM_PPM_TUPLETYPE "RGB" #define PAM_PBM_BLACK 0 #define PAM_PBM_WHITE 1 /* These are values of samples in a PAM image that represents a black and white bitmap image. They are the values of black and white, respectively. For example, if you use pnm_readpamrow() to read a row from a PBM file, the black pixels get returned as PAM_PBM_BLACK. */ #define PAM_RED_PLANE 0 #define PAM_GRN_PLANE 1 #define PAM_BLU_PLANE 2 /* These are plane numbers for the 3 planes of a PAM image that represents an RGB image (tuple type is PAM_PPM_TUPLETYPE). So if 'pixel' is a tuple returned by pnmreadpamrow(), then pixel[PAM_GRN_PLANE] is the value of the green sample in that pixel. */ #define PAM_TRN_PLANE 3 /* Some PAMs with "RGB" or "RGBA" tuple types have this 4th plane for transparency. 0 = transparent, maxval = opaque. */ typedef sample *tuple; /* A tuple in a PAM. This is an array such that tuple[i-1] is the ith sample (element) in the tuple. It's dimension is the depth of the image (see pam.depth above). */ #define PAM_OVERALL_MAXVAL ULONG_MAX #define PAM_MAGIC1 'P' #define PAM_MAGIC2 '7' #define PAM_FORMAT (PAM_MAGIC1 * 256 + PAM_MAGIC2) #define PAM_TYPE PAM_FORMAT /* Macro for turning a format number into a type number. */ #define PAM_FORMAT_TYPE(f) ((f) == PAM_FORMAT ? PAM_TYPE : PPM_FORMAT_TYPE(f)) /* Declarations of library functions. */ /* We don't have a specific PAM function for init and nextimage, because one can simply use pnm_init() and pnm_nextimage() from pnm.h. */ char stripeq(const char * const comparand, const char * const comparator); int pnm_tupleequal(const struct pam * const pamP, tuple const comparand, tuple const comparator); void pnm_assigntuple(const struct pam * const pamP, tuple const dest, tuple const source); static __inline__ sample pnm_scalesample(sample const source, sample const oldmaxval, sample const newmaxval) { if (oldmaxval == newmaxval) /* Fast path for common case */ return source; else return (source * newmaxval + (oldmaxval/2)) / oldmaxval; } void pnm_scaletuple(const struct pam * const pamP, tuple const dest, tuple const source, sample const newmaxval); void createBlackTuple(const struct pam * const pamP, tuple * const blackTupleP); #define pnm_allocpamtuple(pamP) \ ((tuple) pm_allocrow(1, (pamP)->depth*sizeof(sample))) #define pnm_freepamtuple(tuple) pm_freerow((char*) tuple) tuple * pnm_allocpamrow(struct pam * const pamP); #define pnm_freepamrow(tuplerow) pm_freerow((char*) tuplerow) tuple ** pnm_allocpamarray(struct pam * const pamP); void pnm_freepamarray(tuple ** const tuplearray, struct pam * const pamP); void pnm_setpamrow(struct pam const pam, tuple * const tuplerow, sample const value); void pnm_readpaminit(FILE *file, struct pam * const pamP, const int size); void pnm_readpamrow(struct pam * const pamP, tuple* const tuplerow); tuple** pnm_readpam(FILE *file, struct pam * const pamP, const int size); void pnm_writepaminit(struct pam * const pamP); void pnm_writepamrow(struct pam * const pamP, const tuple * const tuplerow); void pnm_writepam(struct pam * const pamP, tuple ** const tuplearray); void pnm_checkpam(struct pam * const pamP, const enum pm_check_type check_type, enum pm_check_code * const retvalP); extern double pnm_lumin_factor[3]; void pnm_YCbCrtuple(const tuple tuple, double * const YP, double * const CbP, double * const CrP); #endif netpbm-free-10.0-1/include/pammap.h0100644004714500471450000000544007776237374017417 0ustar aba-guestaba-guest/****************************************************************************** pammap.h ******************************************************************************* Interface header file for hash table and lookup table pam functions in libpnm. ******************************************************************************/ #ifndef PAMMAP_H #define PAMMAP_H #include "colorname.h" #include "pam.h" struct tupleint { /* An ordered pair of a tuple value and an integer, such as you would find in a tuple table or tuple hash. Note that this is a variable length structure. */ int value; sample tuple[1]; /* This is actually a variable size array -- its size is the depth of the tuple in question. Some compilers do not let us declare a variable length array. */ }; typedef struct tupleint ** tupletable; struct tupleint_list_item { struct tupleint_list_item * next; struct tupleint tupleint; }; typedef struct tupleint_list_item * tupleint_list; typedef tupleint_list * tuplehash; unsigned int pnm_hashtuple(struct pam * const pamP, tuple const tuple); void pnm_addtotuplehash(struct pam * const pamP, tuplehash const tuplehash, tuple const tuple, int const value, int * const fitsP); void pnm_lookuptuple(struct pam * const pamP, const tuplehash tuplehash, const tuple searchval, int * const foundP, int * const retvalP); tupletable pnm_alloctupletable(const struct pam * const pamP, unsigned int const size); void pnm_freetupletable(struct pam * const pamP, tupletable const tupletable); tuplehash pnm_createtuplehash(void); void pnm_destroytuplehash(tuplehash const tuplehash); tupletable pnm_computetuplefreqtable(struct pam * const pamP, tuple ** const tupleArray, unsigned int const maxsize, unsigned int * const sizeP); tuplehash pnm_computetuplefreqhash(struct pam * const pamP, tuple ** const tupleArray, unsigned int const maxsize, unsigned int * const sizeP); tuplehash pnm_computetupletablehash(struct pam * const pamP, tupletable const tupletable, unsigned int const tupletableSize); tupletable pnm_tuplehashtotable(const struct pam * const pamP, tuplehash const tuplehash, unsigned int const maxsize); char* pam_colorname(struct pam * const pamP, tuple const color, enum colornameFormat const format); #endif netpbm-free-10.0-1/include/pbm.h0100644004714500471450000000354707717167171016720 0ustar aba-guestaba-guest/* pbm.h - header file for libpbm portable bitmap library */ #ifndef _PBM_H_ #define _PBM_H_ #include "pm.h" typedef unsigned char bit; #define PBM_WHITE 0 #define PBM_BLACK 1 /* Magic constants. */ #define PBM_MAGIC1 'P' #define PBM_MAGIC2 '1' #define RPBM_MAGIC2 '4' #define PBM_FORMAT (PBM_MAGIC1 * 256 + PBM_MAGIC2) #define RPBM_FORMAT (PBM_MAGIC1 * 256 + RPBM_MAGIC2) #define PBM_TYPE PBM_FORMAT /* Macro for turning a format number into a type number. */ #define PBM_FORMAT_TYPE(f) \ ((f) == PBM_FORMAT || (f) == RPBM_FORMAT ? PBM_TYPE : -1) /* Declarations of routines. */ void pbm_init ARGS(( int* argcP, char* argv[] )); void pbm_nextimage(FILE *file, int * const eofP); #define pbm_allocarray(cols, rows) \ ((bit**) pm_allocarray(cols, rows, sizeof(bit))) #define pbm_allocrow(cols) ((bit*) pm_allocrow( cols, sizeof(bit))) #define pbm_freearray(bits, rows) pm_freearray((char**) bits, rows) #define pbm_freerow(bitrow) pm_freerow((char*) bitrow) #define pbm_packed_bytes(cols) (((cols)+7)/8) bit** pbm_readpbm(FILE* file, int* colsP, int* rowsP); void pbm_readpbminit(FILE* file, int* colsP, int* rowsP, int* formatP); void pbm_readpbmrow(FILE* file, bit* bitrow, int cols, int format); void pbm_readpbmrow_packed( FILE* const file, unsigned char * const packed_bits, const int cols, const int format); void pbm_writepbm (FILE* file, bit** bits, int cols, int rows, int forceplain); void pbm_writepbminit(FILE* file, int cols, int rows, int forceplain); void pbm_writepbmrow (FILE* file, bit* bitrow, int cols, int forceplain); void pbm_writepbmrow_packed( FILE* const file, const unsigned char * const packed_bits, const int cols, const int format); void pbm_check(FILE * file, const enum pm_check_type check_type, const int format, const int cols, const int rows, enum pm_check_code * const retval_p); #endif /*_PBM_H_*/ netpbm-free-10.0-1/include/pbmfont.h0100644004714500471450000000133607717167171017601 0ustar aba-guestaba-guest/* pbmfont.h - header file for font routines in libpbm */ struct glyph { int width, height; int x, y; int xadd; char* bmap; }; struct font { int maxwidth, maxheight; int x, y; struct glyph* glyph[256]; /* for compatibility with old pbmtext routines */ /* oldfont is 0 if the font is BDF derived */ bit** oldfont; int fcols, frows; }; struct font* pbm_defaultfont ARGS(( char* which )); struct font* pbm_dissectfont ARGS(( bit** font, int frows, int fcols )); struct font* pbm_loadfont ARGS(( char* filename )); struct font* pbm_loadpbmfont ARGS(( char* filename )); struct font* pbm_loadbdffont ARGS(( char* filename )); void pbm_dumpfont ARGS(( struct font* fn )); int mk_argvn ARGS(( char* s, char* vec[], int max )); netpbm-free-10.0-1/include/pgm.h0100644004714500471450000000615507776237374016733 0ustar aba-guestaba-guest/* pgm.h - header file for libpgm portable graymap library */ #ifndef _PGM_H_ #define _PGM_H_ #include "pbm.h" /* The following definition has nothing to do with the format of a PGM file */ typedef unsigned int gray; /* Since April 2000, we are capable of reading and generating raw (binary) PGM files with maxvals up to 65535. However, before that the maximum (as usually implemented) was 255, and people still want to generate files with a maxval of no more than 255 in most cases (because then old Netpbm programs can process them, and they're only half as big). So we keep PGM_MAXMAXVAL = 255, even though it's kind of a misnomer. Note that one could always write a file with maxval > PGM_MAXMAXVAL and it would just go into plain (text) format instead of raw (binary) format. Along with the expansion to 16 bit raw files, we took away that ability. Unless you specify 'forceplain' on the pgm_writepgminit() call, it will fail if you specify a maxval > PGM_OVERALLMAXVAL. I made this design decision because I don't think anyone really wants to get a plain format file with samples larger than 65535 in it. However, it should be possible just to increase PGM_OVERALLMAXVAL and get that old function back for maxvals that won't fit in 16 bits. I think the only thing really constraining PGM_OVERALLMAXVAL is the size of the 'gray' data structure, which is generally 32 bits. */ #define PGM_OVERALLMAXVAL 65535 #define PGM_MAXMAXVAL 255 /* Magic constants. */ #define PGM_MAGIC1 'P' #define PGM_MAGIC2 '2' #define RPGM_MAGIC2 '5' #define PGM_FORMAT (PGM_MAGIC1 * 256 + PGM_MAGIC2) #define RPGM_FORMAT (PGM_MAGIC1 * 256 + RPGM_MAGIC2) #define PGM_TYPE PGM_FORMAT /* For the alpha-mask variant of PGM: */ #define PGM_TRANSPARENT 0 /* Macro for turning a format number into a type number. */ #define PGM_FORMAT_TYPE(f) ((f) == PGM_FORMAT || (f) == RPGM_FORMAT ? PGM_TYPE : PBM_FORMAT_TYPE(f)) /* Declarations of routines. */ void pgm_init ARGS(( int* argcP, char* argv[] )); #define pgm_allocarray( cols, rows ) ((gray**) pm_allocarray( cols, rows, sizeof(gray) )) #define pgm_allocrow( cols ) ((gray*) pm_allocrow( cols, sizeof(gray) )) #define pgm_freearray( grays, rows ) pm_freearray( (char**) grays, rows ) #define pgm_freerow( grayrow ) pm_freerow( (char*) grayrow ) gray** pgm_readpgm ARGS(( FILE* file, int* colsP, int* rowsP, gray* maxvalP )); void pgm_readpgminit ARGS(( FILE* file, int* colsP, int* rowsP, gray* maxvalP, int* formatP )); void pgm_readpgmrow ARGS(( FILE* file, gray* grayrow, int cols, gray maxval, int format )); void pgm_writepgm ARGS(( FILE* file, gray** grays, int cols, int rows, gray maxval, int forceplain )); void pgm_writepgminit ARGS(( FILE* file, int cols, int rows, gray maxval, int forceplain )); void pgm_writepgmrow ARGS(( FILE* file, gray* grayrow, int cols, gray maxval, int forceplain )); void pgm_nextimage(FILE * const file, int * const eofP); void pgm_check(FILE * file, const enum pm_check_type check_type, const int format, const int cols, const int rows, const int maxval, enum pm_check_code * const retval_p); #endif /*_PGM_H_*/ netpbm-free-10.0-1/include/pm.h0100644004714500471450000001346607717167171016557 0ustar aba-guestaba-guest/* pm.h - interface to format-independent part of libpbm. ** ** Copyright (C) 1988, 1989, 1991 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #ifndef _PM_H_ #define _PM_H_ #include "pm_config.h" #include #include #include #include #include #ifdef VMS #include #endif /* NOTE: do not use "bool" as a type in an external interface. It could have different definitions on either side of the interface. Even if both sides include this interface header file, the conditional compilation here means one side may use the typedef below and the other side may use some other definition. For an external interface, be safe and just use "int". */ #ifndef TRUE #define TRUE 1 #define FALSE 0 /* C++ has a "bool" type built in. */ #ifndef __cplusplus typedef int bool; #endif #elif defined(__DECC) /* Tru64 defines TRUE in standard header files, but not bool. 2001.09.21 */ typedef int bool; #endif #undef max #define max(a,b) ((a) > (b) ? (a) : (b)) #undef min #define min(a,b) ((a) < (b) ? (a) : (b)) #undef abs #define abs(a) ((a) >= 0 ? (a) : -(a)) #undef odd #define odd(n) ((n) & 1) /* Definitions to make Netpbm programs work with either ANSI C or C Classic. This is obsolete, as all compilers recognize the ANSI syntax now. We are slowly removing all the ARGS invocations from the programs (and replacing them with explicit ANSI syntax), but we have a lot of programs where we have removed ARGS from the definition but not the prototype, and we have discovered that the Sun compiler considers the resulting mismatch between definition and prototype to be an error. So we make ARGS create the ANSI syntax unconditionally to avoid having to fix all those mismatches. */ #if 0 #if __STDC__ #define ARGS(alist) alist #else /*__STDC__*/ #define ARGS(alist) () #define const #endif /*__STDC__*/ #endif #define ARGS(alist) alist void pm_init(const char * const progname, unsigned int const flags); void pm_proginit(int* const argcP, char* argv[]); void pm_setMessage(int const newState, int * const oldStateP); void pm_nextimage(FILE * const file, int * const eofP); /* Variable-sized arrays definitions. */ char** pm_allocarray (int const cols, int const rows, int const size ); char* pm_allocrow (int const cols, int const size); void pm_freearray (char** const its, int const rows); void pm_freerow(char* const itrow); /* Obsolete -- use shhopt instead */ int pm_keymatch (char* const str, char* const keyword, int const minchars); int pm_maxvaltobits (int const maxval); int pm_bitstomaxval (int const bits); unsigned int pm_lcm (const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int limit); /* GNU_PRINTF_ATTR lets the GNU compiler check pm_message() and pm_error() calls to be sure the arguments match the format string, thus preventing runtime segmentation faults and incorrect messages. */ #ifdef __GNUC__ #define GNU_PRINTF_ATTR __attribute__ ((format (printf, 1,2))) #else #define GNU_PRINTF_ATTR #endif void GNU_PRINTF_ATTR pm_message (const char format[], ...); void GNU_PRINTF_ATTR pm_error (const char reason[], ...); /* Obsolete - use helpful error message instead */ void pm_perror (const char reason[]); /* Obsolete - use shhopt and man page instead */ void pm_usage (const char usage[]); FILE* pm_openr (const char* const name); FILE* pm_openw (const char* const name); FILE * pm_openr_seekable(const char name[]); void pm_close (FILE* const f); void pm_closer (FILE* const f); void pm_closew (FILE* const f); int pm_readbigshort ( FILE* const in, short* const sP ); int pm_writebigshort ( FILE* const out, short const s ); int pm_readbiglong ( FILE* const in, long* const lP ); int pm_writebiglong ( FILE* const out, long const l ); int pm_readlittleshort ( FILE* const in, short* const sP ); int pm_writelittleshort ( FILE* const out, short const s ); int pm_readlittlelong ( FILE* const in, long* const lP ); int pm_writelittlelong ( FILE* const out, long const l ); char* pm_read_unknown_size(FILE* const file, long* const buf); unsigned int pm_tell(FILE * const fileP); void pm_seek(FILE * const fileP, unsigned long filepos); enum pm_check_code { PM_CHECK_OK, PM_CHECK_UNKNOWN_TYPE, PM_CHECK_TOO_LONG, PM_CHECK_UNCHECKABLE, PM_CHECK_TOO_SHORT }; enum pm_check_type { PM_CHECK_BASIC }; void pm_check(FILE * const file, const enum pm_check_type check_type, const unsigned int need_raster_size, enum pm_check_code * const retval_p); void *malloc2(int, int); void *malloc3(int, int, int); void overflow2(int, int); void overflow3(int, int, int); void overflow_add(int, int); /* By making this <> instead of "", we avoid making shhopt.h a dependency of every program in the package when we do make dep. */ #include /* Use pm_optParseOptions instead of optParseOptions in order to use the shared Netpbm libraries */ void pm_optParseOptions(int * const argc, char *argv[], optStruct opt[], int const allowNegNum); void pm_optParseOptions2(int * const argc, char *argv[], const optStruct2 opt, const unsigned long flags); void pm_optParseOptions3(int * const argc_p, char *argv[], const optStruct3 opt, const unsigned int optStructSize, const unsigned long flags); char * pm_arg0toprogname(const char arg0[]); #endif netpbm-free-10.0-1/include/pm_config.h0100644004714500471450000002632507776237374020112 0ustar aba-guestaba-guest#ifndef _PM_CONFIG_H #define _PM_CONFIG_H /************************************************************************** NETPBM config.h *************************************************************************** This file provides platform-dependent definitions for all Netpbm libraries and the programs that use them. Though it is hardly ever necessary, it is intended that people modify this file to adapt the Netpbm distribution to a particular platform. In the future, Netpbm's 'configure' program may generate this file automatically. Wherever possible, Netpbm handles customization via the make files instead of via this file. However, Netpbm's make file philosophy discourages lining up a bunch of -D options on every compile, so a #define here would be preferable to a -D compile option. **************************************************************************/ /* uint32n is a 32 bit unsigned integer. There are a bunch of other conventional names for this data type, but we don't know any that are available in all compilation environments, or absent in all compilation environments, so we have to make up our own that we hope no one else defines. We don't know today of any environment where "unsigned int" is not 32 bits, but we also don't know that there aren't any, so we have infrastructure here for the eventuality that we find one where uint32n has to be something else. If you understand the standards and conventions for 32 bit vs 64 bit, please enlighten the Netpbm maintainer. 2002.01.16. */ typedef unsigned int uint32n; typedef signed int int32n; #if defined(USG) || defined(SVR4) || defined(VMS) || defined(__SVR4) #define SYSV #endif #if ! ( defined(BSD) || defined(SYSV) || defined(MSDOS) || defined(AMIGA) ) /* CONFIGURE: If your system is >= 4.2BSD, set the BSD option; if you're a ** System V site, set the SYSV option; if you're IBM-compatible, set MSDOS; ** and if you run on an Amiga, set AMIGA. If your compiler is ANSI C, you're ** probably better off setting SYSV - all it affects is string handling. */ #define BSD /* #define SYSV */ /* #define MSDOS */ /* #define AMIGA */ #endif /* Switch macros like _POSIX_SOURCE are supposed to add features from the indicated standard to the C library. A source file defines one of these macros to declare that it uses features of that standard as opposed to conflicting features of other standards (e.g. the POSIX foo() subroutine might do something different from the X/Open foo() subroutine). Plus, this forces the coder to understand upon what feature sets his program relies. But some C library developers have misunderstood this and think of these macros like the old __ansi__ macro, which tells the C library, "Don't have any features that aren't in the ANSI standard." I.e. it's just the opposite -- the macro subtracts features instead of adding them. This means that on some platforms, Netpbm programs must define _POSIX_SOURCE, and on others, it must not. Netpbm's POSIX_IS_IMPLIED macro indicates that we're on a platform where we need not define _POSIX_SOURCE (and probably must not). */ #if defined(__OpenBSD__) || defined (__NetBSD__) || defined(__bsdi__) || defined(__APPLE__) #define POSIX_IS_IMPLIED #endif /* NOTE: do not use "bool" as a type in an external interface. It could have different definitions on either side of the interface. Even if both sides include this interface header file, the conditional compilation here means one side may use the typedef below and the other side may use some other definition. For an external interface, be safe and just use "int". */ /* We used to assume that if TRUE was defined, then bool was too. However, we had a report on 2001.09.21 of a Tru64 system that had TRUE but not bool and on 2002.03.21 of an AIX 4.3 system that was likewise. So now we define bool all the time, unless the macro HAVE_BOOL is defined. If someone is using the Netpbm libraries and also another library that defines bool, he can either make the other library define/respect HAVE_BOOL or just define HAVE_BOOL in the file that includes pm_config.h or with a compiler option. Note that C++ always has bool. */ #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif /* C++ has a "bool" type built in. */ #ifndef __cplusplus #ifndef HAVE_BOOL #define HAVE_BOOL 1 typedef int bool; #endif #endif /* CONFIGURE: If you have an X11-style rgb color names file, define its ** path here. This is used by PPM to parse color names into rgb values. ** If you don't have such a file, comment this out and use the alternative ** hex and decimal forms to specify colors (see ppm/pgmtoppm.1 for details). */ /* There was some evidence before Netpbm 9.1 that the rgb database macros might be already set right now. I couldn't figure out how, so I changed their meanings and they are now set unconditionally. -Bryan 00.05.03. */ #ifdef VMS #define RGB_DB1 "PBMplus_Dir:RGB.TXT" #define RGB_DB2 "PBMplus_Dir:RGB.TXT" #define RGB_DB3 "PBMplus_Dir:RGB.TXT" #else #define RGB_DB1 "/usr/lib/X11/rgb.txt" #define RGB_DB2 "/usr/openwin/lib/rgb.txt" #define RGB_DB3 "/usr/X11R6/lib/X11/rgb.txt" #endif /* CONFIGURE: This is the name of an environment variable that tells ** where the color names database is. If the environment variable isn't ** set, Netpbm tries the hardcoded defaults set above. */ #define RGBENV "RGBDEF" /* name of env-var */ /* CONFIGURE: Normally, PPM handles a pixel as a struct of three grays. ** If grays are represented as chars, that's 24 bits per color pixel; if ** grays are represented as ints, that's usually 96 bits per color pixel. PPM ** can be modified to pack the three samples into a single longword, ** 10 bits each, for 32 bits per pixel. ** ** If you don't need more than 10 bits for each color component, AND ** you care more about memory use than speed, then this option might ** be a win. Under these circumstances it will make some of the ** programs use 3 times less space, but all of the programs will run ** slower. In one test, it was 1.4 times slower. ** */ /* #define PPM_PACKCOLORS */ /* CONFIGURE: uncomment this to enable debugging checks. */ /* #define DEBUG */ #if ( defined(SYSV) || defined(AMIGA) ) #include /* Before Netpbm 9.1, rand and srand were macros for random and srandom here. This caused a failure on a SunOS 5.6 system, which is SYSV, but has both rand and random declared (with different return types). The macro caused the prototype for random to be a second prototype for rand. Before 9.1, Netpbm programs called random() and on a SVID system, that was really a call to rand(). We assume all modern systems have rand() itself, so now Netpbm always calls rand() and if we find a platform that doesn't have rand(), we will add something here for that platform. -Bryan 00.04.26 #define random rand #define srandom(s) srand(s) extern void srand(); extern int rand(); */ /* Before Netpbm 9.15, there were macro definitions of index() and rindex() here, but there are no longer any invocations of those functions in Netpbm, except in the VMS-only code, so there's no reason for them. */ #ifndef __SASC #ifndef _DCC /* Amiga DICE Compiler */ #define bzero(dst,len) memset(dst,0,len) #define bcopy(src,dst,len) memcpy(dst,src,len) #define bcmp memcmp #endif /* _DCC */ #endif /* __SASC */ #endif /*SYSV or AMIGA*/ #include #include #include #include /* Before Netpbm 9.0, atoi() and exit() were declared for everybody except MSDOS and AMIGA, and time() and write() were declared for everybody except MSDOS, AMIGA, and __osf__. fcntl.h, time.h, and stlib.h were included for MSDOS and AMIGA, and unistd.h was included for everyone except VMS, MSDOS, and AMIGA. With the netbsd patches, atoi(), exit(), time(), and write() were not declared for __NetBSD__. We're hoping that all current systems have the standard header files, and will reinstate some of these explicit declarations if we hear otherwise. If it turns out to be this easy, we should just move these inclusions to the source files that actually need them. -Bryan 2000.04.13 extern int atoi(); extern void exit(); extern long time(); extern int write(); */ /* CONFIGURE: On most BSD systems, malloc() gets declared in stdlib.h, on ** system V, it gets declared in malloc.h. On some systems, malloc.h ** doesn't declare these, so we have to do it here. On other systems, ** for example HP/UX, it declares them incompatibly. And some systems, ** for example Dynix, don't have a malloc.h at all. A sad situation. ** If you have compilation problems that point here, feel free to tweak ** or remove these declarations. */ #ifdef BSD #include #endif #if (defined(SYSV) && !defined(VMS)) #include #endif /* extern char* malloc(); */ /* extern char* realloc(); */ /* extern char* calloc(); */ /* CONFIGURE: Some systems don't have vfprintf(), which we need for the ** error-reporting routines. If you compile and get a link error about ** this routine, uncomment the first define, which gives you a vfprintf ** that uses the theoretically non-portable but fairly common routine ** _doprnt(). If you then get a link error about _doprnt, or ** message-printing doesn't look like it's working, try the second ** define instead. */ /* #define NEED_VFPRINTF1 */ /* #define NEED_VFPRINTF2 */ /* CONFIGURE: Some systems don't have strstr(), which some routines need. ** If you compile and get a link error about this routine, uncomment the ** define, which gives you a strstr. */ /* #define NEED_STRSTR */ /* CONFIGURE: Set this option if your compiler uses strerror(errno) ** instead of sys_errlist[errno] for error messages. */ #define A_STRERROR /* CONFIGURE: On small systems without VM it is possible that there is ** enough memory for a large array, but it is fragmented. So the usual ** malloc( all-in-one-big-chunk ) fails. With this option, if the first ** method fails, pm_allocarray() tries to allocate the array row by row. */ /* #define A_FRAGARRAY */ /* CONFIGURE: If your system has the setmode() function, set HAVE_SETMODE. ** If you do, and also the O_BINARY file mode, pm_init() will set the mode ** of stdin and stdout to binary for all Netpbm programs. ** You need this with Cygwin (Windows). */ #ifdef __CYGWIN__ #define HAVE_SETMODE #endif /* #define HAVE_SETMODE */ #ifdef AMIGA #include #define getpid(x) ((long)FindTask(NULL)) #endif /* AMIGA */ #ifdef DJGPP #define HAVE_SETMODE #define lstat stat #endif /* DJGPP */ /* CONFIGURE: Netpbm uses __inline__ to declare functions that should be compiled as inline code. GNU C recognizes the __inline__ keyword. If your compiler recognizes any other keyword for this, you can set it here. */ #ifndef __GNUC__ #ifndef __inline__ #ifdef __sgi #define __inline__ __inline #else #define __inline__ #endif #endif #endif /* CONFIGURE: Some systems seem to need more than standard program linkage to get a data (as opposed to function) item out of a library. On Windows mingw systems, it seems you have to #include and #define EXTERNDATA DLL_IMPORT . 2001.05.19 */ #define EXTERNDATA extern #endif netpbm-free-10.0-1/include/pnm.h0100644004714500471450000000442607717167171016731 0ustar aba-guestaba-guest/* pnm.h - header file for libpnm portable anymap library */ #ifndef _PNM_H_ #define _PNM_H_ #include "ppm.h" typedef pixel xel; typedef pixval xelval; #define PNM_OVERALLMAXVAL PPM_OVERALLMAXVAL #define PNM_MAXMAXVAL PPM_MAXMAXVAL #define PNM_GET1(x) PPM_GETB(x) #define PNM_ASSIGN1(x,v) PPM_ASSIGN(x,0,0,v) #define PNM_ASSIGN(x,r,g,b) PPM_ASSIGN(x,r,g,b) #define PNM_EQUAL(x,y) PPM_EQUAL(x,y) #define PNM_FORMAT_TYPE(f) PPM_FORMAT_TYPE(f) /* Declarations of routines. */ void pnm_init ARGS(( int* argcP, char* argv[] )); void pnm_nextimage(FILE *file, int * const eofP); #define pnm_allocarray( cols, rows ) ((xel**) pm_allocarray( cols, rows, sizeof(xel) )) #define pnm_allocrow( cols ) ((xel*) pm_allocrow( cols, sizeof(xel) )) #define pnm_freearray( xels, rows ) pm_freearray( (char**) xels, rows ) #define pnm_freerow( xelrow ) pm_freerow( (char*) xelrow ) xel** pnm_readpnm ARGS(( FILE* file, int* colsP, int* rowsP, xelval* maxvalP, int* formatP )); void pnm_readpnminit ARGS(( FILE* file, int* colsP, int* rowsP, xelval* maxvalP, int* formatP )); void pnm_readpnmrow ARGS(( FILE* file, xel* xelrow, int cols, xelval maxval, int format )); void pnm_writepnm ARGS(( FILE* file, xel** xels, int cols, int rows, xelval maxval, int format, int forceplain )); void pnm_writepnminit ARGS(( FILE* file, int cols, int rows, xelval maxval, int format, int forceplain )); void pnm_writepnmrow ARGS(( FILE* file, xel* xelrow, int cols, xelval maxval, int format, int forceplain )); void pnm_check(FILE * file, const enum pm_check_type check_type, const int format, const int cols, const int rows, const int maxval, enum pm_check_code * const retval_p); xel pnm_backgroundxel (xel** xels, int cols, int rows, xelval maxval, int format); xel pnm_backgroundxelrow (xel* xelrow, int cols, xelval maxval, int format); xel pnm_whitexel (xelval maxval, int format); xel pnm_blackxel(xelval maxval, int format); void pnm_invertxel(xel* x, xelval maxval, int format); void pnm_promoteformat(xel** xels, int cols, int rows, xelval maxval, int format, xelval newmaxval, int newformat); void pnm_promoteformatrow(xel* xelrow, int cols, xelval maxval, int format, xelval newmaxval, int newformat); pixel xeltopixel(xel const inputxel); #endif /*_PNM_H_*/ netpbm-free-10.0-1/include/ppm.h0100644004714500471450000001022007717167171016720 0ustar aba-guestaba-guest/* ppm.h - header file for libppm portable pixmap library */ #ifndef _PPM_H_ #define _PPM_H_ #include "pgm.h" typedef gray pixval; #ifdef PPM_PACKCOLORS #define PPM_MAXMAXVAL 1023 typedef unsigned long pixel; #define PPM_GETR(p) (((p) & 0x3ff00000) >> 20) #define PPM_GETG(p) (((p) & 0xffc00) >> 10) #define PPM_GETB(p) ((p) & 0x3ff) /************* added definitions *****************/ #define PPM_PUTR(p, red) ((p) |= (((red) & 0x3ff) << 20)) #define PPM_PUTG(p, grn) ((p) |= (((grn) & 0x3ff) << 10)) #define PPM_PUTB(p, blu) ((p) |= ( (blu) & 0x3ff)) /**************************************************/ #define PPM_ASSIGN(p,red,grn,blu) (p) = ((pixel) (red) << 20) | ((pixel) (grn) << 10) | (pixel) (blu) #define PPM_EQUAL(p,q) ((p) == (q)) #else /*PPM_PACKCOLORS*/ #define PPM_OVERALLMAXVAL PGM_OVERALLMAXVAL #define PPM_MAXMAXVAL PGM_MAXMAXVAL typedef struct { pixval r, g, b; } pixel; #define PPM_GETR(p) ((p).r) #define PPM_GETG(p) ((p).g) #define PPM_GETB(p) ((p).b) /************* added definitions *****************/ #define PPM_PUTR(p,red) ((p).r = (red)) #define PPM_PUTG(p,grn) ((p).g = (grn)) #define PPM_PUTB(p,blu) ((p).b = (blu)) /**************************************************/ #define PPM_ASSIGN(p,red,grn,blu) do { (p).r = (red); (p).g = (grn); (p).b = (blu); } while ( 0 ) #define PPM_EQUAL(p,q) ( (p).r == (q).r && (p).g == (q).g && (p).b == (q).b ) #endif /*PPM_PACKCOLORS*/ /* Magic constants. */ #define PPM_MAGIC1 'P' #define PPM_MAGIC2 '3' #define RPPM_MAGIC2 '6' #define PPM_FORMAT (PPM_MAGIC1 * 256 + PPM_MAGIC2) #define RPPM_FORMAT (PPM_MAGIC1 * 256 + RPPM_MAGIC2) #define PPM_TYPE PPM_FORMAT /* Macro for turning a format number into a type number. */ #define PPM_FORMAT_TYPE(f) ((f) == PPM_FORMAT || (f) == RPPM_FORMAT ? PPM_TYPE : PGM_FORMAT_TYPE(f)) /* Declarations of routines. */ void ppm_init ARGS(( int* argcP, char* argv[] )); #define ppm_allocarray( cols, rows ) ((pixel**) pm_allocarray( cols, rows, sizeof(pixel) )) #define ppm_allocrow( cols ) ((pixel*) pm_allocrow( cols, sizeof(pixel) )) #define ppm_freearray( pixels, rows ) pm_freearray( (char**) pixels, rows ) #define ppm_freerow( pixelrow ) pm_freerow( (char*) pixelrow ) pixel** ppm_readppm ARGS(( FILE* file, int* colsP, int* rowsP, pixval* maxvalP )); void ppm_readppminit ARGS(( FILE* file, int* colsP, int* rowsP, pixval* maxvalP, int* formatP )); void ppm_readppmrow ARGS(( FILE* file, pixel* pixelrow, int cols, pixval maxval, int format )); void ppm_writeppm ARGS(( FILE* file, pixel** pixels, int cols, int rows, pixval maxval, int forceplain )); void ppm_writeppminit ARGS(( FILE* file, int cols, int rows, pixval maxval, int forceplain )); void ppm_writeppmrow ARGS(( FILE* file, pixel* pixelrow, int cols, pixval maxval, int forceplain )); void ppm_check(FILE * file, const enum pm_check_type check_type, const int format, const int cols, const int rows, const int maxval, enum pm_check_code * const retval_p); void ppm_nextimage(FILE *file, int * const eofP); pixel ppm_parsecolor ARGS(( char* colorname, pixval maxval )); char* ppm_colorname ARGS(( pixel* colorP, pixval maxval, int hexok )); /* Color scaling macro -- to make writing ppmtowhatever easier. */ #define PPM_DEPTH(newp,p,oldmaxval,newmaxval) \ PPM_ASSIGN( (newp), \ ( (int) PPM_GETR(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval), \ ( (int) PPM_GETG(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval), \ ( (int) PPM_GETB(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval) ) /* Luminance, Chrominance macros. */ /* The following are weights of the red, green, and blue components respectively in the luminosity of a color */ #define PPM_LUMINR (0.2989) #define PPM_LUMING (0.5866) #define PPM_LUMINB (0.1145) #define PPM_LUMIN(p) ( PPM_LUMINR * PPM_GETR(p) \ + PPM_LUMING * PPM_GETG(p) \ + PPM_LUMINB * PPM_GETB(p) ) #define PPM_CHROM_R(p) ( 0.5 * PPM_GETR(p) \ - 0.41869 * PPM_GETG(p) \ - 0.08131 * PPM_GETB(p) ) #define PPM_CHROM_B(p) ( -0.16874 * PPM_GETR(p) \ - 0.33126 * PPM_GETG(p) \ + 0.5 * PPM_GETB(p) ) #endif /*_PPM_H_*/ netpbm-free-10.0-1/include/ppmcmap.h0100644004714500471450000000541607717167171017574 0ustar aba-guestaba-guest/* ppmcmap.h - header file for colormap routines in libppm */ /* Color histogram stuff. */ typedef struct colorhist_item* colorhist_vector; struct colorhist_item { pixel color; int value; }; typedef struct colorhist_list_item* colorhist_list; struct colorhist_list_item { struct colorhist_item ch; colorhist_list next; }; colorhist_vector ppm_computecolorhist( pixel ** const pixels, const int cols, const int rows, const int maxcolors, int * const colorsP ); colorhist_vector ppm_computecolorhist2(FILE * const ifp, const int cols, const int rows, const pixval maxval, const int format, const int maxcolors, int * const colorsP ); void ppm_addtocolorhist( colorhist_vector chv, int * const colorsP, const int maxcolors, const pixel * const colorP, const int value, const int position ); void ppm_freecolorhist( colorhist_vector chv ); /* Color hash table stuff. */ typedef colorhist_list* colorhash_table; colorhash_table ppm_computecolorhash( pixel ** const pixels, const int cols, const int rows, const int maxcolors, int * const colorsP ); colorhash_table ppm_computecolorhash2(FILE * const ifp, const int cols, const int rows, const pixval maxval, const int format, const int maxcolors, int * const colorsP ); int ppm_lookupcolor( const colorhash_table cht, const pixel * const colorP ); colorhist_vector ppm_colorhashtocolorhist( const colorhash_table cht, const int maxcolors ); colorhash_table ppm_colorhisttocolorhash( const colorhist_vector chv, const int colors ); int ppm_addtocolorhash( colorhash_table cht, const pixel * const colorP, const int value ); /* Returns -1 on failure. */ colorhash_table ppm_alloccolorhash( ); void ppm_freecolorhash( colorhash_table cht ); colorhash_table ppm_colorrowtocolorhash ARGS((pixel *colorrow, int ncolors)); pixel * ppm_computecolorrow ARGS((pixel **pixels, int cols, int rows, int maxcolors, int *ncolorsP)); pixel * ppm_mapfiletocolorrow ARGS((FILE *file, int maxcolors, int *ncolorsP, pixval *maxvalP)); void ppm_colorrowtomapfile ARGS((FILE *ofp, pixel *colormap, int ncolors, pixval maxval)); void ppm_sortcolorrow (pixel * const colorrow, const int ncolors, int (*cmpfunc)(pixel *, pixel *) ); int ppm_addtocolorrow ARGS((pixel *colorrow, int *ncolorsP, int maxcolors, pixel *pixelP)); int ppm_findclosestcolor ARGS((pixel *colorrow, int ncolors, pixel *pP)); /* standard sort function for ppm_sortcolorrow() */ #define PPM_STDSORT (int (*)(pixel *, pixel *))0 netpbm-free-10.0-1/include/ppmfloyd.h0100644004714500471450000000213007717657506017765 0ustar aba-guestaba-guest/* These declarations were supposed to be in the libfloyd.h file in the ilbm package, but that file was missing, so I made them up myself. - Bryan 01.03.10. */ struct ppm_fs_info { /* thisXerr and nextXerr are dynamically allocated arrays each of whose dimension is the width of the image plus 2 */ long *thisrederr; long *thisgreenerr; long *thisblueerr; long *nextrederr; long *nextgreenerr; long *nextblueerr; int lefttoright; int cols; pixval maxval; int flags; pixel *pixrow; int col_end; pixval red, green, blue; }; typedef struct ppm_fs_info ppm_fs_info; /* Bitmasks for ppm_fs_info.flags */ #define FS_RANDOMINIT 0x01 #define FS_ALTERNATE 0x02 ppm_fs_info * ppm_fs_init(int cols, pixval maxval, int flags); void ppm_fs_free(ppm_fs_info *fi); int ppm_fs_startrow(ppm_fs_info *fi, pixel *pixrow); int ppm_fs_next(ppm_fs_info *fi, int col); void ppm_fs_endrow(ppm_fs_info *fi); void ppm_fs_update( ppm_fs_info *fi, int col, pixel *pP); void ppm_fs_update3(ppm_fs_info *fi, int col, pixval r, pixval g, pixval b); netpbm-free-10.0-1/include/version.h0100644004714500471450000000014207776237374017623 0ustar aba-guestaba-guest/* version.h - define the current version of the package */ #define NETPBM_VERSION "Netpbm 10.0" netpbm-free-10.0-1/mainttools/0040755004714500471450000000000007776237751016540 5ustar aba-guestaba-guestnetpbm-free-10.0-1/mainttools/makefiltersfile0100755004714500471450000000261307776237374021634 0ustar aba-guestaba-guest#! /usr/bin/perl -w print ".TH pbmfilters 1 \"08 February 1994\" .IX pbmfilters .SH NAME pbmfilters - list of all programs in the netpbm package .SH DESCRIPTION "; open(LS, "ls -l $ARGV[0] |") || die "Cant ls"; ; # total ... while() { chomp; @a=split ; # print STDERR "$a[0] $a[8]\n"; ($a[8] =~ /netpbm.1/) && (next); ($a[8] =~ /pbmfilters.1/) && (next); if ($a[0] =~ /^l/) { # symbolic link $a[8] =~ s/.1.gz//; $a[10] =~ s/.1.gz//; print ".TP\n.B $a[8] (deprecated)\nis replaced by $a[10](1)\n"; ; } else { if (!(open(IN, "zcat $ARGV[0]/$a[8] |"))) { print STDERR "Cant open $a[8]\n"; next; } $a=; while (defined($a) && ($a !~ / .?- /)) { $a=; } if (!(defined($a))) { print STDERR "Cant find line in $a[8]\n"; next; } $a[8] =~ s/.1.gz//; # print STDERR "in: $a\n"; chomp($a); if (!($a =~ /^([^ ]+) .?- (.*)/)) { print STDERR "Parsing error $a[8]\n"; print STDERR "Text was: $a\n"; next; } print ".TP\n.B $1\n$2\n"; push @b, $1; if ($1 ne $a[8]) { print STDERR "Warning: wrong name $1 vs $a[8]\n"; } } } print "\n\n.SH \"SEE ALSO\"\n"; $a = pop @b; foreach $i (@b) { print "$i(1),\n"; } print "$a(1).\n"; print "\n\n"; print ".SH AUTHORS Many. See the individual manual pages. .\\\" All programms are free (as defined by the DFSG), but have different .\\\" licences. Please see for details the individual manpages. "; netpbm-free-10.0-1/mainttools/re-source-bryan0100755004714500471450000000241007776237374021476 0ustar aba-guestaba-guest#! /bin/bash set -e if [ -d movedir ]; then rm -rf movedir; fi cp -avl netpbm-10.0 movedir cd movedir find -name 'Makefile*' -exec rm '{}' ';' find -type l -exec rm '{}' ';' mv converter/pbm converter/ppm converter/pgm . mkdir pnm/ mv converter/other/jbig converter/other/pnmtopalm/ converter/other/fiasco/ pnm/ mv doc/* . mv converter/other/README.JPEG . mv lib/bitio.* pbm/ mv converter/bmp.h . mv converter/other/dithers.h pgm/ mv converter/other/*topnm* pnm/ mv converter/other/pgmtopbm.c pgm/ mv converter/other/pgmtoppm.c ppm/ mv converter/other/exif.* converter/other/rast.* pnm/ mv converter/other/sgi.h pnm/ mv converter/other/pbmtopgm.c pbm/ mv lib/*pbm* editor/pbm* generator/pbm* pbm/ mv lib/*pnm* editor/pnm* analyzer/pnm* other/pnm* converter/other/pnm* pnm/ mv lib/*pgm* editor/pgm* generator/pgm* analyzer/pgm* pgm/ mv lib/*ppm* editor/ppm* generator/ppm* analyzer/ppm* other/ppm* converter/other/ppm* ppm/ mv lum.h ppm/ mv lib/pm.h lib/libpm.c pbm/ mv lib/*pam* other/pam* editor/pam* analyzer/pam* converter/other/pam* pnm/ mv pbm/pbmtopgm.c pgm/ mkdir shhopt mv lib/util/*shhopt* shhopt/ mv converter/other/x1* pnm/ mv pnm/fiasco/fiascotopnm.c pnm/fiasco/dwfa.c mv pnm/fiasco/pnmtofiasco.c pnm/fiasco/cwfa.c find . -type f -printf '%f %P\n' | sort > ../files-10.0 netpbm-free-10.0-1/pbm/0040755004714500471450000000000007776237751015125 5ustar aba-guestaba-guestnetpbm-free-10.0-1/pbm/pbmtoppa/0040755004714500471450000000000007776237751016747 5ustar aba-guestaba-guestnetpbm-free-10.0-1/pbm/pbmtoppa/INSTALL-MORE0100644004714500471450000001217107716230207020516 0ustar aba-guestaba-guestInstallation of ppa-0.8.5 with S.u.S.E. Linux (Special Installation with Hp820 and paper size A4) ___________________________________________________ 0. Introduction This text describes how to use the package pbm2ppa written by Tim Norman with the S.u.S.E Linux System. This program allows the use of GDI (Winows only) printers with Linux. The program pbm2ppa is actually a converter between the two formats pbm (an output format from ghostscript) and the format understood by the HP printers 720, 820 and 1000. So anyway we have to use ghostscript to produce pbm (or faster: pbmraw) files. To print ascii files there is an extra step invoking enscript to convert the ascii to postscript files. I rather constructed two new printer spoolers in printcap from scratch then using apsfilter: one for postscript files and another for ascii files. I welcome solutions in combination with the apsfilter script. The installation is quiet easy - after seven steps you should be ready to print postscript and ascii files, but it may take some time to adjust the constants properly, don't despair. 0.1. Modifications This was modified on October 18, 1998 by Tim Norman to conform to the new A4 paper support in version 0.8.5. 1. Installation of program package ppa-0.8.5 Get the packate at http://www.rpi.edu/~normat/technical/ppa/ and compile it with # make 820 or put in your printer number (720, 820 or 1000) (see also INSTALL and README file). 2. To adjust the paper size to DIN A4, use the -s a4 option to pbm2ppa or change your pbm2ppa.conf file to read "papersize a4" (see step 5). 3. You can now calibrate the printer with For US size paper: # pbmtpg | pbm2ppa > /dev/lp1 ( as root ) For A4 size paper: # pbmtpg -a4 | pbm2ppa -s a4 > /dev/lp1 ( as root ) or you try first printing some sample files and calibrate in step 5. 4. Now you can print (postscript) files with a shell script like this: Contents of print: cat $1 | gs -sDEVICE=pbmraw -q -dNOPAUSE -r600 -sOutputFile=- - | \ pbm2ppa - - >/dev/lp1 After changing the file modes (i.e. chmod 755 print) you are able to print a postscript file invoking the shell script print like: # print filename.ps To print ascii files just extend the script print with the use of enscript: Contents of printascii: enscript -2rj -p- $1 | \ gs -sDEVICE=pbmraw -q -dNOPAUSE -r600 -sOutputFile=- - | \ pbm2ppa - - >/dev/lp1 Check the manpage for enscript to adjust the options to your flavour. Now you can also print ascii files with # printascii filename.ascii 5. It may be possible that you have to recalibrate your printer (see 3.) Here follow the results from my calibration after printing ascii files with the shell script printascii (see 4.). The program pbm2ppa takes the arguments in the following order: 1. shell arguments 2. config file /etc/pbm2ppa.conf 3. Compiled options from default.h So whenever you invoke pbm2ppa without arguments the program uses the options stored in the file /etc/pbm2ppa.conf, so I suggest to leave there a copy of this file. # Sample configuration file for the HP820 and DIN A4 paper size # # This file will be automatically read upon startup if it's placed in # /etc/pbm2ppa.conf # version 820 papersize a4 xoff 0 # \ Adjust these for your printer. yoff -600 # / (see CALIBRATE) # 1/4 inch margins all around (at 600 DPI) top 50 bottom 50 left 50 right 50 6. To integrate the converter into the Linux system we create two printer spooler in /etc/printcap. One to print postscript files and another to print plain ascii files. Contents of /etc/printcap: lp:\ :lp=/dev/lp1:\ :sd=/var/spool/lpd/lp:\ :lf=/var/spool/lpd/lp/log:\ :af=/var/spool/lpd/lp/acct:\ :if=/usr/local/bin/ps.if:\ :la:mx#0:\ :sh:sf: ascii:\ :lp=/dev/lp1:\ :sd=/var/spool/lpd/ascii:\ :lf=/var/spool/lpd/ascii/log:\ :af=/var/spool/lpd/ascii/acct:\ :if=/usr/local/bin/ascii.if:\ :la:mx#0:\ :sh:sf: Here follow some explanations (for more information consult the printcap manpage). We use the lp1 device, have two spool directories /var/spool/lpd/ascii and /var/spool/lpd/lp (better you create them now) a log file (lf) an accounting file (af), suppress form feeds (sf), suppress printing of burst page header (sh) and the maximum file size is unlimited (mx#0). To integrate the converter pbm2ppa into the system we use two input filters. Maybe you have a better solution in combination with apsfilter but until then try this way. Actually, the two input filter files are almost identical with the shell scripts print and printascii we created in step 4. File /usr/local/bin/ascii.if: #! /bin/sh enscript -2rj -p- | \ gs -sDEVICE=pbmraw -q -dNOPAUSE -r600 -sOutputFile=- - | \ /usr/local/bin/pbm2ppa - - File /usr/local/bin/ps.if: #! /bin/sh gs -sDEVICE=pbmraw -q -dNOPAUSE -r600 -sOutputFile=- - | \ /usr/local/bin/pbm2ppa - - 7. Place pbm2ppa in the directory /usr/local/bin. Now you are ready to print files with # lpr filename.ps and # lpr -P ascii filename.ascii like you are used to it. Enjoy 19. May 1998 Michael Buehlmann Badenerstrasse 285 8003 Zuerich Switzerland mbuehlma@stud.ee.ethz.ch netpbm-free-10.0-1/pbm/pbmtoppa/CREDITS0100644004714500471450000000055107716230207017744 0ustar aba-guestaba-guestCREDITS ------- This project would not be where it is without the help of the following people: Ben Boule - first contacted me about the 720 series and helped with testing Jim Peterson - spent hours modifying the code for the 720 and adding lots of features, including all the configurability options. Kirk Reiten - helped with testing the 1000 series code netpbm-free-10.0-1/pbm/pbmtoppa/Makefile0100644004714500471450000000072607724372231020373 0ustar aba-guestaba-guestSRCDIR = ../.. BUILDDIR = $(SRCDIR) include $(BUILDDIR)/Makefile.config INCLUDE = -I$(SRCDIR)/shhopt -I$(SRCDIR)/include/ all: pbmtoppa merge: pbmtoppa pbmtoppa: pbmtoppa.o ppa.o pbm.o cutswath.o $(NETPBMLIB) $(LD) $(LDFLAGS) -o pbmtoppa pbmtoppa.o ppa.o pbm.o cutswath.o \ -L$(SRCDIR)/lib/shared/ $(NETPBMLIB) %.o: %.c $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ BINARIES=pbmtoppa MANUALS1=pbmtoppa include $(SRCDIR)/Makefile.common clean: clean.common FORCE: netpbm-free-10.0-1/pbm/pbmtoppa/LICENSE0100644004714500471450000004400007716230207017726 0ustar aba-guestaba-guest GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. netpbm-free-10.0-1/pbm/pbmtoppa/Makefile.depend0100644004714500471450000000000007716230207021607 0ustar aba-guestaba-guestnetpbm-free-10.0-1/pbm/pbmtoppa/README.Netpbm0100644004714500471450000000227307716230207021033 0ustar aba-guestaba-guestPbmtoppa was integrated into the Netpbm package in May 2000 by Bryan Henderson. He took it from Tim Norton's pbm2ppa-0.8.6 package dated October 1998. Tim licenses the subject package to the public as described in the LICENSE file. The difference between what's in Netpbm and what was distributed by Tim is: - Tim called it 'pbm2ppa' Netpbm calls it 'pbmtoppa', to fit Netpbm naming conventions. - Tim's package included the program Pbmtpg, but the Netpbm directory doesn't include that. The program was integrated separately into Netpbm as Pbmpage. - Tim's package generated 3 different versions of Pbmtoppa, one for each of the 720, 820 or 1000 printer models. (They only differed in their default parameters). The netpbm version has only one Pbmtoppa, and the (existing) -v option selects defaults for the specified printer model. - Tim didn't have a man page. His package had several other documentation files, though, which are not in the Netpbm package because the information is either specific to Tim's packaging or the information in in the Netpbm man page. - Jozsef Marak's extension to handle draft (300 dpi) printing is included. netpbm-free-10.0-1/pbm/pbmtoppa/README.REDHAT0100644004714500471450000000203107716230207020545 0ustar aba-guestaba-guestRedHat users may find the following tip from Panayotis Vryonis helpful! Here is a tip to intergrate HP720C support in RedHat's printtool: Install pbm2ppa. Copy pbm2ppa to /usr/bin. Edit "printerdb" (in my system it is found in /usr/lib/rhs/rhs-printfilters ) and append the following lines: ----------------------Cut here ------------------------------------------- StartEntry: DeskJet720C GSDriver: pbm Description: {HP DeskJet 720C} About: { \ This driver supports the HP DeskJet 720C inkjet printer. \ It does does not support color printing. \ IMPORTANT! Insert \ "- | pbm2ppa -" \ in the "Extra GS Otions" field.\ } Resolution: {600} {600} {} EndEntry -------------------------------------------------------------------------- Now you can add an HP720C printer just like any other, using printtool. [Author's Note: The same should work for the 820 and 1000, but it hasn't been tested. Also, use the pbmraw GSDriver if you have it; it's faster. ] netpbm-free-10.0-1/pbm/pbmtoppa/cutswath.c0100644004714500471450000002053107716762513020744 0ustar aba-guestaba-guest/* cutswath.c * functions to cut a swath of a PBM file for PPA printers * Copyright (c) 1998 Tim Norman. See LICENSE for details. * 3-15-98 * * Mar 15, 1998 Jim Peterson * * Structured to accommodate both the HP820/1000, and HP720 series. */ #include #include #include #include "ppa.h" #include "ppapbm.h" #include "cutswath.h" extern int Width; extern int Height; extern int Pwidth; /* sweep_data->direction must be set already */ /* Upon successful completion, sweep_data->image_data and sweep_data->nozzle_data have been set to pointers which this routine malloc()'d. */ /* Upon successful completion, all members of *sweep_data have been set except direction, vertical_pos, and next. */ /* Returns: 0 if unsuccessful 1 if successful, but with non-printing result (end of page) 2 if successful, with printing result */ int cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_data) { unsigned char *data, *ppa, *place, *maxplace; int p_width, width8, p_width8; int i, j, left, right, got_nonblank, numlines; int horzpos, hp2; int shift; ppa_nozzle_data nozzles[2]; /* shift = 6 if DPI==300 */ /* shift = 12 if DPI==600 */ shift = ( prn->DPI == 300 ? 6:12 ) ; /* safeguard against the user freeing these */ sweep_data->image_data=NULL; sweep_data->nozzle_data=NULL; /* read the data from the input file */ width8 = (pbm->width + 7) / 8; /* fprintf(stderr,"cutswath(): width=%u\n",pbm->width); fprintf(stderr,"cutswath(): height=%u\n",pbm->height); */ if ((data=malloc(width8*maxlines)) == NULL) { fprintf(stderr,"cutswath(): could not malloc data storage\n"); return 0; } /* ignore lines that are above the upper margin */ while(pbm->current_line < prn->top_margin) if(!pbm_readline(pbm,data)) { fprintf(stderr,"cutswath(): A-could not read top margin\n"); free(data); return 0; } /* eat all lines that are below the lower margin */ if(pbm->current_line >= Height - prn->bottom_margin) { while(pbm->current_line < pbm->height) if(!pbm_readline(pbm,data)) { fprintf(stderr,"cutswath(): could not clear bottom margin\n"); free(data); return 0; } free(data); return 1; } left = Pwidth-prn->right_margin/8; right = prn->left_margin/8; /* eat all beginning blank lines and then up to maxlines or lower margin */ got_nonblank=numlines=0; while( (pbm->current_line < Height-prn->bottom_margin) && (numlines < maxlines) ) { if(!pbm_readline(pbm,data+width8*numlines)) { fprintf(stderr,"cutswath(): B-could not read next line\n"); free(data); return 0; } if(!got_nonblank) for(j=prn->left_margin/8; jleft_margin/8; i < left; i++) if (data[width8*numlines+i]) { newleft = i; break; } /* find right-most nonblank */ for (i = Pwidth-prn->right_margin/8-1; i >= right; i--) if (data[width8*numlines+i]) { newright = i; break; } numlines++; if (newright < newleft) { fprintf (stderr, "Ack! newleft=%d, newright=%d, left=%d, right=%d\n", newleft, newright, left, right); free (data); return 0; } /* if the next line might push us over the buffer size, stop here! */ /* ignore this test for the 720 right now. Will add better */ /* size-guessing for compressed data in the near future! */ if (numlines % 2 == 1 && prn->version != HP720) { int l = newleft, r = newright, w; l--; r+=2; l*=8; r*=8; w = r-l; w = (w+7)/8; if ((w+2*shift)*numlines > prn->bufsize) { numlines--; pbm_unreadline (pbm, data+width8*numlines); break; } else { left = newleft; right = newright; } } else { left = newleft; right = newright; } } } if(!got_nonblank) { /* eat all lines that are below the lower margin */ if(pbm->current_line >= Height - prn->bottom_margin) { while(pbm->current_line < pbm->height) if(!pbm_readline(pbm,data)) { fprintf(stderr,"cutswath(): could not clear bottom margin\n"); free(data); return 0; } free(data); return 1; } free(data); return 0; /* error, since didn't get to lower margin, yet blank */ } /* make sure numlines is even and >= 2 (b/c we have to pass the printer HALF of the number of pins used */ if (numlines == 1) { /* there's no way that we only have 1 line and not enough memory, so we're safe to increase numlines here. Also, the bottom margin should be > 0 so we have some lines to read */ if(!pbm_readline(pbm,data+width8*numlines)) { fprintf(stderr,"cutswath(): C-could not read next line\n"); free(data); return 0; } numlines++; } if (numlines % 2 == 1) { /* decrease instead of increasing so we don't max out the buffer */ numlines--; pbm_unreadline (pbm, data+width8*numlines); } /* calculate vertical position */ sweep_data->vertical_pos = pbm->current_line; /* change sweep params */ left--; right+=2; left *= 8; right *= 8; /* construct the sweep data */ p_width = right - left; p_width8 = (p_width + 7) / 8; if ((ppa = malloc ((p_width8+2*shift) * numlines)) == NULL) { fprintf(stderr,"cutswath(): could not malloc ppa storage\n"); free (data); return 0; } place = ppa; /* place 0's in the first 12 columns */ memset (place, 0, numlines/2 * shift); place += numlines/2 * shift; if(sweep_data->direction == right_to_left) /* right-to-left */ { for (i = p_width8+shift-1; i >= 0; i--) { if (i >= shift) { for (j = 0; j < numlines/2; j++) *place++ = data[j*2*width8 + i + left/8-shift]; } else { memset (place, 0, numlines/2); place += numlines/2; } if (i < p_width8) { for (j = 0; j < numlines/2; j++) *place++ = data[(j*2+1)*width8 + i + left/8]; } else { memset (place, 0, numlines/2); place += numlines/2; } } } else /* sweep_data->direction == left_to_right */ { for (i = 0; i < p_width8+shift; i++) { if (i < p_width8) { for (j = 0; j < numlines/2; j++) *place++ = data[(j*2+1)*width8 + i + left/8]; } else { memset (place, 0, numlines/2); place += numlines/2; } if (i >= shift) { for (j = 0; j < numlines/2; j++) *place++ = data[j*2*width8 + i + left/8 - shift]; } else { memset (place, 0, numlines/2); place += numlines/2; } } } /* done with data */ free(data); /* place 0's in the last 12 columns */ memset (place, 0, numlines/2 * shift); place += numlines/2 * shift; maxplace = place; /* create sweep data */ sweep_data->image_data = ppa; sweep_data->data_size = maxplace-ppa; sweep_data->in_color = False; /* horzpos = left*600/prn->DPI + (sweep_data->direction==left_to_right ? 0*600/prn->DPI : 0); */ horzpos = left * 600/prn->DPI; hp2 = horzpos + ( p_width8 + 2*shift )*8 * 600/prn->DPI; sweep_data->left_margin = horzpos; sweep_data->right_margin = hp2 + prn->marg_diff; for (i = 0; i < 2; i++) { nozzles[i].DPI = prn->DPI; nozzles[i].pins_used_d2 = numlines/2; nozzles[i].unused_pins_p1 = 301-numlines; nozzles[i].first_pin = 1; if (i == 0) { nozzles[i].left_margin = horzpos + prn->marg_diff; nozzles[i].right_margin = hp2 + prn->marg_diff; if(sweep_data->direction == right_to_left) /* 0 */ nozzles[i].nozzle_delay=prn->right_to_left_delay[0]; else /* 6 */ nozzles[i].nozzle_delay=prn->left_to_right_delay[0]; } else { nozzles[i].left_margin = horzpos; nozzles[i].right_margin = hp2; if(sweep_data->direction == right_to_left) /* 2 */ nozzles[i].nozzle_delay=prn->right_to_left_delay[1]; else /* 0 */ nozzles[i].nozzle_delay=prn->left_to_right_delay[1]; } } sweep_data->nozzle_data_size = 2; sweep_data->nozzle_data = malloc(sizeof(nozzles)); if(sweep_data->nozzle_data == NULL) return 0; memcpy(sweep_data->nozzle_data,nozzles,sizeof(nozzles)); return 2; } netpbm-free-10.0-1/pbm/pbmtoppa/cutswath.h0100644004714500471450000000015107716762513020745 0ustar aba-guestaba-guestint cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines, ppa_sweep_data* sweep_data); netpbm-free-10.0-1/pbm/pbmtoppa/defaults.h0100644004714500471450000000321507716230207020704 0ustar aba-guestaba-guest/* defaults.h * Default printer values. Edit these and recompile if so desired. * [Note: a /etc/pbm2ppa.conf file will override these] */ #ifndef _DEFAULTS_H #define _DEFAULTS_H /* Refer to CALIBRATION file about these settings */ #define HP1000_PRINTER ( HP1000 ) #define HP1000_MARG_DIFF ( 0x62 ) #define HP1000_BUFSIZE ( 100*1024 ) #define HP1000_X_OFFSET ( 100 ) #define HP1000_Y_OFFSET ( -650 ) #define HP1000_TOP_MARGIN ( 150 ) #define HP1000_LEFT_MARGIN ( 150 ) #define HP1000_RIGHT_MARGIN ( 150 ) #define HP1000_BOTTOM_MARGIN ( 150 ) #define HP720_PRINTER ( HP720 ) #define HP720_MARG_DIFF ( 2 ) #define HP720_BUFSIZE ( 200*1024 ) #define HP720_X_OFFSET ( 169 ) #define HP720_Y_OFFSET ( -569 ) #define HP720_TOP_MARGIN ( 150 ) #define HP720_LEFT_MARGIN ( 150 ) #define HP720_RIGHT_MARGIN ( 150 ) #define HP720_BOTTOM_MARGIN ( 150 ) #define HP820_PRINTER ( HP820 ) #define HP820_MARG_DIFF ( 0x62 ) #define HP820_BUFSIZE ( 100*1024 ) #define HP820_X_OFFSET ( 75 ) #define HP820_Y_OFFSET ( -500 ) #define HP820_TOP_MARGIN ( 80 ) #define HP820_LEFT_MARGIN ( 80 ) #define HP820_RIGHT_MARGIN ( 80 ) #define HP820_BOTTOM_MARGIN ( 150 ) #define DEFAULT_PRINTER HP1000_PRINTER #define DEFAULT_X_OFFSET HP1000_X_OFFSET #define DEFAULT_Y_OFFSET HP1000_Y_OFFSET #define DEFAULT_TOP_MARGIN HP1000_TOP_MARGIN #define DEFAULT_LEFT_MARGIN HP1000_LEFT_MARGIN #define DEFAULT_RIGHT_MARGIN HP1000_RIGHT_MARGIN #define DEFAULT_BOTTOM_MARGIN HP1000_BOTTOM_MARGIN #endif netpbm-free-10.0-1/pbm/pbmtoppa/pbm.c0100644004714500471450000000525507716230207017654 0ustar aba-guestaba-guest/* pbm.c * code for reading the header of an ASCII PBM file * Copyright (c) 1998 Tim Norman. See LICENSE for details * 2-25-98 * * Mar 18, 1998 Jim Peterson * * Restructured to encapsulate more of the PBM handling. */ #include #include #include #include "ppapbm.h" int make_pbm_stat(pbm_stat* pbm,FILE* fptr) { char line[1024]; pbm->fptr=fptr; pbm->version=none; pbm->current_line=0; pbm->unread = 0; if (fgets (line, 1024, fptr) == NULL) return 0; line[strlen(line)-1] = 0; if(!strcmp(line,"P1")) pbm->version=P1; if(!strcmp(line,"P4")) pbm->version=P4; if(pbm->version == none) { fprintf(stderr,"pbm_readheader(): unknown PBM magic '%s'\n",line); return 0; } do if (fgets (line, 1024, fptr) == NULL) return 0; while (line[0] == '#'); if (2 != sscanf (line, "%d %d", &pbm->width, &pbm->height)) return 0; return 1; } static int getbytes(FILE *fptr,int width,unsigned char* data) { unsigned char mask,acc,*place; int num; if(!width) return 0; for(mask=0x80, acc=0, num=0, place=data; num>=1; num++; if(!mask) /* if(num%8 == 0) */ { *place++ = acc; acc=0; mask=0x80; } } } if(width%8) *place=acc; return 1; } /* Reads a single line into data which must be at least (pbm->width+7)/8 bytes of storage */ int pbm_readline(pbm_stat* pbm,unsigned char* data) { int tmp,tmp2; if(pbm->current_line >= pbm->height) return 0; if (pbm->unread) { memcpy (data, pbm->revdata, (pbm->width+7)/8); pbm->current_line++; pbm->unread = 0; free (pbm->revdata); return 1; } switch(pbm->version) { case P1: if(getbytes(pbm->fptr,pbm->width,data)) { pbm->current_line++; return 1; } return 0; case P4: overflow_add(pbm->width, 7); tmp=(pbm->width+7)/8; tmp2=fread(data,1,tmp,pbm->fptr); if(tmp2 == tmp) { pbm->current_line++; return 1; } fprintf(stderr,"pbm_readline(): error reading line data (%d)\n",tmp2); return 0; default: fprintf(stderr,"pbm_readline(): unknown PBM version\n"); return 0; } } /* push a line back into the buffer; we read too much! */ void pbm_unreadline (pbm_stat *pbm, void *data) { /* can only store one line in the unread buffer */ if (pbm->unread) return; pbm->unread = 1; overflow_add(pbm->width, 7); pbm->revdata = malloc((pbm->width+7)/8); memcpy (pbm->revdata, data, (pbm->width+7)/8); pbm->current_line--; } netpbm-free-10.0-1/pbm/pbmtoppa/pbmtoppa.10100644004714500471450000001551407716230207020635 0ustar aba-guestaba-guest.TH pbmtoppa 1 "01 May 2000" .IX pbmtoppa .SH NAME pbmtoppa - convert PBM image to HP Printer Performance Architecture (PPA) .SH SYNOPSIS .B pbmtoppa .RI [ pbm_file .RI [ ppa_file ]] .SH DESCRIPTION .B pbmtoppa converts page images in PBM format to Hewlett Packard's PPA (Printer Performance Architecture) format, which is the data stream format expected by some HP "Windows-only" printers including the HP Deskjet 820C series, the HP DeskJet 720 series, and the HP DeskJet 1000 series. .I pbm_file is the file specification of the input file or .B - for Standard Input. The default is Standard Input. The input file contains one or more PBM images, with each one being a single page. Each image must have the exact dimensions of a page (at 600 pixels per inch in both directions). Significantly, this is the format the Ghostscript produces. .I ppa_file is the file specification of the output file or .B - for Standard Output. The default is Standard Output. To print Postscript on an HP PPA printer, just use Ghostscript with the .B pbmraw (or .BR pbm ) device driver. You can generate a test page for use with this program with .BR pbmpage . You can also set up a printer filter so you can submit PBM input directly to your print queue. See the documentation for your print spooler for information on how to do that, or look in hp820install.doc for an example lpd print filter for Postscript and text files. Sometimes, .B pbmtoppa generates a file which the printer will not print (because .BR pbmtoppa 's input is unprintable). When this happens, all three lights blink to signal the error. This is usually because there is material outside of the printer's printable area. To make the file print, increase the margins via .B pbmtoppa options or a configuration file. See the CALIBRATION section below. .OPTIONS .TP .BI "-v " version printer version (720, 820, or 1000) .TP .BI "-x " xoff vertical offset adjustment in 1"/600 .TP .BI "-y " yoff horizontal offset adjustment in 1"/600 .TP .BI "-t " topmarg top margin in 1"/600 (default: 150 = 0.25") .TP .BI "-l " leftmarg left margin in 1"/600 (default: 150 = 0.25") .TP .BI "-r " rightmarg right margin in 1"/600 (default: 150 = 0.25") .TP .BI "-b " botmarg bottom margin in 1"/600 (default: 150 = 0.25") .TP .BI "-s " paper paper size: .B us or .BR a4 . Default is .BR us . .TP .BI "-f " cfgfile read parameters from configuration file .I cfgfile .PP The .B -x and .B -y options accumulate. The .B -v option resets the horizontal and vertical adjustments to an internal default. .SH CONFIGURATION FILES You can use configuration files to specify parameters rather than use invocation options. .B pbmtoppa processes the file /etc/pbmtoppa.conf, if it exists, before processing any options. It then processes each configuration file named by a .B -f option in order, applying the parameters from the configuration file as if they were invocation options used in the place of the .B -f option. Configuration files have the following format: .BI # Comment .br .I key1 .I value1 .br .I key2 .I value2 .br [etc.] Valid .IR key s are .BR version , .BR xoffset , .BR yoffset , .BR topmargin , .BR leftmargin , .BR rightmargin , .BR bottommargin , .BR papersize , or any non-null prefix of these words. Valid values are the same as with the corresponding invocation parameters. .SH EXAMPLES Print a test pattern: .B pbmpage | pbmppa >/dev/lp1 Print three pages: .B cat page1.pbm page2.pbm page3.pbm | pbmppa >/dev/lp1 Print the Postscript file myfile.ps: \fBgs -sDEVICE=rawpbm -q -dNOPAUSE -r600 \\ .br -sOutputFile=- myfile.ps \\ .br | pbmtoppa | lpr \fR .SH CALIBRATION To be able to print successfully and properly, you need to tell .B pbmtoppa an X and a Y offset appropriate for your printer to use when generating the page. You can specify these offsets with the .B -x and .B -y invocation options or with the .B xoff and .B yoff parameters in a .B pbmtoppa configuration file. To determine the correct offsets, use the .B pbmpage program. If while trying to do this calibration, the printer refuses to print a page, but just blinks all three lights, specify large margins (e.g. 600 pixels -- one inch) via .B pbmpage invocation options while doing the calibration. For example: .B pbmpage | pbmtoppa >/dev/lp1 .br or .br .B pbmpage | pbmtoppa | lpr -l .br (if your printer filter recognizes the '-l' (direct output) parameter). In the test pattern, the grid is marked off in pixel coordinate numbers. Unfortunately, these coordinates are probably cut off before the edge of the paper. You'll have to use a ruler to estimate the pixel coordinate of the left and top edges of the actual sheet of paper (should be within +/- 300, may be negative; there are 600 pixels per inch). Add these coordinates to the X and Y offsets by either editing the configuration file or using the .B -x and .B -y command-line parameters. When .B pbmtoppa is properly calibrated, the center mark should be in the center of the paper. Also, the margins should be able to be as small as 1/4 inch without causing the printer to choke with 'blinking lights syndrome'. .SH REDHAT LINUX INSTALLATION RedHat users may find the following tip from Panayotis Vryonis helpful. The same should work for the 820 and 1000, but it hasn't been tested. Also, use the pbmraw GSDriver if you have it; it's faster. Here is a tip to intergrate HP720C support in RedHat's printtool: Install pbm2ppa. Copy pbm2ppa to /usr/bin. Edit "printerdb" (in my system it is found in /usr/lib/rhs/rhs-printfilters ) and append the following lines: ----------------------Cut here----------------------- .br StartEntry: DeskJet720C GSDriver: pbm Description: {HP DeskJet 720C} About: { \\ This driver supports the HP DeskJet 720C \\ inkjet printer. \\ It does does not support color printing. \\ IMPORTANT! Insert \\ "- | pbm2ppa -" \\ in the "Extra GS Otions" field.\\ } .br Resolution: {600} {600} {} .br EndEntry ---------------------------------------------------- Now you can add an HP720C printer just like any other, using printtool. .SH "SEE ALSO" .BR pbmpage (1), .BR pstopnm (1), .BR pbm (5) .B pnm2ppa is not part of Netpbm, but does the same things as .B pbmtoppa except it also works with color and has lots more features. See . The file INSTALL-MORE in the pbmtoppa directory of the Netpbm source code contains detailed instructions on setting up a system to use pbmtoppa to allow convenient printing on HP PPA printers. It was written by Michael Buehlmann. For information about the PPA protocol and the separately distributed pbm2ppa program from which .B pbmtoppa was derived, see . .SH AUTHOR Tim Norman. Copyright (C) 1998. Licensed under GNU Public License Manual page by Bryan Henderson, May 2000. netpbm-free-10.0-1/pbm/pbmtoppa/pbmtoppa.c0100644004714500471450000002755607716762513020742 0ustar aba-guestaba-guest/* pbmtoppa.c * program to print a 600 dpi PBM file on the HP DJ820Cse or the HP720 series. * Copyright (c) 1998 Tim Norman. See LICENSE for details * 2-24-98 */ #define _BSD_SOURCE /* This makes sure strcasecmp() is in string.h */ #include #include #include #include #include #include "pbm.h" #include "ppa.h" #include "ppapbm.h" #include "cutswath.h" #include "defaults.h" /* Paper sizes in 600ths of an inch. */ /* US is 8.5 in by 11 in */ #define USWIDTH (5100) #define USHEIGHT (6600) /* A4 is 210 mm by 297 mm == 8.27 in by 11.69 in */ #define A4WIDTH (4960) #define A4HEIGHT (7016) int Width; /* width and height in 600ths of an inch */ int Height; int Pwidth; /* width in bytes */ #define MAX_LINES 300 ppa_stat printer; static int print_pbm (FILE *in) { char line[1024]; pbm_stat pbm; int done_page, numpages = 0; ppa_sweep_data sweeps[2]; int current_sweep, previous_sweep; ppa_init_job(&printer); while(make_pbm_stat(&pbm,in)) { if (pbm.width != Width || pbm.height != Height) { fprintf(stderr, "print_pbm(): Input image is not the size " "of a page for Page %d.\n" "The input is %dW x %dH, while a page is %dW x %dH pixels.\n" "Page size is controlled by options and the configuration " "file.\n", numpages+1, pbm.width, pbm.height, Width, Height); return 1; } ppa_init_page(&printer); ppa_load_page(&printer); sweeps[0].direction = right_to_left; sweeps[0].next=&sweeps[1]; sweeps[1].direction = left_to_right; sweeps[1].next=&sweeps[0]; current_sweep=0; previous_sweep=-1; done_page=0; while(!done_page) switch(cut_pbm_swath(&pbm,&printer,MAX_LINES,&sweeps[current_sweep])) { case 0: fprintf (stderr, "print_pbm(): error calling cut_pbm_swath()\n"); return 1; case 1: done_page=1; break; case 2: if(previous_sweep>=0) { ppa_print_sweep(&printer,&sweeps[previous_sweep]); free(sweeps[previous_sweep].image_data); free(sweeps[previous_sweep].nozzle_data); } previous_sweep=current_sweep; current_sweep= current_sweep==0 ? 1 : 0; break; default: fprintf(stderr,"print_pbm(): unknown return code from cut_pbm_swath()\n"); return 1; } if(previous_sweep>=0) { sweeps[previous_sweep].next=NULL; ppa_print_sweep(&printer,&sweeps[previous_sweep]); } free(sweeps[0].image_data); free(sweeps[0].nozzle_data); free(sweeps[1].image_data); free(sweeps[1].nozzle_data); ppa_eject_page(&printer); /* eat any remaining whitespace */ if(pbm.version==P1) fgets (line, 1024, in); numpages++; } if (numpages == 0) { fprintf (stderr, "No pages printed!\n"); return 1; } ppa_end_print(&printer); fclose (pbm.fptr); fclose (printer.fptr); return 0; } static void set_printer_specific_defaults() { switch(printer.version) { case HP720: printer.marg_diff = HP720_MARG_DIFF; printer.bufsize = HP720_BUFSIZE; printer.x_offset = HP720_X_OFFSET; printer.y_offset = HP720_Y_OFFSET; printer.top_margin = HP720_TOP_MARGIN; printer.left_margin = HP720_LEFT_MARGIN; printer.right_margin = HP720_RIGHT_MARGIN; printer.bottom_margin = HP720_BOTTOM_MARGIN; break; case HP820: printer.marg_diff = HP820_MARG_DIFF; printer.bufsize = HP820_BUFSIZE; printer.x_offset = HP820_X_OFFSET; printer.y_offset = HP820_Y_OFFSET; printer.top_margin = HP820_TOP_MARGIN; printer.left_margin = HP820_LEFT_MARGIN; printer.right_margin = HP820_RIGHT_MARGIN; printer.bottom_margin = HP820_BOTTOM_MARGIN; break; case HP1000: printer.marg_diff = HP1000_MARG_DIFF; printer.bufsize = HP1000_BUFSIZE; printer.x_offset = HP1000_X_OFFSET; printer.y_offset = HP1000_Y_OFFSET; printer.top_margin = HP1000_TOP_MARGIN; printer.left_margin = HP1000_LEFT_MARGIN; printer.right_margin = HP1000_RIGHT_MARGIN; printer.bottom_margin = HP1000_BOTTOM_MARGIN; break; default: fprintf(stderr,"set_printer_defaults(): unknown printer version\n"); exit(1); } } static void show_usage(char* prog) { printf("usage: %s [ options ] [ [ ] ]\n\n",prog); printf(" Prints a pbm- or pbmraw-format to HP720/820/1000-format .\n\n"); printf(" -v printer version (720, 820, or 1000)\n"); printf(" -x vertical offset adjustment in 1\"/600\n"); printf(" -y horizontal offset adjustment in 1\"/600\n"); printf(" -t top margin in 1\"/600 (default: 150 = 0.25\")\n"); printf(" -l left margin in 1\"/600 (default: 150 = 0.25\")\n"); printf(" -r right margin in 1\"/600 (default: 150 = 0.25\")\n"); printf(" -b bottom margin in 1\"/600 (default: 150 = 0.25\")\n"); printf(" -s paper size (us, a4, default: us)\n"); printf(" -f read as parameters\n\n"); printf(" The -x and -y options accumulate. The -v option resets the horizontal and\n"); printf(" vertical adjustments to an internal default. and default\n"); printf(" to stdin and stdout. '-' is a synonym for stdin and stdout.\n\n"); printf(" Configuration files specified with the '-f' parameter have the following\n format:\n\n"); printf(" # Comment\n"); printf(" \n"); printf(" \n"); printf(" [etc.]\n\n"); printf(" Valid keys are 'version', 'xoffset', 'yoffset', 'topmargin', 'leftmargin',\n"); printf(" 'rightmargin', 'bottommargin', 'papersize', or any non-null truncated\n"); printf(" version of these words. Valid values are the same as with the corresponding\n"); printf(" command-line parameters. Parameters in the configuration file act as though\n"); printf(" the corresponding parameters were substituted, in order, for the '-f'\n"); printf(" parameter which specified the file.\n\n"); printf(" The file /etc/pbmtoppa.conf, if it exists, is processed as a configuration\n"); printf(" file before any command-line parameters are processed.\n\n"); } static void parm_version(char* arg) { if(!strcasecmp(arg,"hp720") || !strcmp(arg,"720")) printer.version=HP720; else if(!strcasecmp(arg,"hp820") || !strcmp(arg,"820")) printer.version=HP820; else if(!strcasecmp(arg,"hp1000") || !strcmp(arg,"1000")) printer.version=HP1000; else { fprintf(stderr,"parm_version(): unknown printer version '%s'\n",arg); exit(1); } set_printer_specific_defaults(); } static void parm_iversion(int arg) { switch(arg) { case 720: printer.version=HP720; break; case 820: printer.version=HP820; break; case 1000: printer.version=HP1000; break; default: { fprintf(stderr,"parm_iversion(): unknown printer version '%d'\n",arg); exit(1); } } set_printer_specific_defaults(); } static void dump_config() { printf("version: "); switch(printer.version) { case HP710: printf("HP710\n"); break; case HP720: printf("HP720\n"); break; case HP820: printf("HP820\n"); break; case HP1000: printf("HP1000\n"); break; } printf("x-offset: %d\ny-offset: %d\nmargins:\n top: %d\n" " left: %d\n right: %d\n bottom: %d\n",printer.x_offset, printer.y_offset,printer.top_margin,printer.left_margin, printer.right_margin,printer.bottom_margin); exit(0); } static void read_config_file(char* fname) { FILE* cfgfile=fopen(fname,"r"); char line[1024],key[14],buf[10]; int len,value,lineno=1; if(!cfgfile) { fprintf (stderr, "read_config_file(): couldn't open file '%s'\n", fname); exit(1); } while(fgets(line,1024,cfgfile)) { if(strchr(line,'#')) *strchr(line,'#')=0; switch(sscanf(line,"%13s%9s",key,buf)) { case 2: value=atoi(buf); len=strlen(key); if(!strncmp(key,"version",len)) parm_iversion(value); else if(!strncmp(key,"xoffset",len)) printer.x_offset=value; else if(!strncmp(key,"yoffset",len)) printer.y_offset=value; else if(!strncmp(key,"topmargin",len)) printer.top_margin=value; else if(!strncmp(key,"leftmargin",len)) printer.left_margin=value; else if(!strncmp(key,"rightmargin",len)) printer.right_margin=value; else if(!strncmp(key,"bottommargin",len)) printer.bottom_margin=value; else if(!strncmp(key,"papersize",len)) { if(!strcmp(buf,"us")) { Width = USWIDTH; Height = USHEIGHT; } else if(!strcmp(buf,"a4")) { Width = A4WIDTH; Height = A4HEIGHT; } else { fprintf(stderr,"read_config_file(): unknown paper size %s\n",buf); exit(1); } } else if(!strcmp(key,"dump")) dump_config(); else { fprintf(stderr,"read_config_file(): unrecognized parameter '%s' (line %d)\n\n",key,lineno); show_usage("pbmtoppa"); exit(1); } case EOF: case 0: break; default: fprintf(stderr,"read_config_file(): error parsing config file (line %d)\n",lineno); exit(1); } lineno++; } if(feof(cfgfile)) { fclose(cfgfile); return; } fprintf(stderr,"read_config_file(): error parsing config file\n"); exit(1); } char* defaultcfgfile="/etc/pbmtoppa.conf"; int main (int argc, char *argv[]) { int argn; int got_in=0, got_out=0, do_continue=1; FILE *in=stdin, *out=stdout; struct stat tmpstat; pbm_init(&argc, argv); printer.version = DEFAULT_PRINTER; printer.x_offset = DEFAULT_X_OFFSET; printer.y_offset = DEFAULT_Y_OFFSET; printer.top_margin = DEFAULT_TOP_MARGIN; printer.left_margin = DEFAULT_LEFT_MARGIN; printer.right_margin = DEFAULT_RIGHT_MARGIN; printer.bottom_margin = DEFAULT_BOTTOM_MARGIN; Width = USWIDTH; Height = USHEIGHT; set_printer_specific_defaults(); if(!stat(defaultcfgfile,&tmpstat)) read_config_file(defaultcfgfile); for(argn=1; argn * * Restructured to accommodate both the HP820/1000, and HP720 series. */ #include #include #include #include "pm_config.h" /* pm_config.h is necessary for __inline__ for those compilers that don't define __inline__ themselves */ #include "ppa.h" /* VLink packet structure: Bytes Description -------------------------------------------- 1 Packet-start marker (always '$') 1 Channel (0: image data, 1: commands/responses(*), 2: autostatus(*), 128: pacing(*)) 2 Data length (N) N [remaining data (e.g., SCP or SCP2 packet when Channel=1)] (*): responses, autostatus, and pacing are communicated from the printer to the computer, and may be safely ignored. */ static void vlink_put(FILE *fptr, int channel, int length, void *data) { fputc ('$', fptr); fputc (channel, fptr); fputc (length>>8, fptr); fputc (length&0xFF, fptr); fwrite (data, length, 1, fptr); } /* SCP packet structure: Bytes Description -------------------------------------------- 2 Command specifier 2 Command reference number 1 Priority 1 padding? (always zero) 2 Data length (N) N [remaining data] ComSpec ComRef Command ------------------------------- 35 1 Initialize1 101 2 Initialize2 21 1 Initialize3 19 1 Handle Media 18 1 Print Sweep */ static void scp_put(FILE *fptr, int comspec, int comref, int priority, int length, void *data) { /* encapsulate the vlink_put call in here, to avoid a memcpy */ fputc ('$', fptr); fputc (1, fptr); fputc ((length+8)>>8, fptr); fputc ((length+8)&0xFF, fptr); fputc (comspec>>8, fptr); fputc (comspec&0xFF, fptr); fputc (comref>>8, fptr); fputc (comref&0xFF, fptr); fputc (priority, fptr); fputc (0, fptr); fputc (length>>8, fptr); fputc (length&0xFF, fptr); fwrite (data, length, 1, fptr); } /* SCP2 packet structure: Bytes Description -------------------------------------------- 2 Command specifier 2 Packet length (N) 1 Priority 1 padding? (always zero) 2 Command reference number 4 Channel 0 buffer increment 4 version number? (always 00 02 00 00) N-16 [remaining data] ComSpec ComRef Command ------------------------------- 0x186 1 Initialize1 0x18f 2 Initialize2 0x183 1 Initialize3 0x181 1 Handle Media 0x180 1 Print Sweep */ static void scp2_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16, unsigned char priority,unsigned short comref,unsigned data_len, void *data) { /* encapsulate the vlink_put call in here, to avoid a memcpy */ fputc ('$', fptr); fputc (1, fptr); fputc ((pkt_len_s16+16)>>8, fptr); fputc ((pkt_len_s16+16), fptr); fputc (comspec>>8, fptr); fputc (comspec, fptr); fputc ((pkt_len_s16+16)>>8, fptr); fputc ((pkt_len_s16+16), fptr); fputc (priority, fptr); fputc (0, fptr); fputc (comref>>8, fptr); fputc (comref, fptr); fputc (data_len>>24, fptr); fputc (data_len>>16, fptr); fputc (data_len>>8, fptr); fputc (data_len, fptr); fputc (0, fptr); fputc (2, fptr); fputc (0, fptr); fputc (0, fptr); fwrite (data, pkt_len_s16, 1, fptr); } /* SCP3 packet structure: Bytes Description -------------------------------------------- 2 Command specifier 2 Packet length (N) 1 Priority 1 padding? (always zero) 2 Command reference number 4 Channel 0 buffer increment 4 version number? (always 01 04 00 00) N-16 [remaining data] ComSpec ComRef Command ------------------------------- 0x186 1 Initialize1 0x18C 16 Initialize Printer name 0x1A1 1 Initialize4? 0x18f 2 Initialize2 0x183 1 Initialize3 0x181 1 Handle Media 0x180 1 Print Sweep */ static void scp3_put(FILE *fptr,unsigned short comspec,unsigned short pkt_len_s16, unsigned char priority,unsigned short comref,unsigned data_len, void *data) { /* encapsulate the vlink_put call in here, to avoid a memcpy */ fputc ('$', fptr); fputc (1, fptr); fputc ((pkt_len_s16+16)>>8, fptr); fputc ((pkt_len_s16+16), fptr); fputc (comspec>>8, fptr); fputc (comspec, fptr); fputc ((pkt_len_s16+16)>>8, fptr); fputc ((pkt_len_s16+16), fptr); fputc (priority, fptr); fputc (0, fptr); fputc (comref>>8, fptr); fputc (comref, fptr); fputc (data_len>>24, fptr); fputc (data_len>>16, fptr); fputc (data_len>>8, fptr); fputc (data_len, fptr); fputc (1, fptr); fputc (4, fptr); fputc (0, fptr); fputc (0, fptr); fwrite (data, pkt_len_s16, 1, fptr); } void ppa_init_job(ppa_stat* prn) { unsigned char init1[8] = { 0x00, 0x00, 0x01, 0xf4, 0x01, 0x00, 0x00, 0x00 }; unsigned char init2[4] = { 0xde, 0xad, 0xbe, 0xef }; unsigned char init3[8] = { 0xde, 0xad, 0xbe, 0xef, 0x02, 0x00, 0x00, 0x00 }; unsigned char init4[60] = "!!TAZ \x81*HP DeskJet 1000C Prin (Copy 2)*FILE!!\x00\x00\x00"; /* plus 0 terminator */ unsigned char init5[4] = { 0x01, 0x01, 0x00, 0x00 }; switch(prn->version) { case HP820: scp_put (prn->fptr, 35, 1, 7, sizeof(init1), init1); vlink_put (prn->fptr, 0, sizeof(init2), init2); scp_put (prn->fptr, 101, 2, 7, sizeof(init3), init3); break; case HP720: scp2_put (prn->fptr, 0x0186, sizeof(init1), 7, 1, 0, init1); vlink_put(prn->fptr, 0, sizeof(init2), init2); scp2_put (prn->fptr, 0x018f, sizeof(init3), 7, 2, 4, init3); break; case HP1000: scp3_put (prn->fptr, 0x0186, sizeof(init1), 7, 16, 0, init1); scp3_put (prn->fptr, 0x018C, sizeof(init4), 7, 1, 0, init4); scp3_put (prn->fptr, 0x01A1, sizeof(init5), 7, 1, 0, init5); vlink_put (prn->fptr, 0, sizeof(init2), init2); scp3_put (prn->fptr, 0x018f, sizeof(init3), 7, 2, 4, init3); break; default: fprintf(stderr,"ppa_init_job(): unknown printer verson\n"); } } void ppa_end_print(ppa_stat* prn) { unsigned char pageA[4] = { 0x05, 0x01, 0x03, 0x84 }; if (prn->version == HP1000) scp3_put (prn->fptr, 0x0181, sizeof(pageA), 7, 2, 0, pageA); } void ppa_init_page(ppa_stat* prn) { unsigned char pageA[16] = {0x28, 0x2d, 0x00, 0x41, 0x29, 0x2e, 0x00, 0x42, 0x29, 0x2e, 0x00, 0x42, 0x29, 0x2e, 0x00, 0x42 }; unsigned char pageB[16] = {0x28, 0x2d, 0x00, 0x41, 0x2d, 0x32, 0x00, 0x46, 0x2d, 0x32, 0x00, 0x46, 0x2d, 0x32, 0x00, 0x46 }; switch(prn->version) { case HP820: scp_put (prn->fptr, 21, 1, 5, sizeof(pageA), pageA); break; case HP720: scp2_put (prn->fptr, 0x0183, sizeof(pageB), 5, 1, 0, pageB); break; case HP1000: scp3_put (prn->fptr, 0x0183, sizeof(pageA), 5, 1, 0, pageA); break; default: fprintf(stderr,"ppa_init_page(): unknown printer verson\n"); } } void ppa_load_page(ppa_stat* prn) { unsigned char loadA[4] = {0x01, 0x01, 0x09, 0x60 }; unsigned char loadB[4] = {0x01, 0x01, 0x12, 0xc0 }; unsigned char loadC[4] = {0x01, 0x01, 0x07, 0x08 }; switch(prn->version) { case HP820: scp_put (prn->fptr, 19, 1, 7, sizeof(loadA), loadA); break; case HP720: scp2_put (prn->fptr, 0x0181, sizeof(loadB), 7, 1, 0, loadB); break; case HP1000: scp3_put (prn->fptr, 0x0181, sizeof(loadC), 7, 1, 0, loadC); break; default: fprintf(stderr,"ppa_load_page(): unknown printer verson\n"); } } void ppa_eject_page(ppa_stat* prn) { unsigned char loadA[4] = {0x02, 0x01, 0x09, 0x60 }; unsigned char loadB[4] = {0x02, 0x01, 0x12, 0xc0 }; unsigned char loadC[4] = {0x02, 0x01, 0x07, 0x08 }; switch(prn->version) { case HP820: scp_put (prn->fptr, 19, 1, 7, sizeof(loadA), loadA); break; case HP720: scp2_put (prn->fptr, 0x0181, sizeof(loadB), 7, 1, 0, loadB); break; case HP1000: scp3_put (prn->fptr, 0x0181, sizeof(loadC), 7, 1, 0, loadC); break; default: fprintf(stderr,"ppa_eject_page(): unknown printer verson\n"); } } static int compress(unsigned char *in, int num_lines_d2, int final_len, unsigned char *iout) { unsigned char* out = iout; int I,len=num_lines_d2; for(I=0; I= 1) && (in[i] == 0)) { /* Output run of zeros. */ while (dup_len >= 128) { /* Max is 128 */ *out++ = 0x00; i += 128; dup_len -= 128; } if (dup_len >= 1) { *out++ = dup_len; i += dup_len; } /* See if we have enough non-zeros to be worth compressing. */ /* Here two should be enough. */ } else if (dup_len >= 2) { /* Output run of duplicates. */ while (dup_len >= 64) { /* Max is 64 */ *out++ = 0x80; *out++ = in[i]; i += 64; dup_len -= 64; } if (dup_len >= 2) { *out++ = dup_len + 0x80; *out++ = in[i]; i += dup_len; } } else { /* Look for two zeros, or three duplicates to end literal run. */ /* Note this is one more than the number to start a run. */ int lit_len = -1; int add_more = 1; while (add_more) { lit_len++; if (i + lit_len == len) add_more = 0; /* Always add more if we are near the very end. */ if (i + lit_len < len - 3) { char a = in[i + lit_len + 0]; char b = in[i + lit_len + 1]; char c = in[i + lit_len + 2]; /* See if there are enough zeros */ if ((a == b) && (b == 0)) add_more = 0; /* See if there are enough duplicates */ if ((a == b) && (b == c)) add_more = 0; } } /* Output run of literals. */ while (lit_len >= 64) { /* Max is 64 */ int j; *out++ = 0xc0; for (j = i; j < i + 64; j++) { *out++ = in[j]; } i += 64; lit_len -= 64; } if (lit_len) { int j; *out++ = lit_len + 0xc0; for (j = i; j < i + lit_len; j++) { *out++ = in[j]; } i += lit_len; } } } } return out-iout; } static void __inline__ place_2bytes(int x,unsigned char* y) { y[0]=x>>8; y[1]=x; } static void __inline__ place_4bytes(int x,unsigned char* y) { place_2bytes(x>>16,y); place_2bytes(x,y+2); } #define do_compress_data (1) void ppa_print_sweep(ppa_stat* prn,ppa_sweep_data* data) { unsigned char* pc, *tpc; unsigned i,datasize=data->data_size; unsigned char sweep_packet[144]; int sweep_packet_size; unsigned short HP720constants[] = { 0x8ca0, 0x4650, 0x12c0 }; unsigned short HP820constants[] = { 0x4650, 0x1c20, 0x0960 }; unsigned short HP1000constants[] = { 0x4650, 0x2328, 0x0708 }; unsigned short* constants; int nozzle_data_size; int MF; /* Multiplicative Factor -- quick hack */ pc=data->image_data; if(do_compress_data) { if(!(pc=malloc((datasize/64+1)*65))) { fprintf(stderr,"ppa_print_sweep(): could not malloc storage for compressed data\n"); exit(-1); } datasize=compress(data->image_data,data->nozzle_data->pins_used_d2,datasize,pc); } /* send image data 16k at a time */ for(i=0, tpc=pc; ifptr, 0, datasize-i > 16384 ? 16384 : datasize-i, tpc); /* memory leak fix courtesy of John McKown */ if (do_compress_data) free (pc); /* construct sweep packet */ switch(prn->version) { case HP820: constants=HP820constants; MF=1; break; case HP720: constants=HP720constants; MF=2; break; case HP1000: constants=HP1000constants; MF=1; break; default: fprintf(stderr,"ppa_print_sweep(): unknown printer verson\n"); return; } sweep_packet[0]=0; sweep_packet[1]= do_compress_data; sweep_packet[2]= data->direction==right_to_left ? 1 : 2; sweep_packet[3]= data->in_color ? 14 : 1; place_4bytes(datasize,sweep_packet+4); memset(sweep_packet+8,0,8); place_4bytes(MF*(data->vertical_pos+prn->y_offset),sweep_packet+16); place_2bytes(constants[0],sweep_packet+20); place_2bytes(MF*(data->left_margin+prn->x_offset),sweep_packet+22); place_2bytes(MF*(data->right_margin+prn->x_offset),sweep_packet+24); place_2bytes(constants[1],sweep_packet+26); place_2bytes(constants[2],sweep_packet+28); place_2bytes(0x100,sweep_packet+30); if(data->next) { sweep_packet[32]= data->next->direction==right_to_left ? 1 : 2; sweep_packet[33]= data->next->in_color ? 14 : 1; place_4bytes(MF*(data->next->vertical_pos+prn->y_offset),sweep_packet+34); place_2bytes(MF*(data->next->left_margin+prn->x_offset),sweep_packet+38); place_2bytes(MF*(data->next->right_margin+prn->x_offset),sweep_packet+40); place_2bytes(constants[1],sweep_packet+42); place_2bytes(constants[2],sweep_packet+44); } else memset(sweep_packet+32,0,14); sweep_packet[46]=8; nozzle_data_size=data->nozzle_data_size; if(nozzle_data_size>6) { fprintf(stderr,"ppa_print_sweep(): truncating nozzle data from %d rows to 6 rows\n",nozzle_data_size); nozzle_data_size=6; } sweep_packet[47]=nozzle_data_size; for(pc=sweep_packet+48, i=0; inozzle_data[i].DPI,pc); place_2bytes(data->nozzle_data[i].pins_used_d2,pc+2); place_2bytes(data->nozzle_data[i].unused_pins_p1,pc+4); place_2bytes(data->nozzle_data[i].first_pin,pc+6); place_2bytes(data->nozzle_data[i].pins_used_d2,pc+8); place_2bytes(MF*(data->nozzle_data[i].left_margin+prn->x_offset),pc+10); place_2bytes(MF*(data->nozzle_data[i].right_margin+prn->x_offset),pc+12); pc[14]=data->nozzle_data[i].nozzle_delay; pc[15]=0; } sweep_packet_size = data->in_color ? 144 : 80; /* send sweep packet */ switch(prn->version) { case HP820: scp_put (prn->fptr, 18, 1, 7, sweep_packet_size, sweep_packet); break; case HP720: scp2_put (prn->fptr, 0x0180, sweep_packet_size, 7, 1, datasize, sweep_packet); break; case HP1000: scp3_put (prn->fptr, 0x0180, sweep_packet_size, 7, 1, datasize, sweep_packet); break; default: fprintf(stderr,"ppa_print_sweep(): unknown printer verson\n"); return; } } void ppa_print_sweeps(ppa_stat* prn,ppa_sweep_data* data) { ppa_sweep_data* current_sweep; for(current_sweep=data; current_sweep; current_sweep=current_sweep->next) ppa_print_sweep(prn,current_sweep); } netpbm-free-10.0-1/pbm/pbmtoppa/ppa.h0100644004714500471450000000332507716230207017657 0ustar aba-guestaba-guest/* ppa.h * Copyright (c) 1998 Tim Norman. See LICENSE for details. * 2-25-98 * * Mar 3, 1998 Jim Peterson * * Restructured to accommodate both the HP820/1000, and HP720 series. */ #ifndef _PPA_H #define _PPA_H #include typedef struct { FILE* fptr; enum { HP820, HP1000, HP720, HP710 } version; /* 300 , 600 dpi */ int DPI; /* nozzle delay */ int right_to_left_delay[2]; int left_to_right_delay[2]; /* direction of printing */ enum { RIGHT_ONLY, LEFT_ONLY, BOTH_DIR } direction; int x_offset; int y_offset; int marg_diff; int top_margin; int left_margin; int right_margin; int bottom_margin; int bufsize; } ppa_stat; typedef struct { int DPI; int right; int left; } printer_delay; typedef struct { unsigned short DPI; unsigned short pins_used_d2; unsigned short unused_pins_p1; unsigned short first_pin; unsigned short left_margin; unsigned short right_margin; unsigned char nozzle_delay; } ppa_nozzle_data; typedef struct ppa_sweep_data_s { unsigned char* image_data; unsigned data_size; enum { False=0, True=1 } in_color; enum { right_to_left, left_to_right } direction; int vertical_pos; unsigned short left_margin; unsigned short right_margin; unsigned char nozzle_data_size; ppa_nozzle_data* nozzle_data; struct ppa_sweep_data_s* next; /* NULL indicates last print sweep */ } ppa_sweep_data; void ppa_init_job(ppa_stat*); void ppa_init_page(ppa_stat*); void ppa_load_page(ppa_stat*); void ppa_eject_page(ppa_stat*); void ppa_end_print(ppa_stat*); void ppa_print_sweep(ppa_stat*,ppa_sweep_data*); /* prints one sweep */ void ppa_print_sweeps(ppa_stat*,ppa_sweep_data*); /* prints a linked-list of sweeps */ #endif netpbm-free-10.0-1/pbm/pbmtoppa/ppapbm.h0100644004714500471450000000115507724372231020360 0ustar aba-guestaba-guest/* pbm.h * Copyright (c) 1998 Tim Norman. See LICENSE for details * 2-25-98 * * Mar 18, 1998 Jim Peterson * * Restructured to encapsulate more of the PBM handling. */ #ifndef _PBM_H #define _PBM_H #include #include typedef struct { FILE* fptr; enum { none, P1, P4 } version; int width, height; int current_line; void *revdata; int unread; } pbm_stat; int make_pbm_stat(pbm_stat*,FILE*); int pbm_readline(pbm_stat*,unsigned char*); /* reads a single line into char* */ void pbm_unreadline(pbm_stat*,void*); /* pushes a single line back */ #endif netpbm-free-10.0-1/pbm/Makefile0100644004714500471450000000352007776237374016563 0ustar aba-guestaba-guestSRCDIR = .. SRCSUBDIR = $(SRCDIR)/pbm BUILDDIR = .. include $(BUILDDIR)/Makefile.config INCLUDE = -I$(SRCDIR)/shhopt PORTBINARIES = atktopbm brushtopbm cmuwmtopbm g3topbm \ icontopbm macptopbm mdatopbm mgrtopbm \ pbmclean pbmlife pbmmake pbmmask pbmpscale \ pbmreduce pbmtext pbmtextps \ pbmto10x pbmtoascii pbmtoatk \ pbmtobbnbg pbmtocmuwm \ pbmtoepsi pbmtoepson \ pbmtog3 pbmtogem pbmtogo pbmtoicon pbmtolj \ pbmtomacp pbmtomda pbmtomgr pbmtonokia \ pbmtopi3 pbmtoplot pbmtopsg3 pbmtoptx pbmtowbmp \ pbmtox10bm pbmtoxbm pbmtoybm pbmtozinc \ pbmupc pi3topbm \ wbmptopbm xbmtopbm ybmtopbm ifneq ($(LEX)x,x) PORTBINARIES += thinkjettopbm endif #pbmpage uses sqrt(), which is sometimes in libc, not libm. Is it ever #in libm? MATHBINARIES = pbmpage BINARIES = $(PORTBINARIES) $(MATHBINARIES) OBJECTS = $(patsubst %, %.o, $(BINARIES)) MERGEBINARIES = $(BINARIES) MERGE_OBJECTS = $(patsubst %,%.o2, $(MERGEBINARIES)) # Library objects to be built and linked by Makefile.common: LIBOBJECTS = libpm.o libpbm1.o libpbm2.o libpbm3.o libpbm4.o libpbm5.o bitio.o ifneq (${VMS}x,x) LIBOBJECTS += libpbmvms.o endif # Library objects to be linked but not built by Makefile.common: LIBOBJECTS_X = $(BUILDDIR)/shhopt/shhopt.o MANUALS1 = $(BINARIES) MANUALS3 = libpbm MANUALS5 = pbm MERGENAME = pbmmerge all: build.bin .PHONY: merge merge: $(MERGENAME) $(MAKE) -C pbmtoppa all include $(SRCDIR)/Makefile.common # Note that we create a new compile.h only for the first make after a # make clean. This is good enough. We used to do stamp-date for # every build of "all" from the Netpbm top directory, but nowhere # else, so it was really sloppy. $(BUILDDIR)/shhopt/shhopt.o: cd ../shhopt; $(MAKE) shhopt.o $(BUILDDIR)/shhopt/libshhopt.a: cd ../shhopt; $(MAKE) libshhopt.a .PHONY: clean clean: clean.common $(MAKE) -C pbmtoppa clean FORCE: netpbm-free-10.0-1/pbm/Makefile.depend0100644004714500471450000000000007716230207017765 0ustar aba-guestaba-guestnetpbm-free-10.0-1/pbm/Makefile.dice0100644004714500471450000002413207716230207017446 0ustar aba-guestaba-guest# Makefile for pbm tools, for use with Amiga DICE # # Copyright (C) 1989, 1991 by Jef Poskanzer. # Modified for Amiga DICE by Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, provided # that the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. This software is provided "as is" without express or # implied warranty. # CONFIG: generate executable with debugging information #DEBUG = -s -d1 # CONFIG: use memory pools #MPOOL = -L/amiga -l mpool CC = dcc CFLAGS = -E DCC_ERRORS -ms -mu -gs $(DEBUG) #RGBDEF = -DRGB_DB="RGBDEF" # moved to pbmplus.h TIFFDEF = -DLIBTIFF LDFLAGS = $(MPOOL) /amiga/dice_stack.o BINDIR = bin MERGE= pbmmerge # where to install the binaries, libraries and important header files INSTALLBIN = bin:pbmplus INSTALLLIB = dlib:local INSTALLINCL= dinclude:local # install which headers HEADERS= pbm.h pbmfont.h /pbmplus.h INCLUDE = -I/ RALLCFLAGS = $(CFLAGS) $(RGBDEF) $(TIFFDEF) $(INCLUDE) -proto -mRR SALLCFLAGS = $(CFLAGS) $(RGBDEF) $(TIFFDEF) $(INCLUDE) -proto MALLCFLAGS = $(CFLAGS) $(RGBDEF) $(TIFFDEF) $(INCLUDE) -mD -mC DEFPBM = pbm.h /pbmplus.h DEFLIBPBM = libpbm.h RLIBPBM = pbmsr.lib RLLIBPBM = pbmrl.lib SLIBPBM = pbms.lib SLLIBPBM = pbml.lib DEFPBM2 = /version.h /compile.h # special dep for libpbm1.c LIBRARIES = $(RLIBPBM) $(RLLIBPBM) $(SLIBPBM) $(SLLIBPBM) BINS = atktopbm brushtopbm cmuwmtopbm \ icontopbm gemtopbm macptopbm mgrtopbm \ pbmlife pbmmake pbmmask \ pbmtext pbmto10x pbmto4425 pbmtoascii pbmtoatk \ pbmtobbnbg pbmtocmuwm pbmtoepson pbmtog3 \ pbmtogem pbmtogo pbmtoicon pbmtolj pbmtomacp \ pbmtomgr pbmtopi3 pbmtoplot pbmtoptx \ pbmtox10bm pbmtoxbm pbmtoybm pbmtozinc \ pbmupc pi3topbm xbmtopbm ybmtopbm \ pbmtoepsi pbmclean pbmpscale pbmtoln03 LBINS = g3topbm MATHBINS = pbmreduce pbmtolps # Compile these programs without proto checking, with stackargs & large data. # The source is quite messy and would require too much work to clean up. UGLYFLAGS = -E DCC_ERRORS -ms -mu -gs -mD -mC $(RGBDEF) $(TIFFDEF) $(INCLUDE) UGLYBINS = pktopbm MUGLYBINS = pbmtopk BINARIES = $(BINS) $(LBINS) $(MATHBINS) $(UGLYBINS) $(MUGLYBINS) OBJECTS = atktopbm.om brushtopbm.om cmuwmtopbm.om g3topbm.om \ icontopbm.om gemtopbm.om macptopbm.om mgrtopbm.om \ pbmlife.om pbmmake.om pbmmask.om pbmreduce.om \ pbmtext.om pbmto10x.om pbmto4425.om pbmtoascii.om pbmtoatk.om \ pbmtobbnbg.om pbmtocmuwm.om pbmtoepson.om pbmtog3.om \ pbmtogem.om pbmtogo.om pbmtoicon.om pbmtolj.om pbmtomacp.om \ pbmtomgr.om pbmtopi3.om pbmtoplot.om pbmtoptx.om \ pbmtox10bm.om pbmtoxbm.om pbmtoybm.om pbmtozinc.om \ pbmupc.om pi3topbm.om xbmtopbm.om ybmtopbm.om \ pbmtoepsi.om pbmclean.om pbmpscale.om \ pbmtolps.om pbmtoln03.om UGLYOBJS = pktopbm.ou pbmtopk.ou all: lib binaries bindir: -makedir $(BINDIR) binaries: lib bindir $(BINARIES) lib: $(LIBRARIES) merge: lib bindir $(MERGE) # Rules for merged binary .c.ou: $(DEFPBM) $< $(CC) $(MALLCFLAGS) "-Dmain=$*_main" -c $*.c -o $*.ou .c.om: $(DEFPBM) $< $(CC) -proto $(MALLCFLAGS) "-Dmain=$*_main" -c $*.c -o $*.om $(MERGE): pbmmerge.c $(OBJECTS) $(UGLYOBJS) $(SLLIBPBM) $(CC) $(MALLCFLAGS) $(LDFLAGS) -o $(BINDIR)/$@ $@.c $(OBJECTS) $(UGLYOBJS) -l $(SLLIBPBM) -lm #$(OBJECTS): $(DEFPBM) # $(CC) -mD -mC $(SALLCFLAGS) "-Dmain=$*_main" -c $*.c # Rules for plain programs. $(BINS): $(DEFPBM) $(RLIBPBM) $(CC) -r $(RALLCFLAGS) $(LDFLAGS) -o $(BINDIR)/$@ $@.c -l $(RLIBPBM) $(LBINS): $(DEFPBM) $(RLLIBPBM) $(CC) -mD -mC $(RALLCFLAGS) $(LDFLAGS) -o $(BINDIR)/$@ $@.c -l $(RLLIBPBM) $(MATHBINS): $(DEFPBM) $(RLIBPBM) $(CC) -r $(RALLCFLAGS) $(LDFLAGS) -o $(BINDIR)/$@ $@.c -l $(RLIBPBM) -lm $(UGLYBINS): $(DEFPBM) $(SLLIBPBM) $(CC) $(UGLYFLAGS) $(LDFLAGS) -o $(BINDIR)/$@ $@.c -l $(SLLIBPBM) $(MUGLYBINS): $(DEFPBM) $(SLLIBPBM) $(CC) $(UGLYFLAGS) $(LDFLAGS) -o $(BINDIR)/$@ $@.c -l $(SLLIBPBM) -lm # And libraries. # small data version of libpbm, registerized (arguments in registers) $(RLIBPBM): libpbm1.or libpbm2.or libpbm3.or libpbm4.or libpbm5.or -delete $(RLIBPBM) join libpbm1.or libpbm2.or libpbm3.or libpbm4.or libpbm5.or to $(RLIBPBM) libpbm1.or: $(DEFPBM) $(DEFPBM2) $(DEFLIBPBM) libpbm1.c $(CC) -r $(RALLCFLAGS) -S -o $@ -c libpbm1.c libpbm2.or: $(DEFPBM) $(DEFLIBPBM) libpbm2.c $(CC) -r $(RALLCFLAGS) -S -o $@ -c libpbm2.c libpbm3.or: $(DEFPBM) $(DEFLIBPBM) libpbm3.c $(CC) -r $(RALLCFLAGS) -S -o $@ -c libpbm3.c libpbm4.or: $(DEFPBM) $(DEFLIBPBM) libpbm4.c $(CC) -r $(RALLCFLAGS) -S -o $@ -c libpbm4.c libpbm5.or: $(DEFPBM) pbmfont.h libpbm5.c $(CC) -r $(RALLCFLAGS) -S -o $@ -c libpbm5.c # small data version, not registerized (arguments on stack) $(SLIBPBM): libpbm1.os libpbm2.os libpbm3.os libpbm4.os libpbm5.os -delete $(SLIBPBM) join libpbm1.os libpbm2.os libpbm3.os libpbm4.os libpbm5.os to $(SLIBPBM) libpbm1.os: $(DEFPBM) $(DEFPBM2) $(DEFLIBPBM) libpbm1.c $(CC) -r $(SALLCFLAGS) -S -o $@ -c libpbm1.c libpbm2.os: $(DEFPBM) $(DEFLIBPBM) libpbm2.c $(CC) -r $(SALLCFLAGS) -S -o $@ -c libpbm2.c libpbm3.os: $(DEFPBM) $(DEFLIBPBM) libpbm3.c $(CC) -r $(SALLCFLAGS) -S -o $@ -c libpbm3.c libpbm4.os: $(DEFPBM) $(DEFLIBPBM) libpbm4.c $(CC) -r $(SALLCFLAGS) -S -o $@ -c libpbm4.c libpbm5.os: $(DEFPBM) pbmfont.h libpbm5.c $(CC) -r $(SALLCFLAGS) -S -o $@ -c libpbm5.c # large data version of libpbm, registerized (arguments in registers) $(RLLIBPBM): libpbm1.olr libpbm2.olr libpbm3.olr libpbm4.olr libpbm5.olr -delete $(RLLIBPBM) join libpbm1.olr libpbm2.olr libpbm3.olr libpbm4.olr libpbm5.olr to $(RLLIBPBM) libpbm1.olr: $(DEFPBM) $(DEFPBM2) $(DEFLIBPBM) libpbm1.c $(CC) -mD $(RALLCFLAGS) -S -o $@ -c libpbm1.c libpbm2.olr: $(DEFPBM) $(DEFLIBPBM) libpbm2.c $(CC) -mD $(RALLCFLAGS) -S -o $@ -c libpbm2.c libpbm3.olr: $(DEFPBM) $(DEFLIBPBM) libpbm3.c $(CC) -mD $(RALLCFLAGS) -S -o $@ -c libpbm3.c libpbm4.olr: $(DEFPBM) $(DEFLIBPBM) libpbm4.c $(CC) -mD $(RALLCFLAGS) -S -o $@ -c libpbm4.c libpbm5.olr: $(DEFPBM) pbmfont.h libpbm5.c $(CC) -mD $(RALLCFLAGS) -S -o $@ -c libpbm5.c # large data version of libpbm, not registerized (arguments on stack) $(SLLIBPBM): libpbm1.ols libpbm2.ols libpbm3.ols libpbm4.ols libpbm5.ols -delete $(SLLIBPBM) join libpbm1.ols libpbm2.ols libpbm3.ols libpbm4.ols libpbm5.ols to $(SLLIBPBM) libpbm1.ols: $(DEFPBM) $(DEFPBM2) $(DEFLIBPBM) libpbm1.c $(CC) -mD $(SALLCFLAGS) -S -o $@ -c libpbm1.c libpbm2.ols: $(DEFPBM) $(DEFLIBPBM) libpbm2.c $(CC) -mD $(SALLCFLAGS) -S -o $@ -c libpbm2.c libpbm3.ols: $(DEFPBM) $(DEFLIBPBM) libpbm3.c $(CC) -mD $(SALLCFLAGS) -S -o $@ -c libpbm3.c libpbm4.ols: $(DEFPBM) $(DEFLIBPBM) libpbm4.c $(CC) -mD $(SALLCFLAGS) -S -o $@ -c libpbm4.c libpbm5.ols: $(DEFPBM) pbmfont.h libpbm5.c $(CC) -mD $(SALLCFLAGS) -S -o $@ -c libpbm5.c # Other dependencies. atktopbm atktopbm.om: atktopbm.c brushtopbm brushtopbm.om: brushtopbm.c cmuwmtopbm cmuwmtopbm.om: cmuwmtopbm.c cmuwm.h g3topbm g3topbm.om: g3topbm.c g3.h icontopbm icontopbm.om: icontopbm.c gemtopbm gemtopbm.om: gemtopbm.c macptopbm macptopbm.om: macptopbm.c macp.h mgrtopbm mgrtopbm.om: mgrtopbm.c mgr.h pbmlife pbmlife.om: pbmlife.c pbmmake pbmmake.om: pbmmake.c pbmmask pbmmask.om: pbmmask.c pbmreduce pbmreduce.om: pbmreduce.c pbmtext pbmtext.om: pbmtext.c pbmfont.h pbmto10x pbmto10x.om: pbmto10x.c pbmto4425 pbmto4425.om: pbmto4425.c pbmtoascii pbmtoascii.om: pbmtoascii.c pbmtoatk pbmtoatk.om: pbmtoatk.c pbmtobbnbg pbmtobbnbg.om: pbmtobbnbg.c pbmtocmuwm pbmtocmuwm.om: pbmtocmuwm.c cmuwm.h pbmtoepson pbmtoepson.om: pbmtoepson.c pbmtog3 pbmtog3.om: pbmtog3.c g3.h pbmtogem pbmtogem.om: pbmtogem.c pbmtogo pbmtogo.om: pbmtogo.c pbmtoicon pbmtoicon.om: pbmtoicon.c pbmtolj pbmtolj.om: pbmtolj.c pbmtomacp pbmtomacp.om: pbmtomacp.c macp.h pbmtomgr pbmtomgr.om: pbmtomgr.c mgr.h pbmtopi3 pbmtopi3.om: pbmtopi3.c pbmtoplot pbmtoplot.om: pbmtoplot.c pbmtoptx pbmtoptx.om: pbmtoptx.c pbmtox10bm pbmtox10bm.om: pbmtox10bm.c pbmtoxbm pbmtoxbm.om: pbmtoxbm.c pbmtoybm pbmtoybm.om: pbmtoybm.c pbmtozinc pbmtozinc.om: pbmtozinc.c pbmupc pbmupc.om: pbmupc.c pi3topbm pi3topbm.om: pi3topbm.c xbmtopbm xbmtopbm.om: xbmtopbm.c ybmtopbm ybmtopbm.om: ybmtopbm.c pbmtoepsi pbmtoepsi.om: pbmtoepsi.c pbmtopk pbmtopk.om: pbmtopk.c pktopbm pktopbm.om: pktopbm.c pbmclean pbmclean.om: pbmclean.c pbmpscale pbmpscale.om: pbmpscale.c pbmtolps pbmtolps.om: pbmtolps.c pbmtoln03 pbmtoln03.om: pbmtoln03.c clean: -delete \#.om \#?.ou \#?.os \#?.or \#?.ols \#?.olr DCC_ERRORS cleanall: clean -delete \#?.lib -delete $(BINDIR) all installlib: lib copy $(LIBRARIES) to $(INSTALLLIB) copy $(HEADERS) to $(INSTALLINCL) installbin: binaries copy $(BINDIR) all to $(INSTALLBIN) installall: installlib installbin install: @echo "Please select: installlib, installbin, installall" netpbm-free-10.0-1/pbm/Makefile.std0100644004714500471450000001322507716230207017335 0ustar aba-guestaba-guest# Makefile for pbm tools. # # Copyright (C) 1989, 1991 by Jef Poskanzer. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, provided # that the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. This software is provided "as is" without express or # implied warranty. # Default values, usually overridden by top-level Makefile. #CC = cc CC = gcc -ansi -pedantic -fpcc-struct-return CFLAGS = -O #CFLAGS = -g #CFLAGS = -g -O TIFFDEF = -DLIBTIFF #LDFLAGS = -s LDFLAGS = INSTALLBINARIES = /usr/new/pbm INSTALLMANUALS1 = /usr/man/man1 SUFFIXMANUALS1 = 1 INSTALLMANUALS3 = /usr/man/man3 SUFFIXMANUALS3 = 3 INSTALLMANUALS5 = /usr/man/man5 SUFFIXMANUALS5 = 5 MANCP = cp SHELL = /bin/sh INCLUDE = -I.. ALLCFLAGS = $(CFLAGS) $(TIFFDEF) $(INCLUDE) LIBPBM = libpbm.a DEFPBM = pbm.h ../pbmplus.h PORTBINARIES = atktopbm brushtopbm cmuwmtopbm g3topbm \ icontopbm gemtopbm macptopbm mgrtopbm \ pbmclean pbmlife pbmmake pbmmask pbmpscale \ pbmreduce pbmtext \ pbmto10x pbmto4425 pbmtoascii pbmtoatk \ pbmtobbnbg pbmtocmuwm \ pbmtoepsi pbmtoepson \ pbmtog3 pbmtogem pbmtogo pbmtoicon pbmtolj \ pbmtoln03 pbmtolps pbmtomacp pbmtomgr \ pbmtopi3 pbmtoplot pbmtoptx \ pbmtox10bm pbmtoxbm pbmtoybm pbmtozinc \ pbmupc pi3topbm pktopbm xbmtopbm ybmtopbm MATHBINARIES = pbmtopk BINARIES = $(PORTBINARIES) $(MATHBINARIES) OBJECTS = atktopbm.o brushtopbm.o cmuwmtopbm.o g3topbm.o \ icontopbm.o gemtopbm.o macptopbm.o mgrtopbm.o \ pbmclean.o pbmlife.o pbmmake.o pbmmask.o pbmpscale.o \ pbmreduce.o pbmtext.o \ pbmto10x.o pbmto4425.o pbmtoascii.o pbmtoatk.o \ pbmtobbnbg.o pbmtocmuwm.o \ pbmtoepsi.o pbmtoepson.o \ pbmtog3.o pbmtogem.o pbmtogo.o pbmtoicon.o pbmtolj.o \ pbmtoln03.o pbmtolps.o pbmtomacp.o pbmtomgr.o \ pbmtopi3.o pbmtoplot.o pbmtoptx.o \ pbmtox10bm.o pbmtoxbm.o pbmtoybm.o pbmtozinc.o \ pbmupc.o pi3topbm.o pktopbm.o xbmtopbm.o ybmtopbm.o \ pbmtopk.o MANUALS1 = $(BINARIES) MANUALS3 = libpbm MANUALS5 = pbm #all: binaries all: merge #install: install.bin install: install.merge binaries: $(BINARIES) install.bin: binaries cd $(INSTALLBINARIES) ; rm -f $(BINARIES) cp $(BINARIES) $(INSTALLBINARIES) merge: pbmmerge pbmmerge: pbmmerge.c $(OBJECTS) $(LIBPBM) $(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(OBJECTS) $(LIBPBM) install.merge: install.pbmmerge install.pbmmerge: pbmmerge cd $(INSTALLBINARIES) ; rm -f $(BINARIES) cp pbmmerge $(INSTALLBINARIES) cd $(INSTALLBINARIES) ; for i in $(BINARIES) ; do ln pbmmerge $$i ; done rm -f $(INSTALLBINARIES)/pbmmerge install.man: for i in $(MANUALS1) ; do \ rm -f $(INSTALLMANUALS1)/$$i.$(SUFFIXMANUALS1) ; \ $(MANCP) $$i.1 $(INSTALLMANUALS1)/$$i.$(SUFFIXMANUALS1) ; \ done for i in $(MANUALS3) ; do \ rm -f $(INSTALLMANUALS3)/$$i.$(SUFFIXMANUALS3) ; \ $(MANCP) $$i.3 $(INSTALLMANUALS3)/$$i.$(SUFFIXMANUALS3) ; \ done for i in $(MANUALS5) ; do \ rm -f $(INSTALLMANUALS5)/$$i.$(SUFFIXMANUALS5) ; \ $(MANCP) $$i.5 $(INSTALLMANUALS5)/$$i.$(SUFFIXMANUALS5) ; \ done # Rule for plain programs. $(PORTBINARIES): $(DEFPBM) $(LIBPBM) $(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(LIBPBM) # Rule for math-dependent programs. $(MATHBINARIES): $(DEFPBM) $(LIBPBM) $(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c -lm $(LIBPBM) # Rule for objects. $(OBJECTS): $(DEFPBM) $(CC) $(ALLCFLAGS) "-Dmain=$*_main" -c $*.c # And library. lib: $(LIBPBM) $(LIBPBM): libpbm1.o libpbm2.o libpbm3.o libpbm4.o libpbm5.o -rm -f $(LIBPBM) ar rc $(LIBPBM) libpbm1.o libpbm2.o libpbm3.o libpbm4.o libpbm5.o -ranlib $(LIBPBM) libpbm1.o: $(DEFPBM) ../version.h ../compile.h libpbm.h libpbm1.c $(CC) $(ALLCFLAGS) -c libpbm1.c libpbm2.o: $(DEFPBM) libpbm.h libpbm2.c $(CC) $(ALLCFLAGS) -c libpbm2.c libpbm3.o: $(DEFPBM) libpbm.h libpbm3.c $(CC) $(ALLCFLAGS) -c libpbm3.c libpbm4.o: $(DEFPBM) libpbm.h libpbm4.c $(CC) $(ALLCFLAGS) -c libpbm4.c libpbm5.o: $(DEFPBM) pbmfont.h libpbm5.c $(CC) $(ALLCFLAGS) -c libpbm5.c # Other dependencies. atktopbm atktopbm.o: atktopbm.c brushtopbm brushtopbm.o: brushtopbm.c cmuwmtopbm cmuwmtopbm.o: cmuwmtopbm.c cmuwm.h g3topbm g3topbm.o: g3topbm.c g3.h icontopbm icontopbm.o: icontopbm.c gemtopbm gemtopbm.o: gemtopbm.c macptopbm macptopbm.o: macptopbm.c macp.h mgrtopbm mgrtopbm.o: mgrtopbm.c mgr.h pbmclean pbmclean.o: pbmclean.c pbmlife pbmlife.o: pbmlife.c pbmmake pbmmake.o: pbmmake.c pbmmask pbmmask.o: pbmmask.c pbmpscale pbmpscale.o: pbmpscale.c pbmreduce pbmreduce.o: pbmreduce.c pbmtext pbmtext.o: pbmtext.c pbmfont.h pbmto10x pbmto10x.o: pbmto10x.c pbmto4425 pbmto4425.o: pbmto4425.c pbmtoascii pbmtoascii.o: pbmtoascii.c pbmtoatk pbmtoatk.o: pbmtoatk.c pbmtobbnbg pbmtobbnbg.o: pbmtobbnbg.c pbmtocmuwm pbmtocmuwm.o: pbmtocmuwm.c cmuwm.h pbmtoepson pbmtoepson.o: pbmtoepson.c pbmtog3 pbmtog3.o: pbmtog3.c g3.h pbmtogem pbmtogem.o: pbmtogem.c pbmtogo pbmtogo.o: pbmtogo.c pbmtoicon pbmtoicon.o: pbmtoicon.c pbmtolj pbmtolj.o: pbmtolj.c pbmtoln03 pbmtoln03.o: pbmtoln03.c pbmtolps pbmtolps.o: pbmtolps.c pbmtomacp pbmtomacp.o: pbmtomacp.c macp.h pbmtomgr pbmtomgr.o: pbmtomgr.c mgr.h pbmtopi3 pbmtopi3.o: pbmtopi3.c pbmtopk pbmtopk.o: pbmtopk.c pbmtoplot pbmtoplot.o: pbmtoplot.c pbmtoptx pbmtoptx.o: pbmtoptx.c pbmtox10bm pbmtox10bm.o: pbmtox10bm.c pbmtoxbm pbmtoxbm.o: pbmtoxbm.c pbmtoybm pbmtoybm.o: pbmtoybm.c pbmtozinc pbmtozinc.o: pbmtozinc.c pbmupc pbmupc.o: pbmupc.c pi3topbm pi3topbm.o: pi3topbm.c pktopbm pktopbm.o: pktopbm.c xbmtopbm xbmtopbm.o: xbmtopbm.c ybmtopbm ybmtopbm.o: ybmtopbm.c pbmtoepsi pbmtoepsi.o: pbmtoepsi.c clean: -rm -f *.o *.a *.cat *~ core $(BINARIES) pbmmerge netpbm-free-10.0-1/pbm/SCOPTIONS0100644004714500471450000000026007716230207016403 0ustar aba-guestaba-guestDATA=FAR OPTIMIZE LINK SMALLCODE STRIPDEBUG NOICONS DEFINE A_STRERROR DEFINE A_RGBENV DEFINE A_FRAGARRAY DEFINE A_SMALLSTACK DEFINE A_FORCEPROTO IGNORE=85 IGNORE=93 IGNORE=304 netpbm-free-10.0-1/pbm/SMakefile0100644004714500471450000001433007716230207016665 0ustar aba-guestaba-guest# Makefile for pbm tools. # # Copyright (C) 1989, 1991 by Jef Poskanzer. # Modified by Robert A. Knop Jr. (rknop@cco.caltech.edu) 940126 for Amiga SAS/C # Merge is not currently supported by this makefile # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, provided # that the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. This software is provided "as is" without express or # implied warranty. # Default values, usually overridden by top-level Makefile. #CC = cc #CC = gcc -ansi -pedantic -fcombine-regs -fpcc-struct-return CC = sc #CFLAGS = -O CFLAGS = #CFLAGS = -g -O TIFFDEF = DEFINE=LIBTIFF #LDFLAGS = -s LDFLAGS = INSTALLBINARIES = /pbm INSTALLMANUALS1 = /man/man1 SUFFIXMANUALS1 = 1 INSTALLMANUALS3 = /man/man3 SUFFIXMANUALS3 = 3 INSTALLMANUALS5 = /man/man5 SUFFIXMANUALS5 = 5 MANCP = copy #SHELL = /bin/sh INCLUDE = IDIR=/ ALLCFLAGS = $(CFLAGS) $(TIFFDEF) $(INCLUDE) LIBPBM = libpbm.lib DEFPBM = pbm.h /pbmplus.h PORTBINARIES = atktopbm brushtopbm cmuwmtopbm g3topbm \ icontopbm gemtopbm macptopbm mgrtopbm \ pbmclean pbmlife pbmmake pbmmask pbmpscale \ pbmtext \ pbmto10x pbmto4425 pbmtoascii pbmtoatk \ pbmtobbnbg pbmtocmuwm \ pbmtoepsi pbmtoepson \ pbmtog3 pbmtogem pbmtogo pbmtoicon pbmtolj pbmtoln03 \ pbmtomacp pbmtomgr \ pbmtopi3 pbmtoplot pbmtoptx \ pbmtox10bm pbmtoxbm pbmtoybm pbmtozinc \ pbmupc pi3topbm pktopbm xbmtopbm ybmtopbm MATHBINARIES = pbmreduce pbmtolps pbmtopk BINARIES = $(PORTBINARIES) $(MATHBINARIES) #NOTE -- pbmtoln03 was removed from PORTBINARIES and pbmtoln03.o from OBJECTS # because they were causing problems-- seemed to be calling a routine in # libpbm.lib that is only defined when compiled under VMS (?) RKNOP 931107 OBJECTS = atktopbm.o brushtopbm.o cmuwmtopbm.o g3topbm.o \ icontopbm.o gemtopbm.o macptopbm.o mgrtopbm.o \ pbmclean.o pbmlife.o pbmmake.o pbmmask.o pbmpscale.o \ pbmtext.o \ pbmto10x.o pbmto4425.o pbmtoascii.o pbmtoatk.o \ pbmtobbnbg.o pbmtocmuwm.o \ pbmtoepsi.o pbmtoepson.o \ pbmtog3.o pbmtogem.o pbmtogo.o pbmtoicon.o pbmtolj.o \ pbmtoln03.o pbmtolps.o pbmtomacp.o pbmtomgr.o \ pbmtopi3.o pbmtoplot.o pbmtoptx.o \ pbmtox10bm.o pbmtoxbm.o pbmtoybm.o pbmtozinc.o \ pbmupc.o pi3topbm.o pktopbm.o xbmtopbm.o \ ybmtopbm.o pbmtopk.o pbmreduce.o MANUALS1 = $(BINARIES) MANUALS3 = libpbm MANUALS5 = pbm all: binaries #all: merge install: install.bin #install: install.merge binaries: $(BINARIES) install.bin: binaries # cd $(INSTALLBINARIES) ; rm -f $(BINARIES) copy $(BINARIES) TO $(INSTALLBINARIES) CLONE #merge: pbmmerge #pbmmerge: pbmmerge.c $(OBJECTS) $(LIBPBM) # $(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(OBJECTS) $(LIBPBM) # #install.merge: install.pbmmerge #install.pbmmerge: pbmmerge # cd $(INSTALLBINARIES) ; rm -f $(BINARIES) # cp pbmmerge $(INSTALLBINARIES) # cd $(INSTALLBINARIES) ; for i in $(BINARIES) ; do ln pbmmerge $$i ; done # rm -f $(INSTALLBINARIES)/pbmmerge install.man: execute < <(T:install_man.temp) foreach i in $(MANUALS1) delete $(INSTALLMANUALS1)/$${i}.$(SUFFIXMANUALS1) $(MANCP) $${i}.1 $(INSTALLMANUALS1)/$${i}.$(SUFFIXMANUALS1) end < execute < <(T:install_man.temp) foreach i in $(MANUALS3) delete $(INSTALLMANUALS3)/$${i}.$(SUFFIXMANUALS3) $(MANCP) $${i}.3 $(INSTALLMANUALS3)/$${i}.$(SUFFIXMANUALS3) end < execute < <(T:install_man.temp) foreach i in $(MANUALS5) delete $(INSTALLMANUALS5)/$${i}.$(SUFFIXMANUALS5) $(MANCP) $${i}.5 $(INSTALLMANUALS5)/$${i}.$(SUFFIXMANUALS5) end < # Rule for plain programs. $(PORTBINARIES): $(DEFPBM) $(LIBPBM) $(CC) $(ALLCFLAGS) $(LDFLAGS) LINK $@.c $(LIBPBM) # Rule for math-dependent programs. $(MATHBINARIES): $(DEFPBM) $(LIBPBM) $(CC) $(ALLCFLAGS) $(LDFLAGS) MATH=I LINK $@.c $(LIBPBM) # below commented out until merge is supported RKNOP 931107 # Rule for objects. #$(OBJECTS): $(DEFPBM) # $(CC) $(ALLCFLAGS) "-Dmain=$*_main" -c $*.c # And library. lib: $(LIBPBM) $(LIBPBM): libpbm1.o libpbm2.o libpbm3.o libpbm4.o libpbm5.o -delete $(LIBPBM) oml $(LIBPBM) r libpbm1.o libpbm2.o libpbm3.o libpbm4.o libpbm5.o libpbm1.o: $(DEFPBM) /version.h /compile.h libpbm.h libpbm1.c $(CC) $(ALLCFLAGS) MATH=I NOLINK libpbm1.c libpbm2.o: $(DEFPBM) libpbm.h libpbm2.c $(CC) $(ALLCFLAGS) MATH=I NOLINK libpbm2.c libpbm3.o: $(DEFPBM) libpbm.h libpbm3.c $(CC) $(ALLCFLAGS) MATH=I NOLINK libpbm3.c libpbm4.o: $(DEFPBM) libpbm.h libpbm4.c $(CC) $(ALLCFLAGS) MATH=I NOLINK libpbm4.c libpbm5.o: $(DEFPBM) pbmfont.h libpbm5.c $(CC) $(ALLCFLAGS) MATH=I NOLINK libpbm5.c # Other dependencies. atktopbm atktopbm.o: atktopbm.c brushtopbm brushtopbm.o: brushtopbm.c cmuwmtopbm cmuwmtopbm.o: cmuwmtopbm.c cmuwm.h g3topbm g3topbm.o: g3topbm.c g3.h icontopbm icontopbm.o: icontopbm.c gemtopbm gemtopbm.o: gemtopbm.c macptopbm macptopbm.o: macptopbm.c macp.h mgrtopbm mgrtopbm.o: mgrtopbm.c mgr.h pbmclean pbmclean.o: pbmclean.c pbmlife pbmlife.o: pbmlife.c pbmmake pbmmake.o: pbmmake.c pbmmask pbmmask.o: pbmmask.c pbmpscale pbmpscale.o: pbmpscale.c pbmreduce pbmreduce.o: pbmreduce.c pbmtext pbmtext.o: pbmtext.c pbmfont.h pbmto10x pbmto10x.o: pbmto10x.c pbmto4425 pbmto4425.o: pbmto4425.c pbmtoascii pbmtoascii.o: pbmtoascii.c pbmtoatk pbmtoatk.o: pbmtoatk.c pbmtobbnbg pbmtobbnbg.o: pbmtobbnbg.c pbmtocmuwm pbmtocmuwm.o: pbmtocmuwm.c cmuwm.h pbmtoepson pbmtoepson.o: pbmtoepson.c pbmtog3 pbmtog3.o: pbmtog3.c g3.h pbmtogem pbmtogem.o: pbmtogem.c pbmtogo pbmtogo.o: pbmtogo.c pbmtoicon pbmtoicon.o: pbmtoicon.c pbmtolj pbmtolj.o: pbmtolj.c pbmtoln03 pbmtoln03.o: pbmtoln03.c pbmtolps pbmtolps.o: pbmtolps.c pbmtomacp pbmtomacp.o: pbmtomacp.c macp.h pbmtomgr pbmtomgr.o: pbmtomgr.c mgr.h pbmtopi3 pbmtopi3.o: pbmtopi3.c pbmtopk pbmtopk.o: pbmtopk.c pbmtoplot pbmtoplot.o: pbmtoplot.c pbmtoptx pbmtoptx.o: pbmtoptx.c pbmtox10bm pbmtox10bm.o: pbmtox10bm.c pbmtoxbm pbmtoxbm.o: pbmtoxbm.c pbmtoybm pbmtoybm.o: pbmtoybm.c pbmtozinc pbmtozinc.o: pbmtozinc.c pbmupc pbmupc.o: pbmupc.c pi3topbm pi3topbm.o: pi3topbm.c pktopbm pktopbm.o: pktopbm.c xbmtopbm xbmtopbm.o: xbmtopbm.c ybmtopbm ybmtopbm.o: ybmtopbm.c pbmtoepsi pbmtoepsi.o: pbmtoepsi.c clean: delete *.o *.lib *.lnk $(BINARIES)netpbm-free-10.0-1/pbm/atktopbm.10100644004714500471450000000141007716230207017000 0ustar aba-guestaba-guest.TH atktopbm 1 "26 September 1991" .IX atktopbm .SH NAME atktopbm - convert Andrew Toolkit raster object to portable bitmap .SH SYNOPSIS .B atktopbm .RI [ atkfile ] .SH DESCRIPTION Reads an Andrew Toolkit raster object as input. .IX "Andrew Toolkit raster object" Produces a portable bitmap as output. .SH "SEE ALSO" pbmtoatk(1), pbm(5) .SH AUTHOR Copyright (C) 1991 by Bill Janssen. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/atktopbm.c0100644004714500471450000002220107725102161017060 0ustar aba-guestaba-guest/* atktopbm.c - convert Andrew Toolkit raster object to portable bitmap ** ** Copyright (C) 1991 by Bill Janssen ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include #include "pbm.h" #include void ReadATKRaster ARGS((FILE *file, int *rwidth, int *rheight, unsigned char **destaddr)); static long ReadRow ARGS((register FILE *file, register unsigned char *row, register long length)); int main( argc, argv ) int argc; char *argv[]; { FILE *ifp; register bit *bitrow, *bP; int rows, cols, row, col, charcount; unsigned char *data, mask; pbm_init ( &argc, argv ); if ( argc > 2 ) pm_usage( "[raster obj]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; ReadATKRaster( ifp, &cols, &rows, &data ); pm_close( ifp ); pbm_writepbminit( stdout, cols, rows, 0 ); bitrow = pbm_allocrow( cols ); for ( row = 0; row < rows; ++row ) { charcount = 0; mask = 0x80; for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) { if ( charcount >= 8 ) { ++data; charcount = 0; mask = 0x80; } *bP = ( *data & mask ) ? PBM_BLACK : PBM_WHITE; ++charcount; mask >>= 1; } ++data; pbm_writepbmrow( stdout, bitrow, cols, 0 ); } pm_close( stdout ); exit( 0 ); } /* readatkraster ** ** Routine for reading rasters in .raster form. (BE2 rasters version 2.) */ /* codes for data stream */ #define WHITEZERO 'f' #define WHITETWENTY 'z' #define BLACKZERO 'F' #define BLACKTWENTY 'Z' #define OTHERZERO 0x1F #define WHITEBYTE 0x00 #define BLACKBYTE 0xFF /* error codes (copied from $ANDREW/atk/basics/common/dataobj.ch) */ /* return values from Read */ #define dataobject_NOREADERROR 0 #define dataobject_PREMATUREEOF 1 #define dataobject_NOTBE2DATASTREAM 2 /* backward compatibility */ #define dataobject_NOTATKDATASTREAM 2 /* preferred version */ #define dataobject_MISSINGENDDATAMARKER 3 #define dataobject_OBJECTCREATIONFAILED 4 #define dataobject_BADFORMAT 5 /* ReadRow(file, row, length) ** Reads from 'file' the encoding of bytes to fill in 'row'. Row will be ** truncated or padded (with WHITE) to exactly 'length' bytes. ** ** Returns the code that terminated the row. This may be ** '|' correct end of line ** '\0' if the length was satisfied (before a terminator) ** EOF if the file ended ** '\' '{' other recognized ends. ** The '|' is the expected end and pads the row with WHITE. ** The '\' and '{' are error conditions and may indicate the ** beginning of some other portion of the data stream. ** If the terminator is '\' or '{', it is left at the front of the input. ** '|' is gobbled up. */ /* macros to generate case entries for switch statement */ #define case1(v) case v #define case4(v) case v: case (v)+1: case (v)+2: case(v)+3 #define case6(v) case4(v): case ((v)+4): case ((v)+5) #define case8(v) case4(v): case4((v)+4) static long ReadRow(file, row, length) register FILE *file; /* where to get them from */ register unsigned char *row; /* where to put bytes */ register long length; /* how many bytes in row must be filled */ { /* Each input character is processed by the central loop. There are ** some input codes which require two or three characters for ** completion; these are handled by advancing the state machine. ** Errors are not processed; instead the state machine is reset ** to the Ready state whenever a character unacceptable to the ** current state is read. */ enum stateCode { Ready, /* any input code is allowed */ HexDigitPending, /* have seen the first of a hex digit pair */ RepeatPending, /* repeat code has been seen: must be followed by two hex digits */ RepeatAndDigit}; /* have seen repeat code and its first following digit */ enum stateCode InputState; /* current state */ register int c; /* the current input character */ register long repeatcount = 0; /* current repeat value */ register long hexval; /* current hex value */ long pendinghex = 0; /* the first of a pair of hex characters */ /* We cannot exit when length becomes zero because we need to check ** to see if a row ending character follows. Thus length is checked ** only when we get a data generating byte. If length then is ** zero, we ungetc the byte. */ InputState = Ready; while ((c=getc(file)) != EOF) switch (c) { case8(0x0): case8(0x8): case8(0x10): case8(0x18): case1(' '): /* control characters and space are legal and ignored */ break; case1(0x40): /* '@' */ case1(0x5B): /* '[' */ case4(0x5D): /* ']' '^' '_' '`' */ case4(0x7D): /* '}' '~' DEL 0x80 */ default: /* all above 0x80 */ /* error code: Ignored at present. Reset InputState. */ InputState = Ready; break; case1(0x7B): /* '{' */ case1(0x5C): /* '\\' */ /* illegal end of line: exit anyway */ ungetc(c, file); /* retain terminator in stream */ /* DROP THROUGH */ case1(0x7C): /* '|' */ /* legal end of row: may have to pad */ while (length-- > 0) *row++ = WHITEBYTE; return c; case1(0x21): case6(0x22): case8(0x28): /* punctuation characters: repeat byte given by two ** succeeding hex chars */ if (length <= 0) { ungetc(c, file); return('\0'); } repeatcount = c - OTHERZERO; InputState = RepeatPending; break; case8(0x30): case8(0x38): /* digit (or following punctuation) - hex digit */ hexval = c - 0x30; goto hexdigit; case6(0x41): /* A ... F - hex digit */ hexval = c - (0x41 - 0xA); goto hexdigit; case6(0x61): /* a ... f - hex digit */ hexval = c - (0x61 - 0xA); goto hexdigit; case8(0x67): case8(0x6F): case4(0x77): /* g ... z - multiple WHITE bytes */ if (length <= 0) { ungetc(c, file); return('\0'); } repeatcount = c - WHITEZERO; hexval = WHITEBYTE; goto store; case8(0x47): case8(0x4F): case4(0x57): /* G ... Z - multiple BLACK bytes */ if (length <= 0) { ungetc(c, file); return('\0'); } repeatcount = c - BLACKZERO; hexval = BLACKBYTE; goto store; hexdigit: /* process a hex digit. Use InputState to determine what to do with it. */ if (length <= 0) { ungetc(c, file); return('\0'); } switch(InputState) { case Ready: InputState = HexDigitPending; pendinghex = hexval << 4; break; case HexDigitPending: hexval |= pendinghex; repeatcount = 1; goto store; case RepeatPending: InputState = RepeatAndDigit; pendinghex = hexval << 4; break; case RepeatAndDigit: hexval |= pendinghex; goto store; } break; store: /* generate byte(s) into the output row Use repeatcount, depending on state. */ if (length < repeatcount) /* reduce repeat count if it would exceed available space */ repeatcount = length; length -= repeatcount; /* do this before repeatcount-- */ while (repeatcount-- > 0) *row++ = hexval; InputState = Ready; break; } /* end of while( - )switch( - ) */ return EOF; } #undef case1 #undef case4 #undef case6 #undef case8 void ReadATKRaster(file, rwidth, rheight, destaddr) FILE *file; unsigned char **destaddr; int *rwidth, *rheight; { register long row, rowlen; /* count rows; byte length of row */ int version; int options; long xscale, yscale; long xoffset, yoffset, subwidth, subheight; char keyword[6]; int discardid; int objectid; /* id read for the incoming pixel image */ long tc; /* temp */ int width, height; /* dimensions of image */ if (fscanf(file, "\\begindata{raster,%d", &discardid) != 1 || getc(file) != '}' || getc(file) != '\n') pm_error ("input file not Andrew raster object"); fscanf(file, " %d ", &version); if (version < 2) pm_error ("version too old to parse"); /* ignore all these features: */ fscanf(file, " %u %ld %ld %ld %ld %ld %ld", &options, &xscale, &yscale, &xoffset, &yoffset, &subwidth, &subheight); /* scan to end of line in case this is actually something beyond V2 */ while (((tc=getc(file)) != '\n') && (tc != '\\') && (tc != EOF)) {} /* read the keyword */ fscanf(file, " %5s", keyword); if (strcmp(keyword, "bits") != 0) pm_error ("keyword is not bits!"); fscanf(file, " %d %d %d ", &objectid, &width, &height); if (width < 1 || height < 1 || width > 1000000 || height > 1000000) pm_error ("bad width or height"); *rwidth = width; *rheight = height; rowlen = (width + 7) / 8; *destaddr = (unsigned char *) malloc3 (sizeof(unsigned char), height, rowlen); for (row = 0; row < height; row++) { long c; c = ReadRow(file, *destaddr + (row * rowlen), rowlen); if (c != '|') { if (c == EOF) pm_error ("premature EOF"); else pm_error ("bad format"); break; } } while (! feof(file) && getc(file) != '\\') {}; /* scan for \enddata */ if (fscanf(file, "enddata{raster,%d", &discardid) != 1 || getc(file) != '}' || getc(file) != '\n') pm_error ("missing end-of-object marker"); } netpbm-free-10.0-1/pbm/bitio.c0100644004714500471450000001056507725102161016357 0ustar aba-guestaba-guest/*\ * $Id: bitio.c,v 1.2 2003/09/02 11:52:17 aba-guest Exp $ * * bitio.c - bitstream I/O * * Works for (sizeof(unsigned long)-1)*8 bits. * * Copyright (C) 1992 by David W. Sanderson. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. This software is provided "as is" * without express or implied warranty. * * $Log: bitio.c,v $ * Revision 1.2 2003/09/02 11:52:17 aba-guest * reduced number of compiler warnings * * Revision 1.1 2003/08/15 14:30:17 aba-guest * Next part of update to 9.25 * * Revision 1.5 1992/11/24 19:36:46 dws * Added copyright. * * Revision 1.4 1992/11/17 03:37:50 dws * updated comment * * Revision 1.3 1992/11/10 23:15:16 dws * Removed superfluous code. * * Revision 1.2 1992/11/10 23:11:22 dws * Generalized to handle more than one bitstream at once. * * Revision 1.1 1992/11/10 18:33:21 dws * Initial revision * \*/ #include "bitio.h" #include struct bitstream { FILE * f; /* bytestream */ unsigned long bitbuf; /* bit buffer */ int nbitbuf; /* number of bits in 'bitbuf' */ char mode; }; #define Mask(n) ((1<<(n))-1) #define BitPut(b,ul,n) ((b)->bitbuf = (((b)->bitbuf<<(n)) \ |((ul)&Mask(n))), \ (b)->nbitbuf += (n)) #define BitGet(b,n) (((b)->bitbuf>>((b)->nbitbuf-=(n))) & Mask(n)) /* * pm_bitinit() - allocate and return a struct bitstream * for the * given FILE*. * * mode must be one of "r" or "w", according to whether you will be * reading from or writing to the struct bitstream *. * * Returns 0 on error. */ struct bitstream * pm_bitinit(FILE * const f, char * const mode) { struct bitstream * ans; if (!f || !mode) ans = NULL; else if (strcmp(mode, "r") != 0 && strcmp(mode, "w") != 0) ans = NULL; else { ans = (struct bitstream *)calloc(1, sizeof(struct bitstream)); if (ans != NULL) { ans->f = f; ans->mode = *mode; } } return ans; } /* * pm_bitfini() - deallocate the given struct bitstream *. * * You must call this after you are done with the struct bitstream *. * * It may flush some bits left in the buffer. * * Returns the number of bytes written, -1 on error. */ int pm_bitfini(b) struct bitstream *b; { int nbyte = 0; if(!b) return -1; /* flush the output */ if(b->mode == 'w') { /* flush the bits */ if (b->nbitbuf < 0 || b->nbitbuf >= 8) { /* pm_bitwrite() didn't work */ return -1; } /* * If we get to here, nbitbuf is 0..7 */ if(b->nbitbuf) { char c; BitPut(b, 0, (long)8-(b->nbitbuf)); c = (char) BitGet(b, (long)8); if(putc(c, b->f) == EOF) { return -1; } nbyte++; } } free(b); return nbyte; } /* * pm_bitread() - read the next nbits into *val from the given file. * * The last pm_bitread() must be followed by a call to pm_bitfini(). * * Returns the number of bytes read, -1 on error. */ int pm_bitread(b, nbits, val) struct bitstream *b; unsigned long nbits; unsigned long *val; { int nbyte = 0; int c; if(!b) return -1; while (b->nbitbuf < nbits) { if((c = getc(b->f)) == EOF) { return -1; } nbyte++; BitPut(b, c, (long) 8); } *val = BitGet(b, nbits); return nbyte; } /* * pm_bitwrite() - write the low nbits of val to the given file. * * The last pm_bitwrite() must be followed by a call to pm_bitfini(). * * Returns the number of bytes written, -1 on error. */ int pm_bitwrite(b, nbits, val) struct bitstream *b; unsigned long nbits; unsigned long val; { int nbyte = 0; char c; if(!b) return -1; BitPut(b, val, nbits); while (b->nbitbuf >= 8) { c = (char) BitGet(b, (long)8); if(putc(c, b->f) == EOF) { return -1; } nbyte++; } return nbyte; } netpbm-free-10.0-1/pbm/bitreverse.h0100644004714500471450000000435307716230207017431 0ustar aba-guestaba-guest/* ** bitreverse.h ** ** This particular array seems to be useful in a lot of bitmap ** conversion programs. It's not used in pbm because bits are ** stored one per byte, for easier manipulation. But if you wanted ** to write, for example, a program to directly convert Sun raster ** format into X bitmaps, you could use this. ** ** Of course, you could also use this fairly slick chunk of code: ** ** c = ((c >> 1) & 0x55) | ((c << 1) & 0xaa); ** c = ((c >> 2) & 0x33) | ((c << 2) & 0xcc); ** c = ((c >> 4) & 0x0f) | ((c << 4) & 0xf0); */ #ifndef _BITR_H_ #define _BITR_H_ static unsigned char bitreverse[256] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff}; #endif /*_BITR_H_*/ netpbm-free-10.0-1/pbm/brushtopbm.10100644004714500471450000000145207716230207017352 0ustar aba-guestaba-guest.TH brushtopbm 1 "28 August 1988" .IX brushtopbm .SH NAME brushtopbm - convert a doodle brush file into a portable bitmap .SH SYNOPSIS .B brushtopbm .RI [ brushfile ] .SH DESCRIPTION Reads a Xerox doodle brush file as input. .IX "Xerox doodle brush format" Produces a portable bitmap as output. .PP Note that there is currently no pbmtobrush tool. .SH "SEE ALSO" pbm(5) .SH AUTHOR Copyright (C) 1988 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/brushtopbm.c0100644004714500471450000000453007716230207017434 0ustar aba-guestaba-guest/* brushtopbm.c - read a doodle brush file and write a portable bitmap ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" static void getinit ARGS(( FILE* file, int* colsP, int* rowsP )); static bit getbit ARGS(( FILE* file )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int rows, cols, padright, row, col; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[brushfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; getinit( ifp, &cols, &rows ); pbm_writepbminit( stdout, cols, rows, 0 ); bitrow = pbm_allocrow( cols ); /* Compute padding to round cols up to the next multiple of 16. */ padright = ( ( cols + 15 ) / 16 ) * 16 - cols; for ( row = 0; row < rows; ++row ) { /* Get data. */ for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) *bP = getbit( ifp ); /* Discard line padding. */ for ( col = 0; col < padright; ++col ) (void) getbit( ifp ); /* Write row. */ pbm_writepbmrow( stdout, bitrow, cols, 0 ); } pm_close( ifp ); pm_close( stdout ); exit( 0 ); } static int item, bitsperitem, bitshift; static void getinit( file, colsP, rowsP ) FILE* file; int* colsP; int* rowsP; { int i; if ( getc( file ) != 1 ) pm_error( "bad magic number 1" ); if ( getc( file ) != 0 ) pm_error( "bad magic number 2" ); *colsP = getc( file ) << 8; *colsP += getc( file ); *rowsP = getc( file ) << 8; *rowsP += getc( file ); bitsperitem = 8; /* Junk rest of header. */ for ( i = 0; i < 10; ++i ) /* 10 is just a guess at the header size */ (void) getc( file ); } static bit getbit( file ) FILE* file; { bit b; if ( bitsperitem == 8 ) { item = getc( file ); bitsperitem = 0; bitshift = 7; } ++bitsperitem; b = ( ( item >> bitshift) & 1 ) ? PBM_WHITE : PBM_BLACK; --bitshift; return b; } netpbm-free-10.0-1/pbm/cmuwm.h0100644004714500471450000000037607716230207016410 0ustar aba-guestaba-guest/* cmuwm.h - definitions for the CMU window manager format */ #ifndef _CMUWM_H_ #define _CMUWM_H_ struct cmuwm_header { long magic; long width; long height; short depth; }; #define CMUWM_MAGIC 0xf10040bbL #endif /*_CMUWM_H_*/ netpbm-free-10.0-1/pbm/cmuwmtopbm.10100644004714500471450000000141507716230207017356 0ustar aba-guestaba-guest.TH cmuwmtopbm 1 "15 April 1989" .IX cmuwmtopbm .SH NAME cmuwmtopbm - convert a CMU window manager bitmap into a portable bitmap .SH SYNOPSIS .B cmuwmtopbm .RI [ cmuwmfile ] .SH DESCRIPTION Reads a CMU window manager bitmap as input. .IX "CMU window manager bitmap" Produces a portable bitmap as output. .SH "SEE ALSO" pbmtocmuwm(1), pbm(5) .SH AUTHOR Copyright (C) 1989 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/cmuwmtopbm.c0100644004714500471450000000520307716230207017437 0ustar aba-guestaba-guest/* cmuwmtopbm.c - read a CMU window manager bitmap and produce a portable bitmap ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #include "cmuwm.h" static void getinit ARGS(( FILE* file, int* colsP, int* rowsP, short* depthP, int* padrightP )); static bit getbit ARGS(( FILE* file )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int rows, cols, padright, row, col; short depth; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[cmuwmfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; getinit( ifp, &cols, &rows, &depth, &padright ); if ( depth != 1 ) pm_error( "CMU window manager file has depth of %d, must be 1", (int) depth ); pbm_writepbminit( stdout, cols, rows, 0 ); bitrow = pbm_allocrow( cols ); for ( row = 0; row < rows; ++row ) { /* Get data. */ for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) *bP = getbit( ifp ); /* Discard line padding */ for ( col = 0; col < padright; ++col ) (void) getbit( ifp ); pbm_writepbmrow( stdout, bitrow, cols, 0 ); } pm_close( ifp ); pm_close( stdout ); exit( 0 ); } static int item, bitsperitem, bitshift; static void getinit( file, colsP, rowsP, depthP, padrightP ) FILE* file; int* colsP; int* rowsP; short* depthP; int* padrightP; { long l; if ( pm_readbiglong( file, &l ) == -1 ) pm_error( "EOF / read error" ); if ( l != CMUWM_MAGIC ) pm_error( "bad magic number in CMU window manager file" ); if ( pm_readbiglong( file, &l ) == -1 ) pm_error( "EOF / read error" ); *colsP = (int) l; if ( pm_readbiglong( file, &l ) == -1 ) pm_error( "EOF / read error" ); *rowsP = (int) l; if ( pm_readbigshort( file, depthP ) == -1 ) pm_error( "EOF / read error" ); *padrightP = ( ( *colsP + 7 ) / 8 ) * 8 - *colsP; bitsperitem = 0; } static bit getbit( file ) FILE* file; { bit b; if ( bitsperitem == 0 ) { item = getc( file ); if ( item == EOF ) pm_error( "EOF / read error" ); bitsperitem = 8; bitshift = 7; } b = ( ( item >> bitshift) & 1 ) ? PBM_WHITE : PBM_BLACK; --bitsperitem; --bitshift; return b; } netpbm-free-10.0-1/pbm/g3.h0100644004714500471450000001463307716230207015572 0ustar aba-guestaba-guest/* g3.h - header file for group 3 FAX compression filters */ #ifndef _G3_H_ #define _G3_H_ typedef struct tableentry { int tabid; int code; int length; int count; } tableentry; #define TWTABLE 23 #define MWTABLE 24 #define TBTABLE 25 #define MBTABLE 26 #define EXTABLE 27 #define VRTABLE 28 static struct tableentry twtable[] = { { TWTABLE, 0x35, 8, 0 }, { TWTABLE, 0x7, 6, 1 }, { TWTABLE, 0x7, 4, 2 }, { TWTABLE, 0x8, 4, 3 }, { TWTABLE, 0xb, 4, 4 }, { TWTABLE, 0xc, 4, 5 }, { TWTABLE, 0xe, 4, 6 }, { TWTABLE, 0xf, 4, 7 }, { TWTABLE, 0x13, 5, 8 }, { TWTABLE, 0x14, 5, 9 }, { TWTABLE, 0x7, 5, 10 }, { TWTABLE, 0x8, 5, 11 }, { TWTABLE, 0x8, 6, 12 }, { TWTABLE, 0x3, 6, 13 }, { TWTABLE, 0x34, 6, 14 }, { TWTABLE, 0x35, 6, 15 }, { TWTABLE, 0x2a, 6, 16 }, { TWTABLE, 0x2b, 6, 17 }, { TWTABLE, 0x27, 7, 18 }, { TWTABLE, 0xc, 7, 19 }, { TWTABLE, 0x8, 7, 20 }, { TWTABLE, 0x17, 7, 21 }, { TWTABLE, 0x3, 7, 22 }, { TWTABLE, 0x4, 7, 23 }, { TWTABLE, 0x28, 7, 24 }, { TWTABLE, 0x2b, 7, 25 }, { TWTABLE, 0x13, 7, 26 }, { TWTABLE, 0x24, 7, 27 }, { TWTABLE, 0x18, 7, 28 }, { TWTABLE, 0x2, 8, 29 }, { TWTABLE, 0x3, 8, 30 }, { TWTABLE, 0x1a, 8, 31 }, { TWTABLE, 0x1b, 8, 32 }, { TWTABLE, 0x12, 8, 33 }, { TWTABLE, 0x13, 8, 34 }, { TWTABLE, 0x14, 8, 35 }, { TWTABLE, 0x15, 8, 36 }, { TWTABLE, 0x16, 8, 37 }, { TWTABLE, 0x17, 8, 38 }, { TWTABLE, 0x28, 8, 39 }, { TWTABLE, 0x29, 8, 40 }, { TWTABLE, 0x2a, 8, 41 }, { TWTABLE, 0x2b, 8, 42 }, { TWTABLE, 0x2c, 8, 43 }, { TWTABLE, 0x2d, 8, 44 }, { TWTABLE, 0x4, 8, 45 }, { TWTABLE, 0x5, 8, 46 }, { TWTABLE, 0xa, 8, 47 }, { TWTABLE, 0xb, 8, 48 }, { TWTABLE, 0x52, 8, 49 }, { TWTABLE, 0x53, 8, 50 }, { TWTABLE, 0x54, 8, 51 }, { TWTABLE, 0x55, 8, 52 }, { TWTABLE, 0x24, 8, 53 }, { TWTABLE, 0x25, 8, 54 }, { TWTABLE, 0x58, 8, 55 }, { TWTABLE, 0x59, 8, 56 }, { TWTABLE, 0x5a, 8, 57 }, { TWTABLE, 0x5b, 8, 58 }, { TWTABLE, 0x4a, 8, 59 }, { TWTABLE, 0x4b, 8, 60 }, { TWTABLE, 0x32, 8, 61 }, { TWTABLE, 0x33, 8, 62 }, { TWTABLE, 0x34, 8, 63 }, }; static struct tableentry mwtable[] = { { MWTABLE, 0x1b, 5, 64 }, { MWTABLE, 0x12, 5, 128 }, { MWTABLE, 0x17, 6, 192 }, { MWTABLE, 0x37, 7, 256 }, { MWTABLE, 0x36, 8, 320 }, { MWTABLE, 0x37, 8, 384 }, { MWTABLE, 0x64, 8, 448 }, { MWTABLE, 0x65, 8, 512 }, { MWTABLE, 0x68, 8, 576 }, { MWTABLE, 0x67, 8, 640 }, { MWTABLE, 0xcc, 9, 704 }, { MWTABLE, 0xcd, 9, 768 }, { MWTABLE, 0xd2, 9, 832 }, { MWTABLE, 0xd3, 9, 896 }, { MWTABLE, 0xd4, 9, 960 }, { MWTABLE, 0xd5, 9, 1024 }, { MWTABLE, 0xd6, 9, 1088 }, { MWTABLE, 0xd7, 9, 1152 }, { MWTABLE, 0xd8, 9, 1216 }, { MWTABLE, 0xd9, 9, 1280 }, { MWTABLE, 0xda, 9, 1344 }, { MWTABLE, 0xdb, 9, 1408 }, { MWTABLE, 0x98, 9, 1472 }, { MWTABLE, 0x99, 9, 1536 }, { MWTABLE, 0x9a, 9, 1600 }, { MWTABLE, 0x18, 6, 1664 }, { MWTABLE, 0x9b, 9, 1728 }, }; static struct tableentry tbtable[] = { { TBTABLE, 0x37, 10, 0 }, { TBTABLE, 0x2, 3, 1 }, { TBTABLE, 0x3, 2, 2 }, { TBTABLE, 0x2, 2, 3 }, { TBTABLE, 0x3, 3, 4 }, { TBTABLE, 0x3, 4, 5 }, { TBTABLE, 0x2, 4, 6 }, { TBTABLE, 0x3, 5, 7 }, { TBTABLE, 0x5, 6, 8 }, { TBTABLE, 0x4, 6, 9 }, { TBTABLE, 0x4, 7, 10 }, { TBTABLE, 0x5, 7, 11 }, { TBTABLE, 0x7, 7, 12 }, { TBTABLE, 0x4, 8, 13 }, { TBTABLE, 0x7, 8, 14 }, { TBTABLE, 0x18, 9, 15 }, { TBTABLE, 0x17, 10, 16 }, { TBTABLE, 0x18, 10, 17 }, { TBTABLE, 0x8, 10, 18 }, { TBTABLE, 0x67, 11, 19 }, { TBTABLE, 0x68, 11, 20 }, { TBTABLE, 0x6c, 11, 21 }, { TBTABLE, 0x37, 11, 22 }, { TBTABLE, 0x28, 11, 23 }, { TBTABLE, 0x17, 11, 24 }, { TBTABLE, 0x18, 11, 25 }, { TBTABLE, 0xca, 12, 26 }, { TBTABLE, 0xcb, 12, 27 }, { TBTABLE, 0xcc, 12, 28 }, { TBTABLE, 0xcd, 12, 29 }, { TBTABLE, 0x68, 12, 30 }, { TBTABLE, 0x69, 12, 31 }, { TBTABLE, 0x6a, 12, 32 }, { TBTABLE, 0x6b, 12, 33 }, { TBTABLE, 0xd2, 12, 34 }, { TBTABLE, 0xd3, 12, 35 }, { TBTABLE, 0xd4, 12, 36 }, { TBTABLE, 0xd5, 12, 37 }, { TBTABLE, 0xd6, 12, 38 }, { TBTABLE, 0xd7, 12, 39 }, { TBTABLE, 0x6c, 12, 40 }, { TBTABLE, 0x6d, 12, 41 }, { TBTABLE, 0xda, 12, 42 }, { TBTABLE, 0xdb, 12, 43 }, { TBTABLE, 0x54, 12, 44 }, { TBTABLE, 0x55, 12, 45 }, { TBTABLE, 0x56, 12, 46 }, { TBTABLE, 0x57, 12, 47 }, { TBTABLE, 0x64, 12, 48 }, { TBTABLE, 0x65, 12, 49 }, { TBTABLE, 0x52, 12, 50 }, { TBTABLE, 0x53, 12, 51 }, { TBTABLE, 0x24, 12, 52 }, { TBTABLE, 0x37, 12, 53 }, { TBTABLE, 0x38, 12, 54 }, { TBTABLE, 0x27, 12, 55 }, { TBTABLE, 0x28, 12, 56 }, { TBTABLE, 0x58, 12, 57 }, { TBTABLE, 0x59, 12, 58 }, { TBTABLE, 0x2b, 12, 59 }, { TBTABLE, 0x2c, 12, 60 }, { TBTABLE, 0x5a, 12, 61 }, { TBTABLE, 0x66, 12, 62 }, { TBTABLE, 0x67, 12, 63 }, }; static struct tableentry mbtable[] = { { MBTABLE, 0xf, 10, 64 }, { MBTABLE, 0xc8, 12, 128 }, { MBTABLE, 0xc9, 12, 192 }, { MBTABLE, 0x5b, 12, 256 }, { MBTABLE, 0x33, 12, 320 }, { MBTABLE, 0x34, 12, 384 }, { MBTABLE, 0x35, 12, 448 }, { MBTABLE, 0x6c, 13, 512 }, { MBTABLE, 0x6d, 13, 576 }, { MBTABLE, 0x4a, 13, 640 }, { MBTABLE, 0x4b, 13, 704 }, { MBTABLE, 0x4c, 13, 768 }, { MBTABLE, 0x4d, 13, 832 }, { MBTABLE, 0x72, 13, 896 }, { MBTABLE, 0x73, 13, 960 }, { MBTABLE, 0x74, 13, 1024 }, { MBTABLE, 0x75, 13, 1088 }, { MBTABLE, 0x76, 13, 1152 }, { MBTABLE, 0x77, 13, 1216 }, { MBTABLE, 0x52, 13, 1280 }, { MBTABLE, 0x53, 13, 1344 }, { MBTABLE, 0x54, 13, 1408 }, { MBTABLE, 0x55, 13, 1472 }, { MBTABLE, 0x5a, 13, 1536 }, { MBTABLE, 0x5b, 13, 1600 }, { MBTABLE, 0x64, 13, 1664 }, { MBTABLE, 0x65, 13, 1728 }, }; static struct tableentry extable[] = { { EXTABLE, 0x8, 11, 1792 }, { EXTABLE, 0xc, 11, 1856 }, { EXTABLE, 0xd, 11, 1920 }, { EXTABLE, 0x12, 12, 1984 }, { EXTABLE, 0x13, 12, 2048 }, { EXTABLE, 0x14, 12, 2112 }, { EXTABLE, 0x15, 12, 2176 }, { EXTABLE, 0x16, 12, 2240 }, { EXTABLE, 0x17, 12, 2304 }, { EXTABLE, 0x1c, 12, 2368 }, { EXTABLE, 0x1d, 12, 2432 }, { EXTABLE, 0x1e, 12, 2496 }, { EXTABLE, 0x1f, 12, 2560 }, }; #endif /*_G3_H_*/ netpbm-free-10.0-1/pbm/g3topbm.10100644004714500471450000000300207716230207016531 0ustar aba-guestaba-guest.TH g3topbm 1 "02 October 1989" .IX g3topbm .SH NAME g3topbm - convert a Group 3 fax file into a portable bitmap .SH SYNOPSIS .B g3topbm .RB [ -kludge ] .RB [ -reversebits ] .RB [ -stretch ] .RI [ g3file ] .SH DESCRIPTION Reads a Group 3 fax file as input. .IX "Group 3 fax" .IX fax Produces a portable bitmap as output. .SH OPTIONS .TP .B -kludge Tells .I g3topbm to ignore the first few lines of the file; sometimes fax files have some junk at the beginning. .TP .B -reversebits Tells .I g3topbm to interpret bits least-significant first, instead of the default most-significant first. Apparently some fax modems do it one way and others do it the other way. If you get a whole bunch of "bad code word" messages, try using this flag. .TP .B -stretch Tells .I g3topbm to stretch the image vertically by duplicating each row. This is for the low-quality transmission mode. .PP All flags can be abbreviated to their shortest unique prefix. .SH REFERENCES The standard for Group 3 fax is defined in CCITT Recommendation T.4. .SH BUGS Probably. .SH "SEE ALSO" pbmtog3(1), pbm(5) .SH AUTHOR Copyright (C) 1989 by Paul Haeberli . .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/g3topbm.c0100644004714500471450000001455307716762513016642 0ustar aba-guestaba-guest/* g3topbm.c - read a Group 3 FAX file and produce a portable bitmap ** ** Copyright (C) 1989 by Paul Haeberli . ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #include "g3.h" #define TABSIZE(tab) (sizeof(tab)/sizeof(struct tableentry)) #define MAXCOLS 10800 #define MAXROWS 14400 /* up to two pages long */ static int endoffile = 0; static int eols; static int rawzeros; static int shdata; static int kludge; static int reversebits; static int stretch; #define WHASHA 3510 #define WHASHB 1178 #define BHASHA 293 #define BHASHB 2695 #define HASHSIZE 1021 static tableentry* whash[HASHSIZE]; static tableentry* bhash[HASHSIZE]; static void addtohash ARGS(( tableentry* hash[], tableentry* te, int n, int a, int b )); static tableentry* hashfind ARGS(( tableentry* hash[], int length, int code, int a, int b )); static int getfaxrow ARGS(( FILE* inf, int row, bit* bitrow )); static void skiptoeol ARGS(( FILE* file )); static int rawgetbit ARGS(( FILE* file )); static bit* bits[MAXROWS]; int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; int argn, rows, cols, row, col, i; char* usage = "[-kludge][-reversebits][-stretch] [g3file]"; pbm_init( &argc, argv ); argn = 1; kludge = 0; reversebits = 0; stretch = 0; /* Check for flags. */ while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( pm_keymatch( argv[argn], "-kludge", 2 ) ) kludge = 1; else if ( pm_keymatch( argv[argn], "-reversebits", 2 ) ) reversebits = 1; else if ( pm_keymatch( argv[argn], "-stretch", 2 ) ) stretch = 1; else pm_usage( usage ); argn++; } if ( argn < argc ) { ifp = pm_openr( argv[argn] ); argn++; } else ifp = stdin; if ( argn != argc ) pm_usage( usage ); eols = 0; if ( kludge ) { /* Skip extra lines to get in sync. */ skiptoeol( ifp ); skiptoeol( ifp ); skiptoeol( ifp ); } skiptoeol( ifp ); for ( i = 0; i < HASHSIZE; ++i ) whash[i] = bhash[i] = (tableentry*) 0; addtohash( whash, twtable, TABSIZE(twtable), WHASHA, WHASHB ); addtohash( whash, mwtable, TABSIZE(mwtable), WHASHA, WHASHB ); addtohash( whash, extable, TABSIZE(extable), WHASHA, WHASHB ); addtohash( bhash, tbtable, TABSIZE(tbtable), BHASHA, BHASHB ); addtohash( bhash, mbtable, TABSIZE(mbtable), BHASHA, BHASHB ); addtohash( bhash, extable, TABSIZE(extable), BHASHA, BHASHB ); cols = 0; for ( rows = 0; rows < MAXROWS; ++rows ) { bits[rows] = pbm_allocrow( MAXCOLS ); col = getfaxrow( ifp, rows, bits[rows] ); if ( endoffile ) break; if ( !col) { --rows; continue; } if ( col > cols ) cols = col; if ( stretch ) { bits[rows + 1] = bits[rows]; ++rows; } } pm_close( ifp ); pbm_writepbminit( stdout, cols, rows, 0 ); for ( row = 0; row < rows; ++row ) pbm_writepbmrow( stdout, bits[row], cols, 0 ); pm_close( stdout ); exit(0); } static void addtohash(hash, te, n, a, b) tableentry* hash[]; tableentry* te; int n, a, b; { unsigned int pos; while (n--) { pos = ((te->length+a)*(te->code+b))%HASHSIZE; if (hash[pos] != 0) pm_error( "internal error: addtohash fatal hash collision" ); hash[pos] = te; te++; } } static tableentry* hashfind(hash, length, code, a, b) tableentry* hash[]; int length, code; int a, b; { unsigned int pos; tableentry* te; pos = ((length+a)*(code+b))%HASHSIZE; te = hash[pos]; return ((te && te->length == length && te->code == code) ? te : 0); } static int getfaxrow( inf, row, bitrow ) FILE* inf; int row; bit* bitrow; { int col; bit* bP; int curlen, curcode, nextbit; int count, color; tableentry* te; for ( col = 0, bP = bitrow; col < MAXCOLS; ++col, ++bP ) *bP = PBM_WHITE; col = 0; rawzeros = 0; curlen = 0; curcode = 0; color = 1; count = 0; while (!endoffile) { if (col >= MAXCOLS) { skiptoeol(inf); return (col); } do { if (rawzeros >= 11) { nextbit = rawgetbit(inf); if (nextbit) { if (col == 0) /* XXX should be 6 */ endoffile = (++eols == 3); else eols = 0; #ifdef notdef if (col && col < 1728) pm_message( "warning, row %d short (len %d)", row, col ); #endif /*notdef*/ return (col); } } else nextbit = rawgetbit(inf); curcode = (curcode<<1) + nextbit; curlen++; } while (curcode <= 0); if (curlen > 13) { pm_message( "bad code word at row %d, col %d (len %d code 0x%x), " "skipping to EOL", row, col, curlen, curcode); skiptoeol(inf); return (col); } if (color) { if (curlen < 4) continue; te = hashfind(whash, curlen, curcode, WHASHA, WHASHB); } else { if (curlen < 2) continue; te = hashfind(bhash, curlen, curcode, BHASHA, BHASHB); } if (!te) continue; switch (te->tabid) { case TWTABLE: case TBTABLE: count += te->count; if (col+count > MAXCOLS) count = MAXCOLS-col; if (count > 0) { if (color) { col += count; count = 0; } else { for ( ; count > 0; --count, ++col ) bitrow[col] = PBM_BLACK; } } curcode = 0; curlen = 0; color = !color; break; case MWTABLE: case MBTABLE: count += te->count; curcode = 0; curlen = 0; break; case EXTABLE: count += te->count; curcode = 0; curlen = 0; break; default: pm_error( "internal bad poop" ); } } return (0); } static void skiptoeol( file ) FILE* file; { while ( rawzeros < 11 ) (void) rawgetbit( file ); for ( ; ; ) { if ( rawgetbit( file ) ) break; } } static int shbit = 0; static int rawgetbit( file ) FILE* file; { int b; if ( ( shbit & 0xff ) == 0 ) { shdata = getc( file ); if ( shdata == EOF ) pm_error( "EOF / read error at line %d", eols ); shbit = reversebits ? 0x01 : 0x80; } if ( shdata & shbit ) { rawzeros = 0; b = 1; } else { rawzeros++; b = 0; } if ( reversebits ) shbit <<= 1; else shbit >>= 1; return b; } netpbm-free-10.0-1/pbm/icontopbm.10100644004714500471450000000134407716230207017157 0ustar aba-guestaba-guest.TH icontopbm 1 "31 August 1988" .IX icontopbm .SH NAME icontopbm - convert a Sun icon into a portable bitmap .SH SYNOPSIS .B icontopbm .RI [ iconfile ] .SH DESCRIPTION Reads a Sun icon as input. .IX Sun .IX "Sun icon format" Produces a portable bitmap as output. .SH "SEE ALSO" pbmtoicon(1), pbm(5) .SH AUTHOR Copyright (C) 1988 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/icontopbm.c0100644004714500471450000000714707716230207017250 0ustar aba-guestaba-guest/* icontopbm.c - read a Sun icon file and produce a portable bitmap ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include #include "pbm.h" static void ReadIconFile ARGS(( FILE* file, int* width, int* height, short** data )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int rows, cols, row, col, shortcount, mask; short* data; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[iconfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; ReadIconFile( ifp, &cols, &rows, &data ); pm_close( ifp ); pbm_writepbminit( stdout, cols, rows, 0 ); bitrow = pbm_allocrow( cols ); for ( row = 0; row < rows; row++ ) { shortcount = 0; mask = 0x8000; for ( col = 0, bP = bitrow; col < cols; col++, bP++ ) { if ( shortcount >= 16 ) { data++; shortcount = 0; mask = 0x8000; } *bP = ( *data & mask ) ? PBM_BLACK : PBM_WHITE; shortcount++; mask = mask >> 1; } data++; pbm_writepbmrow( stdout, bitrow, cols, 0 ); } pm_close( stdout ); exit( 0 ); } /* size in bytes of a bitmap */ #define BitmapSize(width, height) (((((width) + 15) >> 3) &~ 1) * (height)) static void ReadIconFile( file, width, height, data ) FILE* file; int* width; int* height; short** data; { char variable[81], ch; int status, value, i, data_length, gotsome; gotsome = 0; *width = *height = -1; for ( ; ; ) { while ( ( ch = getc( file ) ) == ',' || ch == '\n' || ch == '\t' || ch == ' ' ) ; for ( i = 0; ch != '=' && ch != ',' && ch != '\n' && ch != '\t' && ch != ' '; i++ ) { variable[i] = ch; ch = getc( file ); } variable[i] = '\0'; if ( strcmp( variable, "*/" ) == 0 && gotsome ) break; if ( fscanf( file, "%d", &value ) != 1 ) continue; if ( strcmp( variable, "Width" ) == 0 ) { *width = value; gotsome = 1; } else if ( strcmp( variable, "Height" ) == 0 ) { *height = value; gotsome = 1; } else if ( strcmp( variable, "Depth" ) == 0 ) { if ( value != 1 ) pm_error( "invalid depth" ); gotsome = 1; } else if ( strcmp( variable, "Format_version" ) == 0 ) { if ( value != 1 ) pm_error( "invalid Format_version" ); gotsome = 1; } else if ( strcmp( variable, "Valid_bits_per_item" ) == 0 ) { if ( value != 16 ) pm_error( "invalid Valid_bits_per_item" ); gotsome = 1; } } if ( *width <= 0 ) pm_error( "invalid width: %d", *width ); if ( *height <= 0 ) pm_error( "invalid height: %d", *height ); if ( *width > INT_MAX - 16 || *width < 0) pm_error( "invalid width: %d", *width); overflow2(*width + 16, *height); data_length = BitmapSize( *width, *height ); *data = (short*) malloc( data_length ); if ( *data == NULL ) pm_error( "out of memory" ); data_length /= sizeof( short ); for ( i = 0 ; i < data_length; i++ ) { if ( i == 0 ) status = fscanf( file, " 0x%4hx", *data ); else status = fscanf( file, ", 0x%4hx", *data + i ); if ( status != 1 ) pm_error( "error 4 scanning bits item" ); } } netpbm-free-10.0-1/pbm/includes.h0100644004714500471450000000527307716230207017067 0ustar aba-guestaba-guest/* * @(#)includes.h 1.8 89/04/01 Jamie Hanrahan (simpact!jeh) * * Version simpact-1.8, for DECUS uucp (VMS portion). * All changes and additions from previous versions (see below) are in * the public domain. * * Derived from: * * includes.h 1.7 87/09/29 Copyright 1987 Free Software Foundation, Inc. * * Copying and use of this program are controlled by the terms of the * GNU Emacs General Public License. * * Include files for various supported systems: * Note that NAMESIZE should be the max length of a file name, including * all its directories, drive specifiers, extensions, and the like. * E.g. on a Unix with 14-char file names, NAMESIZE is several hundred * characters, since the 14-char names can be nested. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * because I have consolidated ARGPROC.C into LIBPBM1.C for netPBM * these calls are reduntant and cause a compiler warning. * RLD 20-SEP-1993 #include stdlib #include time */ #include #include #define NAMESIZE 255 #define UUXQT_DOORBELL "UUCP_UUXQT_DOORBELL" #define UUCICO_REQMB "UUCP_REQUESTS" #define UUX_QUEUE "UUCP_BATCH_QUEUE" #define UUX_FILE "UUCP_BIN:UUXQT_BATCH.COM" #define DEBUG_LOG_FILE "vmsnet_log:uucico_dbg" #define UUX_LOG "UUCP_LOG:UUXQT.LOG" #define SYSLOCK_TEMPLATE "UUCP_SYS_%s" #define STATUS_LNT "LNM$SYSTEM_TABLE" #define STATUS_TEMPLATE "UUCP_STATUS_%s" #define MAXLOCK 32 #define LOGLEN 255 #define SEQSIZE 4 #define CONTROL_FILE "uucp_cfg:control." #define LOGCLOSE /* Logfile must be closed; VMS locks it when open */ #define EXEDIR "uucp_bin:" /* uuxqt executables live here (not used) */ #define NULL_DEVICE "NL:" #define fork vfork /* (not used) */ #define STATUS int /* (not used) */ #define postmaster "UUCP_POSTMASTER" #define EXIT_OK 1 /* image exit code */ #define EXIT_ERR 0x10000000 /* image exit code */ #define ENABLE 1 /* for $SETAST (and maybe others) */ #define DISABLE 0 #define time_t unsigned /* (not used) */ #define remove delete /* Remove a file */ #define qsort pqsort /* Our own version (not used) */ #define FOPEN_W_MODE "w" /* mode to open files being received */ #define FOPEN_R_MODE "r" /* or sent */ #define SS_FAILED(status) (((status)&1) == 0) #define initdsc(d) d.dsc$b_class = DSC$K_CLASS_S, d.dsc$b_dtype = DSC$K_DTYPE_T #define fillindsc(d, s) d.dsc$w_length=strlen(s), d.dsc$a_pointer=(s) #define init_itmlst3(e,i,l,c,a,r) \ (e[i].len=(l),\ e[i].code=(c),\ e[i].address=(a),\ e[i].retlen=(r)) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/libpbm.3���������������������������������������������������������������������0100644�0047145�0047145�00000030320�07716762513�016442� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������.TH libpbm 3 .SH NAME libpbm - functions to read and write PBM image files .SH SYNOPSIS .B #include .B int pm_keymatch(char * .IB str , .B char * .IB keyword , .B int .IB minchars ); .B int pm_maxvaltobits(int .IB maxval ); .B int pm_bitstomaxval(int .IB bits ); .B unsigned int pm_lcm(unsigned int .IB x , .B unsigned int .IB y , .B unsigned int .IB z , .B unsigned int .IB limit ); .B void pm_message(char * .IB fmt , .B ... ); .B void pm_error(char * .IB fmt , .B ... ); .B void pm_perror(char * .IB fmt , .B ... ); .B void pm_usage(char * .IB usage ); .B FILE *pm_openr(char * .IB name ) .B FILE *pm_openw(char * .IB name ); .B FILE *pm_openr_seekable(const char * .IB name ); .B FILE *pm_close(FILE * .IB fp ); .B char *pm_read_unknown_size(FILE * .IB fp ", long *" nread ); .B unsigned int pm_tell(FILE * .IB fileP ); .B void pm_seek(FILE * .IB fileP ", unsigned long " filepos ); .B bit **pbm_allocarray(int .IB cols ", int " rows ); .B bit *pbm_allocrow(int .IB cols ); .B pbm_freearray(bit .BI ** bits ", int " rows ); .B pbm_freerow(bit .BI * bitrow ); .B void pbm_readpbminit(FILE * .IB fp ", int *" colsP ", int *" rowsP ", int *" formatP ); .B void pbm_readpbmrow(FILE * .IB fp ", bit *" bitrow ", int " cols ", int " format ); .B void pbm_readpbmrow_packed(FILE * .IB fp , .br .BI "unsigned char * const " packed_bits , .BI "const int " cols , .BI "const int " format ); .B void bit** pbm_readpbm(FILE * .IB fp ", int *" colsP ", int *" rowsP ); .B void pbm_writepbminit(FILE * .IB fp ", int " cols ", int " rows ", int " forceplain ); .B void pbm_writepbmrow(FILE * .IB fp ", bit *" bitrow ", int " cols ", int " forceplain ); .B void pbm_writepbmrow_packed(FILE * .IB fp , .br .BI "unsigned char * const " packed_bits , .BI "const int " cols , .BI "const int " forceplain ); .B void pbm_writepbm(FILE * .IB fp ", bit **" bits ", int " cols ", int " rows ", int " forceplain ); .BI "#define pbm_packed_bytes(" cols ") ..." .B void pbm_nextimage( .BI "FILE *" file , .BI "int * const " eofP ); .B void pbm_check( .BI "FILE * " file , .BI "const enum pm_check_type " check_type , .BI "const int " format , .BI "const int " cols , .BI "const int " rows , .BI "enum pm_check_code * const " retval ); .BI "int pm_readbigshort(FILE *" in ", short *" sP ); .BI "int pm_writebigshort(FILE *" out ", short " s ); .BI "int pm_readbiglong(FILE *" in ", long *" lP ); .BI "int pm_writebiglong(FILE *" out ", long " l ); .BI "int pm_readlittleshort(FILE *" in ", short *" sP ); .BI "int pm_writelittleshort(FILE *" out ", short " s ); .BI "int pm_readlittlelong(FILE *" in ", long *" lP ); .BI "int pm_writelittlelong(FILE *" out ", long " l ); .SH DESCRIPTION - PACKAGE-WIDE ROUTINES .SS KEYWORD MATCHING .B pm_keymatch() does a case-insensitive match of .BR str against .BR keyword . .BR str can be a leading sunstring of .BR keyword , but at least .BR minchars must be present. .SS MAXVAL ARITHMETIC .B pm_maxvaltobits() and .B pm_bitstomaxval() convert between a maxval and the minimum number of bits required to hold it. .B pm_lcm() computes the least common multiple of 3 integers. You also specify a limit and if the LCM would be higher than that limit, .B pm_lcm() just returns that limit. .SS MESSAGES AND ERRORS .B pm_message() is a .BR printf() style routine to write an informational message to the Standard Error file stream. .B pm_message() suppresses the message, however, if the user specified the .B -quiet option on the command line. See the initialization functions, e.g. .BR pbm_init() , for information on the .B -quiet option. Note that Netpbm programs are often used interactively, but also often used by programs. In the interactive case, it is nice to issue messages about what the program is doing, but in the program case, such messages are usually undesirable. By using .B pm_message() for all your messages, you make your program usable in both cases. Without any effort on your part, program users of your program can avoid the messages by specifying the .B -quiet option. .B pm_error() is a .BR printf() style routine that writes an error message to the Standard Error file stream and exits the program with an exit code of 1. .SS GENERIC FILE ACCESS .B pm_openr() opens the given file for reading, with appropriate error checking. A filename of .B - is taken to mean Standard Input. .B pm_openw() opens the given file for writing, with appropriate error checking. .B pm_close() closes the file descriptor, with appropriate error checking. .B pm_openr_seekable() appears to open the file just like .BR pm_openr() , but the file thus opened is guaranteed to be seekable (you can use ftell() and fseek() on it). .B pm_openr_seekable() pulls this off by copying the entire file to a temporary file and giving you the handle of the temporary file, if it has to. If the file you name is a regular file, it's already seekable so .B pm_openr_seekable() just does the same thing as .BR pm_openr() . But if it is, say, a pipe, it isn't seekable. So .B pm_openr_seekable() reads the pipe until EOF into a temporary file, then opens that temporary file and returns the handle of the temporary file. The temporary file is seekable. The file .B pm_openr_seekable() creates is one that the operating system recognizes as temporary, so when you close the file, by any means, it gets deleted. You need a seekable file if you intend to make multiple passes through the file. The only alternative is to read the entire image into memory and work from that copy. That may use too much memory. Note that the image takes less space in the file cache than in a buffer in memory. As much as 96 times less space! Each sample is an integer in the buffer, which is usually 96 bits. In the file, a sample may be as small as 1 bit and rarely more than 8 bits. .B pm_read_unknown_size() reads an entire file or input stream of unknown size to a buffer. Allocate memory more memory as needed. The calling routine has to free the allocated buffer with .BR free() . .BR pm_read_unknown_size() returns a pointer to the allocated buffer. The .BR nread argument returns the number of bytes read. .BR pm_tell() returns a handle for the current position of the file, whether it be the header or a row of the raster. Use the handle as an argument to .B pm_seek() to reposition the file there later. The file must be seekable (which you can ensure by opening it with .BR pm_openr_seekable() ) or this may fail. .SS ENDIAN I/O .Ss .BR pm_readbigshort() , .BR pm_writebigshort() , .BR pm_readbiglong() , .BR pm_writebiglong() , .BR pm_readlittleshort() , .BR pm_writelittleshort() , .BR pm_readlittlelong() , and .B pm_writelittlelong() are routines to read and write short and long ints in either big- or little-endian byte order. The return value is .B 0 upon success and .B -1 upon failure (either EOF or I/O error). .SH DESCRIPTION - PBM-SPECIFIC ROUTINES .SS TYPES AND CONSTANTS .B typedef ... bit; .B #define PBM_WHITE ... .B #define PBM_BLACK ... Each .BR bit should contain only the values of .BR PBM_WHITE or .BR PBM_BLACK . .B #define PBM_FORMAT ... .B #define RPBM_FORMAT ... .B #define PBM_TYPE PBM_FORMAT .B #define .BI PBM_FORMAT_TYPE( f ") ..." These are for distinguishing different file formats and types. .SS INITIALIZATION All PBM programs must call .B pbm_init just after invocation, before processing arguments. .SS MEMORY MANAGEMENT .B pbm_allocarray() allocates an array of bits. .B pbm_allocrow() allocates a row of the given number of bits. .B pbm_freearray() frees the array allocated with .BR pbm_allocarray() containing the given number of rows. .B pbm_freerow() frees a row of bits. .SS READING PBM IMAGE FILES .B pbm_readpbminit() reads the header from a PBM image in a PBM file, filling in the rows, cols and format variables. .B pbm_readpbmrow() reads a row of bits into the .I bitrow array. Format and cols were filled in by .BR pbm_readpbminit() . .B pbm_readpbmrow_packed() is like .B pbm_readrow() except instead of returning a .B bits array, it returns an array .I packed_bits of bytes with the pixels of the image row packed into them. The pixels are in order from left to right across the row and from the beginning of the array to the end. Within a byte, the bits are in order from the most significant bit to the least significant bit. If the number of pixels in the row is not a multiple of 8, the last byte returned is padded on the least signficant bit side with undefined bits. White is represented by a .B PBM_WHITE bit; black by .BR PBM_BLACK . .B pbm_readpbm() reads an entire bitmap file into memory, returning the allocated array and filling in the rows and cols variables. This function combines .BR pbm_readpbminit() , .BR pbm_allocarray() and .BR pbm_readpbmrow() . .SS WRITING PBM IMAGE FILES .B pbm_writepbminit() writes the header for a PBM image in a PBM file. .I forceplain is a boolean value specifying that a plain format (text) file to be written, as opposed to a raw format (binary) one. .B pbm_writepbmrow() writes a row to a PBM file. .B pbm_writepbmrow_packed() is the same as .B pbm_writepbmrow() except that you supply the row to write as an array of bytes packed with bits instead of as a .B bits array. The format of .I packed_bits is the same as that returned by .BR pbm_readpbmrow() . .B pbm_writepbm() writes the header and all data for a PBM image to a PBM file. This function combines .BR pbm_writepbminit() and .BR pbm_writepbmrow() . .SS MISCELLANEOUS .B pbm_nextimage() positions a PBM input file to the next image in it (so that a subsequent .B pbm_readpbminit() reads its header). Immediately before a call to .BR pbm_nextimage() , the file must be positioned either at its beginning (i.e. nothing has been read from the file yet) or just after an image (i.e. as left by a .B pbm_readpbmrow() of the last row in the image). In effect, then, all .B pbm_nextimage() does is test whether there is a next image or the file is positioned at end-of-file. If .B pbm_nextimage() successfully positions to the next image, it returns .BI * eofP false (0). If there is no next image in the file, it returns .BI * eofP true (1). If it can't position or determine the file status due to a file error, it issues an error message and exits the program with an error exit code. .B pbm_check() checks for the common file integrity error where the file is the wrong size to contain all the image data. .B pbm_check() assumes the file is positioned after an image header (as if .B pbm_readpbminit() was the last operation on the file). It checks the file size to see if the number of bytes left in the file are the number required to contain the image raster. If the file is too short, .B pbm_check() causes the program to exit with an error message and error completion code. Otherwise, it returns one of the following values (enumerations of the .B enum pm_check_code type) as .BI * retval\fR: .TP .B PM_CHECK_OK The file's size is exactly what is required to hold the image raster. .TP .B PM_CHECK_UNKNOWN_TYPE .I format is not a format whose size .B pbm_check() can anticipate. The only format with which .B pbm_check() can deal is raw PBM format. .TP .B PM_CHECK_TOO_LONG The file is longer than it needs to be to contain the image raster. The extra data might be another image. .TP .B PM_CHECK_UNCHECKABLE The file is not a kind that has a predictable size, so there is no simple way for .B pbm_check() to know if it is the right size. Only a regular file has predictable size. A pipe is a common example of a file that does not. .PP .I check_type must have the value .B PM_CHECK_BASIC (an enumerated value of the .B pm_check_type enumerated type). Otherwise, the effect of .B pbm_check() is unpredictable. This argument exists for future backward compatible expansion of the function of .BR pbm_check() . .SH "SEE ALSO" .BR libpgm (3), .BR libppm (3), .BR libpnm (3), .BR pbm (5) .SH AUTHOR Copyright (C) 1989, 1991 by Tony Hansen and Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/libpbm1.c��������������������������������������������������������������������0100644�0047145�0047145�00000002733�07716762513�016612� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* libpbm1.c - pbm utility library part 1 ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pbm.h" #include "version.h" #include "compile.h" #include "libpbm.h" #include "shhopt.h" void pbm_init(int *argcP, char *argv[]) { pm_proginit(argcP, argv); } void pbm_nextimage(FILE *file, int * const eofP) { pm_nextimage(file, eofP); } void pbm_check(FILE * file, const enum pm_check_type check_type, const int format, const int cols, const int rows, enum pm_check_code * const retval_p) { if (rows < 0 || cols < 0) pm_error("invalid image"); if (check_type != PM_CHECK_BASIC) { if (retval_p) *retval_p = PM_CHECK_UNKNOWN_TYPE; } else if (format != RPBM_FORMAT) { if (retval_p) *retval_p = PM_CHECK_UNCHECKABLE; } else { /* signed to unsigned so wont wrap */ const unsigned int bytes_per_row = (cols+7)/8; const unsigned int need_raster_size = rows * bytes_per_row; overflow2(bytes_per_row, rows); pm_check(file, check_type, need_raster_size, retval_p); } } �������������������������������������netpbm-free-10.0-1/pbm/libpbm2.c��������������������������������������������������������������������0100644�0047145�0047145�00000007654�07716230207�016610� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* libpbm2.c - pbm utility library part 2 ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #include "libpbm.h" static bit pbm_getbit ARGS((FILE *)); static bit pbm_getbit( file ) FILE* file; { register char ch; do { ch = pbm_getc( file ); } while ( ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' ); if ( ch != '0' && ch != '1' ) pm_error( "junk in file where bits should be" ); return ( ch == '1' ) ? 1 : 0; } int pbm_readmagicnumber( file ) FILE* file; { int ich1, ich2; ich1 = getc( file ); if ( ich1 == EOF ) pm_error( "EOF / read error reading magic number" ); ich2 = getc( file ); if ( ich2 == EOF ) pm_error( "EOF / read error reading magic number" ); return ich1 * 256 + ich2; } void pbm_readpbminitrest( file, colsP, rowsP ) FILE* file; int* colsP; int* rowsP; { /* Read size. */ *colsP = pbm_getint( file ); *rowsP = pbm_getint( file ); } void pbm_readpbminit( file, colsP, rowsP, formatP ) FILE* file; int* colsP; int* rowsP; int* formatP; { /* Check magic number. */ *formatP = pbm_readmagicnumber( file ); switch ( PBM_FORMAT_TYPE(*formatP) ) { case PBM_TYPE: pbm_readpbminitrest( file, colsP, rowsP ); break; default: pm_error( "bad magic number - not a pbm file" ); } } void pbm_readpbmrow( file, bitrow, cols, format ) FILE* file; bit* bitrow; int cols, format; { register int col, bitshift; register bit* bP; switch ( format ) { case PBM_FORMAT: for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) *bP = pbm_getbit( file ); break; case RPBM_FORMAT: { register unsigned char item; bitshift = -1; item = 0; /* item's value is meaningless here */ for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) { if ( bitshift == -1 ) { item = pbm_getrawbyte( file ); bitshift = 7; } *bP = ( item >> bitshift ) & 1; --bitshift; } } break; default: pm_error( "can't happen" ); } } void pbm_readpbmrow_packed(FILE * const file, unsigned char * const packed_bits, const int cols, const int format) { switch(format) { case PBM_FORMAT: { int col; for (col = 0; col < cols; ++col) { unsigned char mask; mask = pbm_getbit(file) << (7 - col % 8); packed_bits[col / 8] |= mask; } } break; case RPBM_FORMAT: { int bytes_read; bytes_read = fread(packed_bits, 1, pbm_packed_bytes(cols), file); if (bytes_read < pbm_packed_bytes(cols)) { if (feof(file)) if (bytes_read == 0) pm_error("Attempt to read a raw PBM image row, but " "no more rows left in file."); else pm_error("EOF in the middle of a raw PBM row."); else pm_error("I/O error reading raw PBM row"); } } break; default: pm_error( "Internal error in pbm_readpbmrow_packed." ); } } bit** pbm_readpbm( file, colsP, rowsP ) FILE* file; int* colsP; int* rowsP; { register bit** bits; int format, row; pbm_readpbminit( file, colsP, rowsP, &format ); bits = pbm_allocarray( *colsP, *rowsP ); for ( row = 0; row < *rowsP; ++row ) pbm_readpbmrow( file, bits[row], *colsP, format ); return bits; } ������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/libpbm3.c��������������������������������������������������������������������0100644�0047145�0047145�00000006326�07716230207�016604� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* libpbm3.c - pbm utility library part 3 ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #include "libpbm.h" static void pbm_writepbmrowplain ARGS((FILE* file, bit* bitrow, int cols)); static void pbm_writepbmrowraw ARGS((FILE* file, bit* bitrow, int cols)); void pbm_writepbminit( file, cols, rows, forceplain ) FILE* file; int cols, rows; int forceplain; { if ( ! forceplain ) { fprintf( file, "%c%c\n%d %d\n", PBM_MAGIC1, RPBM_MAGIC2, cols, rows ); #ifdef VMS set_outfile_binary(); #endif } else fprintf( file, "%c%c\n%d %d\n", PBM_MAGIC1, PBM_MAGIC2, cols, rows ); } static void pbm_writepbmrowraw( file, bitrow, cols ) FILE* file; bit* bitrow; int cols; { register int col, bitshift; register unsigned char item; register bit* bP; bitshift = 7; item = 0; for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) { if ( *bP ) item += 1 << bitshift; --bitshift; if ( bitshift == -1 ) { (void) putc( item, file ); bitshift = 7; item = 0; } } if ( bitshift != 7 ) (void) putc( item, file ); } static void pbm_writepbmrowplain( file, bitrow, cols ) FILE* file; bit* bitrow; int cols; { register int col, charcount; register bit* bP; charcount = 0; for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) { if ( charcount >= 70 ) { (void) putc( '\n', file ); charcount = 0; } (void) putc( *bP ? '1' : '0', file ); ++charcount; } (void) putc( '\n', file ); } void pbm_writepbmrow( file, bitrow, cols, forceplain ) FILE* file; bit* bitrow; int cols; int forceplain; { if ( ! forceplain ) pbm_writepbmrowraw( file, bitrow, cols ); else pbm_writepbmrowplain( file, bitrow, cols ); } void pbm_writepbmrow_packed(FILE * const file, const unsigned char * const packed_bits, const int cols, const int forceplain) { if (!forceplain) { int bytes_written; bytes_written = fwrite(packed_bits, 1, pbm_packed_bytes(cols), file); if (bytes_written < pbm_packed_bytes(cols)) pm_error("I/O error writing packed row to raw PBM file."); } else { bit *bitrow; int col; bitrow = pbm_allocrow(cols); for (col = 0; col < cols; ++col) bitrow[col] = packed_bits[col/8] & (0x80 >> (col%8)) ? PBM_BLACK : PBM_WHITE; pbm_writepbmrowplain(file, bitrow, cols); pbm_freerow(bitrow); } } void pbm_writepbm( file, bits, cols, rows, forceplain ) FILE* file; bit** bits; int cols, rows; int forceplain; { int row; pbm_writepbminit( file, cols, rows, forceplain ); for ( row = 0; row < rows; ++row ) pbm_writepbmrow( file, bits[row], cols, forceplain ); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/libpbm4.c��������������������������������������������������������������������0100644�0047145�0047145�00000003330�07716230207�016575� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* libpbm4.c - pbm utility library part 4 ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #include "libpbm.h" char pbm_getc( file ) FILE* file; { register int ich; register char ch; ich = getc( file ); if ( ich == EOF ) pm_error( "EOF / read error" ); ch = (char) ich; if ( ch == '#' ) { do { ich = getc( file ); if ( ich == EOF ) pm_error( "EOF / read error" ); ch = (char) ich; } while ( ch != '\n' && ch != '\r' ); } return ch; } /* This is useful for PBM files. It used to be used for PGM and PPM files too, since the sample size was always one byte. Now, use pbm_getrawsample() for PGM and PPM files. */ unsigned char pbm_getrawbyte( file ) FILE* file; { register int iby; iby = getc( file ); if ( iby == EOF ) pm_error( "EOF / read error reading a one-byte sample" ); return (unsigned char) iby; } int pbm_getint( file ) FILE* file; { register char ch; register int i; do { ch = pbm_getc( file ); } while ( ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' ); if ( ch < '0' || ch > '9' ) pm_error( "junk in file where an integer should be" ); i = 0; do { i = i * 10 + ch - '0'; ch = pbm_getc( file ); } while ( ch >= '0' && ch <= '9' ); return i; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/libpbm5.c��������������������������������������������������������������������0100644�0047145�0047145�00000131520�07716230207�016601� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* libpbm5.c - pbm utility library part 5 ** ** Font routines. ** ** Support for BDF fonts Copyright 1993 by George Phillips. ** ** Copyright (C) 1991 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pbm.h" #include "pbmfont.h" /* The default font, packed in hex so this source file doesn't get huge. ** You can replace this with your own font using pbm_dumpfont(). */ #define DEFAULTFONT_ROWS 155 #define DEFAULTFONT_COLS 112 static unsigned long defaultfont_bits[DEFAULTFONT_ROWS][(DEFAULTFONT_COLS+31)/32] = { {0x00000000L,0x20000c00L,0x10000000L,0x00000000L}, {0xc600a000L,0x42000810L,0x00000002L,0x00000063L}, {0x6c00a000L,0x45000810L,0x00000002L,0x00000036L}, {0x6c00a000L,0x88800808L,0xf2e1dee2L,0x00000036L}, {0x54000000L,0x80000800L,0x11122442L,0x0000002aL}, {0x54000001L,0x00000800L,0x11122442L,0x0000002aL}, {0x54000001L,0x00000800L,0x11122282L,0x0000002aL}, {0x44000102L,0x00000800L,0x11122382L,0x00000022L}, {0xee000102L,0x00000800L,0x11e1e102L,0x00000077L}, {0x00000204L,0x00000800L,0x11002102L,0x00000000L}, {0x00000000L,0x00000c00L,0x11002102L,0x00000000L}, {0x00000000L,0x003f8000L,0xe3807600L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x02000080L,0x00040000L,0x00120000L,0x00000001L}, {0x04000082L,0x828e1838L,0x20210100L,0x00000002L}, {0x04000082L,0x82912448L,0x20210100L,0x00000002L}, {0x08000082L,0x8fd01940L,0x404087c2L,0x00000004L}, {0x08000080L,0x050c0622L,0x00408102L,0x00000004L}, {0x10000080L,0x05061874L,0x0040828fL,0x00008008L}, {0x10000080L,0x1f912688L,0x00408002L,0x00000008L}, {0x20000000L,0x0a11098cL,0x00408002L,0x00000010L}, {0x20000080L,0x0a0e0672L,0x00210000L,0x00000010L}, {0x40000000L,0x00040000L,0x00210000L,0x00000020L}, {0x00000000L,0x00000000L,0x00120000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x004e0838L,0x7023e1cfL,0x00008000L}, {0x00000000L,0x00913844L,0x88620208L,0x00008000L}, {0x08000000L,0x00910844L,0x08a20401L,0x00000004L}, {0x10000000L,0x01110844L,0x08a20401L,0x00000008L}, {0x20000000L,0x01110808L,0x3123c781L,0x00000010L}, {0x400003e0L,0x02110810L,0x0a202441L,0x00000020L}, {0x20000000L,0x02110820L,0x0bf02442L,0x00000010L}, {0x10008000L,0x04110844L,0x88242442L,0x00000008L}, {0x08008002L,0x040e3e7cL,0x7073c382L,0x00000004L}, {0x00010000L,0x08000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x0000e1c0L,0x00000000L,0x00000000L,0x00000000L}, {0x00011220L,0x00000000L,0x70e38f87L,0x00000000L}, {0x20011220L,0x00020020L,0x89108448L,0x00008010L}, {0x10011220L,0x00040010L,0x09314448L,0x00008008L}, {0x0800e221L,0x02083e08L,0x11514788L,0x00000004L}, {0x040111e0L,0x00100004L,0x2153e448L,0x00000002L}, {0x08011020L,0x00083e08L,0x213a2448L,0x00008004L}, {0x10011040L,0x02040010L,0x01022448L,0x00008008L}, {0x2000e381L,0x02020020L,0x20e77f87L,0x00000010L}, {0x00000000L,0x04000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x3803e7efL,0xc73bbe3dL,0xdb863ce7L,0x0000001cL}, {0x44011224L,0x48910808L,0x91036648L,0x00008022L}, {0x4c011285L,0x48910808L,0xa1036648L,0x00008026L}, {0x54011387L,0x081f0808L,0xc102a548L,0x0000802aL}, {0x54011285L,0x09910808L,0xe102a548L,0x0000802aL}, {0x4e011204L,0x08910848L,0x9112a4c8L,0x00008027L}, {0x40011224L,0x08910848L,0x891224c8L,0x00008020L}, {0x3803e7efL,0x073bbe31L,0xcff77e47L,0x0000001cL}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000003L,0x00000000L}, {0x0003e1cfL,0x87bff7efL,0xdfbf77c2L,0x00000000L}, {0x00013224L,0x48a4a244L,0x89122442L,0x00000000L}, {0x00011224L,0x4824a244L,0xa8a14482L,0x00000000L}, {0x00013227L,0x8e04226cL,0xa8414102L,0x00000000L}, {0x0001e224L,0x83842228L,0xa8a08102L,0x00000000L}, {0x00010224L,0x40842228L,0xd8a08242L,0x00000000L}, {0x00010224L,0x48843638L,0x51108442L,0x00000000L}, {0x0003c1ceL,0x6f1f1c10L,0x53b9c7c2L,0x00000000L}, {0x00000060L,0x00000000L,0x00000002L,0x00000000L}, {0x00000000L,0x00000000L,0x00000003L,0x00000000L}, {0xfe000000L,0x00000000L,0x00000000L,0x0000007fL}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00010180L,0x000000c0L,0x003001c0L,0x00000000L}, {0x08008081L,0x00040040L,0x00100200L,0x00000004L}, {0x10008082L,0x80040040L,0x00100200L,0x00000008L}, {0x10004084L,0x40023c78L,0x70f1c7c7L,0x00004008L}, {0x10004080L,0x00000244L,0x89122208L,0x00008008L}, {0x20002080L,0x00001e44L,0x8113e208L,0x00008010L}, {0x10002080L,0x00002244L,0x81120208L,0x00008008L}, {0x10001080L,0x00002244L,0x89122208L,0x00008008L}, {0x10001080L,0x00001db8L,0x70e9c787L,0x00008008L}, {0x10000880L,0x00000000L,0x00000000L,0x00008008L}, {0x08000180L,0x00000000L,0x00000000L,0x00008004L}, {0x00000000L,0x1fc00000L,0x00000007L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00030080L,0x981c0000L,0x00000000L,0x00000000L}, {0x20010000L,0x08040000L,0x00000000L,0x00000010L}, {0x10010000L,0x08040000L,0x00000000L,0x00000008L}, {0x10016387L,0x898474b8L,0x72e1d5c7L,0x00000008L}, {0x10019080L,0x8a042a64L,0x89122208L,0x00008008L}, {0x08011080L,0x8c042a44L,0x89122207L,0x00000004L}, {0x10011080L,0x8a042a44L,0x89122200L,0x00008008L}, {0x10011080L,0x89042a44L,0x89122208L,0x00008008L}, {0x1003bbe0L,0x98dfebe6L,0x71e1e787L,0x00000008L}, {0x10000000L,0x80000000L,0x01002000L,0x00000008L}, {0x20000000L,0x80000000L,0x01002000L,0x00000010L}, {0x00000007L,0x00000000L,0x03807000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00008000L,0x00000000L,0x10410000L,0x00000000L}, {0x00008000L,0x00000000L,0x20408000L,0x00000000L}, {0x0001f66eL,0xfdfbf77cL,0x20408000L,0x00000000L}, {0x24008224L,0x488a2248L,0x20408240L,0x00000012L}, {0x54008224L,0x4a842210L,0x40404540L,0x0000002aL}, {0x48008222L,0x8a8a1420L,0x20408480L,0x00000024L}, {0x00008a23L,0x85111c44L,0x20408000L,0x00000000L}, {0x000071d1L,0x0531887cL,0x20408000L,0x00000000L}, {0x00000000L,0x00000800L,0x20408000L,0x00000000L}, {0x00000000L,0x00000800L,0x10410000L,0x00000000L}, {0x00000000L,0x00003000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, {0x00000000L,0x20000c00L,0x10000000L,0x00000000L}, {0xc600a000L,0x42000810L,0x00000002L,0x00000063L}, {0x6c00a000L,0x45000810L,0x00000002L,0x00000036L}, {0x6c00a000L,0x88800808L,0xf2e1dee2L,0x00000036L}, {0x54000000L,0x80000800L,0x11122442L,0x0000002aL}, {0x54000001L,0x00000800L,0x11122442L,0x0000002aL}, {0x54000001L,0x00000800L,0x11122282L,0x0000002aL}, {0x44000102L,0x00000800L,0x11122382L,0x00000022L}, {0xee000102L,0x00000800L,0x11e1e102L,0x00000077L}, {0x00000204L,0x00000800L,0x11002102L,0x00000000L}, {0x00000000L,0x00000c00L,0x11002102L,0x00000000L}, {0x00000000L,0x003f8000L,0xe3807600L,0x00000000L} }; /* A default BDF font */ /* Not as nicely compacted as the PBM font, oh well. */ static struct glyph _g[190] = { { 1, 1, 0, 0, 3, "\0" }, { 1, 9, 1, 0, 3, "\1\1\1\1\1\1\1\0\1" }, { 3, 3, 1, 6, 5, "\1\0\1\1\0\1\1\0\1" }, { 5, 8, 0, 0, 6, "\0\1\0\1\0\0\1\0\1\0\1\1\1\1\1\0\1\0\1\0\0\1\0\1\0\1\1\1\1\1\0\1\0\1\0\0\1\0\1\0" }, { 5, 11, 0, -1, 6, "\0\0\1\0\0\0\1\1\1\0\1\0\1\0\1\1\0\1\0\0\0\1\1\0\0\0\0\1\1\0\0\0\1\0\1\0\0\1\0\1\1\0\1\0\1\0\1\1\1\0\0\0\1\0\0" }, { 8, 9, 0, 0, 9, "\0\1\1\0\0\0\1\1\1\0\0\1\1\1\1\0\1\0\0\1\0\1\0\0\0\1\1\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\1\0\1\1\0\0\0\1\0\1\0\0\1\0\1\0\0\1\0\0\1\0\1\0\0\0\1\1\0" }, { 9, 9, 0, 0, 10, "\0\0\0\1\1\0\0\0\0\0\0\1\0\0\1\0\0\0\0\0\1\0\0\1\0\0\0\0\0\0\1\1\0\1\1\1\0\1\1\1\1\0\0\1\0\1\1\0\0\1\1\1\0\0\1\0\0\0\0\1\0\0\0\1\1\0\0\1\1\1\0\1\0\1\1\1\1\0\1\1\0" }, { 2, 3, 1, 6, 4, "\1\1\0\1\1\0" }, { 3, 12, 1, -3, 5, "\0\0\1\0\1\0\0\1\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\0\1\0\0\1\0\0\0\1" }, { 3, 12, 0, -3, 5, "\1\0\0\0\1\0\0\1\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\0\0\1\0\1\0\0" }, { 5, 5, 0, 4, 6, "\0\0\1\0\0\1\0\1\0\1\0\1\1\1\0\1\0\1\0\1\0\0\1\0\0" }, { 5, 5, 1, 1, 7, "\0\0\1\0\0\0\0\1\0\0\1\1\1\1\1\0\0\1\0\0\0\0\1\0\0" }, { 2, 3, 0, -2, 3, "\0\1\0\1\1\0" }, { 5, 1, 1, 3, 8, "\1\1\1\1\1" }, { 1, 1, 1, 0, 3, "\1" }, { 3, 9, 0, 0, 3, "\0\0\1\0\0\1\0\0\1\0\1\0\0\1\0\0\1\0\1\0\0\1\0\0\1\0\0" }, { 5, 9, 0, 0, 6, "\0\1\1\1\0\1\1\0\1\1\1\0\0\0\1\1\0\0\0\1\1\0\0\0\1\1\0\0\0\1\1\0\0\0\1\1\1\0\1\1\0\1\1\1\0" }, { 4, 9, 0, 0, 6, "\0\0\1\0\0\1\1\0\1\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\1\1\1" }, { 5, 9, 0, 0, 6, "\0\1\1\1\0\1\0\0\0\1\0\0\0\0\1\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\1\1\1\1\1" }, { 5, 9, 0, 0, 6, "\0\1\1\1\0\1\0\0\0\1\0\0\0\0\1\0\0\0\1\0\0\1\1\1\0\0\0\0\0\1\0\0\0\0\1\1\0\0\0\1\0\1\1\1\0" }, { 5, 9, 0, 0, 6, "\0\0\0\1\0\0\0\1\1\0\0\0\1\1\0\0\1\0\1\0\0\1\0\1\0\1\0\0\1\0\1\1\1\1\1\0\0\0\1\0\0\0\0\1\0" }, { 5, 9, 0, 0, 6, "\0\0\1\1\1\0\1\0\0\0\0\1\0\0\0\0\1\1\1\0\0\0\0\1\1\0\0\0\0\1\0\0\0\0\1\1\0\0\1\1\0\1\1\1\0" }, { 5, 9, 0, 0, 6, "\0\0\0\1\1\0\1\1\0\0\0\1\0\0\0\1\1\1\1\0\1\0\0\1\1\1\0\0\0\1\1\0\0\0\1\1\1\0\0\1\0\1\1\1\0" }, { 5, 9, 0, 0, 6, "\1\1\1\1\1\1\0\0\0\1\0\0\0\1\0\0\0\0\1\0\0\0\1\0\0\0\0\1\0\0\0\1\0\0\0\0\1\0\0\0\0\1\0\0\0" }, { 5, 9, 0, 0, 6, "\0\1\1\1\0\1\0\0\0\1\1\0\0\0\1\1\1\0\0\1\0\1\1\1\0\1\0\0\1\1\1\0\0\0\1\1\0\0\0\1\0\1\1\1\0" }, { 5, 9, 0, 0, 6, "\0\1\1\1\0\1\0\0\1\1\1\0\0\0\1\1\0\0\0\1\1\1\0\0\1\0\1\1\1\1\0\0\0\1\0\0\0\1\1\0\1\1\0\0\0" }, { 1, 6, 1, 0, 3, "\1\0\0\0\0\1" }, { 2, 8, 0, -2, 3, "\0\1\0\0\0\0\0\0\0\0\0\1\0\1\1\0" }, { 6, 5, 0, 1, 8, "\0\0\0\0\1\1\0\0\1\1\0\0\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\1" }, { 5, 3, 1, 2, 7, "\1\1\1\1\1\0\0\0\0\0\1\1\1\1\1" }, { 6, 5, 1, 1, 8, "\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\1\0\0\1\1\0\0\1\1\0\0\0\0" }, { 4, 9, 0, 0, 5, "\0\1\1\0\1\0\0\1\0\0\0\1\0\0\1\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\1\0\0" }, { 10, 11, 1, -2, 11, "\0\0\0\0\1\1\1\1\0\0\0\0\1\1\0\0\0\0\1\0\0\1\1\0\0\0\0\0\0\1\0\1\0\0\1\1\0\1\0\1\1\0\0\1\0\0\1\0\0\1\1\0\1\0\0\0\1\0\0\1\1\0\1\0\0\1\0\0\1\0\1\0\1\0\0\1\0\0\1\0\1\0\0\1\1\0\1\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\1\1\1\1\1\0\0\0" }, { 9, 9, 0, 0, 9, "\0\0\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\1\0\0\0\0\0\0\1\0\1\0\0\0\0\0\1\0\0\0\1\0\0\0\0\1\1\1\1\1\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\0\1\0\1\1\1\0\0\0\1\1\1" }, { 7, 9, 0, 0, 8, "\1\1\1\1\1\1\0\0\1\0\0\0\1\1\0\1\0\0\0\0\1\0\1\0\0\0\1\1\0\1\1\1\1\1\0\0\1\0\0\0\0\1\0\1\0\0\0\0\1\0\1\0\0\0\1\1\1\1\1\1\1\1\0" }, { 7, 9, 0, 0, 8, "\0\0\1\1\1\0\1\0\1\1\0\0\1\1\0\1\0\0\0\0\1\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\0\1\0\1\1\0\0\1\1\0\0\1\1\1\1\0" }, { 8, 9, 0, 0, 9, "\1\1\1\1\1\1\0\0\0\1\0\0\0\1\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\0\1\0\1\0\0\0\0\0\1\0\1\0\0\0\0\0\1\0\1\0\0\0\0\1\0\0\1\0\0\0\1\1\0\1\1\1\1\1\1\0\0" }, { 7, 9, 0, 0, 8, "\1\1\1\1\1\1\1\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\1\0\0\0\1\0\0\1\1\1\1\1\0\0\1\0\0\0\1\0\0\1\0\0\0\0\0\0\1\0\0\0\0\1\1\1\1\1\1\1\1" }, { 7, 9, 0, 0, 8, "\1\1\1\1\1\1\1\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\1\0\0\0\1\0\0\1\1\1\1\1\0\0\1\0\0\0\1\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\1\1\1\1\0\0\0" }, { 8, 9, 0, 0, 9, "\0\0\1\1\1\0\1\0\0\1\1\0\0\1\1\0\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\0\1\0\0\0\0\1\1\1\1\0\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\1\1\1\0\0" }, { 8, 9, 0, 0, 9, "\1\1\1\0\0\1\1\1\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\1\1\1\1\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\1\1\1\0\0\1\1\1" }, { 3, 9, 0, 0, 4, "\1\1\1\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1" }, { 4, 9, 0, 0, 4, "\0\1\1\1\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\1\0\1\0\1\1\0\0" }, { 8, 9, 0, 0, 8, "\1\1\1\0\1\1\1\0\0\1\0\0\0\1\0\0\0\1\0\0\1\0\0\0\0\1\0\1\0\0\0\0\0\1\1\1\0\0\0\0\0\1\0\1\1\0\0\0\0\1\0\0\1\1\0\0\0\1\0\0\0\1\1\0\1\1\1\0\0\1\1\1" }, { 6, 9, 0, 0, 7, "\1\1\1\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\1\1\1\1\1\1\1" }, { 11, 9, 0, 0, 11, "\1\1\0\0\0\0\0\0\0\1\1\0\1\1\0\0\0\0\0\1\1\0\0\1\1\0\0\0\0\0\1\1\0\0\1\0\1\0\0\0\1\0\1\0\0\1\0\1\0\0\0\1\0\1\0\0\1\0\0\1\0\1\0\0\1\0\0\1\0\0\1\0\1\0\0\1\0\0\1\0\0\0\1\0\0\0\1\0\1\1\1\0\0\1\0\0\1\1\1" }, { 9, 9, 0, 0, 9, "\1\1\0\0\0\0\1\1\1\0\1\1\0\0\0\0\1\0\0\1\1\0\0\0\0\1\0\0\1\0\1\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\0\1\0\1\0\0\1\0\0\0\0\1\1\0\1\1\1\0\0\0\0\1\0" }, { 8, 9, 0, 0, 9, "\0\0\1\1\1\1\0\0\0\1\1\0\0\1\1\0\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\0\1\0\0\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\1\1\1\0\0" }, { 7, 9, 0, 0, 7, "\1\1\1\1\1\1\0\0\1\0\0\0\1\1\0\1\0\0\0\0\1\0\1\0\0\0\1\1\0\1\1\1\1\1\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\1\1\1\0\0\0\0" }, { 8, 11, 0, -2, 9, "\0\0\1\1\1\1\0\0\0\1\1\0\0\1\1\0\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\0\1\0\0\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\1\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\0\0\1\1" }, { 8, 9, 0, 0, 8, "\1\1\1\1\1\1\0\0\0\1\0\0\0\1\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\1\1\0\0\1\1\1\1\1\0\0\0\1\0\0\1\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\1\0\1\1\1\0\0\0\1\1" }, { 6, 9, 0, 0, 7, "\0\1\1\1\0\1\1\0\0\0\1\1\1\0\0\0\0\1\0\1\1\0\0\0\0\0\1\1\1\0\0\0\0\0\1\1\1\0\0\0\0\1\1\1\0\0\1\1\1\0\1\1\1\0" }, { 7, 9, 0, 0, 7, "\1\1\1\1\1\1\1\1\0\0\1\0\0\1\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\1\1\1\0\0" }, { 8, 9, 0, 0, 8, "\1\1\1\0\0\1\1\1\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\1\1\1\0\0" }, { 9, 9, 0, 0, 9, "\1\1\1\0\0\0\1\1\1\0\1\0\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\1\0\0\0\1\0\0\0\0\0\1\0\1\0\0\0\0\0\0\1\0\1\0\0\0\0\0\0\1\1\1\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0" }, { 12, 9, 0, 0, 12, "\1\1\1\0\1\1\1\0\0\1\1\1\0\1\0\0\0\1\0\0\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\1\0\0\0\0\1\1\0\1\1\1\0\1\0\0\0\0\0\1\0\1\0\1\0\1\0\0\0\0\0\1\1\0\0\1\1\0\0\0\0\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\1\0\0\0" }, { 8, 9, 0, 0, 8, "\1\1\1\0\0\1\1\1\0\1\0\0\0\0\1\0\0\0\1\0\0\1\0\0\0\0\1\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\1\0\1\1\0\0\0\0\1\0\0\1\0\0\0\1\0\0\0\0\1\0\1\1\1\0\0\1\1\1" }, { 9, 9, 0, 0, 9, "\1\1\1\0\0\0\1\1\1\0\1\0\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\0\1\0\0\1\0\0\0\0\0\1\1\1\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\1\1\0\0\0" }, { 7, 9, 0, 0, 8, "\1\1\1\1\1\1\1\1\0\0\0\0\1\1\0\0\0\0\1\1\0\0\0\0\1\1\0\0\0\0\1\1\0\0\0\0\1\1\0\0\0\0\1\1\0\0\0\0\0\1\0\0\0\0\0\1\1\1\1\1\1\1\1" }, { 3, 12, 1, -3, 5, "\1\1\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\1\1" }, { 3, 9, 0, 0, 3, "\1\0\0\1\0\0\1\0\0\0\1\0\0\1\0\0\1\0\0\0\1\0\0\1\0\0\1" }, { 3, 12, 0, -3, 5, "\1\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\1\1\1" }, { 5, 5, 0, 4, 6, "\0\0\1\0\0\0\1\0\1\0\0\1\0\1\0\1\0\0\0\1\1\0\0\0\1" }, { 6, 1, 0, -3, 6, "\1\1\1\1\1\1" }, { 2, 3, 1, 6, 4, "\0\1\1\0\1\1" }, { 5, 6, 1, 0, 6, "\0\1\1\0\0\1\0\0\1\0\0\1\1\1\0\1\0\0\1\0\1\0\0\1\0\0\1\1\0\1" }, { 5, 9, 0, 0, 6, "\1\1\0\0\0\0\1\0\0\0\0\1\0\0\0\0\1\1\1\0\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\1\1\0" }, { 4, 6, 1, 0, 5, "\0\1\1\0\1\0\0\1\1\0\0\0\1\0\0\0\1\0\0\1\0\1\1\0" }, { 5, 9, 1, 0, 6, "\0\0\1\1\0\0\0\0\1\0\0\0\0\1\0\0\1\1\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\0\1\1\0\1" }, { 5, 6, 1, 0, 6, "\0\1\1\0\0\1\0\0\1\0\1\1\1\1\0\1\0\0\0\0\1\1\0\0\1\0\1\1\1\0" }, { 3, 9, 0, 0, 3, "\0\0\1\0\1\0\0\1\0\1\1\1\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0" }, { 5, 9, 1, -3, 6, "\0\1\1\1\1\1\0\0\1\0\1\0\0\1\0\1\1\1\0\0\0\1\0\0\0\0\1\1\1\0\1\0\0\0\1\1\0\0\0\1\0\1\1\1\0" }, { 6, 9, 0, 0, 6, "\1\1\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\1\1\1\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1\0\1\1" }, { 3, 9, 0, 0, 3, "\0\1\0\0\0\0\0\0\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1" }, { 2, 12, 0, -3, 3, "\0\1\0\0\0\0\1\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\1\0" }, { 6, 9, 0, 0, 6, "\1\1\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\1\0\0\1\0\0\1\0\1\0\0\0\1\1\0\0\0\0\1\0\1\0\0\0\1\0\0\1\0\0\1\0\0\1\1" }, { 3, 9, 0, 0, 3, "\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1" }, { 9, 6, 0, 0, 9, "\1\0\1\1\0\1\1\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1\0\1\1\0\1\1" }, { 6, 6, 0, 0, 6, "\1\0\1\1\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1\0\1\1" }, { 4, 6, 1, 0, 6, "\0\1\1\0\1\0\0\1\1\0\0\1\1\0\0\1\1\0\0\1\0\1\1\0" }, { 5, 9, 0, -3, 6, "\1\1\1\1\0\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\1\1\0\0\1\0\0\0\0\1\0\0\0\1\1\1\0\0" }, { 5, 9, 1, -3, 6, "\0\1\1\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\0\1\1\1\0\0\0\0\1\0\0\0\0\1\0\0\0\1\1\1" }, { 4, 6, 0, 0, 4, "\1\0\1\1\0\1\1\0\0\1\0\0\0\1\0\0\0\1\0\0\1\1\1\0" }, { 4, 6, 1, 0, 6, "\0\1\1\1\1\0\0\1\1\1\0\0\0\0\1\1\1\0\0\1\1\1\1\0" }, { 4, 7, 0, 0, 4, "\0\1\0\0\1\1\1\1\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\1\1" }, { 6, 6, 0, 0, 6, "\1\1\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\0\1\1\0\1" }, { 6, 6, 0, 0, 6, "\1\1\0\0\1\1\0\1\0\0\1\0\0\1\0\1\1\0\0\1\0\1\0\0\0\0\1\1\0\0\0\0\1\0\0\0" }, { 9, 6, 0, 0, 9, "\1\1\1\0\1\1\0\1\1\0\1\0\0\1\0\0\1\0\0\1\1\0\1\0\1\1\0\0\0\1\0\1\0\1\0\0\0\0\1\1\0\1\0\0\0\0\0\1\0\0\1\0\0\0" }, { 5, 6, 1, 0, 6, "\1\1\0\1\1\0\1\0\1\0\0\0\1\0\0\0\0\1\0\0\0\1\0\1\0\1\1\0\1\1" }, { 6, 9, 0, -3, 6, "\1\1\0\0\1\1\0\1\0\0\1\0\0\1\0\1\1\0\0\1\0\1\0\0\0\0\1\1\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\1\0\0\0\0\1\1\0\0\0\0" }, { 4, 6, 1, 0, 6, "\1\1\1\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\1\1\1\1" }, { 4, 12, 1, -3, 6, "\0\0\1\1\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\1\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\1\1" }, { 1, 9, 1, 0, 3, "\1\1\1\1\1\1\1\1\1" }, { 4, 12, 0, -3, 6, "\1\1\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\1\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\1\1\0\0" }, { 6, 2, 0, 3, 7, "\0\1\1\0\0\1\1\0\0\1\1\0" }, { 1, 9, 1, -3, 4, "\1\0\1\1\1\1\1\1\1" }, { 5, 8, 1, -1, 6, "\0\0\0\0\1\0\1\1\1\0\1\0\0\1\1\1\0\1\0\0\1\0\1\0\0\1\1\0\0\1\0\1\1\1\0\1\0\0\0\0" }, { 5, 9, 0, 0, 6, "\0\0\1\1\0\0\1\0\0\1\0\1\0\0\0\0\1\0\0\0\1\1\1\1\0\0\1\0\0\0\0\1\0\0\0\1\1\1\0\1\1\1\0\1\1" }, { 6, 7, 1, 1, 7, "\1\0\0\0\0\1\0\1\1\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\1\1\1\0\1\0\0\0\0\1" }, { 5, 9, 0, 0, 6, "\1\0\0\0\1\1\0\0\0\1\0\1\0\1\0\0\1\0\1\0\1\1\1\1\1\0\0\1\0\0\1\1\1\1\1\0\0\1\0\0\0\1\1\1\0" }, { 1, 9, 1, 0, 3, "\1\1\1\0\0\1\1\1\1" }, { 4, 12, 1, -3, 6, "\0\1\1\1\1\0\0\1\1\1\0\0\0\1\1\0\1\0\1\1\1\0\0\1\1\0\0\1\1\1\0\1\0\1\1\0\0\0\1\1\1\0\0\1\1\1\1\0" }, { 3, 1, 0, 7, 3, "\1\0\1" }, { 9, 9, 1, 0, 11, "\0\0\0\1\1\1\0\0\0\0\1\1\0\0\0\1\1\0\0\1\0\1\1\1\0\1\0\1\0\1\0\0\1\0\0\1\1\0\1\0\0\0\0\0\1\1\0\1\0\0\1\0\0\1\0\1\0\1\1\1\0\1\0\0\1\1\0\0\0\1\1\0\0\0\0\1\1\1\0\0\0" }, { 3, 6, 1, 3, 5, "\1\1\0\0\0\1\1\1\1\1\0\1\0\0\0\1\1\1" }, { 5, 5, 1, 0, 7, "\0\0\1\0\1\0\1\0\1\0\1\0\1\0\0\0\1\0\1\0\0\0\1\0\1" }, { 6, 4, 1, 1, 8, "\1\1\1\1\1\1\0\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\1" }, { 4, 1, 1, 3, 6, "\1\1\1\1" }, { 9, 9, 1, 0, 11, "\0\0\0\1\1\1\0\0\0\0\1\1\0\0\0\1\1\0\0\1\0\1\1\1\0\1\0\1\0\0\1\0\0\1\0\1\1\0\0\1\1\1\0\0\1\1\0\0\1\0\1\0\0\1\1\1\0\1\0\1\0\1\0\0\1\1\0\0\0\1\1\0\0\0\1\1\1\1\0\0\0" }, { 4, 1, 0, 7, 4, "\1\1\1\1" }, { 4, 4, 0, 5, 5, "\0\1\1\0\1\0\0\1\1\0\0\1\0\1\1\0" }, { 5, 7, 1, 0, 7, "\0\0\1\0\0\0\0\1\0\0\1\1\1\1\1\0\0\1\0\0\0\0\1\0\0\0\0\0\0\0\1\1\1\1\1" }, { 4, 5, 0, 4, 4, "\0\1\1\0\1\0\0\1\0\0\1\0\0\1\0\0\1\1\1\1" }, { 3, 5, 0, 4, 4, "\1\1\1\0\0\1\0\1\0\0\0\1\1\1\0" }, { 2, 2, 1, 7, 4, "\0\1\1\0" }, { 6, 9, 0, -3, 6, "\1\1\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\1\1\0\1\0\1\0\0\0\0\0\1\0\0\0\0\0\1\1\0\0\0" }, { 6, 12, 0, -3, 7, "\0\1\1\1\1\1\1\1\1\0\1\0\1\1\1\0\1\0\1\1\1\0\1\0\1\1\1\0\1\0\0\1\1\0\1\0\0\0\1\0\1\0\0\0\1\0\1\0\0\0\1\0\1\0\0\0\1\0\1\0\0\0\1\0\1\0\0\0\1\0\1\0" }, { 1, 1, 1, 3, 3, "\1" }, { 3, 3, 0, -3, 3, "\0\1\0\0\0\1\1\1\1" }, { 3, 5, 0, 4, 4, "\0\1\0\1\1\0\0\1\0\0\1\0\1\1\1" }, { 3, 6, 1, 3, 5, "\0\1\0\1\0\1\1\0\1\0\1\0\0\0\0\1\1\1" }, { 5, 5, 0, 0, 7, "\1\0\1\0\0\0\1\0\1\0\0\0\1\0\1\0\1\0\1\0\1\0\1\0\0" }, { 9, 9, 0, 0, 9, "\0\1\0\0\0\0\1\0\0\1\1\0\0\0\1\0\0\0\0\1\0\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\1\1\0\1\0\0\1\0\0\0\0\1\0\0\1\1\0\0\0\0\1\0\1\0\1\0\0\0\1\0\0\1\1\1\1\0\0\1\0\0\0\0\1\0" }, { 9, 9, 0, 0, 9, "\0\1\0\0\0\0\1\0\0\1\1\0\0\0\1\0\0\0\0\1\0\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\1\1\0\1\0\1\1\0\0\0\0\1\0\1\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\1\0\0\1\1\1\1" }, { 9, 9, 0, 0, 9, "\1\1\1\0\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\0\1\0\0\0\0\0\1\0\1\0\0\0\0\1\1\0\0\1\0\0\1\0\0\0\0\1\0\0\1\1\0\0\0\0\1\0\1\0\1\0\0\0\1\0\0\1\1\1\1\0\0\1\0\0\0\0\1\0" }, { 4, 9, 0, -3, 5, "\0\0\1\0\0\0\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\1\0\0\1\0\0\0\1\0\0\1\0\1\1\0" }, { 9, 12, 0, 0, 9, "\0\0\0\1\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\1\0\0\0\0\0\0\1\0\1\0\0\0\0\0\1\0\0\0\1\0\0\0\0\1\1\1\1\1\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\0\1\0\1\1\1\0\0\0\1\1\1" }, { 9, 12, 0, 0, 9, "\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\1\0\0\0\0\0\0\1\0\1\0\0\0\0\0\1\0\0\0\1\0\0\0\0\1\1\1\1\1\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\0\1\0\1\1\1\0\0\0\1\1\1" }, { 9, 12, 0, 0, 9, "\0\0\0\0\1\0\0\0\0\0\0\0\1\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\1\0\0\0\0\0\0\1\0\1\0\0\0\0\0\1\0\0\0\1\0\0\0\0\1\1\1\1\1\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\0\1\0\1\1\1\0\0\0\1\1\1" }, { 9, 12, 0, 0, 9, "\0\0\0\0\1\0\1\0\0\0\0\0\1\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\1\0\0\0\0\0\0\1\0\1\0\0\0\0\0\1\0\0\0\1\0\0\0\0\1\1\1\1\1\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\0\1\0\1\1\1\0\0\0\1\1\1" }, { 9, 11, 0, 0, 9, "\0\0\0\1\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\1\0\0\0\0\0\0\1\0\1\0\0\0\0\0\1\0\0\0\1\0\0\0\0\1\1\1\1\1\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\0\1\0\1\1\1\0\0\0\1\1\1" }, { 9, 12, 0, 0, 9, "\0\0\0\0\1\0\0\0\0\0\0\0\1\0\1\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\1\0\0\0\0\0\0\1\0\1\0\0\0\0\0\1\0\0\0\1\0\0\0\0\1\1\1\1\1\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\0\1\0\1\1\1\0\0\0\1\1\1" }, { 10, 9, 0, 0, 11, "\0\0\1\1\1\1\1\1\1\1\0\0\0\1\1\0\0\0\0\1\0\0\1\0\1\0\0\0\0\0\0\0\1\0\1\0\0\0\1\0\0\1\0\0\1\1\1\1\1\0\0\1\1\1\1\0\0\0\1\0\0\1\0\0\1\0\0\0\0\0\1\0\0\0\1\0\0\0\0\1\1\1\0\0\1\1\1\1\1\1" }, { 7, 12, 0, -3, 8, "\0\0\1\1\1\0\1\0\1\1\0\0\1\1\0\1\0\0\0\0\1\1\0\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\0\1\0\1\1\0\0\1\1\0\0\1\1\1\1\0\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\0\1\1\1\0\0" }, { 7, 12, 0, 0, 8, "\0\0\1\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\1\1\1\1\1\1\1\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\1\0\0\0\1\0\0\1\1\1\1\1\0\0\1\0\0\0\1\0\0\1\0\0\0\0\0\0\1\0\0\0\0\1\1\1\1\1\1\1\1" }, { 7, 12, 0, 0, 8, "\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\1\1\1\1\1\1\1\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\1\0\0\0\1\0\0\1\1\1\1\1\0\0\1\0\0\0\1\0\0\1\0\0\0\0\0\0\1\0\0\0\0\1\1\1\1\1\1\1\1" }, { 7, 12, 0, 0, 8, "\0\0\0\1\0\0\0\0\0\1\0\1\0\0\0\0\0\0\0\0\0\1\1\1\1\1\1\1\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\1\0\0\0\1\0\0\1\1\1\1\1\0\0\1\0\0\0\1\0\0\1\0\0\0\0\0\0\1\0\0\0\0\1\1\1\1\1\1\1\1" }, { 7, 11, 0, 0, 8, "\0\0\1\0\1\0\0\0\0\0\0\0\0\0\1\1\1\1\1\1\1\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\1\0\0\0\1\0\0\1\1\1\1\1\0\0\1\0\0\0\1\0\0\1\0\0\0\0\0\0\1\0\0\0\0\1\1\1\1\1\1\1\1" }, { 3, 12, 0, 0, 4, "\1\0\0\0\1\0\0\0\0\1\1\1\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1" }, { 3, 12, 0, 0, 4, "\0\0\1\0\1\0\0\0\0\1\1\1\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1" }, { 3, 12, 0, 0, 4, "\0\1\0\1\0\1\0\0\0\1\1\1\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1" }, { 3, 11, 0, 0, 4, "\1\0\1\0\0\0\1\1\1\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1" }, { 8, 9, 0, 0, 9, "\1\1\1\1\1\1\0\0\0\1\0\0\0\1\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\0\1\1\1\1\0\0\0\0\1\0\1\0\0\0\0\0\1\0\1\0\0\0\0\1\0\0\1\0\0\0\1\1\0\1\1\1\1\1\1\0\0" }, { 9, 12, 0, 0, 9, "\0\0\0\0\1\0\1\0\0\0\0\0\1\0\1\0\0\0\0\0\0\0\0\0\0\0\0\1\1\0\0\0\0\1\1\1\0\1\1\0\0\0\0\1\0\0\1\1\0\0\0\0\1\0\0\1\0\1\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\0\1\0\1\0\0\1\0\0\0\0\1\1\0\1\1\1\0\0\0\0\1\0" }, { 8, 12, 0, 0, 9, "\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\1\1\0\0\0\1\1\0\0\1\1\0\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\0\1\0\0\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\1\1\1\0\0" }, { 8, 12, 0, 0, 9, "\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\1\1\0\0\0\1\1\0\0\1\1\0\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\0\1\0\0\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\1\1\1\0\0" }, { 8, 12, 0, 0, 9, "\0\0\0\1\0\0\0\0\0\0\1\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\1\1\0\0\0\1\1\0\0\1\1\0\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\0\1\0\0\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\1\1\1\0\0" }, { 8, 12, 0, 0, 9, "\0\0\0\1\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\1\1\0\0\0\1\1\0\0\1\1\0\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\0\1\0\0\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\1\1\1\0\0" }, { 8, 11, 0, 0, 9, "\0\0\1\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\1\1\1\1\0\0\0\1\1\0\0\1\1\0\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\1\0\0\0\0\0\0\1\0\1\0\0\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\1\1\1\0\0" }, { 5, 5, 1, 1, 7, "\1\0\0\0\1\0\1\0\1\0\0\0\1\0\0\0\1\0\1\0\1\0\0\0\1" }, { 9, 10, 0, 0, 9, "\0\0\0\0\0\0\0\0\1\0\0\1\1\1\1\0\1\0\0\1\1\0\0\1\1\0\0\0\1\0\0\0\1\1\0\0\1\0\0\0\1\0\0\1\0\1\0\0\0\1\0\0\1\0\1\0\0\1\0\0\0\1\0\0\1\1\0\0\0\1\0\0\0\1\1\0\0\1\1\0\0\1\0\1\1\1\1\0\0\0" }, { 8, 12, 0, 0, 8, "\0\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\1\1\1\0\0\1\1\1\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\1\1\1\0\0" }, { 8, 12, 0, 0, 8, "\0\0\0\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\1\1\1\0\0\1\1\1\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\1\1\1\0\0" }, { 8, 12, 0, 0, 8, "\0\0\0\1\0\0\0\0\0\0\1\0\1\0\0\0\0\0\0\0\0\0\0\0\1\1\1\0\0\1\1\1\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\1\1\1\0\0" }, { 8, 11, 0, 0, 8, "\0\0\1\0\1\0\0\0\0\0\0\0\0\0\0\0\1\1\1\0\0\1\1\1\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\0\0\0\0\1\0\0\1\1\0\0\1\1\0\0\0\1\1\1\1\0\0" }, { 9, 12, 0, 0, 9, "\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\1\1\1\0\0\0\1\1\1\0\1\0\0\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\0\1\0\0\1\0\0\0\0\0\1\1\1\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\1\1\0\0\0" }, { 7, 9, 0, 0, 7, "\1\1\1\0\0\0\0\0\1\0\0\0\0\0\0\1\1\1\1\1\0\0\1\0\0\0\1\1\0\1\0\0\0\0\1\0\1\0\0\0\1\1\0\1\1\1\1\1\0\0\1\0\0\0\0\0\1\1\1\0\0\0\0" }, { 6, 9, 0, 0, 6, "\0\0\1\1\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\0\0\0\1\1\1\0\0\0\1\0\0\1\0\0\1\0\0\0\1\0\1\0\0\0\1\1\1\0\1\1\0" }, { 5, 9, 1, 0, 6, "\0\1\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\1\0\0\1\0\0\1\0\0\1\1\1\0\1\0\0\1\0\1\0\0\1\0\0\1\1\0\1" }, { 5, 9, 1, 0, 6, "\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\1\1\0\0\1\0\0\1\0\0\1\1\1\0\1\0\0\1\0\1\0\0\1\0\0\1\1\0\1" }, { 5, 9, 1, 0, 6, "\0\0\1\0\0\0\1\0\1\0\0\0\0\0\0\0\1\1\0\0\1\0\0\1\0\0\1\1\1\0\1\0\0\1\0\1\0\0\1\0\0\1\1\0\1" }, { 5, 9, 1, 0, 6, "\0\1\0\1\0\1\0\1\0\0\0\0\0\0\0\0\1\1\0\0\1\0\0\1\0\0\1\1\1\0\1\0\0\1\0\1\0\0\1\0\0\1\1\0\1" }, { 5, 8, 1, 0, 6, "\0\1\0\1\0\0\0\0\0\0\0\1\1\0\0\1\0\0\1\0\0\1\1\1\0\1\0\0\1\0\1\0\0\1\0\0\1\1\0\1" }, { 5, 9, 1, 0, 6, "\0\0\1\0\0\0\1\0\1\0\0\0\1\0\0\0\1\1\0\0\1\0\0\1\0\0\1\1\1\0\1\0\0\1\0\1\0\0\1\0\0\1\1\0\1" }, { 8, 6, 1, 0, 9, "\0\1\1\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\1\1\1\1\1\0\1\0\0\1\0\0\0\0\1\0\0\1\1\0\0\1\0\1\1\0\1\1\1\0" }, { 4, 9, 1, -3, 5, "\0\1\1\0\1\0\0\1\1\0\0\0\1\0\0\0\1\0\0\1\0\1\1\0\0\1\0\0\0\0\1\0\1\1\1\0" }, { 5, 9, 1, 0, 6, "\0\1\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\1\0\0\1\0\0\1\0\1\1\1\1\0\1\0\0\0\0\1\1\0\0\1\0\1\1\1\0" }, { 5, 9, 1, 0, 6, "\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\1\1\0\0\1\0\0\1\0\1\1\1\1\0\1\0\0\0\0\1\1\0\0\1\0\1\1\1\0" }, { 5, 9, 1, 0, 6, "\0\0\1\0\0\0\1\0\1\0\0\0\0\0\0\0\1\1\0\0\1\0\0\1\0\1\1\1\1\0\1\0\0\0\0\1\1\0\0\1\0\1\1\1\0" }, { 5, 8, 1, 0, 6, "\0\1\0\1\0\0\0\0\0\0\0\1\1\0\0\1\0\0\1\0\1\1\1\1\0\1\0\0\0\0\1\1\0\0\1\0\1\1\1\0" }, { 3, 9, 0, 0, 3, "\1\0\0\0\1\0\0\0\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1" }, { 3, 9, 0, 0, 3, "\0\1\0\1\0\0\0\0\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1" }, { 3, 9, 0, 0, 3, "\0\1\0\1\0\1\0\0\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1" }, { 3, 8, 0, 0, 3, "\1\0\1\0\0\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1" }, { 4, 9, 1, 0, 6, "\0\1\0\0\0\1\1\1\1\0\1\0\0\1\1\1\1\0\0\1\1\0\0\1\1\0\0\1\1\0\0\1\0\1\1\0" }, { 6, 9, 0, 0, 6, "\0\0\1\0\1\0\0\1\0\1\0\0\0\0\0\0\0\0\1\0\1\1\0\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\1\1\1\0\1\1" }, { 4, 9, 1, 0, 6, "\0\1\0\0\0\0\1\0\0\0\0\0\0\1\1\0\1\0\0\1\1\0\0\1\1\0\0\1\1\0\0\1\0\1\1\0" }, { 4, 9, 1, 0, 6, "\0\0\1\0\0\1\0\0\0\0\0\0\0\1\1\0\1\0\0\1\1\0\0\1\1\0\0\1\1\0\0\1\0\1\1\0" }, { 4, 9, 1, 0, 6, "\0\0\1\0\0\1\0\1\0\0\0\0\0\1\1\0\1\0\0\1\1\0\0\1\1\0\0\1\1\0\0\1\0\1\1\0" }, { 4, 9, 1, 0, 6, "\0\1\0\1\1\0\1\0\0\0\0\0\0\1\1\0\1\0\0\1\1\0\0\1\1\0\0\1\1\0\0\1\0\1\1\0" }, { 4, 8, 1, 0, 6, "\1\0\1\0\0\0\0\0\0\1\1\0\1\0\0\1\1\0\0\1\1\0\0\1\1\0\0\1\0\1\1\0" }, { 5, 5, 1, 1, 7, "\0\0\1\0\0\0\0\0\0\0\1\1\1\1\1\0\0\0\0\0\0\0\1\0\0" }, { 6, 7, 0, -1, 6, "\0\0\1\1\0\1\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\1\1\0\0\1\0\0\0\0\0" }, { 6, 9, 0, 0, 6, "\0\0\1\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\1\1\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\0\1\1\0\1" }, { 6, 9, 0, 0, 6, "\0\0\0\1\0\0\0\0\1\0\0\0\0\0\0\0\0\0\1\1\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\0\1\1\0\1" }, { 6, 9, 0, 0, 6, "\0\0\1\0\0\0\0\1\0\1\0\0\0\0\0\0\0\0\1\1\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\0\1\1\0\1" }, { 6, 8, 0, 0, 6, "\0\1\0\1\0\0\0\0\0\0\0\0\1\1\0\1\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\1\0\0\0\1\1\0\1" }, { 6, 12, 0, -3, 6, "\0\0\0\0\1\0\0\0\0\1\0\0\0\0\0\0\0\0\1\1\0\0\1\1\0\1\0\0\1\0\0\1\0\1\1\0\0\1\0\1\0\0\0\0\1\1\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\1\0\0\0\0\1\1\0\0\0\0" }, { 5, 12, 0, -3, 6, "\1\1\0\0\0\0\1\0\0\0\0\1\0\0\0\0\1\1\1\0\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\1\1\0\0\1\0\0\0\0\1\0\0\0\1\1\1\0\0" }, { 6, 11, 0, -3, 6, "\0\1\0\0\1\0\0\0\0\0\0\0\1\1\0\0\1\1\0\1\0\0\1\0\0\1\0\1\1\0\0\1\0\1\0\0\0\0\1\1\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\1\0\0\0\0\1\1\0\0\0\0" } }; static struct font default_bdffont = { 14, 15, -1, -3, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _g + 0, _g + 1, _g + 2, _g + 3, _g + 4, _g + 5, _g + 6, _g + 7, _g + 8, _g + 9, _g + 10, _g + 11, _g + 12, _g + 13, _g + 14, _g + 15, _g + 16, _g + 17, _g + 18, _g + 19, _g + 20, _g + 21, _g + 22, _g + 23, _g + 24, _g + 25, _g + 26, _g + 27, _g + 28, _g + 29, _g + 30, _g + 31, _g + 32, _g + 33, _g + 34, _g + 35, _g + 36, _g + 37, _g + 38, _g + 39, _g + 40, _g + 41, _g + 42, _g + 43, _g + 44, _g + 45, _g + 46, _g + 47, _g + 48, _g + 49, _g + 50, _g + 51, _g + 52, _g + 53, _g + 54, _g + 55, _g + 56, _g + 57, _g + 58, _g + 59, _g + 60, _g + 61, _g + 62, _g + 63, _g + 64, _g + 65, _g + 66, _g + 67, _g + 68, _g + 69, _g + 70, _g + 71, _g + 72, _g + 73, _g + 74, _g + 75, _g + 76, _g + 77, _g + 78, _g + 79, _g + 80, _g + 81, _g + 82, _g + 83, _g + 84, _g + 85, _g + 86, _g + 87, _g + 88, _g + 89, _g + 90, _g + 91, _g + 92, _g + 93, _g + 94, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _g + 95, _g + 96, _g + 97, _g + 98, _g + 99, _g + 100, _g + 101, _g + 102, _g + 103, _g + 104, _g + 105, _g + 106, _g + 107, _g + 108, _g + 109, _g + 110, _g + 111, _g + 112, _g + 113, _g + 114, _g + 115, _g + 116, _g + 117, _g + 118, _g + 119, _g + 120, _g + 121, _g + 122, _g + 123, _g + 124, _g + 125, _g + 126, _g + 127, _g + 128, _g + 129, _g + 130, _g + 131, _g + 132, _g + 133, _g + 134, _g + 135, _g + 136, _g + 137, _g + 138, _g + 139, _g + 140, _g + 141, _g + 142, _g + 143, _g + 144, _g + 145, _g + 146, _g + 147, _g + 148, _g + 149, _g + 150, _g + 151, _g + 152, _g + 153, _g + 154, _g + 155, _g + 156, _g + 157, _g + 158, _g + 159, _g + 160, _g + 161, _g + 162, _g + 163, _g + 164, _g + 165, _g + 166, _g + 167, _g + 168, _g + 169, _g + 170, _g + 171, _g + 172, _g + 173, _g + 174, _g + 175, _g + 176, _g + 177, _g + 178, _g + 179, _g + 180, _g + 181, _g + 182, _g + 183, _g + 184, _g + 185, _g + 186, _g + 187, _g + 188, _g + 189 } }; struct font* pbm_defaultfont( name ) char* name; { bit** defaultfont; int row, col, scol; unsigned long l; if (!strcmp(name, "bdf")) return &default_bdffont; if (strcmp(name, "fixed")) pm_error( "built-in font name unknown, try 'bdf' or 'fixed'" ); defaultfont = pbm_allocarray( DEFAULTFONT_COLS, DEFAULTFONT_ROWS ); for ( row = 0; row < DEFAULTFONT_ROWS; ++row ) { for ( col = 0; col < DEFAULTFONT_COLS; col += 32 ) { l = defaultfont_bits[row][col / 32]; for ( scol = min( col + 32, DEFAULTFONT_COLS ) - 1; scol >= col; --scol ) { if ( l & 1 ) defaultfont[row][scol] = 1; else defaultfont[row][scol] = 0; l >>= 1; } } } return pbm_dissectfont( defaultfont, DEFAULTFONT_ROWS, DEFAULTFONT_COLS ); } struct font* pbm_dissectfont( font, frows, fcols ) bit** font; int frows; int fcols; { /* ** This routine expects a font bitmap representing the following text: ** ** (0,0) ** M ",/^_[`jpqy| M ** ** / !"#$%&'()*+ / ** < ,-./01234567 < ** > 89:;<=>?@ABC > ** @ DEFGHIJKLMNO @ ** _ PQRSTUVWXYZ[ _ ** { \]^_`abcdefg { ** } hijklmnopqrs } ** ~ tuvwxyz{|}~ ~ ** ** M ",/^_[`jpqy| M ** ** The bitmap must be cropped exactly to the edges. ** ** The dissection works by finding the first blank row and column; that ** gives the height and width of the maximum-sized character, which is ** not too useful. But the distance from there to the opposite side is ** an integral multiple of the cell size, and that's what we need. Then ** it's just a matter of filling in all the coordinates. ** ** The difference between char_height, char_width and char_aheight, ** char_awidth is that the first is the size of the cell including ** spacing, while the second is just the actual maximum-size character. */ int char_width, char_height, char_awidth, char_aheight; int brow, bcol, row, col, d, ch, r, c, i; struct font* fn; struct glyph* glyph; char* bmap; bit b; /* Find first blank row. */ for ( brow = 0; brow < frows / 6; ++brow ) { b = font[brow][0]; for ( col = 1; col < fcols; ++col ) if ( font[brow][col] != b ) goto nextrow; goto gotblankrow; nextrow: ; } pm_error( "couldn't find blank row in font" ); gotblankrow: /* Find first blank col. */ for ( bcol = 0; bcol < fcols / 8; ++bcol ) { b = font[0][bcol]; for ( row = 1; row < frows; ++row ) if ( font[row][bcol] != b ) goto nextcol; goto gotblankcol; nextcol: ; } pm_error( "couldn't find blank col in font" ); gotblankcol: /* Now compute character cell size. */ d = frows - brow; char_height = d / 11; if ( char_height * 11 != d ) pm_error( "problem computing character cell height" ); d = fcols - bcol; char_width = d / 15; if ( char_width * 15 != d ) pm_error( "problem computing character cell width" ); char_aheight = brow; char_awidth = bcol; /* Now convert to a general font */ fn = (struct font*) malloc( sizeof(struct font) ); if ( fn == (struct font*) 0 ) pm_error( "out of memory allocating font structure" ); fn->maxwidth = char_awidth; fn->maxheight = char_height; fn->x = fn->y = 0; for (i = 0; i < 256; i++) fn->glyph[i] = 0; fn->oldfont = font; fn->frows = frows; fn->fcols = fcols; glyph = (struct glyph*) malloc2( sizeof(struct glyph), 95 ); if ( glyph == (struct glyph*) 0 ) pm_error( "out of memory allocating glyphs" ); bmap = (char*) malloc3( fn->maxwidth, fn->maxheight, 95 ); if ( bmap == (char*) 0) pm_error( "out of memory allocating glyph data" ); /* Now fill in the 0,0 coords. */ overflow2(char_height, 2); overflow2(char_width, 2); row = char_height * 2; col = char_width * 2; for ( ch = 0; ch < 95; ++ch ) { glyph[ch].width = fn->maxwidth; glyph[ch].height = fn->maxheight; glyph[ch].x = glyph[ch].y = 0; glyph[ch].xadd = char_width; for ( r = 0; r < glyph[ch].height; ++r ) for ( c = 0; c < glyph[ch].width; ++c ) bmap[r * glyph[ch].width + c] = font[row + r][col + c]; glyph[ch].bmap = bmap; bmap += glyph[ch].width * glyph[ch].height; fn->glyph[ch + 32] = glyph + ch; col += char_width; if ( col >= char_width * 14 ) { col = char_width * 2; row += char_height; } } return fn; } struct font* pbm_loadfont( filename ) char* filename; { FILE* fp; struct font* fn; char line[256]; fp = pm_openr( filename ); fgets(line, 256, fp); pm_close( fp ); if (line[0] == PBM_MAGIC1 && (line[1] == PBM_MAGIC2 || line[1] == RPBM_MAGIC2)) { return pbm_loadpbmfont( filename ); } else if (!strncmp(line, "STARTFONT", 9)) { if (!(fn = pbm_loadbdffont( filename ))) pm_error( "could not load BDF font file" ); return fn; } else { pm_error( "font file not in a recognized format "); return NULL; /* should never reach here */ } } struct font* pbm_loadpbmfont( filename ) char* filename; { FILE* ifp; bit** font; int fcols, frows; ifp = pm_openr( filename ); font = pbm_readpbm( ifp, &fcols, &frows ); pm_close( ifp ); return pbm_dissectfont( font, frows, fcols ); } void pbm_dumpfont( fn ) struct font* fn; { /* Dump out font as C source code. */ int row, col, scol, lperrow; unsigned long l; if (fn->oldfont) { printf( "#define DEFAULTFONT_ROWS %d\n", fn->frows ); printf( "#define DEFAULTFONT_COLS %d\n", fn->fcols ); printf( "static unsigned long defaultfont_bits[DEFAULTFONT_ROWS][(DEFAULTFONT_COLS+31)/32] = {\n" ); for ( row = 0; row < fn->frows; ++row ) { lperrow = 0; for ( col = 0; col < fn->fcols; col += 32 ) { if ( lperrow == 0 ) printf( " {" ); else if ( lperrow % 6 == 0 ) { printf( ",\n " ); lperrow = 0; } else printf( "," ); l = 0; for ( scol = col; scol < min( col + 32, fn->fcols ); ++scol ) { l <<= 1; if ( fn->oldfont[row][scol] ) l |= 1; } printf( "0x%08lxL", l ); ++lperrow; } printf( "}%s\n", row == fn->frows - 1 ? "" : "," ); } printf( " };\n" ); } else { struct glyph* glyph; int i, j, ng; ng = 0; for (i = 0; i < 256; i++) if (fn->glyph[i]) ng++; printf("static struct glyph _g[%d] = {\n", ng); for (i = 0; i < 256; i++) { if (!(glyph = fn->glyph[i])) continue; printf(" { %d, %d, %d, %d, %d, \"", glyph->width, glyph->height, glyph->x, glyph->y, glyph->xadd); for (j = 0; j < glyph->width * glyph->height; j++) if (glyph->bmap[j]) printf("\\1"); else printf("\\0"); ng--; printf("\" }%s\n", ng ? "," : ""); } printf("};\n"); printf("static struct font default_bdffont = { %d, %d, %d, %d, {\n", fn->maxwidth, fn->maxheight, fn->x, fn->y); for (i = 0; i < 256; i++) { if (fn->glyph[i]) printf(" _g + %d", ng++); else printf(" 0"); if (i != 255) printf(","); printf("\n"); } printf(" }\n};\n"); exit(0); } } /* Routines for loading a BDF font file */ static int readline ARGS((FILE* fp, char* buf, char* arg[])); #define expect(str) if (readline(fp, line, arg) < 0 || strcmp(arg[0], (str))) \ { fclose(fp); return 0; } struct font* pbm_loadbdffont(name) char* name; { FILE* fp; char line[1024], *arg[32], *b, *hex; int n, numchar, hdig, encoding; struct font* font; struct glyph* glyph; if (!(fp = fopen(name, "rb"))) return 0; expect("STARTFONT"); if (!(font = (struct font*)malloc(sizeof(struct font)))) pm_error("no memory for font"); font->oldfont = 0; { /* Initialize all characters to nonexistent; we will fill the ones we find in the bdf file later. */ int i; for (i = 0; i < 256; i++) font->glyph[i] = NULL; } while (readline(fp, line, arg) >= 0) { if (!strcmp(arg[0], "COMMENT")) continue; if (!strcmp(arg[0], "SIZE")) continue; if (!strcmp(arg[0], "STARTPROPERTIES")) { n = atoi(arg[1]); for (; n > 0 && readline(fp, line, arg) >= 0; n--) ; } else if (!strcmp(arg[0], "FONTBOUNDINGBOX")) { font->maxwidth = atoi(arg[1]); font->maxheight = atoi(arg[2]); font->x = atoi(arg[3]); font->y = atoi(arg[4]); } else if (!strcmp(arg[0], "ENDFONT")) { fclose(fp); return font; } else if (!strcmp(arg[0], "CHARS")) { numchar = atoi(arg[1]); while (numchar > 0) { if (readline(fp, line, arg) < 0) { fclose(fp); return 0; } if (!strcmp(arg[0], "COMMENT")) continue; if (strcmp(arg[0], "STARTCHAR")) { fclose(fp); return 0; } if (!(glyph = (struct glyph*)malloc(sizeof(struct glyph)))) pm_error("no memory for font glyph"); expect("ENCODING"); if ((encoding = atoi(arg[1])) < 0) { if (arg[2]) encoding = atoi(arg[2]); else { while (readline(fp, line, arg) >= 0) if (!strcmp(arg[0], "ENDCHAR")) break; numchar--; continue; } } expect("SWIDTH"); expect("DWIDTH"); glyph->xadd = atoi(arg[1]); expect("BBX"); glyph->width = atoi(arg[1]); glyph->height = atoi(arg[2]); glyph->x = atoi(arg[3]); glyph->y = atoi(arg[4]); if (!(glyph->bmap = (char*)malloc2(glyph->width, glyph->height))) pm_error("no memory for font glyph byte map"); if (readline(fp, line, arg) < 0) { fclose(fp); return 0; } if (!strcmp(arg[0], "ATTRIBUTES")) if (readline(fp, line, arg) < 0) { fclose(fp); return 0; } b = glyph->bmap; for (n = glyph->height; n > 0; n--) { int i; /* dot counter */ if (readline(fp, line, arg) < 0) { fclose(fp); return 0; } hex = line; for (i = glyph->width; i > 0; i -= 4) { hdig = *hex++; if (hdig >= '0' && hdig <= '9') hdig -= '0'; else if (hdig >= 'a' && hdig <= 'f') hdig -= 'a' - 10; else if (hdig >= 'A' && hdig <= 'F') hdig -= 'A' - 10; *b++ = hdig & 8 ? 1 : 0; if (i > 1) *b++ = hdig & 4 ? 1 : 0; if (i > 2) *b++ = hdig & 2 ? 1 : 0; if (i > 3) *b++ = hdig & 1; } } expect("ENDCHAR"); if (encoding < 256) /* We ignore any characters with codes that don't fit in 8 bits. We may want to change this someday. */ font->glyph[encoding] = glyph; numchar--; } } } return font; } static int readline(fp, buf, arg) FILE* fp; char* buf; char* arg[]; { if (!fgets(buf, 1024, fp)) return -1; return mk_argvn(buf, arg, 32); } int mk_argvn(s, vec, mk_max) char* s; char* vec[]; int mk_max; { int n; n = 0; while (*s) { if (isspace(*s)) { *s++ = '\0'; continue; } vec[n++] = s; if (n >= mk_max) break; while (*s && !isspace(*s)) s++; } vec[n] = 0; return n; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/libpbmvms.c������������������������������������������������������������������0100644�0047145�0047145�00000044710�07716230207�017246� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#warning "NOT AUDITED" /*************************************************************************** This file contains library routines needed to build Netpbm for VMS. However, as of 2000.05.26, when these were split out of libpbm1.c (where they were all switched by #ifdef VMS), there is no evidence that anyone is building Netpbm for VMS. ****************************************************************************/ /* * @(#)argproc.c 1.0 89/02/01 Mark Pizzolato (mark@infopiz.uucp) */ #ifndef lint char argproc_version[] = "@(#)argproc.c VMS uucp Version infopiz-1.0"; #endif #include "includes.h" /* System include files, system dependent */ /* * getredirection() is intended to aid in porting C programs * to VMS (Vax-11 C) which does not support '>' and '<' * I/O redirection, along with a command line pipe mechanism * using the '|' AND background command execution '&'. * The piping mechanism will probably work with almost any 'filter' type * of program. With suitable modification, it may useful for other * portability problems as well. * * Author: Mark Pizzolato mark@infopiz.UUCP */ struct list_item { struct list_item *next; char *value; }; int getredirection(ac, av) int *ac; char ***av; /* * Process vms redirection arg's. Exit if any error is seen. * If getredirection() processes an argument, it is erased * from the vector. getredirection() returns a new argc and argv value. * In the event that a background command is requested (by a trailing "&"), * this routine creates a background subprocess, and simply exits the program. * * Warning: do not try to simplify the code for vms. The code * presupposes that getredirection() is called before any data is * read from stdin or written to stdout. * * Normal usage is as follows: * * main(argc, argv) * int argc; * char *argv[]; * { * getredirection(&argc, &argv); * } */ { int argc = *ac; /* Argument Count */ char **argv = *av; /* Argument Vector */ char *ap; /* Argument pointer */ int j; /* argv[] index */ extern int errno; /* Last vms i/o error */ int item_count = 0; /* Count of Items in List */ int new_file; /* flag, true if '>' used */ struct list_item *list_head = 0; /* First Item in List */ struct list_item *list_tail; /* Last Item in List */ char *in = NULL; /* Input File Name */ char *out = NULL; /* Output File Name */ char *outmode = "w"; /* Mode to Open Output File */ int cmargc = 0; /* Piped Command Arg Count */ char **cmargv = NULL;/* Piped Command Arg Vector */ stat_t statbuf; /* fstat buffer */ /* * First handle the case where the last thing on the line ends with * a '&'. This indicates the desire for the command to be run in a * subprocess, so we satisfy that desire. */ ap = argv[argc-1]; if (0 == strcmp("&", ap)) exit(background_process(--argc, argv)); if ('&' == ap[strlen(ap)-1]) { ap[strlen(ap)-1] = '\0'; exit(background_process(argc, argv)); } /* * Now we handle the general redirection cases that involve '>', '>>', * '<', and pipes '|'. */ for (new_file = 0, j = 0; j < argc; ++j) { if (0 == strcmp("<", argv[j])) { if (j+1 >= argc) { errno = EINVAL; perror("No input file"); exit(EXIT_ERR); } in = argv[++j]; continue; } if ('<' == *(ap = argv[j])) { in = 1 + ap; continue; } if (0 == strcmp(">", ap)) { if (j+1 >= argc) { errno = EINVAL; perror("No output file"); exit(EXIT_ERR); } out = argv[++j]; new_file = 1; continue; } if ('>' == *ap) { if ('>' == ap[1]) { outmode = "a"; if ('\0' == ap[2]) out = argv[++j]; else out = 2 + ap; } else { out = 1 + ap; new_file = 1; } continue; } if (0 == strcmp("|", argv[j])) { if (j+1 >= argc) { errno = EPIPE; perror("No command to Pipe to"); exit(EXIT_ERR); } cmargc = argc-(j+1); cmargv = &argv[j+1]; argc = j; outmode = "wb"; /* pipes are binary mode devices */ continue; } if ('|' == *(ap = argv[j])) { ++argv[j]; cmargc = argc-j; cmargv = &argv[j]; argc = j; outmode = "wb"; /* pipes are binary mode devices */ continue; } expand_wild_cards(ap, &list_head, &list_tail, &item_count); } /* * Allocate and fill in the new argument vector, Some Unix's terminate * the list with an extra null pointer. */ argv = *av = calloc(item_count+1, sizeof(char *)); for (j = 0; j < item_count; ++j, list_head = list_head->next) argv[j] = list_head->value; *ac = item_count; if (cmargv != NULL) { char subcmd[1024]; static char *pipe_and_fork(); if (out != NULL) { errno = EINVAL; perror("Invalid '|' and '>' specified"); exit(EXIT_ERR); } strcpy(subcmd, cmargv[0]); for (j = 1; j < cmargc; ++j) { strcat(subcmd, " \""); strcat(subcmd, cmargv[j]); strcat(subcmd, "\""); } out = pipe_and_fork(subcmd); outmode = "wb"; } /* Check for input from a pipe (mailbox) */ if(fstat(0, &statbuf) == 0){ if(strncmp(statbuf.st_dev, "MB", 2) == 0 || strncmp(statbuf.st_dev, "_MB", 3) == 0){ /* Input from a pipe, reopen it in binary mode to disable */ /* carriage control processing. */ if (in != NULL){ errno = EINVAL; perror("Invalid '|' and '<' specified"); exit(EXIT_ERR); } freopen(statbuf.st_dev, "rb", stdin); } } else { perror("fstat failed"); exit(EXIT_ERR); } #ifdef __ALPHA /*, "mbc=32", "mbf=2"))) blows up on the ALPHA cbm 11/08/92 */ if ((in != NULL) && (NULL == freopen(in, "r", stdin))) { #else if ((in != NULL) && (NULL == freopen(in, "r", stdin, "mbc=32", "mbf=2"))) { #endif perror(in); /* Can't find file */ exit(EXIT_ERR); /* Is a fatal error */ } #ifdef __ALPHA if ((out != NULL) && (NULL == freopen(out, outmode, stdout))) { #else if ((out != NULL) && (NULL == freopen(out, outmode, stdout, "mbc=32", "mbf=2"))) { #endif perror(ap); /* Error, can't write or append */ exit(EXIT_ERR); /* Is a fatal error */ } if ( new_file ) { /* * We are making an explicit output file, fstat the file and * declare exit handler to be able change the file to fixed length * records if necessary. */ char fname[256]; static int outfile_rundown(), check_outfile_filetype(); static stat_t ofile_stat; static struct exit_control_block { struct exit_control_block *flink; int (*exit_routine)(); int arg_count; int *status_address; /* arg 1 */ stat_t *stat; /* arg 2 */ int exit_status; int skew[128]; } exit_block = { 0, outfile_rundown, 2, &exit_block.exit_status, &ofile_stat, 0 }; if ( fstat ( fileno(stdout), &ofile_stat ) == 0 ) sys$dclexh ( &exit_block ); else fprintf(stderr,"Error fstating stdout - %s\n", strerror(errno,vaxc$errno) ); if ( fgetname ( stdout, fname, 0 ) ) check_outfile_filetype ( fname ); } #ifdef DEBUG fprintf(stderr, "Arglist:\n"); for (j = 0; j < *ac; ++j) fprintf(stderr, "argv[%d] = '%s'\n", j, argv[j]); #endif } static int binary_outfile = 0; void set_outfile_binary() { binary_outfile = 1; return; } /* * Check if output file should be set to binary (fixed 512) on exit based * upon the filetype. */ static int check_outfile_filetype ( name ) char *name; { char *binary_filetypes, *ext, *p, *t; binary_filetypes = (char *) getenv ( "PBM_BINARY_FILETYPES" ); if ( binary_filetypes == NULL ) return 0; ext = strchr ( name, '.' ); if ( ext == NULL ) return 0; ext++; t = strrchr ( name, '.' ); if ( t != NULL ) *t = '\0'; for ( p = binary_filetypes; *p != '\0'; p++ ) { for ( t = p; (*p != '\0' ) && (strchr ( ", ", *p ) == NULL); p++ ) *p = toupper(*p); *p = '\0'; if ( strcmp ( t, ext ) == 0 ) { binary_outfile = 1; break; } } return binary_outfile; } /* * Exit handler to set output file to binary on image exit. */ static int outfile_rundown ( reason, statbuf ) int *reason; stat_t *statbuf; { int code, channel, status, LIB$GETDVI(), sys$assign(), sys$qiow(); long int fib_desc[2], devchar; short int iosb[4]; $DESCRIPTOR(device, statbuf->st_dev); struct fibdef fib; /* File information block (XQP) */ struct atrdef atr[2]; struct fat { unsigned char rtype, ratattrib; unsigned short int rsize, hiblk[2], efblk[2], ffbyte, maxrec, defext, gbc; unsigned short int reserved[4], versions; } rat; if ( !binary_outfile ) return 1; /* leave file alone */ /* * Assign channel to device listed in stat block and test if it is * a directory structured device, returning if not. */ device.dsc$w_length = strlen ( statbuf->st_dev ); status = sys$assign ( &device, &channel, 0, 0 ); if ((status & 1) == 0) { fprintf(stderr, "assign error to %s (%d)\n", device.dsc$a_pointer, status); return status; } code = DVI$_DEVCHAR; status = LIB$GETDVI ( &code, &channel, 0, &devchar ); if ((status & 1) == 0) { fprintf(stderr, "getdvi error: %d\n", status); return status; } if ( (devchar & DEV$M_DIR) == 0 ) return 1; /* * Build File Information Block and Atrribute block. */ #ifdef __ALPHA fib.fib$w_fid[0] = statbuf->st_ino[0]; fib.fib$w_fid[1] = statbuf->st_ino[1]; fib.fib$w_fid[2] = statbuf->st_ino[2]; #else fib.fib$r_fid_overlay.fib$w_fid[0] = statbuf->st_ino[0]; fib.fib$r_fid_overlay.fib$w_fid[1] = statbuf->st_ino[1]; fib.fib$r_fid_overlay.fib$w_fid[2] = statbuf->st_ino[2]; #endif atr[0].atr$w_size = sizeof(rat); atr[0].atr$w_type = ATR$C_RECATTR; atr[0].atr$l_addr = &rat; atr[1].atr$w_size = 0; atr[1].atr$w_type = 0; /* * Perform access function with read_attributes sub-function. */ freopen ( "SYS$OUTPUT:", "a", stdout ); fib_desc[0] = 10; fib_desc[1] = (long int) &fib; #ifdef __ALPHA fib.fib$l_acctl = FIB$M_WRITE; #else fib.fib$r_acctl_overlay.fib$l_acctl = FIB$M_WRITE; #endif status = sys$qiow ( 0, channel, IO$_ACCESS|IO$M_ACCESS, &iosb, 0, 0, &fib_desc, 0, 0, 0, &atr, 0 ); /* * If status successful, update record byte and perform a MODIFY. */ if ( (status&1) == 1 ) status = iosb[0]; if ( (status&1) == 1 ) { rat.rtype = 1; /* fixed length records */ rat.rsize = 512; /* 512 byte block recrods */ rat.ratattrib = 0; /* Record attributes: none */ status = sys$qiow ( 0, channel, IO$_MODIFY, &iosb, 0, 0, &fib_desc, 0, 0, 0, &atr, 0 ); if ( (status&1) == 1 ) status = iosb[0]; } sys$dassgn ( channel ); if ( (status & 1) == 0 ) fprintf ( stderr, "Failed to convert output file to binary format, status: %d\n", status); return status; } static add_item(head, tail, value, count) struct list_item **head; struct list_item **tail; char *value; int *count; { if (*head == 0) { if (NULL == (*head = calloc(1, sizeof(**head)))) { errno = ENOMEM; perror(""); exit(EXIT_ERR); } *tail = *head; } else if (NULL == ((*tail)->next = calloc(1, sizeof(**head)))) { errno = ENOMEM; perror(""); exit(EXIT_ERR); } else *tail = (*tail)->next; (*tail)->value = value; ++(*count); } static expand_wild_cards(item, head, tail, count) char *item; struct ltem_list **head; struct ltem_list **tail; int *count; { int expcount = 0; int context = 0; int status; int status_value; int had_version; $DESCRIPTOR(filespec, item); $DESCRIPTOR(defaultspec, "SYS$DISK:[]*.*;"); $DESCRIPTOR(resultspec, ""); if (strcspn(item, "*%") == strlen(item)) { add_item(head, tail, item, count); return; } resultspec.dsc$b_dtype = DSC$K_DTYPE_T; resultspec.dsc$b_class = DSC$K_CLASS_D; resultspec.dsc$a_pointer = NULL; filespec.dsc$w_length = strlen(item); /* * Only return version specs, if the caller specified a version */ had_version = strchr(item, ';'); while (1 == (1&lib$find_file(&filespec, &resultspec, &context, &defaultspec, 0, &status_value, &0))) { char *string; char *c; if (NULL == (string = calloc(1, resultspec.dsc$w_length+1))) { errno = ENOMEM; perror(""); exit(EXIT_ERR); } strncpy(string, resultspec.dsc$a_pointer, resultspec.dsc$w_length); string[resultspec.dsc$w_length] = '\0'; if (NULL == had_version) *((char *)strrchr(string, ';')) = '\0'; /* * Be consistent with what the C RTL has already done to the rest of * the argv items and lowercase all of these names. */ for (c = string; *c; ++c) if (isupper(*c)) *c = tolower(*c); add_item(head, tail, string, count); ++expcount; } if (expcount == 0) add_item(head, tail, item, count); lib$sfree1_dd(&resultspec); lib$find_file_end(&context); } static int child_st[2]; /* Event Flag set when child process completes */ static short child_chan;/* I/O Channel for Pipe Mailbox */ static exit_handler(status) int *status; { short iosb[4]; if (0 == child_st[0]) { #ifdef DEBUG fprintf(stderr, "Waiting for Child Process to Finnish . . .\n"); #endif fflush(stdout); /* Have to flush pipe for binary data to */ /* terminate properly -- */ #ifdef DEBUG fprintf(stderr, " stdout flushed. . .\n"); #endif sys$qio(0, child_chan, IO$_WRITEOF, iosb, 0, 0, 0, 0, 0, 0, 0, 0); #ifdef DEBUG fprintf(stderr, " Pipe terminated. . .\n"); #endif fclose(stdout); #ifdef DEBUG fprintf(stderr, " stdout closed. . .\n"); #endif sys$synch(0, child_st); sys$dassgn(child_chan); } #ifdef DEBUG fprintf(stderr, " sync done. . .\n"); #endif } #include /* System Information Definitions */ static sig_child(chan) int chan; { #ifdef DEBUG fprintf(stderr, "Child Completion AST, st: %x\n", child_st[0] ); #endif if (child_st[0] == 0) { child_st[0] = 1; } sys$setef ( 0 ); } static struct exit_control_block { struct exit_control_block *flink; int (*exit_routine)(); int arg_count; int *status_address; int exit_status; } exit_block = { 0, exit_handler, 1, &exit_block.exit_status, 0 }; static char *pipe_and_fork(cmd) char *cmd; { $DESCRIPTOR(cmddsc, cmd); static char mbxname[64], ef = 0; $DESCRIPTOR(mbxdsc, mbxname); short iosb[4]; int status; int pid; struct { short dna_buflen; short dna_itmcod; char *dna_buffer; short *dna_retlen; int listend; } itmlst = { sizeof(mbxname), DVI$_DEVNAM, mbxname, &mbxdsc.dsc$w_length, 0 }; int mbxsize; struct { short mbf_buflen; short mbf_itmcod; int *mbf_maxbuf; short *mbf_retlen; int listend; } syiitmlst = { sizeof(mbxsize), SYI$_MAXBUF, &mbxsize, 0, 0 }; cmddsc.dsc$w_length = strlen(cmd); /* * Get the SYSGEN parameter MAXBUF, and the smaller of it and 2048 as * the size of the 'pipe' mailbox. */ if (1 == (1&(vaxc$errno = sys$getsyiw(0, 0, 0, &syiitmlst, iosb, 0, 0, 0)))) vaxc$errno = iosb[0]; if (0 == (1&vaxc$errno)) { errno = EVMSERR; perror("Can't get SYSGEN parameter value for MAXBUF"); exit(EXIT_ERR); } if (mbxsize > 2048) mbxsize = 2048; if (0 == (1&(vaxc$errno = sys$crembx(0, &child_chan, mbxsize, mbxsize, 0, 0, 0)))) { errno = EVMSERR; perror("Can't create pipe mailbox"); exit(EXIT_ERR); } if (1 == (1&(vaxc$errno = sys$getdviw(0, child_chan, 0, &itmlst, iosb, 0, 0, 0)))) vaxc$errno = iosb[0]; if (0 == (1&vaxc$errno)) { errno = EVMSERR; perror("Can't get pipe mailbox device name"); exit(EXIT_ERR); } mbxname[mbxdsc.dsc$w_length] = '\0'; #ifdef DEBUG fprintf(stderr, "Pipe Mailbox Name = '%s'\n", mbxname); #endif if (0 == (1&(vaxc$errno = lib$spawn(&cmddsc, &mbxdsc, 0, &1, 0, &pid, child_st, &ef, sig_child, &child_chan)))) { errno = EVMSERR; perror("Can't spawn subprocess"); exit(EXIT_ERR); } #ifdef DEBUG fprintf(stderr, "Subprocess's Pid = %08X\n", pid); #endif sys$dclexh(&exit_block); return(mbxname); } background_process(argc, argv) int argc; char **argv; { char command[2048] = "$"; $DESCRIPTOR(value, command); $DESCRIPTOR(cmd, "BACKGROUND$COMMAND"); $DESCRIPTOR(null, "NLA0:"); int pid; strcat(command, argv[0]); while (--argc) { strcat(command, " \""); strcat(command, *(++argv)); strcat(command, "\""); } value.dsc$w_length = strlen(command); if (0 == (1&(vaxc$errno = lib$set_symbol(&cmd, &value)))) { errno = EVMSERR; perror("Can't create symbol for subprocess command"); exit(EXIT_ERR); } if (0 == (1&(vaxc$errno = lib$spawn(&cmd, &null, 0, &17, 0, &pid)))) { errno = EVMSERR; perror("Can't spawn subprocess"); exit(EXIT_ERR); } #ifdef DEBUG fprintf(stderr, "%s\n", command); #endif fprintf(stderr, "%08X\n", pid); return(EXIT_OK); } /* got this off net.sources */ #ifdef VMS #define index strchr #endif /*VMS*/ /* * get option letter from argument vector */ int opterr = 1, /* useless, never set or used */ optind = 1, /* index into parent argv vector */ optopt; /* character checked for validity */ char *optarg; /* argument associated with option */ #define BADCH (int)'?' #define EMSG "" #define tell(s) fputs(progname,stderr);fputs(s,stderr); \ fputc(optopt,stderr);fputc('\n',stderr);return(BADCH); getopt(nargc,nargv,ostr) int nargc; char **nargv, *ostr; { static char *place = EMSG; /* option letter processing */ register char *oli; /* option letter list index */ char *index(); char *progname; if(!*place) { /* update scanning pointer */ if(optind >= nargc || *(place = nargv[optind]) != '-' || !*++place) return(EOF); if (*place == '-') { /* found "--" */ ++optind; return(EOF); } } /* option letter okay? */ if ((optopt = (int)*place++) == (int)':' || !(oli = index(ostr,optopt))) { if(!*place) ++optind; #ifdef VMS progname = strrchr(nargv[0],']'); #else progname = rindex(nargv[0],'/'); #endif if (!progname) progname = nargv[0]; else progname++; tell(": illegal option -- "); } if (*++oli != ':') { /* don't need argument */ optarg = NULL; if (!*place) ++optind; } else { /* need an argument */ if (*place) optarg = place; /* no white space */ else if (nargc <= ++optind) { /* no arg */ place = EMSG; #ifdef VMS progname = strrchr(nargv[0],']'); #else progname = rindex(nargv[0],'/'); #endif if (!progname) progname = nargv[0]; else progname++; tell(": option requires an argument -- "); } else optarg = nargv[optind]; /* white space */ place = EMSG; ++optind; } return(optopt); /* dump back option letter */ } ��������������������������������������������������������netpbm-free-10.0-1/pbm/libpm.c����������������������������������������������������������������������0100644�0047145�0047145�00000060755�07776237374�016407� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/************************************************************************** libpm.c *************************************************************************** This is the most fundamental Netpbm library. It contains routines not specific to any particular Netpbm format. Some of the subroutines in this library are intended and documented for use by Netpbm users, but most of them are just used by other Netpbm library subroutines. Before May 2001, this function was served by the libpbm library (in addition to being the library for handling the PBM format). **************************************************************************/ #include #include #include "version.h" #include "compile.h" #include "shhopt.h" #include "pm.h" #include #include #include /* The following are set by pm_init(), then used by subsequent calls to other pm_xxx() functions. */ static const char* pm_progname; static bool pm_showmessages; /* Programs should display informational messages (because the user didn't specify the --quiet option). */ void pm_usage( const char usage[] ) { fprintf( stderr, "usage: %s %s\n", pm_progname, usage ); exit( 1 ); } void pm_perror(const char reason[] ) { const char* e; #ifdef A_STRERROR e = strerror(errno); #else /* A_STRERROR */ e = sys_errlist[errno]; #endif /* A_STRERROR */ if ( reason != 0 && reason[0] != '\0' ) pm_error( "%s - %s", reason, e ); else pm_error( "%s", e ); } void GNU_PRINTF_ATTR pm_message(const char format[], ... ) { va_list args; va_start( args, format ); if ( pm_showmessages ) { fprintf( stderr, "%s: ", pm_progname ); (void) vfprintf( stderr, format, args ); fputc( '\n', stderr ); } va_end( args ); } void GNU_PRINTF_ATTR pm_error(const char format[], ... ) { va_list args; va_start( args, format ); fprintf( stderr, "%s: ", pm_progname ); (void) vfprintf( stderr, format, args ); fputc( '\n', stderr ); va_end( args ); exit( 1 ); } /* Variable-sized arrays. */ char* pm_allocrow(int const cols, int const size) { register char* itrow; itrow = (char*) malloc2( cols , size ); if ( itrow == (char*) 0 ) pm_error( "out of memory allocating a row" ); return itrow; } void pm_freerow(char * const itrow) { free( itrow ); } #ifndef A_FRAGARRAY char** pm_allocarray(int const cols, int const rows, int const size ) { char** its; int i; its = (char**) malloc2( rows, sizeof(char*) ); if ( its == (char**) 0 ) pm_error( "out of memory allocating an array" ); its[0] = (char*) malloc3( rows, cols, size ); if ( its[0] == (char*) 0 ) pm_error( "out of memory allocating an array" ); for ( i = 1; i < rows; ++i ) its[i] = &(its[0][i * cols * size]); return its; } void pm_freearray(char ** const its, int const rows) { free( its[0] ); free( its ); } #else /* A_FRAGARRAY */ char** pm_allocarray(int const cols, int const rows, int const size) { char** its; int i; overflow_add(rows, 1); its = (char**) malloc2( (rows + 1), sizeof(char*) ); if ( its == (char**) 0 ) pm_error( "out of memory allocating an array" ); its[rows] = its[0] = (char*) malloc3( rows. cols, size ); if ( its[0] != (char*) 0 ) for ( i = 1; i < rows; ++i ) its[i] = &(its[0][i * cols * size]); else for( i = 0; i < rows; ++i ) its[i] = pm_allocrow( cols, size ); return its; } void pm_freearray(char ** const its, int const rows) { int i; if( its[rows] != (char*) 0 ) free( its[rows] ); else for( i = 0; i < rows; ++i ) pm_freerow( its[i] ); free( its ); } #endif /* A_FRAGARRAY */ /* Case-insensitive keyword matcher. */ int pm_keymatch(char * const strarg, char * const keywordarg, int const minchars) { register int len; char *str, *keyword; str = strarg; keyword = keywordarg; len = strlen( str ); if ( len < minchars ) return 0; while ( --len >= 0 ) { register char c1, c2; c1 = *str++; c2 = *keyword++; if ( c2 == '\0' ) return 0; if ( isupper( c1 ) ) c1 = tolower( c1 ); if ( isupper( c2 ) ) c2 = tolower( c2 ); if ( c1 != c2 ) return 0; } return 1; } /* Log base two hacks. */ int pm_maxvaltobits(int const maxval) { if ( maxval <= 1 ) return 1; else if ( maxval <= 3 ) return 2; else if ( maxval <= 7 ) return 3; else if ( maxval <= 15 ) return 4; else if ( maxval <= 31 ) return 5; else if ( maxval <= 63 ) return 6; else if ( maxval <= 127 ) return 7; else if ( maxval <= 255 ) return 8; else if ( maxval <= 511 ) return 9; else if ( maxval <= 1023 ) return 10; else if ( maxval <= 2047 ) return 11; else if ( maxval <= 4095 ) return 12; else if ( maxval <= 8191 ) return 13; else if ( maxval <= 16383 ) return 14; else if ( maxval <= 32767 ) return 15; else if ( (long) maxval <= 65535L ) return 16; else pm_error( "maxval of %d is too large!", maxval ); return -1; /* Should never come here */ } int pm_bitstomaxval(int const bits) { return ( 1 << bits ) - 1; } unsigned int pm_lcm(const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int limit) { /*---------------------------------------------------------------------------- Compute the least common multiple of x, y, and z. If it's bigger than 'limit', though, just return 'limit'. -----------------------------------------------------------------------------*/ unsigned int biggest; unsigned int candidate; if (x == 0 || y == 0 || z == 0) pm_error("pm_lcm(): Least common multiple of zero taken."); biggest = max(x, max(y,z)); candidate = biggest; while (((candidate % x) != 0 || /* not a multiple of x */ (candidate % y) != 0 || /* not a multiple of y */ (candidate % z) != 0 ) && /* not a multiple of z */ candidate <= limit) candidate += biggest; if (candidate > limit) candidate = limit; return candidate; } /* Initialization. */ #ifdef VMS static const char * vmsProgname(int * const argcP, char * argv[]) { char **temp_argv = argv; int old_argc = *argcP; int i; const char * retval; getredirection( argcP, &temp_argv ); if (*argcP > old_argc) { /* Number of command line arguments has increased */ fprintf( stderr, "Sorry!! getredirection() for VMS has " "changed the argument list!!!\n"); fprintf( stderr, "This is intolerable at the present time, " "so we must stop!!!\n"); exit(1); } for (i=0; i<*argcP; i++) argv[i] = temp_argv[i]; retval = strrchr( argv[0], '/'); if ( retval == NULL ) retval = rindex( argv[0], ']'); if ( retval == NULL ) retval = rindex( argv[0], '>'); return retval; } #endif void pm_init(const char * const progname, unsigned int const flags) { /*---------------------------------------------------------------------------- Initialize static variables that Netpbm library routines use. Any user of Netpbm library routines is expected to call this at the beginning of this program, before any other Netpbm library routines. A program may call this via pm_proginit() instead, though. -----------------------------------------------------------------------------*/ pm_setMessage(FALSE, NULL); pm_progname = progname; #ifdef O_BINARY #ifdef HAVE_SETMODE /* Set the stdin and stdout mode to binary. This means nothing on Unix, but matters on Windows. Note that stdin and stdout aren't necessarily image files. In particular, stdout is sometimes text for human consumption, typically printed on the terminal. Binary mode isn't really appropriate for that case. We do this setting here without any knowledge of how stdin and stdout are being used because it is easy. But we do make an exception for the case that we know the file is a terminal, to get a little closer to doing the right thing. */ if (!isatty(0)) setmode(0,O_BINARY); /* Standard Input */ if (!isatty(1)) setmode(1,O_BINARY); /* Standard Output */ #endif /* HAVE_SETMODE */ #endif /* O_BINARY */ } static void showVersion(void) { pm_message( "Using libpbm from Netpbm Version: %s", NETPBM_VERSION ); #if defined(COMPILE_TIME) && defined(COMPILED_BY) pm_message( "Compiled %s by user \"%s\"", COMPILE_TIME, COMPILED_BY ); #endif #ifdef BSD pm_message( "BSD defined" ); #endif /*BSD*/ #ifdef SYSV #ifdef VMS pm_message( "VMS & SYSV defined" ); #else pm_message( "SYSV defined" ); #endif #endif /*SYSV*/ #ifdef MSDOS pm_message( "MSDOS defined" ); #endif /*MSDOS*/ #ifdef AMIGA pm_message( "AMIGA defined" ); #endif /* AMIGA */ { const char * rgbdef; pm_message( "RGB_ENV='%s'", RGBENV ); rgbdef = getenv(RGBENV); if( rgbdef ) pm_message( "RGBENV= '%s' (env vbl set to '%s')", RGBENV, rgbdef ); else pm_message( "RGBENV= '%s' (env vbl is unset)", RGBENV); } } static void showNetpbmHelp(const char progname[]) { /*---------------------------------------------------------------------------- Tell the user where to get help for this program, assuming it is a Netpbm program (a program that comes with the Netpbm package, as opposed to a program that just uses the Netpbm libraries). As we are in debian, everything is in the manpages or /usr/share/ -----------------------------------------------------------------------------*/ pm_message("For more help see man %s or" "the files in /usr/share/doc/netpbm*", progname); } void pm_proginit(int * const argcP, char * argv[]) { /*---------------------------------------------------------------------------- Do various initialization things that all programs in the Netpbm package, and programs that emulate such programs, should do. This includes processing global options. This includes calling pm_init() to initialize the Netpbm libraries. -----------------------------------------------------------------------------*/ int argn, i; const char * progname; bool showmessages; bool show_version; /* We're supposed to just show the version information, then exit the program. */ bool show_help; /* We're supposed to just tell user where to get help, then exit the program. */ /* Extract program name. */ #ifdef VMS progname = vmsProgname(argcP, argv); #else progname = strrchr( argv[0], '/'); #endif if (progname == NULL) progname = argv[0]; else ++progname; pm_init(progname, 0); /* Check for any global args. */ showmessages = TRUE; show_version = FALSE; show_help = FALSE; for (argn = 1; argn < *argcP; ++argn) { if (pm_keymatch(argv[argn], "-quiet", 6) || pm_keymatch(argv[argn], "--quiet", 7)) showmessages = FALSE; else if (pm_keymatch(argv[argn], "-version", 8) || pm_keymatch(argv[argn], "--version", 9)) show_version = TRUE; else if (pm_keymatch(argv[argn], "-help", 5) || pm_keymatch(argv[argn], "--help", 6) || pm_keymatch(argv[argn], "-?", 2)) show_help = TRUE; else continue; for (i = argn + 1; i <= *argcP; ++i) argv[i - 1] = argv[i]; --(*argcP); } pm_setMessage((unsigned int) showmessages, NULL); if (show_version) { showVersion(); exit( 0 ); } else if (show_help) { pm_error("Use 'man %s' for help.", progname); /* If we can figure out a way to distinguish Netpbm programs from other programs using the Netpbm libraries, we can do better here. */ if (0) showNetpbmHelp(progname); exit(0); } } void pm_setMessage(int const newState, int * const oldStateP) { if (oldStateP) *oldStateP = pm_showmessages; pm_showmessages = !!newState; } char * pm_arg0toprogname(const char arg0[]) { /*---------------------------------------------------------------------------- Given a value for argv[0] (a command name or file name passed to a program in the standard C calling sequence), return the name of the Netpbm program to which is refers. In the most ordinary case, this is simply the argument itself. But if the argument contains a slash, it is the part of the argument after the last slash, and if there is a .exe on it (as there is for DJGPP), that is removed. The return value is in static storage within. It is null-terminated, but truncated at 64 characters. -----------------------------------------------------------------------------*/ static char retval[64+1]; char *slash_pos; /* Chop any directories off the left end */ slash_pos = strrchr(arg0, '/'); if (slash_pos == NULL) { strncpy(retval, arg0, sizeof(retval)); retval[sizeof(retval)-1] = '\0'; } else { strncpy(retval, slash_pos +1, sizeof(retval)); retval[sizeof(retval)-1] = '\0'; } /* Chop any .exe off the right end */ if (strlen(retval) >= 4 && strcmp(retval+strlen(retval)-4, ".exe") == 0) retval[strlen(retval)-4] = 0; return(retval); } /* File open/close that handles "-" as stdin/stdout and checks errors. */ FILE* pm_openr(const char * const name) { FILE* f; if (strcmp(name, "-") == 0) f = stdin; else { #ifndef VMS f = fopen(name, "rb"); #else f = fopen (name, "r", "ctx=stm"); #endif if (f == NULL) { pm_perror(name); exit(1); } } return f; } FILE* pm_openw(const char * const name) { FILE* f; if (strcmp(name, "-") == 0) f = stdout; else { #ifndef VMS f = fopen(name, "wb"); #else f = fopen (name, "w", "mbc=32", "mbf=2"); /* set buffer factors */ #endif if (f == NULL) { pm_perror(name); exit(1); } } return f; } FILE * pm_openr_seekable(const char name[]) { /*---------------------------------------------------------------------------- Open the file named by name[] such that it is seekable (i.e. it can be rewound and read in multiple passes with fseek()). If the file is actually seekable, this reduces to the same as pm_openr(). If not, we copy the named file to a temporary file and return that file's stream descriptor. We use a file that the operating system recognizes as temporary, so it picks the filename and deletes the file when we close it. -----------------------------------------------------------------------------*/ int stat_rc; int seekable; /* logical: file is seekable */ struct stat statbuf; FILE * original_file; FILE * seekable_file; original_file = pm_openr((char *) name); /* I would use fseek() to determine if the file is seekable and be a little more general than checking the type of file, but I don't have reliable information on how to do that. I have seen streams be partially seekable -- you can, for example seek to 0 if the file is positioned at 0 but you can't actually back up to 0. I have seen documentation that says the errno for an unseekable stream is EBADF and in practice seen ESPIPE. On the other hand, regular files are always seekable and even if some other file is, it doesn't hurt much to assume it isn't. */ stat_rc = fstat(fileno(original_file), &statbuf); if (stat_rc == 0 && S_ISREG(statbuf.st_mode)) seekable = TRUE; else seekable = FALSE; if (seekable) { seekable_file = original_file; } else { seekable_file = tmpfile(); /* Copy the input into the temporary seekable file */ while (!feof(original_file) && !ferror(original_file) && !ferror(seekable_file)) { char buffer[4096]; int bytes_read; bytes_read = fread(buffer, 1, sizeof(buffer), original_file); fwrite(buffer, 1, bytes_read, seekable_file); } if (ferror(original_file)) pm_error("Error reading input file into temporary file. " "Errno = %s (%d)", strerror(errno), errno); if (ferror(seekable_file)) pm_error("Error writing input into temporary file. " "Errno = %s (%d)", strerror(errno), errno); pm_close(original_file); { int seek_rc; seek_rc = fseek(seekable_file, 0, SEEK_SET); if (seek_rc != 0) pm_error("fseek() failed to rewind temporary file. " "Errno = %s (%d)", strerror(errno), errno); } } return seekable_file; } void pm_close(FILE * const f) { fflush( f ); if ( ferror( f ) ) pm_message( "a file read or write error occurred at some point" ); if ( f != stdin ) if ( fclose( f ) != 0 ) pm_perror( "fclose" ); } /* The pnmtopng package uses pm_closer() and pm_closew() instead of pm_close(), apparently because the 1999 Pbmplus package has them. I don't know what the difference is supposed to be. */ void pm_closer(FILE * const f) { pm_close(f); } void pm_closew(FILE * const f) { pm_close(f); } /* Endian I/O. */ int pm_readbigshort(FILE * const in, short * const sP) { int c; if ( (c = getc( in )) == EOF ) return -1; *sP = ( c & 0xff ) << 8; if ( (c = getc( in )) == EOF ) return -1; *sP |= c & 0xff; return 0; } int pm_writebigshort(FILE* const out, short const s) { (void) putc( ( s >> 8 ) & 0xff, out ); (void) putc( s & 0xff, out ); return 0; } int pm_readbiglong(FILE * const in, long * const lP) { int c; if ( (c = getc( in )) == EOF ) return -1; *lP = ( c & 0xff ) << 24; if ( (c = getc( in )) == EOF ) return -1; *lP |= ( c & 0xff ) << 16; if ( (c = getc( in )) == EOF ) return -1; *lP |= ( c & 0xff ) << 8; if ( (c = getc( in )) == EOF ) return -1; *lP |= c & 0xff; return 0; } int pm_writebiglong(FILE * const out, long const l) { (void) putc( ( l >> 24 ) & 0xff, out ); (void) putc( ( l >> 16 ) & 0xff, out ); (void) putc( ( l >> 8 ) & 0xff, out ); (void) putc( l & 0xff, out ); return 0; } int pm_readlittleshort(FILE * const in, short * const sP) { int c; if ( (c = getc( in )) == EOF ) return -1; *sP = c & 0xff; if ( (c = getc( in )) == EOF ) return -1; *sP |= ( c & 0xff ) << 8; return 0; } int pm_writelittleshort(FILE* const out, short const s) { (void) putc( s & 0xff, out ); (void) putc( ( s >> 8 ) & 0xff, out ); return 0; } int pm_readlittlelong(FILE * const in, long * const lP) { int c; if ( (c = getc( in )) == EOF ) return -1; *lP = c & 0xff; if ( (c = getc( in )) == EOF ) return -1; *lP |= ( c & 0xff ) << 8; if ( (c = getc( in )) == EOF ) return -1; *lP |= ( c & 0xff ) << 16; if ( (c = getc( in )) == EOF ) return -1; *lP |= ( c & 0xff ) << 24; return 0; } int pm_writelittlelong(FILE * const out, long const l) { (void) putc( l & 0xff, out ); (void) putc( ( l >> 8 ) & 0xff, out ); (void) putc( ( l >> 16 ) & 0xff, out ); (void) putc( ( l >> 24 ) & 0xff, out ); return 0; } /* Read a file of unknown size to a buffer. Return the number of bytes read. Allocate more memory as we need it. The calling routine has to free() the buffer. Oliver Trepte, oliver@fysik4.kth.se, 930613 */ #define PM_BUF_SIZE 16384 /* First try this size of the buffer, then double this until we reach PM_MAX_BUF_INC */ #define PM_MAX_BUF_INC 65536 /* Don't allocate more memory in larger blocks than this. */ char *pm_read_unknown_size(FILE * const file, long * const nread) { long nalloc; register int val; char* buf; *nread = 0; if ((buf=malloc(PM_BUF_SIZE)) == NULL) pm_error("Cannot allocate memory"); nalloc = PM_BUF_SIZE; while(1) { if (*nread >= nalloc) { /* We need a larger buffer */ if (nalloc > PM_MAX_BUF_INC) nalloc += PM_MAX_BUF_INC; else nalloc += nalloc; if ((buf=realloc(buf, nalloc)) == NULL) pm_error("Cannot allocate %ld bytes of memory", nalloc); } if ((val = getc(file)) == EOF) return (buf); buf[(*nread)++] = val; } } unsigned int pm_tell(FILE * const fileP) { /*---------------------------------------------------------------------------- Return the current file position. Abort the program if error, including if *fileP isn't a file that has a position. -----------------------------------------------------------------------------*/ long const rc = ftell(fileP); if (rc < 0) pm_error("ftell() to get current file position failed. " "Errno = %s (%d)\n", strerror(errno), errno); return rc; } void pm_seek(FILE * const fileP, unsigned long filepos) { /*---------------------------------------------------------------------------- Position file *fileP to position 'filepos'. Abort if error, including if *fileP isn't a seekable file. -----------------------------------------------------------------------------*/ fseek(fileP, filepos, SEEK_SET); } void pm_nextimage(FILE * const file, int * const eofP) { int c; c = getc(file); if (c == EOF) { if (feof(file)) *eofP = TRUE; else pm_error("File error on getc() to position to image"); } else { int rc; *eofP = FALSE; rc = ungetc(c, file); if (rc == EOF) pm_error("File error doing ungetc() to position to image."); } } void pm_check(FILE * const file, const enum pm_check_type check_type, const unsigned int need_raster_size, enum pm_check_code * const retval_p) { struct stat statbuf; int curpos; /* Current position of file; -1 if none */ int rc; curpos = ftell(file); if (curpos >= 0) { /* This type of file has a current position */ rc = fstat(fileno(file), &statbuf); if (rc != 0) pm_error("fstat() failed to get size of file, though ftell() " "successfully identified\n" "the current position. Errno=%s (%d)", strerror(errno), errno); else if (!S_ISREG(statbuf.st_mode)) { /* Not a regular file; we can't know its size */ if (retval_p) *retval_p = PM_CHECK_UNCHECKABLE; } else { const unsigned int have_raster_size = statbuf.st_size - curpos; if (have_raster_size < need_raster_size) pm_error("File has invalid format. The raster should " "contain %d bytes, but\n" "the file ends after only %d bytes.", need_raster_size, have_raster_size); else if (have_raster_size > need_raster_size) { if (retval_p) *retval_p = PM_CHECK_TOO_LONG; } else { if (retval_p) *retval_p = PM_CHECK_OK; } } } else if (retval_p) *retval_p = PM_CHECK_UNCHECKABLE; } /* * Maths wrapping */ void overflow2(int a, int b) { if(a < 0 || b < 0) pm_error("object too large"); if(b == 0) return; if(a > INT_MAX / b) pm_error("object too large"); } void overflow3(int a, int b, int c) { overflow2(a,b); overflow2(a*b, c); } void overflow_add(int a, int b) { if( a > INT_MAX - b) pm_error("object too large"); } void *malloc2(int a, int b) { overflow2(a, b); if(a*b == 0) pm_error("Zero byte allocation"); return malloc(a*b); } void *malloc3(int a, int b, int c) { overflow3(a, b, c); if(a*b*c == 0) pm_error("Zero byte allocation"); return malloc(a*b*c); } void *realloc2(void * a, int b, int c) { overflow2(b, c); if(b*c == 0) pm_error("Zero byte allocation"); return realloc(a, b*c); } �������������������netpbm-free-10.0-1/pbm/macp.h�����������������������������������������������������������������������0100644�0047145�0047145�00000000331�07716230207�016167� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* macp.h - header file for MacPaint files */ #ifndef _MACP_H_ #define _MACP_H_ #define HEADER_LENGTH 512 #define MAX_LINES 720 #define BYTES_WIDE 72 #define MAX_COLS 576 /* = BYTES_WIDE * 8 */ #endif /*_MACP_H_*/ �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/macptopbm.1������������������������������������������������������������������0100644�0047145�0047145�00000003364�07716230207�017153� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������.TH macptopbm 1 "29 March 1989" .IX macptopbm .SH NAME macptopbm - convert a MacPaint file into a portable bitmap .SH SYNOPSIS .B macptopbm .RB [ -extraskip .IR N ] .RI [ macpfile ] .SH DESCRIPTION Reads a MacPaint file as input. .IX MacPaint .IX Macintosh Produces a portable bitmap as output. .SH OPTIONS .TP .B -extraskip This flag is to get around a problem with some methods of transferring files from the Mac world to the Unix world. Most of these methods leave the Mac files alone, but a few of them add the "finderinfo" data onto the front of the Unix file. This means an extra 128 bytes to skip over when reading the file. The symptom to watch for is that the resulting PBM file looks shifted to one side. If you get this, try .B -extraskip 128, and if that still doesn't look right try another value. .PP All flags can be abbreviated to their shortest unique prefix. .SH "SEE ALSO" picttoppm(1), pbmtomacp(1), pbm(5) .SH AUTHOR Copyright (C) 1988 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. The MacPaint-reading code is copyright (c) 1987 by Patrick J. Naughton (naughton@wind.sun.com). .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, .\" provided that the above copyright notice appear in all copies and that .\" both that copyright notice and this permission notice appear in .\" supporting documentation. ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/macptopbm.c������������������������������������������������������������������0100644�0047145�0047145�00000006613�07716230207�017235� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* macptopbm.c - read a MacPaint file and produce a portable bitmap ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #include "macp.h" static void ReadMacPaintFile ARGS(( FILE* file, int extraskip, int* scanLineP, unsigned char Pic[MAX_LINES][BYTES_WIDE] )); static unsigned char Pic[MAX_LINES][BYTES_WIDE]; int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; int argn, extraskip, scanLine, rows, cols, row, bcol, i; char* usage = "[-extraskip N] [macpfile]"; pbm_init( &argc, argv ); argn = 1; extraskip = 0; /* Check for flags. */ if ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( pm_keymatch( argv[argn], "-extraskip", 2 ) ) { argn++; if ( argn == argc || sscanf( argv[argn], "%d", &extraskip ) != 1 ) pm_usage( usage ); } else pm_usage( usage ); argn++; } if ( argn < argc ) { ifp = pm_openr( argv[argn] ); argn++; } else ifp = stdin; if ( argn != argc ) pm_usage( usage ); ReadMacPaintFile( ifp, extraskip, &scanLine, Pic ); pm_close( ifp ); cols = BYTES_WIDE * 8; rows = scanLine; pbm_writepbminit( stdout, cols, rows, 0 ); bitrow = pbm_allocrow( cols ); for ( row = 0; row < rows; row++ ) { for ( bcol = 0; bcol < BYTES_WIDE; bcol++ ) for ( i = 0; i < 8; i++ ) bitrow[bcol * 8 + i] = ( (Pic[row][bcol] >> (7 - i)) & 1 ) ? PBM_BLACK : PBM_WHITE; pbm_writepbmrow( stdout, bitrow, cols, 0 ); } pm_close( stdout ); exit( 0 ); } /* ** Some of the following routine is: ** ** Copyright 1987 by Patrick J. Naughton ** All Rights Reserved ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, ** provided that the above copyright notice appear in all copies and that ** both that copyright notice and this permission notice appear in ** supporting documentation. */ static void ReadMacPaintFile( file, extraskip, scanLineP, Pic ) FILE* file; int extraskip; int* scanLineP; unsigned char Pic[MAX_LINES][BYTES_WIDE]; { unsigned int i, j, k; unsigned char ch; /* Skip over the header. */ for ( i = 0; i < extraskip; i++ ) getc( file ); for ( i = 0; i < HEADER_LENGTH; i++ ) getc( file ); *scanLineP = 0; k = 0; while ( *scanLineP < MAX_LINES ) { ch = (unsigned char) getc( file ); /* Count byte */ i = (unsigned int) ch; if ( ch < 0x80 ) { /* Unpack next (I+1) chars as is */ for ( j = 0; j <= i; j++ ) if ( *scanLineP < MAX_LINES ) { Pic[*scanLineP][k++] = (unsigned char) getc( file ); if ( ! (k %= BYTES_WIDE) ) *scanLineP += 1; } } else { /* Repeat next char (2's comp I) times */ ch = getc( file ); for ( j = 0; j <= 256 - i; j++ ) if ( *scanLineP < MAX_LINES ) { Pic[*scanLineP][k++] = (unsigned char) ch; if ( ! (k %= BYTES_WIDE) ) *scanLineP += 1; } } } } ���������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/mdaspec.txt������������������������������������������������������������������0100644�0047145�0047145�00000025116�07716230207�017263� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� MicroDesign 3 page (.MDP) and area (.MDA) file specifications This publication and all information contained herein is Copyright Creative Technology 1992. This information carries no guarantees of accuracy or liabilities on the part of either Creative Technology or myself. A hard copy of this document (with far better artwork) is available from Creative Technology, 10 Park Street, Uttoxeter, Staffs ST14 7AG, creative@net-shopper.co.uk. [Note: throughout this file hexadecimal numbers are represented as #nn; 'one pixel' refers to one PCW screen pixel, ie. a MicroDesign half-pixel; 'word' format indicates a 16-bit word stored with the LSBs first] The MDA (MicroDesign Area) file formats There are two different MDA file formats. The earlier MicroDesign2 format uses a simple compression technique to reduce continuous areas of white and black, while the more recent MicroDesign3 format uses a more sophisticated technique which generally results in smaller disc files. MicroDesign2, ProSCAN and Tweak (versions 1 and 2) can only load and save the earlier format, but either format may be loaded or saved in MicroDesign3. In MD3, the filetype is detected automatically on load, but the user must choose whether to save in 'AREA2' or 'AREA3' format. The format is identified in byte 21 of the initial file 'stamp' record - for a MicroDesign2 area this byte is "0" (#30), whereas for a MicroDesign3 area it is "3" (#33). When loaded into memory and uncompressed an Area file can occupy up the 720k of data, but its size on disc is indeterminate due to the compression used. Because of the compression it is not possible to perform 'random-access' reads or writes to the disc file - it must be read sequentially in order correctly to decompress the data. The older MicroDesign2 Area file format is as follows: Bytes 0..127: file 'stamp': 0 - 3 (#00 - #03) .MDA File Type (4 bytes) 4 - 17 (#04 - #11) MicroDesignPCW Program Identifier (14 bytes) 18 - 22 (#12 - #16) v1.00 File Version (5 bytes) 23 - 24 (#17 - #18) CR,LF ie. 13,10 decimal (2 bytes) 25 - 31 (#19 - #1F) xxxxxxx User Serial No (ASCII) (7 bytes) 32 - 33 (#20 - #21) CR,LF ie. 13,10 decimal (2 bytes) 34 - 127 (#22 - #7F) fill with zeroes (#00) (94 bytes) Bytes 128..: file proper: 128 - 129 (#80 - #81) Height in Lines (multiple of 4) (word) 130 - 131 (#82 - #83) Width in Bytes (Pixels * 8) (word) 132 - (#84 - ) Bit-Image Data as follows... Bytes read from left to right in lines, top line first. Each byte is standard 1-bit-per-pixel layout where MSB = LH pixel, LSB = RH pixel, 1 = white ('on'), and 0 = black ('off'). Each #00 (all black) or #FF (all white) byte is followed by a 'count' byte (ie. #00 #03 means 3 whole bytes width of solid black; #FF #A0 means 160 bytes width of solid white). A value #00 for the count byte means 256. This 'count' can overrun into the next (several) lines. For example: (. represents black, # white) ....#### ##..##.. ####.... ........ ..###### ######## ######## 0F CC F0 00,01 3F FF,02 ####.... ........ ........ ........ ........ ........ ........ F0 00,06 Because of this compression the file length is indeterminate, but there must be HEIGHT * WIDTH bytes of actual image data by the time it has been uncompressed. The newer MicroDesign3 Area file format is as follows: Bytes 0..127: file 'stamp': 0 - 3 (#00 - #03) .MDA File Type (4 bytes) 4 - 17 (#04 - #11) MicroDesignPCW Program Identifier (14 bytes) 18 - 22 (#12 - #16) v1.30 File Version (5 bytes) 23 - 24 (#17 - #18) CR,LF ie. 13,10 decimal (2 bytes) 25 - 31 (#19 - #1F) xxxxxxx User Serial No (ASCII) (7 bytes) 32 - 33 (#20 - #21) CR,LF ie. 13,10 decimal (2 bytes) 34 - 127 (#22 - #7F) fill with zeroes (#00) (94 bytes) Bytes 128..: file proper: 128 - 129 (#80 - #81) Height in Lines (multiple of 4) (word) 130 - 131 (#82 - #83) Width in Bytes (Pixels * 8) (word) 132 - (#84 - ) Bit-Image Data as follows... Bytes read from left to right in lines, top line first. Each byte is standard 1-bit-per-pixel layout where MSB = LH pixel, LSB = RH pixel, 1 = white ('on'), and 0 = black ('off'). Each line of data is compressed according to one of three 'line types'. The first byte of data for each line is the line type. Line type byte: #00: Line is ALL-SAME-BYTE type #01: Line is DATA type #02: Line is DIFFERENCE DATA type The actual data for each line follows this type byte: ALL-SAME-BYTE type: One more byte follows the initial #00 type byte - this is the actual bit-image data with which to fill the whole line width. eg. Whole line of white = #00 #FF, whole line of black = #00 #00 DATA type: Following the initial #01 type byte, the data content of the line is compressed as follows: Data is encoded in 'blocks', which are of *either* repeating data bytes *or* non-repeating bytes. Each block starts with a control byte, which determines whether the data which follows it is *either* just one data byte to be repeated *or* a sequence of dissimilar bytes. If the control byte N is negative (-1 to -127 in two's complement - #FF for -1, #81 for -127), *one* data byte follows which is to be repeated -N times. This means that there are to be a total of (-N+1) occurrences of this data byte. If the control byte N is positive (0 to 127; #00 to #7F), it is followed by (N+1) bytes of dissimilar data to load directly into the line. For instance: 01 (line type), then: ....#### ##..##.. ####.... ........ ######## ######## ######## 03,0F,CC,F0,00 FE,FF #####... #.#.#.#. #.#.#.#. #.#.#.#. #.#.#.#. #.#..... ........ 00,F8 FD,AA 01,A0,00 Note: the POSITIVE control bytes are 1 LESS than the number of dissimilar bytes following them; NEGATIVE ones are (MINUS) 1 LESS than the number of occurrences of the byte following them. DIFFERENCE DATA type: Following the initial #02 type byte, the difference between the data content of this line and the content of the previous line is stored: ie. this line is XORed with the previous line to produce a 'difference' line, which is then compressed using the same method as for a DATA type line. For instance, the following line stored as a 'difference' line from the line above would be 02 (line type), then: (the second pixel row below shows the results of XORing the first two lines) ....#### ##..##.. ##..##.. ......## ######## ######## ######## ........ ........ ..####.. ......## ........ ........ ........ FF,00 01,3C,03 FE,00 ######.. #.#.#.#. #.#.#.#. #.#.#.#. #.#.#.#. #.#.#.#. ........ .....#.. ........ ........ ........ ........ ....#.#. ........ 00,04 FD,00 01,0A,00 Note: this DIFFERENCE encoding is used if it will result in less bytes of data being stored in the file. The line type of the previous line is irrelevant. Because of these various types of compression the file length on the disc is indeterminate, but there must be HEIGHT * WIDTH bytes of actual image data by the time it has been uncompressed. The MDP (MicroDesign Page) file formats MicroDesign3's Page (.MDP) files are identical to its Area (.MDA) files except for the following differences: Bytes 0..127: file 'stamp': 0 - 3 (#00 - #03) .MDP File Type (4 bytes) 34 (#22) nn: dpi 00 = 240dpi 01 = 360dpi 02 = 300dpi 35 (#23) nn: format 00 = A5 portrait 01 = A5 landscape 02 = A4 portrait 03 = A4 landscape 04 = A5 portrait (hi-res) 05 = A5 landscape (hi-res) 36 (#24) nn: page ram required in 16k blocks In all other respects a Page (.MDP) file is identical to an Area (.MDA) file (MD3 type). The CUT image format (Note: this information is in no way 'official' and results from my own dabblings; it is separate from the above information on the MDA format and is included here for convenience. No warranty expressed or implied) CUT files have a format as follows: 0 - 1 (#00 - #01) Height code h1 (word) (see below) 2 - 3 (#02 - #03) Width code w1 (word) (see below) 4 - (#04 - ) Bitmap data, row-by-row The height in pixels h1 can be calculated from the height code h using h = (h1+3)/2; the width in pixels is w = w1+2; the number of whole bytes per row in the file is wb = INT((w+8)/8). Bitmap data in the file is stored row-by-row, with a whole number of bytes per row; the LSBs of the last byte that extend beyond the right edge of the image should be discarded. As usual in bitmap data the MSB is towards the left and the LSB towards the right. Note: the formula above for wb implies that if the image is a whole multiple of 8 pixels wide, none of the bits from the last byte in the row will be used. Strange, but there you go. The GRF image format (Same disclaimer applies; this is all from experiment) GRF files are substantially similar to CUTs (although slightly more logical) and have a format as follows: 0 - 1 (#00 - #01) Width in pixels (word) 2 - 3 (#02 - #03) Height in pixels (word) 4 - (#04 - ) Bitmap data, row-by-row The number of bytes per row is simply the width in pixels divided by 8, rounded up; no catches here. As with CUTs unused rightmost bits should be discarded. _________________________________________________________________ Go to CP/M page or main page Last updated 16 April 1997; Jacob Nevins ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/mdatopbm.1�������������������������������������������������������������������0100644�0047145�0047145�00000001406�07716230207�016767� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������.TH mdatopbm 1 "3 June 1999" .IX mdatopbm .SH NAME mdatopbm - convert a Microdesign .mda or .mdp file into a portable bitmap .SH SYNOPSIS .B mdatopbm .RB [ -a ][ -d ][ -i ][ -- ] .I [ mdafile ] .SH DESCRIPTION Reads a MicroDesign file as input. Reads from stdin if input file is omitted. .IX MicroDesign Produces a portable bitmap as output. .SH OPTIONS .TP .B -a Output the PBM in ASCII rather than binary. .TP .B -d Double the height of the output file, to compensate for the aspect ratio used in MicroDesign files. .TP .B -i Invert the colours used. .TP .B -- End of options (use this if the filename starts with "-") .SH "SEE ALSO" pbmtomda(1), pbm(5) .SH AUTHOR Copyright (C) 1999 John Elliott . .\" Copying policy: GNU GPL version 2 or later ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/mdatopbm.c�������������������������������������������������������������������0100644�0047145�0047145�00000014755�07716230207�017064� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� /*************************************************************************** MDATOPBM: Convert Microdesign area to portable bitmap Copyright (C) 1999 John Elliott This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA See the file mdaspec.txt for a specification of the MDA format. ******************************************************************************/ #include #include #include "pbm.h" /* Simple MDA -> portable bitmap converter */ typedef unsigned char mdbyte; /* Must be exactly one byte */ static FILE *infile; /* Input file */ static mdbyte header[128]; /* MDA file header */ static bit **data; /* PBM image */ static mdbyte *mdrow; /* MDA row after decompression (MD3 only) */ static int bInvert = 0; /* Invert image? */ static int bScale = 0; /* Scale image? */ static int bAscii = 0; /* Ouput ASCII PBM? */ static int nInRows, nInCols; /* Height, width of input (rows x bytes) */ static int nOutCols, nOutRows; /* Height, width of output (rows x bytes) */ static mdbyte getbyte() /* Read a byte from the input stream, */ { /* with error trapping */ int b; b = fgetc(infile); if (b == EOF) pm_error("Unexpected end of MDA file\n"); return (mdbyte)b; } /* Convert a byte to 8 cells in the destination bitmap * * *col = source column * *xp = destination column * *yp = destination row * b = byte to draw * * Will update *col, *xp and *yp to point to the next bit of the row. */ static void render_byte(int *col, int *xp, int *yp, int b) { int mask = 0x80; int n; int y3 = *yp; if (bScale) y3 *= 2; if (y3 >= nOutRows) return; for (n = 0; n < 8; n++) { if (bInvert) data[y3][*xp] = (b & mask) ? PBM_BLACK : PBM_WHITE; else data[y3][*xp] = (b & mask) ? PBM_WHITE : PBM_BLACK; mask = mask >> 1; if (bScale) data[y3+1][*xp] = data[y3][*xp]; ++(*xp); } ++(*col); /* Next byte */ if ((*col) >= nInCols) /* Onto next line? */ { *col = 0; *xp = 0; ++(*yp); } } static void md2_trans() /* Convert a MicroDesign 2 area to PBM */ { /* MD2 has RLE encoding that may go over */ int x1, y1, col; /* multiple lines. */ mdbyte b; int c; x1 = y1 = col = 0; while (y1 < nInRows) { b = getbyte(); if (b == 0 || b == 0xFF) /* RLE sequence */ { c = getbyte(); if (c == 0) c = 256; while (c > 0) { render_byte(&col, &x1, &y1, b); --c; } } else render_byte(&col, &x1, &y1, b); /* Not RLE */ } } static void md3_trans() /* Convert MD3 file. MD3 are encoded as rows, and */ { /* there are three types. */ int x1, y1, col; mdbyte b; int c, d, n; for (y1 = 0; y1 < nInRows; y1++) { b = getbyte(); switch(b) /* Row type */ { case 0: /* All the same byte */ c = getbyte(); for (n = 0; n < nInCols; n++) mdrow[n] = c; break; case 1: /* Encoded data */ case 2: col = 0; /* Encoded as XOR with previous row */ while (col < nInCols) { c = getbyte(); if (c >= 129) /* RLE sequence */ { c = 257 - c; d = getbyte(); for (n = 0; n < c; n++) { if (b == 1) mdrow[col++] = d; else mdrow[col++] ^= d; } } else /* not RLE sequence */ { ++c; for (n = 0; n < c; n++) { d = getbyte(); if (b == 1) mdrow[col++] = d; else mdrow[col++] ^= d; } } /* if c >= 129 */ } /* while col < x */ } /* switch */ /* Row loaded. Convert it. */ x1 = 0; col = 0; for (n = 0; n < nInCols; n++) { d = y1; render_byte(&col, &x1, &d, mdrow[n]); } } /* while (y1 < y) */ } static void usage(char *s) { printf("mdatopbm v1.00, Copyright (C) 1999 John Elliott \n" "This program is redistributable under the terms of the GNU General Public\n" "License, version 2 or later.\n\n" "Usage: %s [ -a ] [ -d ] [ -i ] [ -- ] [ infile ]\n\n" "-a: Output an ASCII pbm file\n" "-d: Double height (to compensate for the PCW aspect ratio)\n" "-i: Invert colours\n" "--: No more options (use if filename begins with a dash)\n", s); exit(0); } int main(int argc, char **argv) { int n, optstop = 0; char *fname = NULL; short yy; pbm_init(&argc, argv); /* Parse options */ for (n = 1; n < argc; n++) { if (argv[n][0] == '-' && !optstop) { if (argv[n][1] == 'a' || argv[n][1] == 'A') bAscii = 1; if (argv[n][1] == 'd' || argv[n][1] == 'D') bScale = 1; if (argv[n][1] == 'i' || argv[n][1] == 'I') bInvert = 1; if (argv[n][1] == 'h' || argv[n][1] == 'H') usage(argv[0]); if (argv[n][1] == '-' && argv[n][2] == 0 && !fname) /* "--" */ { optstop = 1; } if (argv[n][1] == '-' && (argv[n][2] == 'h' || argv[n][2] == 'H')) usage(argv[0]); } else if (argv[n][0] && !fname) /* Filename */ { fname = argv[n]; } } if (fname) infile = pm_openr(fname); else infile = stdin; /* Read MDA file header */ if (fread(header, 1, 128, infile) < 128) { pm_error("Not a .MDA file\n"); exit(1); } if (strncmp((char*) header, ".MDA", 4) && strncmp((char*) header, ".MDP", 4)) { pm_error("Not a .MDA file\n"); exit(1); } pm_readlittleshort(infile, &yy); nInRows = yy; pm_readlittleshort(infile, &yy); nInCols = yy; overflow2(nOutCols, 8); nOutCols = 8*nInCols; nOutRows = nInRows; if (bScale) { overflow2(nOutRows, 2); nOutRows *= 2; } data = pbm_allocarray(nOutCols, nOutRows); mdrow = malloc(nInCols); if (!data || !mdrow) { if (data) pbm_freearray(data, nOutRows); if (mdrow) free(mdrow); pm_error("Not enough memory for conversion.\n"); } if (header[21] == '0') md2_trans(); else md3_trans(); pbm_writepbm(stdout, data, nInCols*8, nOutRows, bAscii); if (infile != stdin) pm_close(infile); fflush(stdout); pbm_freearray(data, nOutRows); free(mdrow); return 0; } �������������������netpbm-free-10.0-1/pbm/mgr.h������������������������������������������������������������������������0100644�0047145�0047145�00000000600�07716230207�016033� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* mgr.h - the following defs are taken from the MGR header file lib/dump.h */ #ifndef _MGR_H_ #define _MGR_H_ struct old_b_header { char magic[2]; char h_wide; char l_wide; char h_high; char l_high; }; struct b_header { char magic[2]; char h_wide; char l_wide; char h_high; char l_high; char depth; char _reserved; }; #endif /*_MGR_H_*/ ��������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/mgrtopbm.1�������������������������������������������������������������������0100644�0047145�0047145�00000001315�07716230207�017012� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������.TH mgrtopbm 1 "24 January 1989" .IX mgrtopbm .SH NAME mgrtopbm - convert a MGR bitmap into a portable bitmap .SH SYNOPSIS .B mgrtopbm .RI [ mgrfile ] .SH DESCRIPTION Reads a MGR bitmap as input. .IX MGR Produces a portable bitmap as output. .SH "SEE ALSO" pbmtomgr(1), pbm(5) .SH AUTHOR Copyright (C) 1989 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/mgrtopbm.c�������������������������������������������������������������������0100644�0047145�0047145�00000007065�07716230207�017104� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* mgrtopbm.c - read a MGR bitmap and produce a portable bitmap ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #include "mgr.h" static void getinit ARGS(( FILE* file, int* colsP, int* rowsP, int* depthP, int* padrightP )); static bit getbit ARGS(( FILE* file )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int rows, cols, depth, padright, row, col; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[mgrfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; getinit( ifp, &cols, &rows, &depth, &padright ); if ( depth != 1 ) pm_error( "MGR file has depth of %d, must be 1", depth ); pbm_writepbminit( stdout, cols, rows, 0 ); bitrow = pbm_allocrow( cols ); for ( row = 0; row < rows; row++ ) { /* Get data, bit-reversed within each byte. */ for ( col = 0, bP = bitrow; col < cols; col++, bP++ ) *bP = getbit( ifp ); /* Discard line padding */ for ( col = 0; col < padright; col ++ ) (void) getbit( ifp ); pbm_writepbmrow( stdout, bitrow, cols, 0 ); } pm_close( ifp ); pm_close( stdout ); exit( 0 ); } static unsigned char item; static int bitsperitem, bitshift; static void getinit( file, colsP, rowsP, depthP, padrightP ) FILE* file; int* colsP; int* rowsP; int* depthP; int* padrightP; { struct b_header head; int pad; if ( fread( &head, sizeof(struct old_b_header), 1, file ) != 1 ) pm_perror( "reading header" ); if ( head.magic[0] == 'y' && head.magic[1] == 'z' ) { /* new style bitmap */ if ( fread( &head.depth, sizeof(head) - sizeof(struct old_b_header), 1, file ) != 1 ) pm_perror( "reading rest of header" ); *depthP = (int) head.depth - ' '; pad = 8; } else if ( head.magic[0] == 'x' && head.magic[1] == 'z' ) { /* old style bitmap with 32-bit padding */ *depthP = 1; pad = 32; } else if ( head.magic[0] == 'z' && head.magic[1] == 'z' ) { /* old style bitmap with 16-bit padding */ *depthP = 1; pad = 16; } else if ( head.magic[0] == 'z' && head.magic[1] == 'y' ) { /* old style 8-bit pixmap with 16-bit padding */ *depthP = 8; pad = 16; } else { pm_error( "bad magic chars in MGR file: '%c%c'", head.magic[0], head.magic[1] ); pad = -1; /* should never reach here */ } if(head.h_wide < ' ' || head.l_wide < ' ') pm_error("bad width/height chars in MGR file"); overflow_add(*colsP, pad); *colsP = ( ( (int) head.h_wide - ' ' ) << 6 ) + ( (int) head.l_wide - ' ' ); *rowsP = ( ( (int) head.h_high - ' ' ) << 6 ) + ( (int) head.l_high - ' ' ); *padrightP = ( ( *colsP + pad - 1 ) / pad ) * pad - *colsP; bitsperitem = 8; } static bit getbit( file ) FILE* file; { bit b; if ( bitsperitem == 8 ) { item = getc( file ); bitsperitem = 0; bitshift = 7; } bitsperitem++; b = ( ( item >> bitshift) & 1 ) ? PBM_BLACK : PBM_WHITE; bitshift--; return b; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/pbm.5������������������������������������������������������������������������0100644�0047145�0047145�00000010720�07716230207�015745� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������.TH pbm 5 "05 March 2000" .SH NAME pbm - portable bitmap file format .SH DESCRIPTION The portable bitmap format is a lowest common denominator monochrome file format. .IX "PBM file format" It serves as the common language of a large family of bitmap conversion filters. Because the format pays no heed to efficiency, it is simple and general enough that one can easily develop programs to convert to and from just about any other graphics format, or to manipulate the image. .PP This is not a format that one would normally use to store a file or to transmit it to someone -- it's too expensive and not expressive enough for that. It's just an intermediary format. In it's purest use, it lives only in a pipe between two other programs. .PP The format definition is as follows. .PP A PBM file consists of a sequence of one or more PBM images. There are no data, delimiters, or padding before, after, or between images. .PP Each PBM image consists of the following: .IP - 2 A "magic number" for identifying the file type. A pbm image's magic number is the two characters "P4". .IX "magic numbers" .IP - 2 Whitespace (blanks, TABs, CRs, LFs). .IP - 2 The width in pixels of the image, formatted as ASCII characters in decimal. .IP - 2 Whitespace. .IP - 2 The height in pixels of the image, again in ASCII decimal. .IP - 2 Newline or other single whitespace character. .IP - 2 A raster of Height rows, in order from top to bottom. Each row is Width bits, packed 8 to a byte, with don't care bits to fill out the last byte in the row. Each bit represents a pixel: 1 is black, 0 is white. The order of the pixels is left to right. The order of their storage within each file byte is most significant bit to least significant bit. The order of the file bytes is from the beginning of the file toward the end of the file. .IP - 2 Characters from a "#" to the next end-of-line, before the width/height line, are comments and are ignored. .PP There is actually another version of the PBM format, even more more simplistic, more lavishly wasteful of space than PBM, called Plain PBM. Plain PBM actually came first, but even its inventor couldn't stand its recklessly squanderous use of resources after a while and switched to what we now know as the regular PBM format. But Plain PBM is so redundant -- so overstated -- that it's virtually impossible to break. You can send it through the most liberal mail system (which was the original purpose of the PBM format) and it will arrive still readable. You can flip a dozen random bits and easily piece back together the original image. And we hardly need to define the format here, because you can decode it by inspection. .PP The difference is: .IP - 2 There is exactly one image in a file. .IP - 2 The "magic number" is "P1" instead of "P4". .IP - 2 Each pixel in the raster is represented by a byte containing ASCII '1' or '0', representing black and white respectively. There are no fill bits at the end of a row. .IP - 2 White space in the raster section is ignored. .IP - 2 You can put any junk you want after the raster, if it starts with a white space character. .IP - 2 No line should be longer than 70 characters. .PP Here is an example of a small bitmap in the plain PBM format: .nf P1 # feep.pbm 24 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .fi .PP You can generate the Plain PBM format from the regular PBM format (first image in the file only) with the .B pnmtoplainpnm program. .PP Programs that read this format should be as lenient as possible, accepting anything that looks remotely like a bitmap. .SH COMPATIBILITY Before July 2000, there could be at most one image in a PBM file. As a result, most tools to process PBM files ignore (and don't read) any data after the first image. .SH "SEE ALSO" .BR libpbm (3), pnm (5), pgm (5), ppm (5) .SH AUTHOR Copyright (C) 1989, 1991 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. ������������������������������������������������netpbm-free-10.0-1/pbm/pbmclean.1�������������������������������������������������������������������0100644�0047145�0047145�00000004200�07721162447�016746� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������.TH pbmclean 1 "18 Oct 2001" .IX pbmclean .SH NAME pbmclean - flip isolated pixels in portable bitmap .SH SYNOPSIS .B pbmclean .RB [ -minneighbors=\fIN\fR ] .RB [ -black | -white ] .RI [ pbmfile ] You can use the minimum unique abbreviation of the options. You can use two hyphens instead of one. You can separate an option name from its value with white space instead of an equals sign. Before December 2001, .B pbmclean accepted .BI - N instead of .BR -minneighbors . .SH DESCRIPTION .B pbmclean cleans up a PBM image of random specs. It reads a PBM image as input and outputs a PBM that is the same as the input except with every pixel which has less than .I N identical neighbours inverted. The default for .I N is 1 - only completely isolated pixels are flipped. (A value of .I N greater than 8 generates a completely inverted image (but use .B pnminvert to do that) -- or a completely white or completely black image with the .B -black or .B -white option). .B pbmclean considers the area beyond the edges of the image to be white. (This matters when you consider pixels right on the edge of the image). You can use .B pbmclean to clean up "snow" on bitmap images. .SH OPTIONS .TP .B -black .TP .B -white Flip pixels of the specified color. By default, if you specify neither .B -black nor .BR -white , .B pbmclean flips both black and white pixels which do not have sufficient identical neighbors. If you specify .BR -black , .B pbmclean leaves the white pixels alone and just erases isolated black pixels. Vice versa for .BR -white . You may specify both .B -black and .B -white to get the same as the default behavior. .SH "SEE ALSO" .BR pbm (5) .SH AUTHOR Copyright (C) 1990 by Angus Duggan Copyright (C) 1989 by Jef Poskanzer. Copyright (C) 2001 by Michael Sternberg. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is" without express or implied warranty. ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/pbmclean.c�������������������������������������������������������������������0100644�0047145�0047145�00000015705�07717167171�017050� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* pbmclean.c - pixel cleaning. Remove pixel if less than n connected * identical neighbours, n=1 default. * AJCD 20/9/90 * stern, Fri Oct 19 00:10:38 MET DST 2001 * add '-white/-black' flags to restrict operation to given blobs */ #include #include "pbm.h" struct cmdlineInfo { /* All the information the user supplied in the command line, in a form easy for the program to use. */ char *inputFilespec; /* Filespecs of input files */ bool flipWhite; bool flipBlack; unsigned int connect; unsigned int verbose; }; #define PBM_INVERT(p) ((p) == PBM_WHITE ? PBM_BLACK : PBM_WHITE) /* input bitmap size and storage */ static bit *inrow[3] ; #define THISROW (1) enum compass_heading { WEST=0, NORTHWEST=1, NORTH=2, NORTHEAST=3, EAST=4, SOUTHEAST=5, SOUTH=6, SOUTHWEST=7 }; /* compass directions from west clockwise. Indexed by enum compass_heading */ int const xd[] = { -1, -1, 0, 1, 1, 1, 0, -1 } ; int const yd[] = { 0, -1, -1, -1, 0, 1, 1, 1 } ; static void parseCommandLine(int argc, char ** argv, struct cmdlineInfo *cmdlineP) { /*---------------------------------------------------------------------------- Note that the file spec array we return is stored in the storage that was passed to us as the argv array. -----------------------------------------------------------------------------*/ optStruct3 opt; /* set by OPTENT3 */ optEntry *option_def = malloc(100*sizeof(optEntry)); unsigned int option_def_index; unsigned int black, white; unsigned int minneighborSpec; option_def_index = 0; /* incremented by OPTENT3 */ OPTENT3(0, "verbose", OPT_FLAG, NULL, &cmdlineP->verbose, 0); OPTENT3(0, "black", OPT_FLAG, NULL, &black, 0); OPTENT3(0, "white", OPT_FLAG, NULL, &white, 0); OPTENT3(0, "minneighbor", OPT_UINT, &cmdlineP->connect, &minneighborSpec, 0); opt.opt_table = option_def; opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */ opt.allowNegNum = TRUE; /* We sort of allow negative numbers as parms */ pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0); /* Uses and sets argc, argv, and some of *cmdlineP and others. */ if (!black && !white) { cmdlineP->flipBlack = TRUE; cmdlineP->flipWhite = TRUE; } else { cmdlineP->flipBlack = !!black; cmdlineP->flipWhite = !!white; } if (!minneighborSpec) { /* Now we do a sleazy tour through the parameters to see if one is -N where N is a positive integer. That's for backward compatibility, since Pbmclean used to have unconventional syntax where a -N option was used instead of the current -minneighbor option. The only reason -N didn't get processed by pm_optParseOptions3() is that it looked like a negative number parameter instead of an option. If we find a -N, we make like it was a -minneighbor=N option. */ int i; bool foundNegative; cmdlineP->connect = 1; /* default */ foundNegative = FALSE; for (i = 1; i < argc; ++i) { if (foundNegative) argv[i-1] = argv[i]; else { if (atoi(argv[i]) < 0) { cmdlineP->connect = - atoi(argv[i]); foundNegative = TRUE; } } } if (foundNegative) --argc; } if (argc-1 < 1) cmdlineP->inputFilespec = "-"; else if (argc-1 == 1) cmdlineP->inputFilespec = argv[1]; else pm_error("You specified too many arguments (%d). The only " "argument is the optional input file specification.", argc-1); } static void nextrow(FILE * const ifd, int const row, int const cols, int const rows, int const format) { /*---------------------------------------------------------------------------- Advance one row in the input. 'row' is the row number that will be the current row. -----------------------------------------------------------------------------*/ bit *shuffle; /* First, get the "next" row in inrow[2] if this is the very first call to nextrow(). */ if (inrow[2] == NULL && row <= rows) { inrow[2] = pbm_allocrow(cols); pbm_readpbmrow(ifd, inrow[2], cols, format); } /* Now advance the inrow[] window, rotating the buffer that now holds the "previous" row to use it for the new "next" row. */ shuffle = inrow[0]; inrow[0] = inrow[1]; inrow[1] = inrow[2]; inrow[2] = shuffle ; if (row+1 < rows) { /* Read the "next" row in from the file. Allocate buffer if neeeded */ if (inrow[2] == NULL) inrow[2] = pbm_allocrow(cols); pbm_readpbmrow(ifd, inrow[2], cols, format); } else { /* There is no next row */ if (inrow[2]) { pbm_freerow(inrow[2]); inrow[2] = NULL; } } } static unsigned int likeNeighbors(bit * const inrow[3], unsigned int const col, unsigned int const cols) { int const point = inrow[THISROW][col]; enum compass_heading heading; int joined; joined = 0; /* initial value */ for (heading = WEST; heading <= SOUTHWEST; ++heading) { int x = col + xd[heading] ; int y = THISROW + yd[heading] ; if (x < 0 || x >= cols || !inrow[y]) { if (point == PBM_WHITE) joined++; } else if (inrow[y][x] == point) joined++ ; } return joined; } int main(int argc, char *argv[]) { struct cmdlineInfo cmdline; FILE *ifp; bit *outrow; int cols, rows, format; unsigned int row; unsigned int nFlipped; /* Number of pixels we have flipped so far */ pbm_init( &argc, argv ); parseCommandLine(argc, argv, &cmdline); ifp = pm_openr(cmdline.inputFilespec); inrow[0] = inrow[1] = inrow[2] = NULL; pbm_readpbminit(ifp, &cols, &rows, &format) ; outrow = pbm_allocrow(cols) ; pbm_writepbminit(stdout, cols, rows, 0) ; nFlipped = 0; /* No pixels flipped yet */ for (row = 0; row < rows; ++row) { int col; nextrow(ifp, row, cols, rows, format); for (col = 0; col < cols; col++) { bit const thispoint = inrow[THISROW][col]; if ((cmdline.flipWhite && thispoint == PBM_WHITE) || (cmdline.flipBlack && thispoint == PBM_BLACK)) { if (likeNeighbors(inrow, col, cols) < cmdline.connect) { outrow[col] = PBM_INVERT(thispoint); ++nFlipped; } else outrow[col] = thispoint; } else outrow[col] = thispoint; } pbm_writepbmrow(stdout, outrow, cols, 0) ; } pbm_freerow(outrow); pm_close(ifp); if (cmdline.verbose) pm_message("%d pixels flipped", nFlipped); exit(0); } �����������������������������������������������������������netpbm-free-10.0-1/pbm/pbmfilters.1�����������������������������������������������������������������0100644�0047145�0047145�00000043521�07776237374�017361� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������.TH pbmfilters 1 "08 February 1994" .IX pbmfilters .SH NAME pbmfilters - list of all programs in the netpbm package .SH DESCRIPTION .TP .B 411toppm convert Sony Mavica .411 image to ppm .TP .B anytopnm attempt to convert an unknown type of image file to a portable anymap .TP .B asciitopgm convert ASCII graphics into a portable graymap .TP .B atktopbm convert Andrew Toolkit raster object to portable bitmap .TP .B bioradtopgm convert a Biorad confocal file into a portable graymap .TP .B bmptopnm convert a BMP file into a portable anymap .TP .B bmptoppm (deprecated) is replaced by bmptopnm(1) .TP .B brushtopbm convert a doodle brush file into a portable bitmap .TP .B cmuwmtopbm convert a CMU window manager bitmap into a portable bitmap .TP .B eyuvtoppm convert a Berkeley YUV file to a portable pixmap file .TP .B fiascotopnm Convert compressed FIASCO image to PGM, or PPM .TP .B fitstopnm convert a FITS file into a portable anymap .TP .B fstopgm convert a Usenix FaceSaver(tm) file into a portable graymap .TP .B g3topbm convert a Group 3 fax file into a portable bitmap .TP .B gemtopbm (deprecated) is replaced by gemtopnm(1) .TP .B gemtopnm convert a GEM .img file into a portable anymap .TP .B giftopnm convert a GIF file into a portable anymap .TP .B gouldtoppm convert Gould scanner file into a portable pixmap .TP .B hipstopgm convert a HIPS file into a portable graymap .TP .B icontopbm convert a Sun icon into a portable bitmap .TP .B ilbmtoppm convert an ILBM file into a portable pixmap .TP .B imgtoppm convert an Img-whatnot file into a portable pixmap .TP .B jpegtopnm convert JPEG/JFIF file to portable pixmap or graymap .TP .B leaftoppm convert Interleaf image format to a portable anymap .TP .B lispmtopgm convert a Lisp Machine bitmap file into pgm format .TP .B macptopbm convert a MacPaint file into a portable bitmap .TP .B mdatopbm convert a Microdesign .mda or .mdp file into a portable bitmap .TP .B mgrtopbm convert a MGR bitmap into a portable bitmap .TP .B mtvtoppm convert output from the MTV or PRT ray tracers into a portable pixmap .TP .B neotoppm convert an Atari Neochrome .neo into a portable pixmap .TP .B palmtopnm convert a Palm pixmap into a portable anymap .TP .B pamcut cut a rectangle out of a PAM, PBM, PGM, or PPM image .TP .B pamdeinterlace remove ever other row from a PAM/PNM image .TP .B pamdice slice a Netpbm image into many horizontally and/or vertically .TP .B pamfile describe a Netpbm (PAM or PNM) file .TP .B pamoil turn a PAM image into an oil painting .TP .B pamstack stack planes of multiple PAM images into one PAM image .TP .B pamstretch-gen use pamstretch and pnmscale to scale by non-integer values .TP .B pamstretch scale up a PNM or PAM image by interpolating between pixels .TP .B pbmclean flip isolated pixels in portable bitmap .TP .B pbmlife apply Conway's rules of Life to a portable bitmap .TP .B pbmmake create a blank bitmap of a specified size .TP .B pbmmask create a mask bitmap from a regular bitmap .TP .B pbmpage create a one page test pattern for printing .TP .B pbmpscale enlarge a portable bitmap with edge smoothing .TP .B pbmreduce read a portable bitmap and reduce it N times .TP .B pbmtext render text into a bitmap .TP .B pbmtextps render text into a bitmap via postscript .TP .B pbmto10x convert a portable bitmap into Gemini 10X printer graphics .TP .B pbmtoascii convert a portable bitmap into ASCII graphics .TP .B pbmtoatk convert portable bitmap to Andrew Toolkit raster object .TP .B pbmtobbnbg convert a portable bitmap into BitGraph graphics .TP .B pbmtocmuwm convert a portable bitmap into a CMU window manager bitmap .TP .B pbmtoepsi convert a portable bitmap into an encapsulated PostScript .TP .B pbmtoepson convert a portable bitmap into Epson printer graphics .TP .B pbmtog3 convert a portable bitmap into a Group 3 fax file .TP .B pbmtogem convert a portable bitmap into a GEM .img file .TP .B pbmtogo convert a portable bitmap into compressed GraphOn graphics .TP .B pbmtoicon convert a portable bitmap into a Sun icon .TP .B pbmtolj convert a portable bitmap into HP LaserJet format .TP .B pbmtomacp convert a portable bitmap into a MacPaint file .TP .B pbmtomda convert a portable bitmap to a Microdesign .mda .TP .B pbmtomgr convert a portable bitmap into a MGR bitmap .TP .B pbmtonokia convert a portable bitmap to Nokia Smart Messaging Formats .TP .B pbmtopgm convert portable bitmap to portable graymap by averaging areas .TP .B pbmtopi3 convert a portable bitmap into an Atari Degas .pi3 file .TP .B pbmtoplot convert a portable bitmap into a Unix plot(5) file .TP .B pbmtoppa convert PBM image to HP Printer Performance Architecture (PPA) .TP .B pbmtopsg3 convert PBM images to Postscript with G3 fax compression .TP .B pbmtoptx convert a portable bitmap into Printronix printer graphics .TP .B pbmtowbmp convert a portable bitmap to a wireless bitmap (wbmp) file .TP .B pbmtox10bm convert a portable bitmap into an X10 bitmap .TP .B pbmtoxbm convert a portable bitmap into an X11 bitmap .TP .B pbmtoybm convert a portable bitmap into a Bennet Yee "face" file .TP .B pbmtozinc convert a portable bitmap into a Zinc bitmap .TP .B pbmupc create a Universal Product Code bitmap .TP .B pcxtoppm convert a PCX file into a portable pixmap .TP .B pgmbentley Bentleyize a portable graymap .TP .B pgmcrater create cratered terrain by fractal forgery .TP .B pgmedge edge-detect a portable graymap .TP .B pgmenhance edge-enhance a portable graymap .TP .B pgmhist print a histogram of the values in a portable graymap .TP .B pgmkernel generate a convolution kernel .TP .B pgmnoise create a graymap made up of white noise .TP .B pgmnorm (deprecated) is replaced by pnmnorm(1) .TP .B pgmoil (deprecated) is replaced by pamoil(1) .TP .B pgmramp generate a grayscale ramp .TP .B pgmslice extract one line of pixel values out of a portable graymap .TP .B pgmtexture calculate textural features on a portable graymap .TP .B pgmtofs convert portable graymap to Usenix FaceSaver(tm) format .TP .B pgmtolispm convert a portable graymap into Lisp Machine format .TP .B pgmtopbm convert a portable graymap into a portable bitmap .TP .B pgmtoppm colorize a portable graymap into a portable pixmap .TP .B pi1toppm convert an Atari Degas .pi1 into a portable pixmap .TP .B pi3topbm convert an Atari Degas .pi3 file into a portable bitmap .TP .B pjtoppm convert an HP PaintJet file to a portable pixmap .TP .B pngtopnm convert a Portable Network Graphics file into portable anymap .TP .B pnmalias antialias a portable anyumap. .TP .B pnmarith perform arithmetic on two portable anymaps .TP .B pnmcat concatenate portable anymaps .TP .B pnmcolormap create quantization color map for a portable anymap .TP .B pnmcomp composite (overlay) two portable anymap files together .TP .B pnmconvol general MxN convolution on a portable anymap .TP .B pnmcrop crop a portable anymap .TP .B pnmcut cut a rectangle out of a portable anymap .TP .B pnmdepth change the maxval in a portable anymap .TP .B pnmenlarge read a portable anymap and enlarge it N times .TP .B pnmfile describe a portable anymap .TP .B pnmflip perform one or more flip operations on a portable anymap .TP .B pnmgamma perform gamma correction on a portable anymap .TP .B pnmhisteq histogram equalise a portable anymap .TP .B pnmhistmap draw a histogram for a PGM or PPM file .TP .B pnmindex build a visual index of a bunch of anymaps .TP .B pnminterp-gen (deprecated) is replaced by pamstretch-gen(1) .TP .B pnminterp (deprecated) is replaced by pamstretch(1) .TP .B pnminvert invert a portable anymap .TP .B pnmmargin add a border to a portable anymap .TP .B pnmmontage create a montage of portable anymaps .TP .B pnmnlfilt non-linear filters: smooth, alpha trim mean, optimal .TP .B pnmnoraw (deprecated) is replaced by pnmtoplainpnm(1) .TP .B pnmnorm normalize the contrast in a Netbpm image .TP .B pnmpad add borders to portable anymap .TP .B pnmpaste paste a rectangle into a portable anymap .TP .B pnmpsnr compute the difference between two portable anymaps .TP .B pnmquant quantize the colors in a Netpbm image to a smaller set .TP .B pnmremap replace colors in a PPM image with colors from another set .TP .B pnmrotate rotate a portable anymap by some angle .TP .B pnmscale scale a portable anymap .TP .B pnmscalefixed scale a portable anymap quickly, but less accurate .TP .B pnmshear shear a portable anymap by some angle .TP .B pnmsmooth smooth out an image .TP .B pnmsplit split a multi-image portable anymap into multiple single-image files .TP .B pnmtile replicate a portable anymap into a specified size .TP .B pnmtoddif Convert a portable anymap to DDIF format .TP .B pnmtofiasco Convert a portable anymap to FIASCO compressed file .TP .B pnmtofits convert a portable anymap into FITS format .TP .B pnmtojpeg convert PNM image to a JFIF ("JPEG") image .TP .B pnmtopalm convert a portable anymap into a Palm pixmap .TP .B pnmtoplainpnm convert portable any map to plain (ASCII) anymap format .TP .B pnmtopng convert a portable anymap into a Portable Network Graphics file .TP .B pnmtops convert portable anymap to PostScript .TP .B pnmtorast convert a portable pixmap into a Sun rasterfile .TP .B pnmtorle convert a Netpbm image file into an RLE image file. .TP .B pnmtosgi convert a portable anymap to a SGI image file .TP .B pnmtosir convert a portable anymap into a Solitaire format .TP .B pnmtotiff convert a portable anymap into a TIFF file .TP .B pnmtotiffcmyk convert a portable anymap into a CMYK encoded TIFF file .TP .B pnmtoxwd convert a portable anymap into an X11 window dump .TP .B ppm3d convert two portable pixmap into a red/blue 3d glasses pixmap .TP .B ppmbrighten change an images Saturation and Value from an HSV map .TP .B ppmchange change all pixels of one color to another in a portable pixmap .TP .B ppmcie draw a CIE color chart as a PPM image .TP .B ppmcolormask produce mask of areas of a certain color in a PPM file .TP .B ppmcolors generate a color map of all colors of a certain maxval .TP .B ppmdim dim a portable pixmap down to total blackness .TP .B ppmdist simplistic grayscale assignment for machine generated, color images .TP .B ppmdither ordered dither for color images .TP .B ppmfade generate a transition between two image files using special effects. .TP .B ppmflash brighten a picture up to complete white-out .TP .B ppmforge fractal forgeries of clouds, planets, and starry skies .TP .B ppmhist print a histogram of a portable pixmap .TP .B ppmlabel add text to a portable pixmap .TP .B ppmmake create a pixmap of a specified size and color .TP .B ppmmix blend together two portable pixmaps .TP .B ppmnorm (deprecated) is replaced by pnmnorm(1) .TP .B ppmntsc make a portable pixmap look like taken from an American TV .TP .B ppmpat make a pretty pixmap .TP .B ppmquant quantize the colors in a portable pixmap down to a specified number .TP .B ppmquantall run ppmquant on a bunch of files all at once, so they share a common colormap .TP .B ppmqvga 8 plane quantization .TP .B ppmrainbow Generate a rainbow .TP .B ppmrelief run a Laplacian relief filter on a portable pixmap .TP .B ppmshadow add simulated shadows to a portable pixmap image .TP .B ppmshift shift lines of a portable pixmap left or right by a random amount .TP .B ppmspread displace a portable pixmap's pixels by a random amount .TP .B ppmtoacad convert portable pixmap to AutoCAD database or slide .TP .B ppmtobmp convert a portable pixmap into a BMP file .TP .B ppmtoeyuv convert a portable pixmap into a Berkeley YUV file .TP .B ppmtoicr convert a portable pixmap into NCSA ICR format .TP .B ppmtoilbm convert a portable pixmap into an ILBM file .TP .B ppmtojpeg (deprecated) is replaced by pnmtojpeg(1) .TP .B ppmtoleaf convert portable pixmap to Interleaf image format .TP .B ppmtolj convert a portable pixmap to an HP LaserJet PCL 5 Color file .TP .B ppmtomap extract all colors from a portable pixmap .TP .B ppmtomitsu convert a portable pixmap to a Mitsubishi S340-10 file .TP .B ppmtompeg encodes MPEG-1 bitstreams .TP .B ppmtoneo convert a portable pixmap into an Atari Neochrome .neo file .TP .B ppmtopcx convert a portable pixmap into a PCX file .TP .B ppmtopgm convert a portable pixmap into a portable graymap .TP .B ppmtopi1 convert a portable pixmap into an Atari Degas .pi1 file .TP .B ppmtopict convert a portable pixmap into a Macintosh PICT file .TP .B ppmtopj convert a portable pixmap to an HP PaintJet file .TP .B ppmtopuzz convert a portable pixmap into an X11 "puzzle" file .TP .B ppmtorgb3 separate a portable pixmap into three portable graymaps .TP .B ppmtosixel convert a portable pixmap into DEC sixel format .TP .B ppmtotga convert portable pixmap into a TrueVision Targa file .TP .B ppmtouil convert a portable pixmap into a Motif UIL icon file .TP .B ppmtowinicon convert 1 or more portable pixmaps into a Windows .ico .TP .B ppmtoxpm convert a portable pixmap into an X11 pixmap .TP .B ppmtoyuv convert a portable pixmap into an Abekas YUV file .TP .B ppmtoyuvsplit convert a portable pixmap into 3 subsampled raw YUV files .TP .B ppmtv make a portable pixmap look like taken from an American TV .TP .B psidtopgm convert PostScript "image" data into a portable graymap .TP .B pstopnm convert a PostScript file into a portable anymap .TP .B qrttoppm convert output from the QRT ray tracer into a portable pixmap .TP .B rasttopnm convert a Sun rasterfile into a portable anymap .TP .B rawtopgm convert raw grayscale bytes into a portable graymap .TP .B rawtoppm convert raw RGB bytes into a portable pixmap .TP .B rgb3toppm combine three portable graymaps into one portable pixmap .TP .B rletopnm convert a Utah Raster Tools RLE image file into a PNM image file. .TP .B sbigtopgm convert an SBIG CCDOPS file into a portable graymap .TP .B sgitopnm convert a SGI image file to a portable anymap .TP .B sirtopnm convert a Solitaire file into a portable anymap .TP .B sldtoppm convert an AutoCAD slide file into a portable pixmap .TP .B spctoppm convert an Atari compressed Spectrum file into a portable pixmap .TP .B sputoppm convert an Atari uncompressed Spectrum file into a portable pixmap .TP .B tgatoppm convert TrueVision Targa file into a portable pixmap .TP .B thinkjettopbm convert HP ThinkJet printer commands file to PBM .TP .B tifftopnm convert a TIFF file into a portable anymap .TP .B wbmptopbm convert a wireless bitmap (wbmp) file to a portable bitmap (pbm) .TP .B winicontoppm convert a Windows .ico file into 1 or more portable pixmap .TP .B xbmtopbm convert an X11 or X10 bitmap into a portable bitmap .TP .B ximtoppm convert an Xim file into a portable pixmap .TP .B xpmtoppm convert an X11 pixmap into a portable pixmap .TP .B xvminitoppm convert a XV "thumbnail" picture to PPM .TP .B xwdtopnm convert a X11 or X10 window dump file into a portable anymap .TP .B ybmtopbm convert a Bennet Yee "face" file into a portable bitmap .TP .B yuvsplittoppm convert a Y- and a U- and a V-file into a portable pixmap .TP .B yuvtoppm convert Abekas YUV bytes into a portable pixmap .TP .B zeisstopnm convert a Zeiss confocal file into a portable anymap .SH "SEE ALSO" 411toppm(1), anytopnm(1), asciitopgm(1), atktopbm(1), bioradtopgm(1), bmptopnm(1), brushtopbm(1), cmuwmtopbm(1), eyuvtoppm(1), fiascotopnm(1), fitstopnm(1), fstopgm(1), g3topbm(1), gemtopnm(1), giftopnm(1), gouldtoppm(1), hipstopgm(1), icontopbm(1), ilbmtoppm(1), imgtoppm(1), jpegtopnm(1), leaftoppm(1), lispmtopgm(1), macptopbm(1), mdatopbm(1), mgrtopbm(1), mtvtoppm(1), neotoppm(1), palmtopnm(1), pamcut(1), pamdeinterlace(1), pamdice(1), pamfile(1), pamoil(1), pamstack(1), pamstretch-gen(1), pamstretch(1), pbmclean(1), pbmlife(1), pbmmake(1), pbmmask(1), pbmpage(1), pbmpscale(1), pbmreduce(1), pbmtext(1), pbmtextps(1), pbmto10x(1), pbmtoascii(1), pbmtoatk(1), pbmtobbnbg(1), pbmtocmuwm(1), pbmtoepsi(1), pbmtoepson(1), pbmtog3(1), pbmtogem(1), pbmtogo(1), pbmtoicon(1), pbmtolj(1), pbmtomacp(1), pbmtomda(1), pbmtomgr(1), pbmtonokia(1), pbmtopgm(1), pbmtopi3(1), pbmtoplot(1), pbmtoppa(1), pbmtopsg3(1), pbmtoptx(1), pbmtowbmp(1), pbmtox10bm(1), pbmtoxbm(1), pbmtoybm(1), pbmtozinc(1), pbmupc(1), pcxtoppm(1), pgmbentley(1), pgmcrater(1), pgmedge(1), pgmenhance(1), pgmhist(1), pgmkernel(1), pgmnoise(1), pgmramp(1), pgmslice(1), pgmtexture(1), pgmtofs(1), pgmtolispm(1), pgmtopbm(1), pgmtoppm(1), pi1toppm(1), pi3topbm(1), pjtoppm(1), pngtopnm(1), pnmalias(1), pnmarith(1), pnmcat(1), pnmcolormap(1), pnmcomp(1), pnmconvol(1), pnmcrop(1), pnmcut(1), pnmdepth(1), pnmenlarge(1), pnmfile(1), pnmflip(1), pnmgamma(1), pnmhisteq(1), pnmhistmap(1), pnmindex(1), pnminvert(1), pnmmargin(1), pnmmontage(1), pnmnlfilt(1), pnmnorm(1), pnmpad(1), pnmpaste(1), pnmpsnr(1), pnmquant(1), pnmremap(1), pnmrotate(1), pnmscale(1), pnmscalefixed(1), pnmshear(1), pnmsmooth(1), pnmsplit(1), pnmtile(1), pnmtoddif(1), pnmtofiasco(1), pnmtofits(1), pnmtojpeg(1), pnmtopalm(1), pnmtoplainpnm(1), pnmtopng(1), pnmtops(1), pnmtorast(1), pnmtorle(1), pnmtosgi(1), pnmtosir(1), pnmtotiff(1), pnmtotiffcmyk(1), pnmtoxwd(1), ppm3d(1), ppmbrighten(1), ppmchange(1), ppmcie(1), ppmcolormask(1), ppmcolors(1), ppmdim(1), ppmdist(1), ppmdither(1), ppmfade(1), ppmflash(1), ppmforge(1), ppmhist(1), ppmlabel(1), ppmmake(1), ppmmix(1), ppmntsc(1), ppmpat(1), ppmquant(1), ppmquantall(1), ppmqvga(1), ppmrainbow(1), ppmrelief(1), ppmshadow(1), ppmshift(1), ppmspread(1), ppmtoacad(1), ppmtobmp(1), ppmtoeyuv(1), ppmtoicr(1), ppmtoilbm(1), ppmtoleaf(1), ppmtolj(1), ppmtomap(1), ppmtomitsu(1), ppmtompeg(1), ppmtoneo(1), ppmtopcx(1), ppmtopgm(1), ppmtopi1(1), ppmtopict(1), ppmtopj(1), ppmtopuzz(1), ppmtorgb3(1), ppmtosixel(1), ppmtotga(1), ppmtouil(1), ppmtowinicon(1), ppmtoxpm(1), ppmtoyuv(1), ppmtoyuvsplit(1), ppmtv(1), psidtopgm(1), pstopnm(1), qrttoppm(1), rasttopnm(1), rawtopgm(1), rawtoppm(1), rgb3toppm(1), rletopnm(1), sbigtopgm(1), sgitopnm(1), sirtopnm(1), sldtoppm(1), spctoppm(1), sputoppm(1), tgatoppm(1), thinkjettopbm(1), tifftopnm(1), wbmptopbm(1), winicontoppm(1), xbmtopbm(1), ximtoppm(1), xpmtoppm(1), xvminitoppm(1), xwdtopnm(1), ybmtopbm(1), yuvsplittoppm(1), yuvtoppm(1), zeisstopnm(1). .SH AUTHORS Many. See the individual manual pages. .\" All programms are free (as defined by the DFSG), but have different .\" licences. Please see for details the individual manpages. �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/pbmlife.1��������������������������������������������������������������������0100644�0047145�0047145�00000001555�07716230207�016607� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������.TH pbmlife 1 "21 February 1991" .IX pbmlife .SH NAME pbmlife - apply Conway's rules of Life to a portable bitmap .SH SYNOPSIS .B pbmlife .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Applies the rules of Life to it for one generation, .IX Life and produces a portable bitmap as output. .PP A white pixel in the image is interpreted as a live beastie, and a black pixel as an empty space. .SH "SEE ALSO" pbm(5) .SH AUTHOR Copyright (C) 1988, 1991 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. ���������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/pbmlife.c��������������������������������������������������������������������0100644�0047145�0047145�00000005160�07716230207�016665� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* pbmlife.c - read a portable bitmap and apply Conway's rules of Life to it ** ** Copyright (C) 1988,1 1991 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* prevrow; bit* thisrow; bit* nextrow; bit* temprow; register bit* newrow; int rows, cols, row; register int col, count; int format; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[pbmfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; pbm_readpbminit( ifp, &cols, &rows, &format ); prevrow = pbm_allocrow( cols ); thisrow = pbm_allocrow( cols ); nextrow = pbm_allocrow( cols ); pbm_writepbminit( stdout, cols, rows, 0 ); newrow = pbm_allocrow( cols ); pbm_readpbmrow( ifp, nextrow, cols, format ); for ( row = 0; row < rows; ++row ) { temprow = prevrow; prevrow = thisrow; thisrow = nextrow; nextrow = temprow; if ( row <= rows ) pbm_readpbmrow( ifp, nextrow, cols, format ); for ( col = 0; col < cols; ++col ) { /* Check the neighborhood, with an unrolled double loop. */ count = 0; if ( row > 0 ) { /* upper left */ if ( col > 0 && prevrow[col - 1] == PBM_WHITE ) ++count; /* upper center */ if ( prevrow[col] == PBM_WHITE ) ++count; /* upper right */ if ( col < cols - 1 && prevrow[col + 1] == PBM_WHITE ) ++count; } /* left */ if ( col > 0 && thisrow[col - 1] == PBM_WHITE ) ++count; /* right */ if ( col < cols - 1 && thisrow[col + 1] == PBM_WHITE ) ++count; if ( row < rows - 1 ) { /* lower left */ if ( col > 0 && nextrow[col - 1] == PBM_WHITE ) ++count; /* lower center */ if ( nextrow[col] == PBM_WHITE ) ++count; /* lower right */ if ( col < cols - 1 && nextrow[col + 1] == PBM_WHITE ) ++count; } /* And compute the new value. */ if ( thisrow[col] == PBM_WHITE ) if ( count == 2 || count == 3 ) newrow[col] = PBM_WHITE; else newrow[col] = PBM_BLACK; else if ( count == 3 ) newrow[col] = PBM_WHITE; else newrow[col] = PBM_BLACK; } pbm_writepbmrow( stdout, newrow, cols, 0 ); } pm_close( ifp ); pm_close( stdout ); exit( 0 ); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/pbmmake.1��������������������������������������������������������������������0100644�0047145�0047145�00000002001�07716230207�016570� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������.TH pbmmake 1 "22 February 1989" .IX pbmmake .SH NAME pbmmake - create a blank bitmap of a specified size .SH SYNOPSIS .B pbmmake .RB [ -white | -black | -gray .RB ] .I width height .SH DESCRIPTION Produces a portable bitmap of the specified width and height. .IX "generating bitmaps" The color defaults to white. .SH OPTIONS .PP In addition to the usual .B -white and .BR -black , this program implements .BR -gray . This gives a simple 50% gray pattern with 1's and 0's alternating. .PP All flags can be abbreviated to their shortest unique prefix. .SH "SEE ALSO" pbm(5), ppmmake(1) .SH AUTHOR Copyright (C) 1989 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/pbmmake.c��������������������������������������������������������������������0100644�0047145�0047145�00000005000�07716230207�016654� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* pbmmake.c - create a blank bitmap of a specified size ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" int main( argc, argv ) int argc; char* argv[]; { register bit color, gray; bit* bitrow; register bit* bP; int argn, rows, cols, row, col; char* usage = "[-white|-black|-gray] "; pbm_init( &argc, argv ); argn = 1; color = PBM_WHITE; gray = 0; /* Check for flags. */ if ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( pm_keymatch( argv[argn], "-white", 2 ) ) color = PBM_WHITE; else if ( pm_keymatch( argv[argn], "-black", 2 ) ) color = PBM_BLACK; else if ( pm_keymatch( argv[argn], "-gray", 2 ) || pm_keymatch( argv[argn], "-grey", 2 ) ) gray = 1; else pm_usage( usage ); ++argn; } if ( argn == argc ) pm_usage( usage ); if ( sscanf( argv[argn], "%d", &cols ) != 1 ) pm_usage( usage ); ++argn; if ( argn == argc ) pm_usage( usage ); if ( sscanf( argv[argn], "%d", &rows ) != 1 ) pm_usage( usage ); ++argn; if ( argn != argc ) pm_usage( usage ); if (rows < 1) pm_error("Number of rows must be positive. You specified %d.", rows); if (cols < 1) pm_error("Number of columns must be positive. You specified %d.", cols); pbm_writepbminit( stdout, cols, rows, 0 ); bitrow = pbm_allocrow( cols ); if (gray) { register bit rowcolor; rowcolor = PBM_WHITE; /* arbitrarily make the corner white */ for ( row = 0; row < rows; ++row ) { color = rowcolor; rowcolor = 1 - rowcolor; for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) { *bP = color; color = 1 - color; } pbm_writepbmrow( stdout, bitrow, cols, 0 ); } } else { for ( row = 0; row < rows; ++row ) { for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) { *bP = color; } pbm_writepbmrow( stdout, bitrow, cols, 0 ); } } pm_close( stdout ); exit( 0 ); } netpbm-free-10.0-1/pbm/pbmmask.1��������������������������������������������������������������������0100644�0047145�0047145�00000004500�07716762513�016626� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������.TH pbmmask 1 "08 August 1989" .IX pbmmask .SH NAME pbmmask - create a mask bitmap from a regular bitmap .SH SYNOPSIS .B pbmmask .RB [ -expand ] .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Creates a corresponding mask bitmap and writes it out. .PP The color to be interpreted as "background" is determined automatically. Regardless of which color is background, the mask will be white where the background is and black where the figure is. .PP This lets you do a masked paste like this, for objects with a black background: .nf pbmmask obj > objmask pnmpaste < dest -and objmask | pnmpaste -or obj .fi .IX pnmpaste For objects with a white background, you can either invert them or add a step: .nf pbmmask obj > objmask pnminvert objmask | pnmpaste -and obj 0 0 > blackback pnmpaste < dest -and objmask | pnmpaste -or blackback .fi .IX pnminvert Note that this three-step version works for objects with black backgrounds too, if you don't care about the wasted time. .PP You can also use masks with graymaps and pixmaps, using the .I pnmarith tool. For instance: .nf ppmtopgm obj.ppm | pgmtopbm -threshold | pbmmask > objmask.pbm pnmarith -multiply dest.ppm objmask.pbm > t1.ppm pnminvert objmask.pbm | pnmarith -multiply obj.ppm - > t2.ppm pnmarith -add t1.ppm t2.ppm .fi .IX pnmarith An interesting variation on this is to pipe the mask through the .I pnmsmooth .IX pnmsmooth script before using it. This makes the boundary between the two images less sharp. .SH OPTIONS .TP .B -expand Expands the mask by one pixel out from the image. This is useful if you want a little white border around your image. (A better solution might be to turn the .I pbmlife tool into a general cellular automaton tool...) .SH "SEE ALSO" .BR ppmcolormask (1), .BR pnmpaste (1), .BR pnminvert (1), .BR pbm (5), .BR pnmarith (1), .BR pnmsmooth (1) .SH AUTHOR Copyright (C) 1988 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/pbmmask.c��������������������������������������������������������������������0100644�0047145�0047145�00000012257�07716230207�016706� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* pbmmask.c - create a mask bitmap from a portable bitmap ** ** Copyright (C) 1989, 1991 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" static void addflood ARGS(( int col, int row )); static void flood ARGS(( void )); static bit** bits; static bit** mask; static bit backcolor; static int rows, cols; int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; int argn, expand, wcount; register int row, col; char* usage = "[-expand] [pbmfile]"; pbm_init( &argc, argv ); argn = 1; expand = 0; if ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( pm_keymatch( argv[argn], "-expand", 2 ) ) expand = 1; else if ( pm_keymatch( argv[argn], "-noexpand", 2 ) ) expand = 0; else pm_usage( usage ); ++argn; } if ( argn == argc ) ifp = stdin; else { ifp = pm_openr( argv[argn] ); ++argn; } if ( argn != argc ) pm_usage( usage ); bits = pbm_readpbm( ifp, &cols, &rows ); pm_close( ifp ); mask = pbm_allocarray( cols, rows ); /* Clear out the mask. */ for ( row = 0; row < rows; ++row ) for ( col = 0; col < cols; ++col ) mask[row][col] = PBM_BLACK; /* Figure out the background color, by counting along the edge. */ wcount = 0; for ( row = 0; row < rows; ++row ) { if ( bits[row][0] == PBM_WHITE ) ++wcount; if ( bits[row][cols - 1] == PBM_WHITE ) ++wcount; } for ( col = 1; col < cols - 1; ++col ) { if ( bits[0][col] == PBM_WHITE ) ++wcount; if ( bits[rows - 1][col] == PBM_WHITE ) ++wcount; } if ( wcount >= rows + cols - 2 ) backcolor = PBM_WHITE; else backcolor = PBM_BLACK; /* Flood the entire edge. Probably the first call will be enough, but ** might as well be sure. */ for ( col = cols - 3; col >= 2; col -= 2 ) { addflood( col, rows - 1 ); addflood( col, 0 ); } for ( row = rows - 1; row >= 0; row -= 2 ) { addflood( cols - 1, row ); addflood( 0, row ); } flood( ); if ( ! expand ) /* Done. */ pbm_writepbm( stdout, mask, cols, rows, 0 ); else { /* Expand by one pixel. */ register int srow, scol; bit** emask; emask = pbm_allocarray( cols, rows ); for ( row = 0; row < rows; ++row ) for ( col = 0; col < cols; ++col ) if ( mask[row][col] == PBM_BLACK ) emask[row][col] = PBM_BLACK; else { emask[row][col] = PBM_WHITE; for ( srow = row - 1; srow <= row + 1; ++srow ) for ( scol = col - 1; scol <= col + 1; ++scol ) if ( srow >= 0 && srow < rows && scol >= 0 && scol < cols && mask[srow][scol] == PBM_BLACK ) { emask[row][col] = PBM_BLACK; break; } } /* Done. */ pbm_writepbm( stdout, emask, cols, rows, 0 ); } pm_close( stdout ); exit( 0 ); } static short* fcols; static short* frows; static int fstacksize = 0, fstackp = 0; static void addflood( col, row ) int col, row; { if ( bits[row][col] == backcolor && mask[row][col] == PBM_BLACK ) { if ( fstackp >= fstacksize ) { if ( fstacksize == 0 ) { fstacksize = 1000; fcols = (short*) malloc( fstacksize * sizeof(short) ); frows = (short*) malloc( fstacksize * sizeof(short) ); if ( fcols == (short*) 0 || frows == (short*) 0 ) pm_error( "out of memory" ); } else { fstacksize *= 2; fcols = (short*) realloc( (char*) fcols, fstacksize * sizeof(short) ); frows = (short*) realloc( (char*) frows, fstacksize * sizeof(short) ); if ( fcols == (short*) 0 || frows == (short*) 0 ) pm_error( "out of memory" ); } } fcols[fstackp] = col; frows[fstackp] = row; ++fstackp; } } static void flood( ) { register int col, row, c; while ( fstackp > 0 ) { --fstackp; col = fcols[fstackp]; row = frows[fstackp]; if ( bits[row][col] == backcolor && mask[row][col] == PBM_BLACK ) { mask[row][col] = PBM_WHITE; if ( row - 1 >= 0 ) addflood( col, row - 1 ); if ( row + 1 < rows ) addflood( col, row + 1 ); for ( c = col + 1; c < cols; ++c ) { if ( bits[row][c] == backcolor && mask[row][c] == PBM_BLACK ) { mask[row][c] = PBM_WHITE; if ( row - 1 >= 0 && ( bits[row - 1][c - 1] != backcolor || mask[row - 1][c - 1] != PBM_BLACK ) ) addflood( c, row - 1 ); if ( row + 1 < rows && ( bits[row + 1][c - 1] != backcolor || mask[row + 1][c - 1] != PBM_BLACK ) ) addflood( c, row + 1 ); } else break; } for ( c = col - 1; c >= 0; --c ) { if ( bits[row][c] == backcolor && mask[row][c] == PBM_BLACK ) { mask[row][c] = PBM_WHITE; if ( row - 1 >= 0 && ( bits[row - 1][c + 1] != backcolor || mask[row - 1][c + 1] != PBM_BLACK ) ) addflood( c, row - 1 ); if ( row + 1 < rows && ( bits[row + 1][c + 1] != backcolor || mask[row + 1][c + 1] != PBM_BLACK ) ) addflood( c, row + 1 ); } else break; } } } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/pbmmerge.c�������������������������������������������������������������������0100644�0047145�0047145�00000002424�07716230207�017045� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* pbmmerge.c - wrapper program for PBM ** ** Copyright (C) 1991 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ /* Note: be careful using any Netpbm library functions in here, since we don't call pbm_init() */ #include #include #include "pbm.h" int main(int argc, char *argv[]) { char* cp; if (strcmp(pm_arg0toprogname(argv[0]), "pbmmerge") == 0) { ++argv; --argc; if (!*argv) { fprintf(stderr, "Usage: pbmmerge pbm_program_name [args ...]\n"); exit(1); } } cp = pm_arg0toprogname(argv[0]); /* merge.h is an automatically generated file that generates code to match the string 'cp' against the name of every program that is part of this merge and, upon finding a match, invoke that program. */ #include "merge.h" fprintf(stderr,"'%s' is a PBM program name unknown to pbmmerge\n", cp ); exit(1); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/pbmpage.1��������������������������������������������������������������������0100644�0047145�0047145�00000003503�07716762513�016611� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������.TH pbmpage 1 "01 May 2000" .IX pbmpage .SH NAME pbmpage - create a one page test pattern for printing .SH SYNOPSIS .B pbmpage .RB [ -a4 ] .I test_pattern .SH DESCRIPTION .B pbmpage generates a one page test pattern to print on a sheet of paper, for use in calibrating a printer. The test pattern in is PBM format. .B pbmpage produces an image intended for 600 dots per inch printer resolution. If you are printing on an HP PPA printer, you can convert the output of this program to a stream that you can feed to the printer with .BR pbmtoppa . Bear in mind that when you print the test pattern, you are testing not only the printer, but any converter or driver software along the printing path. Any one of these components may adjust margins, crop the image, erase edges, and such. If, due to addition of margins, the printer refuses to print the image because it is too big, use .B pnmcut to cut the right and bottom edges off the test pattern until it is small enough to print. .I test_pattern is the number of the test pattern to generate, as follows. The default is .BR 1 . .TP .B 1 A grid ruled in numbers of pixels. The outermost rules are exactly at the edges of the paper. .TP .B 2 A vertical line segment, one pixel wide, extending 1/2" up from the exact center of the page. .TP .B 3 Two diagonal line segments, one starting at the upper left corner of the page, the other starting from the lower left corner of the page. Both extend 1/2" toward the center of the page at 45 degrees. .SH OPTIONS .TP .B -a4 Generate an image for A4 (European) paper. Without this option, .B pbmpage generates an image for US standard paper (8 1/2" wide x 11" high). .SH "SEE ALSO" .BR pbmtoppa (1), .BR pnmcut (1), .BR pbm (5) .SH AUTHOR Tim Norman. Copyright (C) 1998. Licensed under GNU Public License Manual page by Bryan Henderson, May 2000. ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������netpbm-free-10.0-1/pbm/pbmpage.c��������������������������������������������������������������������0100644�0047145�0047145�00000012666�07716762513�016705� 0����������������������������������������������������������������������������������������������������ustar �aba-guest�����������������������aba-guest��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*************************************************************************** pbmpage This program produces a printed page test pattern in PBM format. This was adapted from Tim Norman's 'pbmtpg' program, part of his 'pbm2ppa' package, by Bryan Henderson on 2000.05.01. The only change was to make it use the Netpbm libraries to generate the output. For copyright and licensing information, see the pbmtoppa program, which was also derived from the same package. ****************************************************************************/ #include #include #include #include #include "pbm.h" /* Support both US and A4. */ /* US is 8.5 in by 11 in */ #define USWIDTH (5100) #define USHEIGHT (6600) /* A4 is 210 mm by 297 mm == 8.27 in by 11.69 in */ #define A4WIDTH (4960) #define A4HEIGHT (7016) int Width; /* width and height in 600ths of an inch */ int Height; int Pwidth; /* width in bytes */ char *bitmap; static void setpixel(int x,int y,int c) { int charidx=y*Pwidth+x/8; char bitmask=128>>(x%8); if(x<0 || x>=Width) return; if(y<0 || y>=Height) return; if(c) bitmap[charidx] |= bitmask; else bitmap[charidx] &= ~bitmask; } static void setplus(int x,int y,int s) { int i; for(i=0; i='0') for(xo=0; xo<5; xo++) for(yo=0; yo<8; yo++) if((charmap[c-'0'][xo]>>yo)&1) setblock(x+xo*3,y+yo*3,3); } static void setstring(int x,int y,char* s) { char* p; int xo; for(xo=0, p=s; *p; xo+=21, p++) setchar(x+xo,y,*p); } static void setCG(int x,int y) { int xo,yo,zo; for(xo=0; xo<=50; xo++) { yo=sqrt(50.0*50.0-xo*xo); setpixel(x+xo,y+yo,1); setpixel(x+yo,y+xo,1); setpixel(x-1-xo,y-1-yo,1); setpixel(x-1-yo,y-1-xo,1); setpixel(x+xo,y-1-yo,1); setpixel(x-1-xo,y+yo,1); for(zo=0; zo1 && strcmp(argv[1], "-a4")==0) { Width = A4WIDTH; Height = A4HEIGHT; argc--; argv++; } Pwidth = (Width+7)/8; bitmap = (char *)malloc(Pwidth*Height); if(argc>1) TP=atoi(argv[1]); switch(TP) { case 1: for(x=0; x #include "pbm.h" /* prototypes */ void nextrow_pscale ARGS((FILE *ifd, int row)); int corner ARGS((int pat)); /* input bitmap size and storage */ int rows, columns, format ; bit *inrow[3] ; #define thisrow (1) /* compass directions from west clockwise */ int xd_pscale[] = { -1, -1, 0, 1, 1, 1, 0, -1 } ; int yd_pscale[] = { 0, -1, -1, -1, 0, 1, 1, 1 } ; /* starting positions for corners */ #define NE(f) ((f) & 3) #define SE(f) (((f) >> 2) & 3) #define SW(f) (((f) >> 4) & 3) #define NW(f) (((f) >> 6) & 3) typedef unsigned short sixteenbits ; /* list of corner patterns; bit 7 is current colour, bits 0-6 are squares * around (excluding square behind), going clockwise. * The high byte of the patterns is a mask, which determines which bits are * not ignored. */ sixteenbits patterns[] = { 0x0000, 0xd555, /* no corner */ 0x0001, 0xffc1, 0xd514, /* normal corner */ 0x0002, 0xd554, 0xd515, /* reduced corners */ 0xbea2, 0xdfc0, 0xfd81, 0xfd80, 0xdf80, 0x0003, 0xbfa1, 0xfec2 /* reduced if > 1 */ }; /* search for corner patterns, return type of corner found: * 0 = no corner, * 1 = normal corner, * 2 = reduced corner, * 3 = reduced if cutoff > 1 */ int corner(pat) int pat; { register int i, r=0; for (i = 0; i < sizeof(patterns)/sizeof(sixteenbits); i++) if (patterns[i] < 0x100) r = patterns[i]; else if ((pat & (patterns[i] >> 8)) == (patterns[i] & (patterns[i] >> 8))) return r; return 0; } /* get a new row */ void nextrow_pscale(ifd, row) FILE *ifd; int row; { bit *shuffle = inrow[0] ; inrow[0] = inrow[1]; inrow[1] = inrow[2]; inrow[2] = shuffle ; if (row < rows) { if (shuffle == NULL) inrow[2] = shuffle = pbm_allocrow(columns); pbm_readpbmrow(ifd, inrow[2], columns, format) ; } else inrow[2] = NULL; /* discard storage */ } int main(argc, argv) int argc; char *argv[]; { FILE *ifd; register bit *outrow; register int row, col, i, k; int scale, cutoff, ucutoff ; unsigned char *flags; pbm_init( &argc, argv ); if (argc < 2) pm_usage("scale [pbmfile]"); scale = atoi(argv[1]); if (scale < 1) pm_perror("bad scale (< 1)"); if (argc == 3) ifd = pm_openr(argv[2]); else ifd = stdin ; inrow[0] = inrow[1] = inrow[2] = NULL; pbm_readpbminit(ifd, &columns, &rows, &format) ; overflow2(columns, scale); outrow = pbm_allocrow(columns*scale) ; flags = (unsigned char *)malloc2(sizeof(unsigned char), columns) ; if (flags == NULL) pm_perror("out of memory") ; pbm_writepbminit(stdout, columns*scale, rows*scale, 0) ; cutoff = scale / 2; ucutoff = scale - 1 - cutoff; nextrow_pscale(ifd, 0); for (row = 0; row < rows; row++) { nextrow_pscale(ifd, row+1); for (col = 0; col < columns; col++) { flags[col] = 0 ; for (i = 0; i != 8; i += 2) { int vec = inrow[thisrow][col] != PBM_WHITE; for (k = 0; k < 7; k++) { int x = col + xd_pscale[(k+i)&7] ; int y = thisrow + yd_pscale[(k+i)&7] ; vec <<= 1; if (x >=0 && x < columns && inrow[y]) vec |= (inrow[y][x] != PBM_WHITE) ; } flags[col] |= corner(vec)< ucutoff) - (i < cutoff) ; int cut = (zone < 0) ? (cutoff - i) : (zone > 0) ? (i - ucutoff) : 0 ; for (col = 0; col < columns; col++) { int pix = inrow[thisrow][col] ; int flag = flags[col] ; int cutl, cutr ; switch (zone) { case -1: switch (NW(flag)) { case 0: cutl = 0; break; case 1: cutl = cut; break; case 2: cutl = cut ? cut-1 : 0; break; case 3: cutl = (cut && cutoff > 1) ? cut-1 : cut; break; default: cutl = 0; /* Should never reach here */ } switch (NE(flag)) { case 0: cutr = 0; break; case 1: cutr = cut; break; case 2: cutr = cut ? cut-1 : 0; break; case 3: cutr = (cut && cutoff > 1) ? cut-1 : cut; break; default: cutr = 0; /* Should never reach here */ } break; case 0: cutl = cutr = 0; break ; case 1: switch (SW(flag)) { case 0: cutl = 0; break; case 1: cutl = cut; break; case 2: cutl = cut ? cut-1 : 0; break; case 3: cutl = (cut && cutoff > 1) ? cut-1 : cut; break; default: cutl = 0; /* should never reach here */ } switch (SE(flag)) { case 0: cutr = 0; break; case 1: cutr = cut; break; case 2: cutr = cut ? cut-1 : 0; break; case 3: cutr = (cut && cutoff > 1) ? cut-1 : cut; break; default: cutr = 0; /* should never reach here */ } break; default: cutl = 0; cutr = 0; /* Should never reach here */ } for (k = 0; k < cutl; k++) /* left part */ *ptr++ = !pix ; for (k = 0; k < scale-cutl-cutr; k++) /* centre part */ *ptr++ = pix ; for (k = 0; k < cutr; k++) /* right part */ *ptr++ = !pix ; } pbm_writepbmrow(stdout, outrow, scale*columns, 0) ; } } pm_close(ifd); exit(0); } netpbm-free-10.0-1/pbm/pbmreduce.10100644004714500471450000000402307716230207017130 0ustar aba-guestaba-guest.TH pbmreduce 1 "02 August 1989" .IX pbmreduce .SH NAME pbmreduce - read a portable bitmap and reduce it N times .SH SYNOPSIS .B pbmreduce .RB [ -floyd | -fs | -threshold .RB ] .RB [ -value .IR val ] .I N .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Reduces it by a factor of .IR N , and produces a portable bitmap as output. .IX shrinking .PP .I pbmreduce duplicates a lot of the functionality of .I pgmtopbm; .IX pgmtopbm you could do something like .B pnmscale | pgmtopbm, .IX pnmscale but .I pbmreduce is a lot faster. .PP .I pbmreduce can be used to "re-halftone" an image. .IX halftoning Let's say you have a scanner that only produces black&white, not grayscale, and it does a terrible job of halftoning (most b&w scanners fit this description). One way to fix the halftoning is to scan at the highest possible resolution, say 300 dpi, and then reduce by a factor of three or so using .IR pbmreduce . You can even correct the brightness of an image, by using the .B -value flag. .SH OPTIONS .PP By default, the halftoning after the reduction is done via boustrophedonic Floyd-Steinberg error diffusion; however, the .IX Floyd-Steinberg .IX "error diffusion" .B -threshold flag can be used to specify simple thresholding. This gives better .IX thresholding results when reducing line drawings. .PP The .B -value flag alters the thresholding value for all quantizations. It should be a real number between 0 and 1. Above 0.5 means darker images; below 0.5 means lighter. .PP All flags can be abbreviated to their shortest unique prefix. .SH "SEE ALSO" pnmenlarge(1), pnmscale(1), pgmtopbm(1), pbm(5) .SH AUTHOR Copyright (C) 1988 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmreduce.c0100644004714500471450000001141307716230207017213 0ustar aba-guestaba-guest/* pbmreduce.c - read a portable bitmap and reduce it N times ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; register bit** bitslice; register bit* newbitrow; register bit* nbP; int argn, n, rows, cols, format, newrows, newcols; int row, col, limitcol, subrow, subcol, count, direction; char* usage = "[-floyd|-fs | -threshold] [-value ] N [pbmfile]"; int halftone; #define QT_FS 1 #define QT_THRESH 2 #define SCALE 1024 #define HALFSCALE 512 long threshval, sum; long* thiserr; /* used for Floyd-Steinberg stuff */ long* nexterr; /* used for Floyd-Steinberg stuff */ long* temperr; pbm_init( &argc, argv ); argn = 1; halftone = QT_FS; threshval = HALFSCALE; while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( pm_keymatch( argv[argn], "-fs", 2 ) || pm_keymatch( argv[argn], "-floyd", 2 ) ) halftone = QT_FS; else if ( pm_keymatch( argv[argn], "-threshold", 2 ) ) halftone = QT_THRESH; else if ( pm_keymatch( argv[argn], "-value", 2 ) ) { float f; ++argn; if ( argn == argc || sscanf( argv[argn], "%f", &f ) != 1 || f < 0.0 || f > 1.0 ) pm_usage( usage ); threshval = f * SCALE; } else pm_usage( usage ); ++argn; } if ( argn == argc ) pm_usage( usage ); if ( sscanf( argv[argn], "%d", &n ) != 1 ) pm_usage( usage ); if ( n < 2 ) pm_error( "N must be greater than 1" ); ++argn; if ( argn == argc ) ifp = stdin; else { ifp = pm_openr( argv[argn] ); ++argn; } if ( argn != argc ) pm_usage( usage ); pbm_readpbminit( ifp, &cols, &rows, &format ); bitslice = pbm_allocarray( cols, n ); newrows = rows / n; newcols = cols / n; pbm_writepbminit( stdout, newcols, newrows, 0 ); newbitrow = pbm_allocrow( newcols ); if ( halftone == QT_FS ) { /* Initialize Floyd-Steinberg. */ overflow_add(newcols, 2); thiserr = (long*) malloc2( ( newcols + 2 ), sizeof(long) ); nexterr = (long*) malloc2( ( newcols + 2 ), sizeof(long) ); if ( thiserr == 0 || nexterr == 0 ) pm_error( "out of memory" ); srand( (int) ( time( 0 ) ^ getpid( ) ) ); for ( col = 0; col < newcols + 2; ++col ) thiserr[col] = ( rand( ) % SCALE - HALFSCALE ) / 4; /* (random errors in [-SCALE/8 .. SCALE/8]) */ } else { /* These variables are meaningless in this case, and the values should never be used. */ thiserr = NULL; nexterr = NULL; } direction = 1; for ( row = 0; row < newrows; ++row ) { for ( subrow = 0; subrow < n; ++subrow ) pbm_readpbmrow( ifp, bitslice[subrow], cols, format ); if ( halftone == QT_FS ) for ( col = 0; col < newcols + 2; ++col ) nexterr[col] = 0; if ( direction ) { col = 0; limitcol = newcols; nbP = newbitrow; } else { col = newcols - 1; limitcol = -1; nbP = &(newbitrow[col]); } do { sum = 0; count = 0; for ( subrow = 0; subrow < n; ++subrow ) for ( subcol = 0; subcol < n; ++subcol ) if ( row * n + subrow < rows && col * n + subcol < cols ) { count += 1; if ( bitslice[subrow][col * n + subcol] == PBM_WHITE ) sum += 1; } sum = ( sum * SCALE ) / count; if ( halftone == QT_FS ) sum += thiserr[col + 1]; if ( sum >= threshval ) { *nbP = PBM_WHITE; if ( halftone == QT_FS ) sum = sum - threshval - HALFSCALE; } else *nbP = PBM_BLACK; if ( halftone == QT_FS ) { if ( direction ) { thiserr[col + 2] += ( sum * 7 ) / 16; nexterr[col ] += ( sum * 3 ) / 16; nexterr[col + 1] += ( sum * 5 ) / 16; nexterr[col + 2] += ( sum ) / 16; } else { thiserr[col ] += ( sum * 7 ) / 16; nexterr[col + 2] += ( sum * 3 ) / 16; nexterr[col + 1] += ( sum * 5 ) / 16; nexterr[col ] += ( sum ) / 16; } } if ( direction ) { ++col; ++nbP; } else { --col; --nbP; } } while ( col != limitcol ); pbm_writepbmrow( stdout, newbitrow, newcols, 0 ); if ( halftone == QT_FS ) { temperr = thiserr; thiserr = nexterr; nexterr = temperr; direction = ! direction; } } pm_close( ifp ); pm_close( stdout ); exit( 0 ); } netpbm-free-10.0-1/pbm/pbmtext.10100644004714500471450000001060707776237374016674 0ustar aba-guestaba-guest.TH pbmtext 1 "28 January 2001" .IX pbmtext .SH NAME pbmtext - render text into a bitmap .SH SYNOPSIS .B pbmtext .RB [ \-font .IR fontfile ] .RB [ \-builtin .IR fontname ] .RB [ \-space .IR pixels ] .RB [ \-lspace .IR pixels ] .RI [ text ] .SH DESCRIPTION .PP Takes the specified text, either a single line from the command line or multiple lines from standard input, and renders it into a bitmap. In the bitmap, each line of input is a line of output. Formatting characters such as newline have no effect on the formatting; like any unprintable character, they turn into spaces. The bitmap is just wide enough for the longest line of text, plus margins, and just high enough to contain the lines of text, plus margins. The left and right margins are twice the width of the widest character in the font; the top and bottom margins are the height of the tallest character in the font. But if the text is only one line, all the margins are half of this. .IX text .SH OPTIONS .TP .BR -font , -builtin By default, pbmtext uses a built-in font called bdf (about a 10 point Times-Roman font). You can use a fixed width font by specifying .BR "-builtin fixed" . You can also specify your own font with the .B -font flag. The .I fontfile is either a BDF file from the X window system or a PBM file. If the .I fontfile is a PBM file, it is created in a very specific way. In your window system of choice, display the following text in the desired (fixed-width) font: .nf M ",/^_[`jpqy| M / !"#$%&'()*+ / < ,-./01234567 < > 89:;<=>?@ABC > @ DEFGHIJKLMNO @ _ PQRSTUVWXYZ[ _ { \\]^_`abcdefg { } hijklmnopqrs } ~ tuvwxyz{|}~ ~ M ",/^_[`jpqy| M .fi Do a screen grab or window dump of that text, using for instance .BR xwd , .BR xgrabsc , or .BR screendump . Convert the result into a pbm file. If necessary, use .B pnmcut to remove everything except the text. Finally, run it through .B pnmcrop .IX pnmcrop to make sure the edges are right up against the text. .B pbmtext can figure out the sizes and spacings from that. .TP .B -space \fIpixels Add .I pixels pixels of space between characters. This is in addition to whatever space surrounding characters is built into the font, which is usually enough to produce a reasonable string of text. .I pixels may be negative to crowd text together, but the author has not put much thought or testing into how this works in every possible case, so it might cause disastrous results. .TP -B -lspace \fIpixels Add .I pixels pixels of space between lines. This is in addition to whatever space above and below characters is built into the font, which is usually enough to produce a reasonable line spacing. .I pixels must be a whole number. .I pixels may be negative to crowd lines together, but the author has not put much thought or testing into how this works in every possible case, so it might cause disastrous results. .SH USAGE Often, you want to place text over another image. One way to do this is with .BR ppmlabel . .B ppmlabel does not give you the font options that .B pbmtext does, though. Another way is to use .B pbmtext to create an image containing the text, then use .B pnmcomp to overlay the text image onto your base image. To make only the text (and not the entire rectangle containing it) cover the base image, you will need to give .B pnmcomp a mask, via its .B -alpha option. You can just use the text image itself as the mask, as long as you also specify the .B -invert option to .BR pnmcomp . If you want to overlay colored text instead of black, just use .B ppmchange to change all black pixels to the color of your choice before overlaying the text image. But still use the original black and white image for the alpha mask. If you want the text at an angle, use .B pnmrotate on the text image (and alpha mask) before overlaying. .SH "SEE ALSO" .BR pnmcut (1), .BR pnmcrop (1), .BR pnmcomp (1), .BR ppmchange (1), .BR pnmrotate (1), .BR pbmtextps (1), .BR ppmlabel (1), .BR pbm (5) .SH AUTHOR Copyright (C) 1993 by Jef Poskanzer and George Phillips .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtext.c0100644004714500471450000004310607776237374016756 0ustar aba-guestaba-guest/* pbmtext.c - render text into a bitmap ** ** Copyright (C) 1991 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pbm.h" #include "pbmfont.h" struct cmdline_info { /* All the information the user supplied in the command line, in a form easy for the program to use. */ char *text; /* text from command line or NULL if none */ char *font; /* -font option value or NULL if none */ char *builtin; /* -builtin option value or NULL if none */ int dump; /* undocumented dump flag for installing a new built-in font */ float space; /* -space option value or default */ unsigned int width; /* future -width option value or zero */ int lspace; /* lspace option value or default */ }; static void parse_command_line(int argc, char ** argv, struct cmdline_info *cmdline_p) { /*---------------------------------------------------------------------------- Note that the file spec array we return is stored in the storage that was passed to us as the argv array. -----------------------------------------------------------------------------*/ optStruct *option_def = malloc(100*sizeof(optStruct)); /* Instructions to OptParseOptions2 on how to parse our options. */ optStruct2 opt; unsigned int option_def_index; option_def_index = 0; /* incremented by OPTENTRY */ OPTENTRY(0, "font", OPT_STRING, &cmdline_p->font, 0); OPTENTRY(0, "builtin", OPT_STRING, &cmdline_p->builtin, 0); OPTENTRY(0, "dump", OPT_UINT, &cmdline_p->dump, 0); OPTENTRY(0, "space", OPT_FLOAT, &cmdline_p->space, 0); OPTENTRY(0, "width", OPT_UINT, &cmdline_p->width, 0); OPTENTRY(0, "lspace", OPT_INT, &cmdline_p->lspace, 0); /* Set the defaults */ cmdline_p->font = NULL; cmdline_p->builtin = NULL; cmdline_p->dump = FALSE; cmdline_p->space = 0.0; cmdline_p->width = 0; cmdline_p->lspace = 0; opt.opt_table = option_def; opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */ opt.allowNegNum = FALSE; /* We have no parms that are negative numbers */ pm_optParseOptions2(&argc, argv, opt, 0); /* Uses and sets argc, argv, and some of *cmdline_p and others. */ if (argc-1 == 0) cmdline_p->text = NULL; else { int i; int totaltextsize; totaltextsize = 1; /* initial value */ cmdline_p->text = malloc(totaltextsize); cmdline_p->text[0] = '\0'; for (i = 1; i < argc; i++) { if (i > 1) { overflow_add(totaltextsize, 1); totaltextsize += 1; cmdline_p->text = realloc(cmdline_p->text, totaltextsize); if (cmdline_p->text == NULL) pm_error("out of memory"); strcat(cmdline_p->text, " "); } overflow_add(totaltextsize, strlen(argv[i])); totaltextsize += strlen(argv[i]); cmdline_p->text = realloc(cmdline_p->text, totaltextsize); if (cmdline_p->text == NULL) pm_error("out of memory"); strcat(cmdline_p->text, argv[i]); } } } static void fix_control_chars(char * const buf, struct font * const fn) { int i; /* chop off terminating newline */ if (strlen(buf) >= 1 && buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = '\0'; for ( i = 0; buf[i] != '\0'; ++i ) { if ( buf[i] == '\t' ) { /* Turn tabs into the right number of spaces. */ int j, n, l; n = ( i + 8 ) / 8 * 8; l = strlen( buf ); for ( j = l; j > i; --j ) buf[j + n - i - 1] = buf[j]; for ( ; i < n; ++i ) buf[i] = ' '; --i; } else if ( !fn->glyph[(unsigned char)buf[i]] ) /* Turn unknown chars into a single space. */ buf[i] = ' '; } } static void fill_rect(bit** const bits, int const row0, int const col0, int const height, int const width, bit const color) { int row; for (row = row0; row < row0 + height; ++row) { int col; for (col = col0; col < col0 + width; ++col) bits[row][col] = color; } } static void get_line_dimensions(const char line[], const struct font * const font_p, const float intercharacter_space, int * const bwid_p, int * const backup_space_needed_p) { /*---------------------------------------------------------------------------- Determine the width in pixels of the line of text line[] in the font *font_p, and return it as *bwid_p. Also determine how much of this width goes to the left of the nominal starting point of the line because the first character in the line has a "backup" distance. Return that as *backup_space_needed_p. -----------------------------------------------------------------------------*/ int cursor; /* cursor into the line of text */ unsigned char lastch; /* line[cursor] */ float accumulated_ics; /* accumulated intercharacter space so far in the line we are stepping through. Because the intercharacter space might not be an integer, we accumulate it here and realize full pixels whenever we have more than one pixel. */ int no_chars_yet; /* logical: we haven't seen any renderable characters yet in the line. */ no_chars_yet = TRUE; /* initial value */ *bwid_p = 0; /* initial value */ accumulated_ics = 0.0; /* initial value */ for (cursor = 0; line[cursor] != '\0'; cursor++) { lastch = line[cursor]; if (font_p->glyph[(unsigned char)lastch]) { if (no_chars_yet) { no_chars_yet = FALSE; if (font_p->glyph[lastch]->x < 0) *backup_space_needed_p = -font_p->glyph[lastch]->x; else { *backup_space_needed_p = 0; *bwid_p += font_p->glyph[lastch]->x; } } else { /* handle extra intercharacter space (-space option) */ int full_pixels; /* integer part of accumulated_ics */ accumulated_ics += intercharacter_space; full_pixels = (int) accumulated_ics; if (full_pixels > 0) { *bwid_p += full_pixels; accumulated_ics -= full_pixels; } } *bwid_p += font_p->glyph[lastch]->xadd; } } if (no_chars_yet) /* Line has no renderable characters */ *backup_space_needed_p = 0; else { /* Line has at least one renderable character. Recalculate width of last character in line so it ends right at the right edge of the glyph (no extra space to anticipate another character). */ *bwid_p -= font_p->glyph[lastch]->xadd; *bwid_p += font_p->glyph[lastch]->width + font_p->glyph[lastch]->x; } } static void insert_character(const struct glyph * const glyph, const int toprow, const int leftcol, bit ** const bits) { /*---------------------------------------------------------------------------- Insert one character (whose glyph is 'glyph') into the image bits[]. Its top left corner shall be row 'toprow', column 'leftcol'. -----------------------------------------------------------------------------*/ int glyph_y, glyph_x; /* position within the glyph */ for (glyph_y = 0; glyph_y < glyph->height; glyph_y++) { for (glyph_x = 0; glyph_x < glyph->width; glyph_x++) { if (glyph->bmap[glyph_y * glyph->width + glyph_x]) bits[toprow+glyph_y][leftcol+glyph->x+glyph_x] = PBM_BLACK; } } } static void insert_characters(bit ** const bits, const char ** const lp, const int lines, struct font *font_p, const int topmargin, const int leftmargin, const float intercharacter_space, const int lspace) { /*---------------------------------------------------------------------------- Put the lines of text 'lp' (array of 'lines' strings) into the image 'bits' using font *font_p and putting 'intercharacter_space' pixels between characters and 'lspace' pixels between the lines. -----------------------------------------------------------------------------*/ int line; /* Line number in input text */ for ( line = 0; line < lines; ++line ) { int row; /* row in image of top of current typeline */ int leftcol; /* Column in image of left edge of current glyph */ int cursor; /* cursor into a line of input text */ float accumulated_ics; /* accumulated intercharacter space so far in the line we are building. Because the intercharacter space might not be an integer, we accumulate it here and realize full pixels whenever we have more than one pixel. */ row = topmargin + line * (font_p->maxheight + lspace); leftcol = leftmargin; accumulated_ics = 0.0; /* initial value */ for ( cursor = 0; lp[line][cursor] != '\0'; ++cursor ) { struct glyph* glyph; /* the glyph for this character */ glyph = font_p->glyph[(unsigned char)lp[line][cursor]]; if (glyph != NULL) { const int toprow = row + font_p->maxheight + font_p->y - glyph->height - glyph->y; /* row number in image of top row in glyph */ insert_character(glyph, toprow, leftcol, bits); leftcol += glyph->xadd; { /* handle extra intercharacter space (-space option) */ int full_pixels; /* integer part of accumulated_ics */ accumulated_ics += intercharacter_space; full_pixels = (int) accumulated_ics; if (full_pixels > 0) { leftcol += full_pixels; accumulated_ics -= full_pixels; } } } } } } static void flow_text(char **lp[], const char input_text[], int *linesP, const int width, struct font * const font_p, const float intercharacter_space) { /* under construction */ *lp[0] = "not implemented"; *linesP = 1; } static void truncate_text(char **lp[], const char *input_text[], const int lines, const int width, struct font * const font_p, const float intercharacter_space) { /* under construction */ int line; /* Line number on which we are currently working */ *lp[0] = "not implemented"; for (line = 0; line < lines; line++){ int cursor; /* cursor into the line of text */ unsigned char lastch; /* line[cursor] */ int width_so_far; /* How long the line we've built, in pixels, is so far */ float accumulated_ics; /* accumulated intercharacter space so far in the line we are stepping through. Because the intercharacter space might not be an integer, we accumulate it here and realize full pixels whenever we have more than one pixel. */ int no_chars_yet; /* logical: we haven't seen any renderable characters yet in the line. */ no_chars_yet = TRUE; /* initial value */ width_so_far = 0; /* initial value */ accumulated_ics = 0.0; /* initial value */ for (cursor = 0; input_text[line][cursor] != '\0' && width_so_far < width; cursor++) { lastch = input_text[line][cursor]; if (font_p->glyph[(unsigned char)lastch]) { if (no_chars_yet) { no_chars_yet = FALSE; if (font_p->glyph[lastch]->x > 0) width_so_far += font_p->glyph[lastch]->x; } else { /* handle extra intercharacter space (-space option) */ int full_pixels; /* integer part of accumulated_ics */ accumulated_ics += intercharacter_space; full_pixels = (int) intercharacter_space; if (full_pixels > 0) { width_so_far += full_pixels; accumulated_ics -= full_pixels; } } width_so_far += font_p->glyph[lastch]->xadd; } if (width_so_far < width) { /* not implemented yet lp[line][cursor] = input_text[line][cursor]; lp[line][cursor+1] = '\0'; */ } } } } static void get_text(const char cmdline_text[], struct font * const fn, char *** const input_textP, int * linesP) { int maxlines; /* Maximum number of lines for which we presently have space in the text array */ maxlines = 50; /* initial value */ *input_textP = (char**) malloc2(maxlines, sizeof(char*)); if (*input_textP == NULL) pm_error("out of memory"); if (cmdline_text) { overflow_add(strlen(cmdline_text), 1); (*input_textP)[0] = malloc(strlen(cmdline_text)+1); if ((*input_textP)[0] == NULL) pm_error("Out of memory."); strcpy((*input_textP)[0], cmdline_text); fix_control_chars((*input_textP)[0], fn); *linesP = 1; } else { /* Read text from stdin. */ char buf[5000]; *linesP = 0; /* initial value */ while (fgets(buf, sizeof(buf), stdin) != NULL) { fix_control_chars(buf, fn); if (*linesP >= maxlines) { overflow2(maxlines, 2); maxlines *= 2; overflow2(maxlines, sizeof(char *)); *input_textP = (char**) realloc((char*) *input_textP, maxlines * sizeof(char*)); if(*input_textP == NULL) pm_error( "out of memory" ); } (*input_textP)[*linesP] = (char*) malloc(strlen(buf) + 1); if ((*input_textP)[*linesP] == NULL) pm_error( "out of memory" ); strcpy((*input_textP)[*linesP], buf); ++(*linesP); } } } static void compute_image_width(char ** const lp, const int lines, const struct font * const fn, const float intercharacter_space, int * const maxwidthP, int * maxleftbP) { int line; *maxwidthP = 0; /* initial value */ *maxleftbP = 0; /* initial value */ for (line = 0; line < lines; ++line) { int bwid, backup_space_needed; get_line_dimensions(lp[line], fn, intercharacter_space, &bwid, &backup_space_needed); *maxwidthP = max(*maxwidthP, bwid); *maxleftbP = max(*maxleftbP, backup_space_needed); } } int main(int argc, char *argv[]) { struct cmdline_info cmdline; bit** bits; int rows, cols; struct font* fn; int vmargin, hmargin; char** input_text; char** lp; int lines; int maxwidth; /* width in pixels of the longest line of text in the image */ int maxleftb; pbm_init( &argc, argv ); parse_command_line(argc, argv, &cmdline); if (cmdline.font) fn = pbm_loadfont(cmdline.font); else { if (cmdline.builtin) fn = pbm_defaultfont(cmdline.builtin); else fn = pbm_defaultfont("bdf"); } if (cmdline.dump) { pbm_dumpfont(fn); exit(0); } get_text(cmdline.text, fn, &input_text, &lines); if (lines == 1) { vmargin = fn->maxheight / 2; hmargin = fn->maxwidth; } else { vmargin = fn->maxheight; overflow2(2, fn->maxwidth); hmargin = 2 * fn->maxwidth; } if (cmdline.width > 0) { /* Flow or truncate lines to meet user's width request */ /* Not actually implemented yet. */ if (lines == 1) flow_text(&lp, input_text[0], &lines, cmdline.width, fn, cmdline.space); else truncate_text(&lp, (const char **) input_text, lines, cmdline.width, fn, cmdline.space); } else lp = input_text; overflow2(2, vmargin); overflow2(lines, fn->maxheight); overflow_add(vmargin * 2, lines * fn->maxheight); rows = 2 * vmargin + lines * fn->maxheight + (lines-1) * cmdline.lspace; compute_image_width(lp, lines, fn, cmdline.space, &maxwidth, &maxleftb); overflow2(2, hmargin); overflow_add(2*hmargin, maxwidth); cols = 2 * hmargin + maxwidth; bits = pbm_allocarray(cols, rows); /* Fill background with white */ fill_rect(bits, 0, 0, rows, cols, PBM_WHITE); /* Put the text in */ insert_characters(bits, (const char **) lp, lines, fn, vmargin, hmargin + maxleftb, cmdline.space, cmdline.lspace); /* All done. */ pbm_writepbm(stdout, bits, cols, rows, 0); pm_close(stdout); exit(0); } netpbm-free-10.0-1/pbm/pbmtextps.10100644004714500471450000000430607776237374017236 0ustar aba-guestaba-guest.TH pbmtextps 1 "02 January 2003" .IX pbmtextps .SH NAME pbmtextps - render text into a bitmap via postscript .SH SYNOPSIS .B pbmtextps .RB [ \-font .IR fontfile ] .RB [ \-fontsize .IR fontsize ] .RB [ \-resolution .IR resolution ] .RB [ \-stroke .IR strokesize ] .RB [ \-verbose .RI [ text ] .SH DESCRIPTION .PP .B pbmtextps takes a single line of text from the command line and renders it into a PBM image. The image is cropped at the top and the right. It is not cropped at the left or bottom so that the text begins at the same position relative to the origin. You can use .B pnmcrop to crop it all the way. .SH OPTIONS .TP .BR -font By default, .B pbmtextps uses TimesRoman. You can specify the font to use with the .B -font option. This is the name of any valid postscript font which is installed on your system. .TP .BR -fontsize Size of font in points. See the .B -resolution option for information on how to interpret this size. Default is 24 points. .TP .BR -resolution Resolution in dots per inch of distance measurements pertaining to generation of the image. PBM images don't have any inherent resolution, so a distance such as "1 inch" doesn't mean anything unless you separately specify what resolution you're talking about. That's what this option does. In particular, the meaning of the font size is determined by this resolution. If the font size is 24 points and the resolution is 150 dpi, then the font size is 50 pixels. Default is 150 dpi. .TP .BR -stroke Width of line to use for stroke font. There is no default stroke width because the letters are solid by default. .SH USAGE See .B pbmtext for usage examples. .SH "SEE ALSO" .BR pbmtext (1), .BR pnmcut (1), .BR pnmcrop (1), .BR pnmcomp (1), .BR ppmchange (1), .BR pnmrotate (1), .BR ppmlabel (1), .BR pbm (5) .SH AUTHOR Copyright (C) 2002 by James McCann .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtextps.c0100644004714500471450000001732507776237374017325 0ustar aba-guestaba-guest/* * pbmtextps.c - render text into a bitmap using a postscript interpreter * * Copyright (C) 2002 by James McCann. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation. This software is provided "as is" without express or * implied warranty. * * PostScript is a registered trademark of Adobe Systems International. * */ #include #include #include #include "pbm.h" #define FILENAME_LEN 200 static FILE *psfile = 0; char psfname[FILENAME_LEN]; static FILE *pbmfile = 0; char pbmfname[FILENAME_LEN]; #define BUFFER_SIZE 2048 const char *gs_exe_path = #ifdef GHOSTSCRIPT_EXECUTABLE_PATH GHOSTSCRIPT_EXECUTABLE_PATH; #else 0; #endif const char *pnmcrop_exe_path = #ifdef PNMCROP_EXECUTABLE_PATH PNMCROP_EXECUTABLE_PATH; #else 0; #endif static struct cmdlineInfo { /* All the information the user supplied in the command line, in a form easy for the program to use. */ int res; /* resolution, DPI */ int fontsize; /* Size of font in points */ char *font; /* Name of postscript font */ float stroke; /* Width of stroke in points (only for outline font) */ unsigned int verbose; char *text; } cmdline; static void parseCommandLine(int argc, char ** argv, struct cmdlineInfo *cmdlineP) { /*--------------------------------------------------------------------------- Note that the file spec array we return is stored in the storage that was passed to us as the argv array. -------------------------------------------------------------------------*/ optEntry *option_def = malloc(100*sizeof(optStruct)); /* Instructions to OptParseOptions2 on how to parse our options. */ optStruct3 opt; unsigned int option_def_index; int i; int totaltextsize = 0; option_def_index = 0; /* incremented by OPTENTRY */ OPTENT3(0, "resolution", OPT_INT, &cmdlineP->res, NULL, 0); OPTENT3(0, "font", OPT_STRING, &cmdlineP->font, NULL, 0); OPTENT3(0, "fontsize", OPT_INT, &cmdlineP->fontsize, NULL, 0); OPTENT3(0, "stroke", OPT_FLOAT, &cmdlineP->stroke, NULL, 0); OPTENT3(0, "verbose", OPT_FLAG, NULL, &cmdlineP->verbose, 0); /* Set the defaults */ cmdlineP->res = 150; cmdlineP->fontsize = 24; cmdlineP->font = "Times-Roman"; cmdlineP->stroke = -1; cmdlineP->text = NULL; opt.opt_table = option_def; opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */ opt.allowNegNum = FALSE; pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0); for (i = 1; i < argc; i++) { if (i > 1) { totaltextsize += 1; cmdlineP->text = realloc(cmdlineP->text, totaltextsize); if (cmdlineP->text == NULL) pm_error("out of memory"); strcat(cmdlineP->text, " "); } totaltextsize += strlen(argv[i]); cmdlineP->text = realloc(cmdlineP->text, totaltextsize); if (cmdlineP->text == NULL) pm_error("out of memory"); strcat(cmdlineP->text, argv[i]); } } static char * construct_postscript(struct cmdlineInfo *cmdl) { int size = 100; char *buffer = malloc (size); int nchars; const char *template; if(cmdl->stroke <= 0) { template ="/%s findfont\n%d scalefont\nsetfont\n12 36 moveto\n" "(%s) show\nshowpage\n"; } else { template ="/%s findfont\n%d scalefont\nsetfont\n12 36 moveto\n" "%f setlinewidth\n0 setgray\n" "(%s) true charpath\nstroke\nshowpage\n"; } nchars = snprintf (buffer, size, template, cmdl->font, cmdl->fontsize, cmdl->text); if (nchars >= size) { if(!(buffer = realloc (buffer, nchars + 1))) pm_error("Can't allocate buffer for postscript string"); } if(cmdl->stroke < 0) snprintf (buffer, nchars, template, cmdl->font, cmdl->fontsize, cmdl->text); else snprintf (buffer, nchars, template, cmdl->font, cmdl->fontsize, cmdl->stroke, cmdl->text); return buffer; } static const char * gs_executable_name() { static char buffer[BUFFER_SIZE]; if(! gs_exe_path) { char *which = "which gs"; FILE *f; memset(buffer, 0, BUFFER_SIZE); if(!(f = popen(which, "r"))) pm_error("Can't find ghostscript"); fread(buffer, 1, BUFFER_SIZE, f); if(buffer[strlen(buffer) - 1] == '\n') buffer[strlen(buffer) - 1] = 0; pclose(f); if(buffer[0] != '/' && buffer[0] != '.') pm_error("Can't find ghostscript"); } else strcpy(buffer, gs_exe_path); return buffer; } static const char * crop_executable_name() { static char buffer[BUFFER_SIZE]; if(! pnmcrop_exe_path) { char *which = "which pnmcrop"; FILE *f; memset(buffer, 0, BUFFER_SIZE); if(!(f = popen(which, "r"))) { return 0; } fread(buffer, 1, BUFFER_SIZE, f); if(buffer[strlen(buffer) - 1] == '\n') buffer[strlen(buffer) - 1] = 0; pclose(f); if(buffer[0] != '/' && buffer[0] != '.') { buffer[0] = 0; pm_message("Can't find pnmcrop"); } } else strcpy(buffer, pnmcrop_exe_path); return buffer; } static char * gs_command(struct cmdlineInfo *cmdl) { static char com[BUFFER_SIZE]; int x = cmdl->res * 11; int y = cmdl->res * (cmdl->fontsize * 2 + 72) / 72.; snprintf(com, BUFFER_SIZE, "%s -g%dx%d -r%d -sDEVICE=pbm " "-sOutputFile=%s -q -dBATCH -dNOPAUSE %s /dev/null", gs_executable_name(), x, y, cmdl->res, pbmfname, psfname); return com; } static char * crop_command(void) { static char com[BUFFER_SIZE]; if(crop_executable_name()) snprintf(com, BUFFER_SIZE, "%s -top -right %s", crop_executable_name(), pbmfname); else return 0; return com; } static void cleanup(void) { if(psfile) { fclose(psfile); unlink(psfname); } if(pbmfile) { pm_close(pbmfile); unlink(pbmfname); } } static void create_outputfile(struct cmdlineInfo *cmdl) { char *ps; char *com; const char *template = "./pstextpbm.%d.tmp.%s"; FILE *pnmcrop; sprintf(psfname, template, getpid(), "ps"); if(! (psfile = fopen(psfname, "w"))) pm_error("Can't open temp file"); sprintf(pbmfname, template, getpid(), "pbm"); if(! (com = strdup(gs_command(cmdl)))) pm_error("Can't allocate ghostscript command"); ps = construct_postscript(cmdl); if (cmdl->verbose) pm_message("Postscript program = '%s'", ps); if(fwrite(ps, 1, strlen(ps), psfile) != strlen(ps)) pm_error("Can't write postscript to temp file"); fclose(psfile); if (cmdl->verbose) pm_message("Running Postscript interpreter '%s'", com); if(system(com)) pm_error("Can't run ghostscript process"); free(com); pbmfile = pm_openw(pbmfname); com = crop_command(); if(com) { if (cmdl->verbose) pm_message("Running crop command '%s'", com); if(!(pnmcrop= popen(com, "r"))) pm_error("Can't run pnmcrop process"); else { char buf[2048]; int chars; while( (chars = fread(buf, 1, 2048, pnmcrop) ) == 2048) { if(fwrite(buf, 1, chars, stdout) != chars) pm_error("Can't write to stdout"); } if(chars < 0) pm_error("Can't read from pbm file"); if(chars > 0) if(fwrite(buf, 1, chars, stdout) != chars) pm_error("Can't write to stdout"); fclose(pnmcrop); } } else /* If the crop command can't be found warn and keep going */ pm_message("Can't find pnmcrop command, image will be large"); } int main(int argc, char *argv[]) { pbm_init( &argc, argv ); parseCommandLine(argc, argv, &cmdline); atexit(cleanup); create_outputfile(&cmdline); exit(0); } netpbm-free-10.0-1/pbm/pbmto10x.10100644004714500471450000000212507716230207016635 0ustar aba-guestaba-guest.TH pbmto10x 1 "1 January 1990" .IX pbmto10x .SH NAME pbmto10x - convert a portable bitmap into Gemini 10X printer graphics .SH SYNOPSIS .B pbmto10x .RB [ -h ] .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces a file of Gemini 10X printer graphics as output. .IX "Gemini 10X printer graphics" The 10x's printer codes are alleged to be similar to the Epson codes. .IX Epson .PP Note that there is no 10xtopbm tool - this transformation is one way. .SH OPTIONS .PP The resolution is normally 60H by 72V. If the .B -h flag is specified, resolution is 120H by 144V. You may find it useful to rotate landscape images before printing. .SH "SEE ALSO" pbm(5) .SH AUTHOR Copyright (C) 1990 by Ken Yap .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmto10x.c0100644004714500471450000000712407716230207016723 0ustar aba-guestaba-guest/* pbmto10x.c - read a portable bitmap and produce a Gemini 10X printer file ** ** Copyright (C) 1990, 1994 by Ken Yap ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. ** ** Modified to shorten stripes and eliminate blank stripes. Dec 1994. */ #include "pbm.h" #define LOW_RES_ROWS 8 /* printed per pass */ #define HIGH_RES_ROWS 16 /* printed per pass */ static void res_60x72 ARGS(( void )); static void res_120x144 ARGS(( void )); static int highres = 0; static FILE *ifp; static int rows, cols, format; int main(argc, argv) int argc; char *argv[]; { pbm_init( &argc, argv ); if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'h') { highres = 1; --argc; ++argv; } if (argc > 2) pm_usage("[pbmfile]"); if (argc == 2) ifp = pm_openr(argv[1]); else ifp = stdin; pbm_readpbminit(ifp, &cols, &rows, &format); if (highres) res_120x144(); else res_60x72(); pm_close(ifp); return 0; } static void outstripe(stripe, sP, reschar) register char *stripe, *sP; register int reschar; { register int ncols; /* scan backwards, removing empty columns */ while (sP != stripe) if (*--sP != 0) { ++sP; break; } ncols = sP - stripe; if (ncols > 0) { printf("\033%c%c%c", reschar, ncols % 256, ncols / 256); fwrite(stripe, sizeof(char), ncols, stdout); } putchar('\n'); /* flush buffer */ } static void res_60x72() { register int i, item, npins, row, col; bit *bitrows[LOW_RES_ROWS], *bP[LOW_RES_ROWS]; char *stripe, *sP; stripe = malloc(cols); if(stripe == NULL) pm_error("out of memory"); for (i = 0; i < LOW_RES_ROWS; ++i) bitrows[i] = pbm_allocrow(cols); printf("\033A\010"); /* '\n' = 8/72 */ for (row = 0, sP = stripe; row < rows; row += LOW_RES_ROWS, sP = stripe) { if (row + LOW_RES_ROWS <= rows) npins = LOW_RES_ROWS; else npins = rows - row; for (i = 0; i < npins; ++i) pbm_readpbmrow(ifp, bP[i] = bitrows[i], cols, format); for (col = 0; col < cols; ++col) { item = 0; for (i = 0; i < npins; ++i) if (*(bP[i]++) == PBM_BLACK) item |= 1 << (7 - i); *sP++ = item; } outstripe(stripe, sP, 'K'); } printf("\033@"); free(stripe); } static void res_120x144() { register int i, pin, item, npins, row, col; bit *bitrows[HIGH_RES_ROWS], *bP[HIGH_RES_ROWS]; char *stripe, *sP; stripe = malloc(cols); if(stripe == NULL) pm_error("out of memory"); for (i = 0; i < HIGH_RES_ROWS; ++i) bitrows[i] = pbm_allocrow(cols); printf("\0333\001"); /* \n = 1/144" */ for (row = 0, sP = stripe; row < rows; row += HIGH_RES_ROWS, sP = stripe) { if (row + HIGH_RES_ROWS <= rows) npins = HIGH_RES_ROWS; else npins = rows - row; for (i = 0; i < npins; ++i) pbm_readpbmrow(ifp, bP[i] = bitrows[i], cols, format); for (col = 0; col < cols; ++col) { item = 0; /* even rows */ for (pin = i = 0; i < npins; i += 2, ++pin) if (*(bP[i]++) == PBM_BLACK) item |= 1 << (7 - pin); *sP++ = item; } outstripe(stripe, sP, 'L'); sP = stripe; for (col = 0; col < cols; ++col) { item = 0; /* odd rows */ for (i = 1, pin = 0; i < npins; i += 2, ++pin) if (*(bP[i]++) == PBM_BLACK) item |= 1 << (7 - pin); *sP++ = item; } outstripe(stripe, sP, 'L'); printf("\033J\016"); /* 14/144 down, \n did 1/144 */ } printf("\033@"); free(stripe); } netpbm-free-10.0-1/pbm/pbmtoascii.10100644004714500471450000000265007716230207017320 0ustar aba-guestaba-guest.TH pbmtoascii 1 "20 March 1992" .SH NAME pbmtoascii - convert a portable bitmap into ASCII graphics .SH SYNOPSIS .B pbmtoascii .RB [ -1x2 | -2x4 ] .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces a somewhat crude ASCII graphic as output. .PP Note that there is no asciitopbm tool - this transformation is one-way. .SH OPTIONS The .B -1x2 and .B -2x4 flags give you two alternate ways for the bits to get mapped to characters. With .BR 1x2 , the default, each character represents a group of 1 bit across by 2 bits down. With .BR -2x4 , each character represents 2 bits across by 4 bits down. With the 1x2 mode you can see the individual bits, so it's useful for previewing small bitmaps on a non-graphics terminal. The 2x4 mode lets you display larger bitmaps on a standard 80-column display, but it obscures bit-level details. 2x4 mode is also good for displaying graymaps - "pnmscale -width 158 | pgmnorm | pgmtopbm -thresh" should give good results. .SH "SEE ALSO" pbm(5) .SH AUTHOR Copyright (C) 1988, 1992 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtoascii.c0100644004714500471450000001122707716230207017402 0ustar aba-guestaba-guest/* pbmtoascii.c - read a portable bitmap and produce ASCII graphics ** ** Copyright (C) 1988, 1992 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #define SQQ '\'' #define BSQ '\\' /* Bit-map for 1x2 mode: ** 1 ** 2 */ static char carr1x2[4] = { /* 0 1 2 3 */ ' ', '"', 'o', 'M' }; /* Bit-map for 2x4 mode (hex): ** 1 2 ** 4 8 ** 10 20 ** 40 80 ** The idea here is first to preserve geometry, then to show density. */ #define D08 'M' #define D07 'H' #define D06 '&' #define D05 '$' #define D04 '?' static char carr2x4[256] = { /*0 1 2 3 4 5 6 7 8 9 A B C D E F */ ' ',SQQ, '`','"', '-',SQQ, SQQ,SQQ, '-','`', '`','`', '-','^', '^','"',/*00-0F*/ '.',':', ':',':', '|','|', '/',D04, '/','>', '/','>', '~','+', '/','*',/*10-1F*/ '.',':', ':',':', BSQ,BSQ, '<','<', '|',BSQ, '|',D04, '~',BSQ, '+','*',/*20-2F*/ '-',':', ':',':', '~',D04, '<','<', '~','>', D04,'>', '=','b', 'd','#',/*30-3F*/ '.',':', ':',':', ':','!', '/',D04, ':',':', '/',D04, ':',D04, D04,'P',/*40-4F*/ ',','i', '/',D04, '|','|', '|','T', '/',D04, '/','7', 'r','}', '/','P',/*50-5F*/ ',',':', ';',D04, '>',D04, 'S','S', '/',')', '|','7', '>',D05, D05,D06,/*60-6F*/ 'v',D04, D04,D05, '+','}', D05,'F', '/',D05, '/',D06, 'p','D', D06,D07,/*70-7F*/ '.',':', ':',':', ':',BSQ, ':',D04, ':',BSQ, '!',D04, ':',D04, D04,D05,/*80-8F*/ BSQ,BSQ, ':',D04, BSQ,'|', '(',D05, '<','%', D04,'Z', '<',D05, D05,D06,/*90-9F*/ ',',BSQ, 'i',D04, BSQ,BSQ, D04,BSQ, '|','|', '|','T', D04,BSQ, '4','9',/*A0-AF*/ 'v',D04, D04,D05, BSQ,BSQ, D05,D06, '+',D05, '{',D06, 'q',D06, D06,D07,/*B0-BF*/ '_',':', ':',D04, ':',D04, D04,D05, ':',D04, D04,D05, ':',D05, D05,D06,/*C0-CF*/ BSQ,D04, D04,D05, D04,'L', D05,'[', '<','Z', '/','Z', 'c','k', D06,'R',/*D0-DF*/ ',',D04, D04,D05, '>',BSQ, 'S','S', D04,D05, 'J',']', '>',D06, '1','9',/*E0-EF*/ 'o','b', 'd',D06, 'b','b', D06,'6', 'd',D06, 'd',D07, '#',D07, D07,D08 /*F0-FF*/ }; int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; int argn, gridx, gridy, rows, cols, format; int ccols, lastcol, row, subrow, subcol; register int col, b; bit* bitrow; register bit* bP; int* sig; register int* sP; char* line; register char* lP; char* carr; char* usage = "[-1x2|-2x4] [pbmfile]"; pbm_init( &argc, argv ); /* Set up default parameters. */ argn = 1; gridx = 1; gridy = 2; carr = carr1x2; /* Check for flags. */ while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( pm_keymatch( argv[argn], "-1x2", 2 ) ) { gridx = 1; gridy = 2; carr = carr1x2; } else if ( pm_keymatch( argv[argn], "-2x4", 2 ) ) { gridx = 2; gridy = 4; carr = carr2x4; } else pm_usage( usage ); ++argn; } if ( argn < argc ) { ifp = pm_openr( argv[argn] ); ++argn; } else ifp = stdin; if ( argn != argc ) pm_usage( usage ); pbm_readpbminit( ifp, &cols, &rows, &format ); overflow_add(cols, gridx); ccols = ( cols + gridx - 1 ) / gridx; bitrow = pbm_allocrow( cols ); sig = (int*) pm_allocrow( ccols, sizeof(int) ); overflow_add(ccols, 1); line = (char*) pm_allocrow( ccols + 1, sizeof(char) ); for ( row = 0; row < rows; row += gridy ) { /* Get a character-row's worth of sigs. */ for ( col = 0; col < ccols; ++col ) sig[col] = 0; b = 1; for ( subrow = 0; subrow < gridy; ++subrow ) { if ( row + subrow < rows ) { pbm_readpbmrow( ifp, bitrow, cols, format ); for ( subcol = 0; subcol < gridx; ++subcol ) { for ( col = subcol, bP = &(bitrow[subcol]), sP = sig; col < cols; col += gridx, bP += gridx, ++sP ) if ( *bP == PBM_BLACK ) *sP |= b; b <<= 1; } } } /* Ok, now remove trailing blanks. */ for ( lastcol = ccols - 1; lastcol >= 0; --lastcol ) if ( carr[sig[lastcol]] != ' ' ) break; /* Copy chars to an array and print. */ for ( col = 0, sP = sig, lP = line; col <= lastcol; ++col, ++sP, ++lP ) *lP = carr[*sP]; *lP++ = '\0'; puts( line ); } pm_close( ifp ); pbm_freerow( bitrow ); pm_freerow( (char*) sig ); pm_freerow( (char*) line ); /* If the program failed, it previously aborted with nonzero completion code, via various function calls. */ return 0; } netpbm-free-10.0-1/pbm/pbmtoatk.10100644004714500471450000000140707716230207017006 0ustar aba-guestaba-guest.TH pbmtoatk 1 "26 September 1991" .IX pbmtoatk .SH NAME pbmtoatk - convert portable bitmap to Andrew Toolkit raster object .SH SYNOPSIS .B pbmtoatk .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces a Andrew Toolkit raster object as output. .IX "Andrew Toolkit raster object" .SH "SEE ALSO" atktopbm(1), pbm(5) .SH AUTHOR Copyright (C) 1991 by Bill Janssen. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtoatk.c0100644004714500471450000001071407716230207017071 0ustar aba-guestaba-guest/* pbmtoatk.c - convert portable bitmap to Andrew Toolkit raster object ** ** Copyright (C) 1991 by Bill Janssen. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include #include "pbm.h" static void process_atk_byte ARGS((int *pcurcount, unsigned char *pcurbyte, FILE *file, unsigned char newbyte, int eolflag)); static void write_atk_bytes ARGS((FILE *file, unsigned char curbyte, unsigned int curcount)); #define DEFAULTSCALE (1<<16) #define RASTERVERSION 2 #define TRUE 1 #define FALSE 0 int main( argc, argv ) int argc; char *argv[]; { FILE *ifd; bit *bitrow; register bit *bP; int rows, cols, format, padright, row; register int col; char name[100], *cp; unsigned char curbyte, newbyte; int curcount, gather; pbm_init ( &argc, argv ); if ( argc > 2 ) pm_usage( "[pbmfile]" ); if ( argc == 2 ) { ifd = pm_openr( argv[1] ); strcpy( name, argv[1] ); if ( strcmp( name, "-" ) == 0 ) strcpy( name, "noname" ); if ( ( cp = strchr( name, '.' ) ) != 0 ) *cp = '\0'; } else { ifd = stdin; strcpy( name, "noname" ); } pbm_readpbminit( ifd, &cols, &rows, &format ); bitrow = pbm_allocrow( cols ); /* Compute padding to round cols up to the nearest multiple of 16. */ overflow_add(cols, 15); padright = ( ( cols + 15 ) / 16 ) * 16 - cols; printf ("\\begindata{raster,%d}\n", 1); printf ("%d %d %d %d ", RASTERVERSION, 0, DEFAULTSCALE, DEFAULTSCALE); printf ("%d %d %d %d\n", 0, 0, cols, rows); /* subraster */ printf ("bits %d %d %d\n", 1, cols, rows); for ( row = 0; row < rows; row++ ) { pbm_readpbmrow( ifd, bitrow, cols, format ); bP = bitrow; gather = 0; newbyte = 0; curbyte = 0; curcount = 0; col = 0; while (col < cols) { if (gather > 7) { process_atk_byte (&curcount, &curbyte, stdout, newbyte, FALSE); gather = 0; newbyte = 0; } newbyte = (newbyte << 1) | (*bP++); gather += 1; col += 1; } if (gather > 0) { newbyte = (newbyte << (8 - gather)); process_atk_byte (&curcount, &curbyte, stdout, newbyte, TRUE); } } pm_close( ifd ); printf ("\\enddata{raster, %d}\n", 1); exit( 0 ); } static void write_atk_bytes (FILE *file, unsigned char curbyte, unsigned int curcount) { /* codes for data stream */ #define WHITEZERO 'f' #define WHITETWENTY 'z' #define BLACKZERO 'F' #define BLACKTWENTY 'Z' #define OTHERZERO 0x1F #define WHITEBYTE 0x00 #define BLACKBYTE 0xFF /* WriteRow table for conversion of a byte value to two character hex representation */ static unsigned char hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; switch (curbyte) { case WHITEBYTE: while (curcount > 20) fputc(WHITETWENTY, file), curcount -= 20; fputc(WHITEZERO + curcount, file); break; case BLACKBYTE: while (curcount > 20) fputc(BLACKTWENTY, file), curcount -= 20; fputc(BLACKZERO + curcount, file); break; default: while (curcount > 16) fputc(OTHERZERO+16, file), fputc(hex[curbyte / 16], file), fputc(hex[curbyte & 15], file), curcount -= 16; if (curcount > 1) fputc(OTHERZERO+curcount, file); else ; /* the byte written will represent a single instance */ fputc(hex[curbyte / 16], file); fputc(hex[curbyte & 15], file); } } static void process_atk_byte (int *pcurcount, unsigned char *pcurbyte, FILE *file, unsigned char newbyte, int eolflag) { int curcount = *pcurcount; unsigned char curbyte = *pcurbyte; if (curcount < 1) { *pcurbyte = curbyte = newbyte; *pcurcount = curcount = 1; } else if (newbyte == curbyte) { *pcurcount = (curcount += 1); } if (curcount > 0 && newbyte != curbyte) { write_atk_bytes (file, curbyte, curcount); *pcurcount = 1; *pcurbyte = newbyte; } if (eolflag) { write_atk_bytes (file, *pcurbyte, *pcurcount); fprintf (file, " |\n"); *pcurcount = 0; *pcurbyte = 0; } } netpbm-free-10.0-1/pbm/pbmtobbnbg.10100644004714500471450000000217007721162447017305 0ustar aba-guestaba-guest.TH pbmtobbnbg 1 "16 May 1989" .IX pbmtobbnbg .SH NAME pbmtobbnbg - convert a portable bitmap into BitGraph graphics .SH SYNOPSIS .B pbmtobbnbg .RI [ rasterop ] .RI [ x .IR y ] < .I pbmfile .SH DESCRIPTION Reads a portable bitmap as input. Produces BBN BitGraph terminal Display Pixel Data (DPD) sequence as output. .IX "BBN BitGraph" .PP The rasterop can be specified on the command line. If this is omitted, 3 (replace) will be used. A position in (x,y) coordinates can also be specified. If both are given, the rasterop comes first. The portable bitmap is always taken from the standard input. .PP Note that there is no bgtopbm tool. .PP This programm was initially named pbmtobg. .SH "SEE ALSO" pbm(5) .SH AUTHOR Copyright 1989 by Mike Parker. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtobbnbg.c0100644004714500471450000000560407716230207017366 0ustar aba-guestaba-guest/* pbmtobg.c - read a portable bitmap and produce BitGraph graphics ** ** Copyright 1989 by Mike Parker. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ /* ** Changed to take advantage of negative Packed Pixed Data values and ** supply ANSI-standard string terminator. Paul Milazzo, 28 May 1990. */ #include "pbm.h" static void write16 ARGS(( unsigned int )); static int nco; int main(argc,argv) int argc; char **argv; { int rows; int cols; int format; bit *bitrow; int row; unsigned int sixteen; int i; unsigned int mask; int op; int x; int y; pbm_init( &argc, argv ); op = 3; switch (argc) { case 1: break; case 2: op = atoi(argv[1]); break; case 3: x = atoi(argv[1]); y = atoi(argv[2]); printf("\33:%d;%dm",x,y); break; case 4: op = atoi(argv[1]); x = atoi(argv[2]); y = atoi(argv[3]); printf("\33:%d;%dm",x,y); break; } nco = 0; pbm_readpbminit(stdin,&cols,&rows,&format); printf("\33P:%d;%d;%ds\n",op,cols,rows); bitrow = pbm_allocrow(cols); for (row=0;row>= 1; if (mask == 0) { mask = 0x8000; write16(sixteen); sixteen = 0; } } if (mask != 0x8000) { write16(sixteen); } } puts("\033\\"); exit(0); } #ifdef POSITIVE_VALUES_ONLY static void write16(sixteen) unsigned int sixteen; { if (nco > 75) { putchar('\n'); nco = 0; } if (sixteen & 0xfc00) { putchar(0100+(sixteen>>10)); nco ++; } if (sixteen & 0xfff0) { putchar(0100+((sixteen>>4)&0x3f)); nco ++; } putchar(060+(sixteen&0xf)); nco ++; } #else /* * This version of "write16" uses negative Packed Pixel Data values to * represent numbers in the range 0x7fff--0xffff; negative values will * require fewer characters as they approach the upper end of that range. */ static void write16 (word) unsigned int word; { int high; int mid; int low; int signChar; if (nco > 75) { putchar ('\n'); nco = 0; } if (word > 0x7fff) { word = (unsigned int) (0x10000L - (long) word); signChar = ' '; } else signChar = '0'; high = (word >> 10) + '@'; mid = ((word & 0x3f0) >> 4) + '@'; low = (word & 0xf) + signChar; if (high != '@') { printf ("%c%c%c", high, mid, low); nco += 3; } else if (mid != '@') { printf ("%c%c", mid, low); nco += 2; } else { putchar (low); nco++; } } #endif netpbm-free-10.0-1/pbm/pbmtocmuwm.10100644004714500471450000000141307716230207017354 0ustar aba-guestaba-guest.TH pbmtocmuwm 1 "15 April 1989" .IX pbmtocmuwm .SH NAME pbmtocmuwm - convert a portable bitmap into a CMU window manager bitmap .SH SYNOPSIS .B pbmtocmuwm .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces a CMU window manager bitmap as output. .IX "CMU window manager bitmap" .SH "SEE ALSO" cmuwmtopbm(1), pbm(5) .SH AUTHOR Copyright (C) 1989 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtocmuwm.c0100644004714500471450000000474307716230207017447 0ustar aba-guestaba-guest/* pbmtocmuwm.c - read a portable bitmap and produce a CMU window manager bitmap ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #include "cmuwm.h" static void putinit ARGS(( int rows, int cols )); static void putbit ARGS(( bit b )); static void putrest ARGS(( void )); static void putitem ARGS(( void )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int rows, cols, format, padright, row, col; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[pbmfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; pbm_readpbminit( ifp, &cols, &rows, &format ); bitrow = pbm_allocrow( cols ); /* Round cols up to the nearest multiple of 8. */ overflow_add(cols, 7); padright = ( ( cols + 7 ) / 8 ) * 8 - cols; putinit( rows, cols ); for ( row = 0; row < rows; row++ ) { pbm_readpbmrow( ifp, bitrow, cols, format ); for ( col = 0, bP = bitrow; col < cols; col++, bP++ ) putbit( *bP ); for ( col = 0; col < padright; col++ ) putbit( 0 ); } pm_close( ifp ); putrest( ); exit( 0 ); } static unsigned char item; static int bitsperitem, bitshift; static void putinit( rows, cols ) int rows, cols; { if ( pm_writebiglong( stdout, CMUWM_MAGIC ) == -1 ) pm_error( "write error" ); if ( pm_writebiglong( stdout, cols ) == -1 ) pm_error( "write error" ); if ( pm_writebiglong( stdout, rows ) == -1 ) pm_error( "write error" ); if ( pm_writebigshort( stdout, (short) 1 ) == -1 ) pm_error( "write error" ); item = 0; bitsperitem = 0; bitshift = 7; } #if __STDC__ static void putbit( bit b ) #else /*__STDC__*/ static void putbit( b ) bit b; #endif /*__STDC__*/ { if ( bitsperitem == 8 ) putitem( ); if ( b == PBM_WHITE ) item += 1 << bitshift; bitsperitem++; bitshift--; } static void putrest( ) { if ( bitsperitem > 0 ) putitem( ); } static void putitem( ) { (void) putc( item, stdout ); item = 0; bitsperitem = 0; bitshift = 7; } netpbm-free-10.0-1/pbm/pbmtoepsi.10100644004714500471450000000235107716230207017166 0ustar aba-guestaba-guest.TH pbmtoepsi 1 "1992" .IX pbmtoepsi .SH NAME pbmtoepsi - convert a portable bitmap into an encapsulated PostScript style preview bitmap .SH SYNOPSIS .B pbmtoepsi .RB [ -bbonly ] .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produce an encapsulated Postscript style bitmap as output. The output is not a stand alone postscript file, it is only a preview bitmap, which can be included in an encapsulated PostScript file. Note that there is no epsitopbm tool - this transformation is one way. This utility is a part of the pstoepsi tool by Doug Crabill (dgc@cs.purdue.edu). .SH OPTIONS .TP .B -bbonly Only create a boundary box, don't fill it with the image. .SH "SEE ALSO" .BR pbm (5), .BR pnmtops (1), .BR pstopnm (1), .BR psidtopgm (1), .BR pbmtolps (1), .BR ps (1) .SH AUTHOR Copyright (C) 1988 Jef Poskanzer, modified by Doug Crabill 1992 .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtoepsi.c0100644004714500471450000000500207716230207017244 0ustar aba-guestaba-guest/* pbmtoepsi.c ** ** by Doug Crabill, based heavily on pbmtoascii ** ** Converts a pbm file to an encapsulated PostScript style bitmap. ** Note that it does NOT covert the pbm file to PostScript, only to ** a bitmap to be added to a piece of PostScript generated elsewhere. ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #if !defined(MAXINT) #define MAXINT (0x7fffffff) #endif int main( argc, argv ) int argc; char *argv[]; { FILE *ifd; register bit **bits; int argn, rows, cols, row, col, tot, count; int top = MAXINT, bottom = -MAXINT, left = MAXINT, right = -MAXINT; int bbonly = 0; char *usage = "[-bbonly] [pbmfile]"; pbm_init( &argc, argv ); argn = 1; if ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( pm_keymatch( argv[argn], "-bbonly", 2 ) ) { bbonly = 1; } else { pm_usage( usage ); } ++argn; } if ( argn != argc ) { ifd = pm_openr( argv[argn] ); ++argn; } else { ifd = stdin; } if ( argn != argc ) pm_usage( usage ); bits = pbm_readpbm( ifd, &cols, &rows ); pm_close( ifd ); for (row = 0; row < rows; row++) { for (col = 0; col < cols; col++) { if (bits[row][col] == PBM_BLACK) { if (row < top) { top = row; } if (row > bottom) { bottom = row; } if (col < left) { left = col; } if (col > right) { right = col; } } } } printf("%%!PS-Adobe-2.0 EPSF-1.2\n"); printf("%%%%BoundingBox: %d %d %d %d\n", left, rows - bottom, right, rows - top); if (bbonly) { exit(0); } printf("%%%%BeginPreview: %d %d 1 %d\n", right - left + 1, bottom - top + 1, bottom - top + 1); for (row = top; row <= bottom; row++) { printf("%% "); count = 0; for (col = left; col <= right; col += 4) { tot = 0; if (bits[row][col] == PBM_BLACK) { tot += 8; } if (bits[row][col+1] == PBM_BLACK) { tot += 4; } if (bits[row][col+2] == PBM_BLACK) { tot += 2; } if (bits[row][col+3] == PBM_BLACK) { tot++; } printf("%x", tot); count++; } printf((count % 2) == 0 ? "\n" : "0\n"); } printf("%%%%EndImage\n"); printf("%%%%EndPreview\n"); exit( 0 ); } netpbm-free-10.0-1/pbm/pbmtoepson.10100644004714500471450000000154107716230207017352 0ustar aba-guestaba-guest.TH pbmtoepson 1 "4 January 1991" .IX pbmtoepson .SH NAME pbmtoepson - convert a portable bitmap into Epson printer graphics .SH SYNOPSIS .B pbmtoepson .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces a file of Epson printer graphics as output. .IX Epson .PP Note that there is no epsontopbm tool - this transformation is one way. .SH "SEE ALSO" pbm(5) .SH AUTHOR Copyright (C) 1991 by John Tiller (tiller@galois.msfc.nasa.gov) and Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtoepson.c0100644004714500471450000000402607716230207017435 0ustar aba-guestaba-guest/* pbmtoeps.c - read a portable bitmap and produce Epson graphics ** ** Copyright (C) 1990 by John Tiller (tiller@galois.msfc.nasa.gov) ** and Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pbm.h" static int mask[] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit** bits; bit* bP[8]; int rows, cols, row, col, lastcol; int idx; int val; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[pbmfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; bits = pbm_readpbm( ifp, &cols, &rows ); pm_close( ifp ); /* Change line spacing to 8/72 inches. */ printf("\033A\010"); /* Write out rows by eights. */ for ( row = 0; row < rows; row += 8 ) { /* Find end of lines. */ for ( lastcol = cols-1; lastcol >= 0; --lastcol ) { for ( idx = 0; idx < 8 && row+idx < rows; ++idx ) if ( bits[row+idx][lastcol] == PBM_BLACK ) break; if ( idx < 8 && row+idx < rows ) break; } for ( idx = 0; idx < 8 && row+idx < rows; ++idx ) bP[idx] = bits[row+idx]; /* Put in plotter (1:1) graphics. */ if ( lastcol >= 0 ) printf("\033*\005%c%c", (lastcol+1)%256, (lastcol+1)/256); for ( col = 0; col <= lastcol; ++col ) { val = 0; for ( idx = 0; idx < 8 && row+idx < rows; ++idx ) if ( *bP[idx] == PBM_BLACK ) val |= mask[idx]; putchar( val ); for ( idx = 0; idx < 8 && row+idx < rows; ++idx ) ++bP[idx]; } putchar( '\n' ); } putchar( '\f' ); /* Restore normal line spacing. */ printf("\033@"); exit( 0 ); } netpbm-free-10.0-1/pbm/pbmtog3.10100644004714500471450000000154307716230207016541 0ustar aba-guestaba-guest.TH pbmtog3 1 "02 October 1989" .IX pbmtog3 .SH NAME pbmtog3 - convert a portable bitmap into a Group 3 fax file .SH SYNOPSIS .B pbmtog3 .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as output. Produces a Group 3 fax file as input. .IX "Group 3 fax" .IX fax .SH REFERENCES The standard for Group 3 fax is defined in CCITT Recommendation T.4. .SH BUGS Probably. .SH "SEE ALSO" g3topbm(1), pbm(5) .SH AUTHOR Copyright (C) 1989 by Paul Haeberli . .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtog3.c0100644004714500471450000001064107716230207016622 0ustar aba-guestaba-guest/* pbmtog3.c - read a portable bitmap and produce a Group 3 FAX file ** ** Copyright (C) 1989 by Paul Haeberli . ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #include "g3.h" static void tofax ARGS(( bit* bitrow, int n )); static void putwhitespan ARGS(( int c )); static void putblackspan ARGS(( int c )); static void putcode ARGS(( tableentry* te )); static void puteol ARGS(( void )); static void putinit ARGS(( void )); static void putbit ARGS(( int d )); static void flushbits ARGS(( void )); static int reversebits; int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; int argn, rows, cols, format, row, i; char* usage = " [-reversebits] [pbmfile]"; pbm_init( &argc, argv ); argn = 1; reversebits = 0; if ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( pm_keymatch( argv[argn], "-reversebits", 2 ) ) reversebits = 1; else pm_usage( usage ); ++argn; } if ( argn == argc ) ifp = stdin; else { ifp = pm_openr( argv[argn] ); ++argn; } if ( argn != argc ) pm_usage( usage ); pbm_readpbminit( ifp, &cols, &rows, &format ); bitrow = pbm_allocrow( cols ); /* Write out four extra rows to get things stabilized. */ putinit(); puteol(); /* Write out bitmap. */ for ( row = 0; row < rows; ++row ) { pbm_readpbmrow( ifp, bitrow, cols, format ); tofax( bitrow, cols ); } /* And finish off. */ for( i = 0; i < 6; ++i ) puteol( ); flushbits( ); pm_close( ifp ); exit( 0 ); } static void tofax(bitrow,n) bit* bitrow; int n; { int c; while(n>0) { c = 0; while(*bitrow == PBM_WHITE && n>0) { ++bitrow; ++c; --n; } putwhitespan(c); c = 0; if(n==0) break; while(*bitrow == PBM_BLACK && n>0) { ++bitrow; ++c; --n; } putblackspan(c); } puteol(); } static void putwhitespan(c) int c; { int tpos; tableentry* te; do { if(c>=64) { if (c < 1792) { tpos = (c - 64) / 64; te = mwtable+tpos; } else { tpos = (c - 1792) / 64; if (tpos > ((2560 - 1792) / 64)) tpos = (2560 - 1792) / 64; te = extable+tpos; } c -= te->count; putcode(te); } tpos = c; if (tpos >= 64) tpos = 63; te = twtable+tpos; c -= te->count; putcode(te); if (c) putblackspan(0); } while (c); } static void putblackspan(c) int c; { int tpos; tableentry* te; do { if(c>=64) { if (c < 1792) { tpos = (c - 64) / 64; te = mbtable+tpos; } else { tpos = (c - 1792) / 64; if (tpos > ((2560 - 1792) / 64)) tpos = (2560 - 1792) / 64; te = extable+tpos; } c -= te->count; putcode(te); } tpos = c; if (tpos >= 64) tpos = 63; te = tbtable+tpos; c -= te->count; putcode(te); if (c) putwhitespan(0); } while (c); } static void putcode(te) tableentry* te; { unsigned int mask; int code; mask = 1<<(te->length-1); code = te->code; while(mask) { if(code&mask) putbit(1); else putbit(0); mask >>= 1; } } static void puteol() { int i; for(i=0; i<11; ++i) putbit(0); putbit(1); } static int shdata; static int shbit; static void putinit() { shdata = 0; shbit = reversebits ? 0x01 : 0x80; } static void putbit(d) int d; { if(d) shdata = shdata|shbit; if ( reversebits ) shbit = shbit<<1; else shbit = shbit>>1; if((shbit&0xff) == 0) { putchar(shdata); shdata = 0; shbit = reversebits ? 0x01 : 0x80; } } static void flushbits( ) { if ( ( reversebits && shbit != 0x01 ) || ( ! reversebits && shbit != 0x80 ) ) { putchar(shdata); shdata = 0; shbit = reversebits ? 0x01 : 0x80; } } netpbm-free-10.0-1/pbm/pbmtogem.10100644004714500471450000000136207716230207016777 0ustar aba-guestaba-guest.TH pbmtogem 1 "11 July 1992" .IX pbmtogem .SH NAME pbmtogem - convert a portable bitmap into a GEM .img file .SH SYNOPSIS .B pbmtogem .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces a compressed GEM .img file as output. .IX GEM .SH BUGS pbmtogem does not support compression of repeated lines .SH "SEE ALSO" gemtopbm(1), pbm(5) .SH AUTHOR Copyright (C) 1988 by David Beckemeyer (bdt!david) and Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, .\" provided that the above copyright notice appear in all copies and that .\" both that copyright notice and this permission notice appear in .\" supporting documentation. netpbm-free-10.0-1/pbm/pbmtogem.c0100644004714500471450000001365507716230207017071 0ustar aba-guestaba-guest/* pbmtogem.c - read a portable bitmap and produce a GEM .img file ** ** Author: David Beckemeyer (bdt!david) ** ** Much of the code for this program was taken from other ** pbmto* programs. I just modified the code to produce ** a .img header and generate .img "Bit Strings". ** ** Thanks to Diomidis D. Spinellis for the .img header format. ** ** Copyright (C) 1988 by David Beckemeyer (bdt!david) and Jef Poskanzer. ** ** Modified by Johann Haider to produce Atari ST compatible files ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ /* * 92/07/11 jh * * Changes made to this program: * changed header length to count words to conform with Atari ST documentation * removed rounding of the imagewidth to the next word boundary * removed arbitrary limit to imagewidth * changed pattern length to 1 to simplify locating of compressable parts * in real world images * add solid run and pattern run compression * * Deficiencies: * Compression of repeated scanlines not added * * Johann Haider (jh@fortec.tuwien.ac.at) * * 94/01/31 Andreas Schwab (schwab@ls5.informatik.uni-dortmund.de) * Changed to remove architecture dependencies * Added compression of repeated scanlines */ #include #include #include "pbm.h" #define SOLID_0 0 #define SOLID_1 0xff #define MINRUN 4 #define putsolid(v,c) putc((v&0x80)|c, stdout) #define putpattern(v,c) putc(0, stdout);putc(c, stdout);putc(v, stdout) static void putinit ARGS ((int rows, int cols)); static void putbit ARGS(( bit b )); static void putitem ARGS(( void )); static void putrow ARGS(( void )); static void flushrow ARGS ((void)); static void putstring ARGS((register unsigned char *p, register int n)); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int rows, cols, format, row, col; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[pbmfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; pbm_readpbminit( ifp, &cols, &rows, &format ); bitrow = pbm_allocrow( cols ); putinit (rows, cols); for ( row = 0; row < rows; ++row ) { #ifdef DEBUG fprintf (stderr, "row %d\n", row); #endif pbm_readpbmrow( ifp, bitrow, cols, format ); for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) putbit( *bP ); putrow( ); } flushrow (); pm_close( ifp ); exit( 0 ); } static short item; static int outcol, outmax; static short bitsperitem, bitshift; static short linerepeat; static unsigned char *outrow, *lastrow; static void putinit (rows, cols) int rows, cols; { if (pm_writebigshort (stdout, (short) 1) == -1 /* Image file version */ || pm_writebigshort (stdout, (short) 8) == -1 /* Header length */ || pm_writebigshort (stdout, (short) 1) == -1 /* Number of planes */ || pm_writebigshort (stdout, (short) 1) == -1 /* Pattern length */ || pm_writebigshort (stdout, (short) 372) == -1 /* Pixel width */ || pm_writebigshort (stdout, (short) 372) == -1 /* Pixel height */ || pm_writebigshort (stdout, (short) cols) == -1 || pm_writebigshort (stdout, (short) rows) == -1) pm_error ("write error"); item = 0; bitsperitem = 0; bitshift = 7; outcol = 0; overflow_add(cols, 7); outmax = (cols + 7) / 8; outrow = (unsigned char *) pm_allocrow (outmax, sizeof (unsigned char)); lastrow = (unsigned char *) pm_allocrow (outmax, sizeof (unsigned char)); linerepeat = -1; } #if __STDC__ static void putbit( bit b ) #else /*__STDC__*/ static void putbit( b ) bit b; #endif /*__STDC__*/ { if ( bitsperitem == 8 ) putitem( ); ++bitsperitem; if ( b == PBM_BLACK ) item += 1 << bitshift; --bitshift; } static void putitem( ) { outrow[outcol++] = item; item = 0; bitsperitem = 0; bitshift = 7; } static void putstring (p, n) register unsigned char *p; register int n; { #ifdef DEBUG fprintf (stderr, "Bitstring, length: %d, pos %d\n", n, outcol); #endif (void) putc((char) 0x80, stdout); /* a Bit string */ (void) putc(n, stdout); /* count */ fwrite( p, n, 1, stdout ); } static void putrow( ) { if (bitsperitem > 0) putitem (); outcol = 0; if (linerepeat == -1 || linerepeat == 255 || memcmp (outrow, lastrow, outmax) != 0) { unsigned char *temp; if (linerepeat != -1) /* Unless first line */ flushrow (); /* Swap the pointers */ temp = outrow; outrow = lastrow; lastrow = temp; linerepeat = 1; } else /* Repeated line */ linerepeat++; } static void flushrow( ) { register unsigned char *outp, *p, *q; register int count; int col = outmax; if (linerepeat > 1) { /* Put out line repeat count */ fwrite ("\0\0\377", 3, 1, stdout); putchar (linerepeat); } for (outp = p = lastrow; col > 0;) { for (q = p, count=0; (count < col) && (*q == *p); q++,count++); if (count > MINRUN) { if (p > outp) { putstring (outp, p-outp); outp = p; } col -= count; switch (*p) { case SOLID_0: #ifdef DEBUG /* if (outcol > 0) */ fprintf (stderr, "Solid run 0, length: %d\n", count); #endif putsolid (SOLID_0, count); break; case SOLID_1: #ifdef DEBUG fprintf (stderr, "Solid run 1, length: %d, pos %d\n", count, outcol); #endif putsolid (SOLID_1, count); break; default: #ifdef DEBUG fprintf (stderr, "Pattern run, length: %d\n", count); #endif putpattern (*p, count); break; } outp = p = q; } else { p++; col--; } } if (p > outp) putstring (outp, p-outp); if (ferror (stdout)) pm_error ("write error"); } netpbm-free-10.0-1/pbm/pbmtogo.10100644004714500471450000000176107716230207016637 0ustar aba-guestaba-guest.TH pbmtogo 1 "24 November 1989" .IX pbmtogo .SH NAME pbmtogo - convert a portable bitmap into compressed GraphOn graphics .SH SYNOPSIS .B pbmtogo .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces 2D compressed GraphOn graphics as output. .IX GraphOn Be sure to set up your GraphOn with the following modes: 8 bits / no parity; obeys no XON/XOFF; NULs are accepted. These are all on the Comm menu. Also, remember to turn off tty post processing. Note that there is no gotopbm tool. .SH "SEE ALSO" pbm(5) .SH AUTHOR Copyright (C) 1988, 1989 by Jef Poskanzer, Michael Haberler, and Bo Thide'. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtogo.c0100644004714500471450000002255507716230207016725 0ustar aba-guestaba-guest/* pbmtogo.c - read a portable bitmap and produce a GraphOn terminal raster file ** ** Rev 1.1 was based on pbmtolj.c ** ** Bo Thide', Swedish Institute of Space Physics, bt@irfu.se ** ** ** $Log: pbmtogo.c,v $ ** Revision 1.1.1.1 2003/08/12 18:23:03 aba-guest ** Latest debian release ** * Revision 1.5 89/11/25 00:24:12 00:24:12 root (Bo Thide) * Bug found: The byte after 64 repeated bytes sometimes lost. Fixed. * * Revision 1.4 89/11/24 14:56:04 14:56:04 root (Bo Thide) * Fixed the command line parsing since pbmtogo now always uses 2D * compression. Added a few comments to the source. * * Revision 1.3 89/11/24 13:43:43 13:43:43 root (Bo Thide) * Added support for > 63 repeated bytes and > 62 repeated lines in * the 2D compression scheme. * * Revision 1.2 89/11/15 01:04:47 01:04:47 root (Bo Thide) * First version that works reasonably well with GraphOn 2D runlength * encoding/compression. * * Revision 1.1 89/11/02 23:25:25 23:25:25 root (Bo Thide) * Initial revision * ** ** Copyright (C) 1988, 1989 by Jef Poskanzer, Michael Haberler, and Bo Thide'. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include #include "pbm.h" #define TRUE 1 #define BUFSIZE 132 /* GraphOn has 132 byte/1056 bit wide raster lines */ #define REPEAT_CURRENT_LINE_MASK 0x00 #define SKIP_AND_PLOT_MASK 0x40 #define REPEAT_PLOT_MASK 0x80 #define PLOT_ARBITRARY_DATA_MASK 0xc0 #define MAX_REPEAT 64 static unsigned char *scanlineptr; /* Pointer to current scan line byte */ static void putinit ARGS(( void )); static void putbit ARGS(( bit b )); static void putrest ARGS(( void )); static void putitem ARGS(( void )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int argn, rows, cols, format, rucols, padright, row, col; int nbyte, bytesperrow, ecount, ucount, nout, i, linerepeat; int olditem; unsigned char oldscanline[BUFSIZE]; unsigned char newscanline[BUFSIZE]; unsigned char diff[BUFSIZE]; unsigned char buffer[BUFSIZE]; unsigned char outbuffer[2*(BUFSIZE+1)]; /* Worst case. Should malloc */ char* usage = "[-c] [pbmfile]"; pbm_init( &argc, argv ); argn = 2; /* Check for flags. */ if (argc > argn + 1) pm_usage(usage); if (argc == argn) ifp = pm_openr( argv[argn-1] ); else ifp = stdin; pbm_readpbminit(ifp, &cols, &rows, &format); bitrow = pbm_allocrow(cols); /* Round cols up to the nearest multiple of 8. */ overflow_add(cols, 7); rucols = ( cols + 7 ) / 8; bytesperrow = rucols; /* GraphOn uses bytes */ rucols = rucols * 8; padright = rucols - cols; for (i = 0; i < BUFSIZE; ++i ) buffer[i] = 0; putinit(); /* Start donwloading screen raster */ printf("\033P0;1;0;4;1;%d;%d;1!R1/", rows, rucols); linerepeat = 63; /* 63 means "Start new picture" */ nout = 0; /* To prevent compiler warning */ for (row = 0; row < rows; row++) { /* Store scan line data in the new scan line vector */ scanlineptr = newscanline; pbm_readpbmrow(ifp, bitrow, cols, format); /* Transfer raster graphics */ for (col = 0, bP = bitrow; col < cols; col++, bP++) putbit(*bP); for (col = 0; col < padright; col++) putbit(0); /* XOR data from the new scan line with data from old scan line */ for (i = 0; i < bytesperrow; i++) diff[i] = oldscanline[i]^newscanline[i]; /* ** If the difference map is different from current internal buffer, ** encode the difference and put it in the output buffer. ** Else, increase the counter for the current buffer by one. */ if ((memcmp(buffer, diff, bytesperrow) != 0) || (row == 0)) { /* **Since the data in the buffer has changed, send the **scan line repeat count to cause the old line(s) to **be plotted on the screen, copy the new data into **the internal buffer, and reset the counters. */ putchar(linerepeat); for (i = 0; i < bytesperrow; ++i) buffer[i] = diff[i]; nbyte = 0; /* Internal buffer byte counter */ nout = 0; /* Output buffer byte counter */ /* Run length encode the new internal buffr (= difference map) */ while (TRUE) { ucount = 0; /* Unique items counter */ do /* Find unique patterns */ { olditem = buffer[nbyte++]; ucount++; } while ((olditem != buffer[nbyte]) && (ucount < min(bytesperrow, MAX_REPEAT))); if ((ucount != MAX_REPEAT) && (nbyte != bytesperrow)) { /* Back up to the last truly unique pattern */ ucount--; nbyte--; } if (ucount > 0) { /* Output the unique patterns */ outbuffer[nout++] = (ucount-1) | PLOT_ARBITRARY_DATA_MASK; for (i = nbyte-ucount; i < nbyte; i++) outbuffer[nout++] = buffer[i]; } /* ** If we already are at the end of the current scan ** line, skip the rest of the encoding and start ** with a new scan line. */ if (nbyte >= bytesperrow) goto nextrow; ecount = 0; /* Equal items counter */ do /* Find equal patterns */ { olditem = buffer[nbyte++]; ecount++; } while ((olditem == buffer[nbyte]) && (ecount < min(bytesperrow, MAX_REPEAT))); if (ecount > 1) { /* More than 1 equal pattern */ if (olditem == '\0') { /* White patterns */ if (nbyte >= bytesperrow-1) { /* No more valid data ahead */ outbuffer[nout++] = (ecount-2) | SKIP_AND_PLOT_MASK; outbuffer[nout++] = buffer[nbyte-1]; } else { /* More valid data ahead */ outbuffer[nout++] = (ecount-1) | SKIP_AND_PLOT_MASK; outbuffer[nout++] = buffer[nbyte++]; } } else { /* Non-white patterns */ outbuffer[nout++] = (ecount-1) | REPEAT_PLOT_MASK; outbuffer[nout++] = olditem; } /* if (olditem == '\0') */ } /* if (ecount > 1) */ else nbyte--; /* No equal items found */ if (nbyte >= bytesperrow) goto nextrow; } /* while (TRUE) */ nextrow: printf("%d/", nout+1); /* Total bytes to xfer = nout+1 */ fflush(stdout); /* Output the plot data */ write(1, outbuffer, nout); /* Reset the counters */ linerepeat = 0; } else { linerepeat++; if (linerepeat == 62) /* 62 lines max, then restart */ { putchar(linerepeat); printf("%d/", nout+1); fflush(stdout); write(1, outbuffer, nout); linerepeat = 0; } } /* Now we are ready for a new scan line */ for (i = 0; i < bytesperrow; ++i) oldscanline[i] = newscanline[i]; } putchar(linerepeat); /* For the last line(s) to be plotted */ pm_close(ifp); putrest(); exit(0); } static int item, bitsperitem, bitshift; static void putinit() { /* Enter graphics window */ printf("\0331"); /* Erase graphics window */ printf("\033\014"); /* Set graphics window in raster mode */ printf("\033r"); /* Select standard Tek coding **/ printf("\033[=11l"); bitsperitem = 1; item = 0; bitshift = 7; } #if __STDC__ static void putbit(bit b) #else /*__STDC__*/ static void putbit(b) bit b; #endif /*__STDC__*/ { if (b == PBM_BLACK) item += 1 << bitshift; bitshift--; if (bitsperitem == 8) { putitem(); bitshift = 7; } bitsperitem++; } static void putrest() { if (bitsperitem > 1) putitem(); /* end raster downloading */ printf("\033\134"); /* Exit raster mode */ printf("\033t"); /* Exit graphics window printf("\0332"); */ } static void putitem() { *scanlineptr++ = item; bitsperitem = 0; item = 0; } netpbm-free-10.0-1/pbm/pbmtoicon.10100644004714500471450000000134307716230207017156 0ustar aba-guestaba-guest.TH pbmtoicon 1 "31 August 1988" .IX pbmtoicon .SH NAME pbmtoicon - convert a portable bitmap into a Sun icon .SH SYNOPSIS .B pbmtoicon .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces a Sun icon as output. .IX Sun .IX "Sun icon format" .SH "SEE ALSO" icontopbm(1), pbm(5) .SH AUTHOR Copyright (C) 1988 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtoicon.c0100644004714500471450000000544107716230207017243 0ustar aba-guestaba-guest/* pbmtoicon.c - read a portable bitmap and produce a Sun icon file ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" static void putinit ARGS(( void )); static void putbit ARGS(( bit b )); static void putrest ARGS(( void )); static void putitem ARGS(( void )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int rows, cols, format, pad, padleft, padright, row, col; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[pbmfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; pbm_readpbminit( ifp, &cols, &rows, &format ); bitrow = pbm_allocrow( cols ); /* Round cols up to the nearest multiple of 16. */ overflow_add(cols, 15); pad = ( ( cols + 15 ) / 16 ) * 16 - cols; padleft = pad / 2; padright = pad - padleft; printf( "/* Format_version=1, Width=%d, Height=%d", cols + pad, rows ); printf( ", Depth=1, Valid_bits_per_item=16\n */\n" ); putinit( ); for ( row = 0; row < rows; ++row ) { pbm_readpbmrow( ifp, bitrow, cols, format ); for ( col = 0; col < padleft; ++col ) putbit( 0 ); for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) putbit( *bP ); for ( col = 0; col < padright; ++col ) putbit( 0 ); } pm_close( ifp ); putrest( ); exit( 0 ); } static int item, bitsperitem, bitshift, itemsperline, firstitem; static void putinit( ) { itemsperline = 0; bitsperitem = 0; item = 0; bitshift = 15; firstitem = 1; } #if __STDC__ static void putbit( bit b ) #else /*__STDC__*/ static void putbit( b ) bit b; #endif /*__STDC__*/ { if ( bitsperitem == 16 ) putitem( ); ++bitsperitem; if ( b == PBM_BLACK ) item += 1 << bitshift; --bitshift; } static void putrest( ) { if ( bitsperitem > 0 ) putitem( ); putchar( '\n' ); } static void putitem( ) { char* hexits = "0123456789abcdef"; if ( firstitem ) firstitem = 0; else putchar( ',' ); if ( itemsperline == 8 ) { putchar( '\n' ); itemsperline = 0; } if ( itemsperline == 0 ) putchar( '\t' ); putchar( '0' ); putchar( 'x' ); putchar( hexits[item >> 12] ); putchar( hexits[( item >> 8 ) & 15] ); putchar( hexits[( item >> 4 ) & 15] ); putchar( hexits[item & 15] ); ++itemsperline; bitsperitem = 0; item = 0; bitshift = 15; } netpbm-free-10.0-1/pbm/pbmtolj.10100644004714500471450000000352607721162447016646 0ustar aba-guestaba-guest.TH pbmtolj 1 "22 April 2000" .IX pbmtolj .SH NAME pbmtolj - convert a portable bitmap into HP LaserJet format .SH SYNOPSIS .B pbmtolj .RB [ -resolution .IR N ] .RB [ -float ] .RB [ -noreset ] .RB [ -packbits ] .RB [ -delta ] .RB [ -compress ] .RI [ pbmfile ] .RB [ -copies .IR N ] .SH DESCRIPTION Reads a PBM image as input. Produces HP LaserJet data as output. .IX "HP LaserJet" .PP Note that there is no ljtopbm tool. .SH OPTIONS .TP .B -resolution Specifies the resolution of the output device, in dpi. Typical values are 75, 100, 150, 300, and 600. The default is 75. .TP .B -float Suppresses positioning information. The default is to write the sequence .I ESC & l 0 E to the output file. .TP .B -noreset Prevents pbmtolj from writing the reset sequences to the beginning and end of the output file. .TP .B -packbits Enables use of TIFF packbits compression. .TP .B -delta Enables use of delta-between-rows compression. .TP .B -compress Enables use of both TIFF packbits, and delta-between-rows compression. .TP .B -copies Specifies the the number of copies. The default is 1. This option controls the "number of copies" printer control; .B pbmtolj generates only one copy of the image. .PP All flags can be abbreviated to their shortest unique prefix. .SH "SEE ALSO" .BR pbm (5) .SH AUTHOR Copyright (C) 1988 by Jef Poskanzer and Michael Haberler. .B -float and .B -noreset options added by Wim Lewis. .B -delta, -packbits, and .B -compress options added by Dave Platt. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtolj.c0100644004714500471450000002741007717167171016732 0ustar aba-guestaba-guest/* pbmtolj.c - read a portable bitmap and produce a LaserJet bitmap file ** ** based on pbmtops.c ** ** Michael Haberler HP Vienna mah@hpuviea.uucp ** mcvax!tuvie!mah ** misfeatures: ** no positioning ** ** Bug fix Dec 12, 1988 : ** lines in putbit() reshuffled ** now runs OK on HP-UX 6.0 with X10R4 and HP Laserjet II ** Bo Thide', Swedish Institute of Space Physics, Uppsala ** ** Flags added December, 1993: ** -noreset to suppress printer reset code ** -float to suppress positioning code (such as it is) ** Wim Lewis, Seattle ** ** Copyright (C) 1988 by Jef Poskanzer and Michael Haberler. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #include #include #include static int dpi = 75; static int floating = 0; /* suppress the ``ESC & l 0 E'' ? */ static int pack = 0; /* use TIFF packbits compression */ static int delta = 0; /* use row-delta compression */ static int resets = 3; /* bit mask for when to emit printer reset seq */ static int copies = 1; /* number of copies */ static char *rowBuffer, *prevRowBuffer, *packBuffer, *deltaBuffer; static int rowBufferSize, rowBufferIndex; static int packBufferSize, packBufferIndex; static int deltaBufferSize, deltaBufferIndex; static void putinit ARGS(( void )); static void putbit ARGS(( bit b )); static void putflush ARGS(( void )); static void putrest ARGS(( void )); static void putitem ARGS(( void )); static void packbits ARGS(( void )); static void deltarow ARGS(( void )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int argn, rows, cols, format, rucols, padright, row, mode, blankRows; int prevRowBufferIndex; int savedRowBufferIndex; register int nzcol, col; char* usage = "[-noreset|-float|-packbits|-delta|-compress|-resolution N|-copies N] [pbmfile]\n\tresolution = [75|100|150|300|600] (dpi)"; pbm_init( &argc, argv ); argn = 1; /* Check for flags. */ while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( pm_keymatch( argv[argn], "-resolution", 2 ) ) { ++argn; if ( argn == argc || sscanf( argv[argn], "%d", &dpi ) != 1 ) pm_usage( usage ); } else if ( pm_keymatch( argv[argn], "-copies", 2 ) ) { ++argn; if ( argn == argc || sscanf( argv[argn], "%d", &copies ) != 1 ) pm_usage( usage ); } else if ( pm_keymatch( argv[argn], "-float", 2 ) ) { floating = 1; } else if ( pm_keymatch( argv[argn], "-noreset", 2 ) ) { resets = 0; } else if ( pm_keymatch( argv[argn], "-packbits", 2 ) ) { pack = 1; } else if ( pm_keymatch( argv[argn], "-delta", 2 ) ) { delta = 1; } else if ( pm_keymatch( argv[argn], "-compress", 2 ) ) { pack = 1; delta = 1; } else pm_usage( usage ); ++argn; } if ( argn != argc ) { ifp = pm_openr( argv[argn] ); ++argn; } else ifp = stdin; if ( argn != argc ) pm_usage( usage ); pbm_readpbminit( ifp, &cols, &rows, &format ); bitrow = pbm_allocrow( cols ); overflow_add(cols, 8); rowBufferSize = (cols + 7) / 8; overflow_add(rowBufferSize, 128); overflow_add(rowBufferSize, rowBufferSize+128); overflow_add(rowBufferSize+10, rowBufferSize/8); packBufferSize = rowBufferSize + (rowBufferSize + 127) / 128 + 1; deltaBufferSize = rowBufferSize + rowBufferSize / 8 + 10; prevRowBuffer = (char *) malloc(rowBufferSize); rowBuffer = (char *) malloc(rowBufferSize); packBuffer = (char *) malloc(packBufferSize); deltaBuffer = (char *) malloc(deltaBufferSize); if (!rowBuffer || !prevRowBuffer || !packBuffer || !deltaBuffer) { fprintf(stderr, "Can't allocate row buffer\n"); return 1; } putinit( ); blankRows = 0; prevRowBufferIndex = 0; memset(prevRowBuffer, 0, rowBufferSize); mode = -1; for ( row = 0; row < rows; ++row ) { pbm_readpbmrow( ifp, bitrow, cols, format ); /* Find rightmost black pixel. */ for ( nzcol = cols - 1; nzcol >= 0 && bitrow[nzcol] == PBM_WHITE; --nzcol ) continue; if (nzcol < 0) { blankRows ++; continue; } if (blankRows > 0) { int x; /* The code used to be this, but Charles Howes reports that this escape sequence does not exist on his HP Laserjet IIP plus, so we use the following less elegant code instead. printf("\033*b%dY", blankRows); */ for (x=0;x 1) { /* number of copies */ printf("\033&l%dX", copies); } if(!floating) { /* Ensure top margin is zero */ printf("\033&l0E"); } /* Set raster graphics resolution */ printf("\033*t%dR",dpi); /* Start raster graphics, relative adressing */ printf("\033*r1A"); itemsperline = 0; bitsperitem = 1; item = 0; bitshift = 7; firstitem = 1; } #if __STDC__ static void putbit( bit b ) #else /*__STDC__*/ static void putbit( b ) bit b; #endif /*__STDC__*/ { if ( b == PBM_BLACK ) item += 1 << bitshift; bitshift--; if ( bitsperitem == 8 ) { putitem( ); bitshift = 7; } bitsperitem++; } static void putflush( ) { if ( bitsperitem > 1 ) putitem( ); } static void putrest( ) { /* end raster graphics */ printf( "\033*rB" ); if(resets & 2) { /* Printer reset. */ printf("\033E"); } } static void putitem( ) { assert (rowBufferIndex < rowBufferSize); rowBuffer[rowBufferIndex++] = item; bitsperitem = 0; item = 0; } static void packbits() { int ptr, litStart, runStart, thisByte, startByte, chew, spit; packBufferIndex = 0; ptr = 0; while (ptr < rowBufferIndex) { litStart = ptr; runStart = ptr; startByte = rowBuffer[ptr]; ptr++; while (ptr < rowBufferIndex) { thisByte = rowBuffer[ptr]; if (thisByte != startByte) { if (ptr - runStart > 3) { /* found literal after nontrivial run */ break; } startByte = thisByte; runStart = ptr; } ptr ++; } /* We drop out here after having found a [possibly empty] literal, followed by a [possibly degenerate] run of repeated bytes. Degenerate runs can occur at the end of the scan line... there may be a "repeat" of 1 byte (which can't actually be represented as a repeat) so we simply fold it into the previous literal. */ if (runStart == rowBufferIndex - 1) { runStart = rowBufferIndex; } /* Spit out the leading literal if it isn't empty */ chew = runStart - litStart; while (chew > 0) { spit = (chew > 127) ? 127 : chew; packBuffer[packBufferIndex++] = (char) (spit - 1); memcpy(packBuffer+packBufferIndex, rowBuffer+litStart, spit); packBufferIndex += spit; litStart += spit; chew -= spit; } /* Spit out the repeat, if it isn't empty */ chew = ptr - runStart; while (chew > 0) { spit = (chew > 128) ? 128 : chew; if (chew == spit + 1) { spit--; /* don't leave a degenerate run at the end */ } if (spit == 1) { fprintf(stderr, "packbits created a degenerate run!\n"); } packBuffer[packBufferIndex++] = (char) -(spit - 1); packBuffer[packBufferIndex++] = startByte; chew -= spit; } } } static void deltarow() { int burstStart, burstEnd, burstCode, mustBurst, ptr, skip, skipped, code; deltaBufferIndex = 0; if (memcmp(rowBuffer, prevRowBuffer, rowBufferIndex) == 0) { return; /* exact match, no deltas required */ } ptr = 0; skipped = 0; burstStart = -1; burstEnd = -1; mustBurst = 0; while (ptr < rowBufferIndex) { skip = 0; if (ptr == 0 || skipped == 30 || rowBuffer[ptr] != prevRowBuffer[ptr] || (burstStart != -1 && ptr == rowBufferIndex - 1)) { /* we want to output this byte... */ if (burstStart == -1) { burstStart = ptr; } if (ptr - burstStart == 7 || ptr == rowBufferIndex - 1) { /* we have to output it now... */ burstEnd = ptr; mustBurst = 1; } } else { /* duplicate byte, we can skip it */ if (burstStart != -1) { burstEnd = ptr - 1; mustBurst = 1; } skip = 1; } if (mustBurst) { burstCode = burstEnd - burstStart; /* 0-7, means 1-8 bytes follow */ code = (burstCode << 5) | skipped; deltaBuffer[deltaBufferIndex++] = (char) code; memcpy(deltaBuffer+deltaBufferIndex, rowBuffer+burstStart, burstCode + 1); deltaBufferIndex += burstCode + 1; burstStart = -1; burstEnd = -1; mustBurst = 0; skipped = 0; } if (skip) { skipped ++; } ptr ++; } } netpbm-free-10.0-1/pbm/pbmtomacp.10100644004714500471450000000270207716230207017146 0ustar aba-guestaba-guest.TH pbmtomacp 1 "31 August 1988" .IX pbmtomacp .SH NAME pbmtomacp - convert a portable bitmap into a MacPaint file .SH SYNOPSIS .B pbmtomacp .RB [ -l .IR left ] .RB [ -r .IR right ] .RB [ -b .IR bottom ] .RB [ -t .IR top ] .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. If no input-file is given, standard input is assumed. Produces a MacPaint file as output. .IX MacPaint .IX Macintosh .PP The generated file is only the data fork of a picture. You will need a program such as .I mcvert to generate a Macbinary or a BinHex file that contains the necessary information to identify the file as a PNTG file to MacOS. .SH OPTIONS .PP Left, right, bottom & top let you define a square into the pbm file, that must be converted. Default is the whole file. If the file is too large for a MacPaint-file, the bitmap is cut to fit from ( left, top ). .SH BUGS The source code contains comments in a language other than English. .SH "SEE ALSO" ppmtopict(1), macptopbm(1), pbm(5), mcvert(1) .SH AUTHOR Copyright (C) 1988 by Douwe van der Schaaf (...!mcvax!uvapsy!vdschaaf). .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtomacp.c0100644004714500471450000001477307725102161017240 0ustar aba-guestaba-guest/* pbmtomacp.c - read a portable bitmap and produce a MacPaint bitmap file ** ** Copyright (C) 1988 by Douwe vand der Schaaf. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #include "macp.h" #include #define TRUE 1 #define FALSE 0 #define EQUAL 1 #define UNEQUAL 0 static void fillbits ARGS(( bit **bits, bit **bitsr, int top, int left, int bottom, int right )); static void writemacp ARGS(( bit **bits )); static int packit ARGS(( bit *pb, bit *bits )); static void filltemp ARGS(( bit *dest, bit *src )); static void sendbytes ARGS(( bit *pb, register int npb )); static void header ARGS(( void )); static FILE *fdout; int main(argc, argv) int argc; char *argv[]; { FILE *ifp; register bit **bits, **bitsr; int argn, rows, cols; int left,bottom,right,top; int lflg, rflg, tflg, bflg; char name[100]; char *usage = "[-l left] [-r right] [-b bottom] [-t top] [pbmfile]"; pbm_init( &argc, argv ); argn = 1; fdout = stdout; lflg = rflg = tflg = bflg = 0; left = right = top = bottom = 0; /* To quiet compiler warning */ while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { switch ( argv[argn][1] ) { case 'l': lflg++; argn++; left = atoi( argv[argn] ); break; case 'r': rflg++; argn++; right = atoi( argv[argn] ); break; case 't': tflg++; argn++; top = atoi( argv[argn] ); break; case 'b': bflg++; argn++; bottom = atoi( argv[argn] ); break; case '?': default: pm_usage( usage ); } ++argn; } if ( argn == argc ) { ifp = stdin; strcpy( name, "noname" ); } else { ifp = pm_openr( argv[argn] ); strcpy( name, argv[argn] ); ++argn; } if ( argn != argc ) pm_usage( usage ); bitsr = pbm_readpbm( ifp, &cols, &rows ); pm_close( ifp ); bits = pbm_allocarray( MAX_COLS, MAX_LINES ); if( !lflg ) left = 0; overflow_add(left, MAX_COLS - 1); if( rflg ) { if( right - left >= MAX_COLS ) right = left + MAX_COLS - 1; } else right = ( left + MAX_COLS > cols ) ? ( cols - 1 ) : ( left + MAX_COLS - 1 ); if( !tflg ) top = 0; overflow_add(top, MAX_LINES - 1); if( bflg ) { if( bottom - top >= MAX_LINES ) bottom = top + MAX_LINES - 1; } else bottom = ( top + MAX_LINES > rows ) ? ( rows - 1 ) : ( top + MAX_LINES - 1 ); if( right <= left || left < 0 || right - left + 1 > MAX_COLS ) pm_error("error in right (= %d) and/or left (=%d)",right,left ); if( bottom <= top || top < 0 || bottom - top + 1 > MAX_LINES ) pm_error("error in bottom (= %d) and/or top (=%d)",bottom,top ); fillbits( bits, bitsr, top, left, bottom, right ); writemacp( bits ); exit( 0 ); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* centreer het over te zenden plaatje in het MacPaint document * * Het plaatje wordt vanaf al of niet opgegeven (left, bottom) * in een pbm bitmap van de juist macpaint afmetingen gezet, * en eventueel afgekapt. */ static void fillbits( bits, bitsr, top, left, bottom, right ) bit **bits, **bitsr; int top, left, bottom, right; { register bit *bi, *bir; register int i, j; register int bottomr, leftr, topr, rightr; int width, height; width = right - left + 1; leftr = (MAX_COLS - width) / 2; rightr = leftr + width - 1; height = bottom - top + 1; topr = ( MAX_LINES - height ) / 2; bottomr = topr + height - 1; for( i = 0; i < topr; i++ ) { bi = bits[i]; for( j = 0; j < MAX_COLS; j++ ) *bi++ = 0; } for( i = topr; i <= bottomr; i++ ) { bi = bits[i]; { for( j = 0; j < leftr; j++ ) *bi++ = 0; bir = bitsr[ i - topr + top ]; for( j = leftr; j <= rightr; j++ ) *bi++ = bir[j - leftr + left]; for( j = rightr + 1; j < MAX_COLS; j++ ) *bi++ = 0; } } for( i = bottomr + 1; i < MAX_LINES; i++ ) { bi = bits[i]; for( j = 0; j < MAX_COLS; j++ ) *bi++ = 0; } } /* fillbits */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - */ static void writemacp( bits ) bit **bits; { register int i; bit pb[MAX_COLS * 2]; int npb; header(); for( i=0; i < MAX_LINES; i++ ) { npb = packit( pb, bits[i] ); sendbytes( pb, npb ); } } /* writemacp */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* pack regel van MacPaint doc in Apple's format * return value = # of bytes in pb */ static int packit( pb, bits ) bit *pb, *bits; { register int charcount, npb, newcount, flg; bit temp[72]; bit *count, *srcb, *destb, save; srcb = bits; destb = temp; filltemp( destb, srcb ); srcb = temp; destb = pb; npb = 0; charcount = BYTES_WIDE; flg = EQUAL; while( charcount ) { save = *srcb++; charcount--; newcount = 1; while( (*srcb == save) && charcount ) { srcb++; newcount++; charcount--; } if( newcount > 2 ) { count = destb++; *count = 257 - newcount; *destb++ = save; npb += 2; flg = EQUAL; } else { if( flg == EQUAL ) { count = destb++; *count = newcount - 1; npb++; } else *count += newcount; while( newcount-- ) { *destb++ = save; npb++; } flg = UNEQUAL; } } return npb; } /* packit */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - */ static void filltemp( dest, src ) bit *dest, *src; { register unsigned char ch, zero, acht; register int i, j; zero = '\0'; acht = 8; i = BYTES_WIDE; while( i-- ) { ch = zero; j = acht; while( j-- ) { ch <<= 1; if( *src++ ) ch++; } *dest++ = ch; } } /* filltemp */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - */ static void sendbytes( pb, npb ) bit *pb; register int npb; { register bit *b; b = pb; while( npb-- ) (void) putc( *b++, fdout ); } /* sendbytes */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - */ static void header() { register int i; register char ch; /* header contains nothing ... */ ch = '\0'; for(i = 0; i < HEADER_LENGTH; i++ ) (void) putc( ch, fdout ); } /* header */ netpbm-free-10.0-1/pbm/pbmtomda.10100644004714500471450000000151407716230207016767 0ustar aba-guestaba-guest.TH pbmtomda 1 "3 June 1999" .IX pbmtomda .SH NAME pbmtomda - convert a portable bitmap to a Microdesign .mda .SH SYNOPSIS .B pbmtomda .RB [ -d ][ -i ][ -- ] .I [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap file as input. Reads from stdin if input file is omitted. .IX MicroDesign Produces a MicroDesign 2 area file (.MDA) as output. .SH OPTIONS .TP .B -d Halve the height of the output file, to compensate for the aspect ratio used in MicroDesign files. .TP .B -i Invert the colours used. .TP .B -- End of options (use this if the filename starts with "-") .SH BUGS There's no way to produce files in MicroDesign 3 format. MD3 itself and mdatopbm(1) can read files in either format. .SH "SEE ALSO" mdatopbm(1), pbm(5) .SH AUTHOR Copyright (C) 1999 John Elliott . .\" Copying policy: GNU GPL version 2 or later netpbm-free-10.0-1/pbm/pbmtomda.c0100644004714500471450000001073207725102161017050 0ustar aba-guestaba-guest /*************************************************************************** PBMTOMDA: Convert portable bitmap to Microdesign area Copyright (C) 1999 John Elliott This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ******************************************************************************/ #include "pbm.h" #include #include /* I'm being somewhat conservative in the PBM -> MDA translation. I output * only the MD2 format and don't allow RLE over the ends of lines. */ typedef unsigned char mdbyte; static FILE *infile; static mdbyte header[128]; static bit **data; static mdbyte *mdrow; static int bInvert = 0; static int bScale = 0; static int nInRows, nInCols, nOutCols, nOutRows; /* Encode 8 pixels as a byte */ static mdbyte encode(int row, int col) { int n, mask = 0x80; mdbyte b = 0; for (n = 0; n < 8; n++) { if (data[row][col+n] == PBM_BLACK) b |= mask; mask = mask >> 1; } return bInvert ? b : ~b; } /* Translate a pbm to MD2 format, one row at a time */ static void do_translation() { int x, x1, row, step; mdbyte b; step = bScale ? 2 : 1; for (row = 0; row < nOutRows; row+=step) { /* Encode image into non-compressed bitmap */ for (x = 0; x < nOutCols; x++) { mdrow[x] = encode(row, x*8); } /* Encoded. Now RLE it */ for (x = 0; x < nOutCols; ) { b = mdrow[x]; if (b != 0xFF && b != 0) /* Normal byte */ { putchar(b); ++x; } else /* RLE a run of 0s or 0xFFs */ { for (x1 = x; x1 < nOutCols; x1++) { if (mdrow[x1] != b) break; if (x1 - x > 256) break; } x1 -= x; /* x1 = no. of repeats */ if (x1 == 256) x1 = 0; putchar(b); putchar(x1); x += x1; } } } } static void usage(char *s) { printf("pbmtomda v1.00, Copyright (C) 1999 John Elliott \n" "This program is redistributable under the terms of the GNU General Public\n" "License, version 2 or later.\n\n" "Usage: %s [ -d ] [ -i ] [ -- ] [ infile ]\n\n" "-d: Halve height (to compensate for the PCW aspect ratio)\n" "-i: Invert colours\n" "--: No more options (use if filename begins with a dash)\n", s); exit(0); } int main(int argc, char **argv) { int n, optstop = 0; char *fname = NULL; pbm_init(&argc, argv); /* Output v2-format MDA images. Simulate MDA header... */ strcpy((char*) header, ".MDA pbmtomda Unixv1.00\r\n GPL \r\n"); for (n = 1; n < argc; n++) { if (argv[n][0] == '-' && !optstop) { if (argv[n][1] == 'd' || argv[n][1] == 'D') bScale = 1; if (argv[n][1] == 'i' || argv[n][1] == 'I') bInvert = 1; if (argv[n][1] == 'h' || argv[n][1] == 'H') usage(argv[0]); if (argv[n][1] == '-' && argv[n][2] == 0 && !fname) /* "--" */ { optstop = 1; } if (argv[n][1] == '-' && (argv[n][2] == 'h' || argv[n][2] == 'H')) usage(argv[0]); } else if (argv[n][0] && !fname) /* Filename */ { fname = argv[n]; } } if (fname) infile = pm_openr(fname); else infile = stdin; data = pbm_readpbm(infile, &nInCols, &nInRows); if (!data) { fprintf(stderr,"%s: Cannot read input file.\n", argv[0]); exit(1); } if (bScale) nOutRows = nInRows / 2; else nOutRows = nInRows; overflow_add(nOutRows, 3); nOutRows = ((nOutRows + 3) / 4) * 4; /* MDA wants rows a multiple of 4 */ nOutCols = nInCols / 8; if (fwrite(header, 1, 128, stdout) < 128) { perror(argv[0]); exit(2); } pm_writelittleshort(stdout, nOutRows); pm_writelittleshort(stdout, nOutCols); mdrow = malloc(nOutCols); if (!mdrow) { if (data) pbm_freearray(data, nInRows); pm_error("Not enough memory for conversion.\n"); } do_translation(); if (infile != stdin) pm_close(infile); fflush(stdout); pbm_freearray(data, nInRows); free(mdrow); return 0; } netpbm-free-10.0-1/pbm/pbmtomgr.10100644004714500471450000000131507716230207017012 0ustar aba-guestaba-guest.TH pbmtomgr 1 "24 January 1989" .IX pbmtomgr .SH NAME pbmtomgr - convert a portable bitmap into a MGR bitmap .SH SYNOPSIS .B pbmtomgr .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces a MGR bitmap as output. .IX MGR .SH "SEE ALSO" mgrtopbm(1), pbm(5) .SH AUTHOR Copyright (C) 1989 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtomgr.c0100644004714500471450000000501407716230207017074 0ustar aba-guestaba-guest/* pbmtomgr.c - read a portable bitmap and produce a MGR bitmap ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #include "mgr.h" static void putinit ARGS(( int rows, int cols )); static void putbit ARGS(( bit b )); static void putrest ARGS(( void )); static void putitem ARGS(( void )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int rows, cols, format, padright, row, col; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[pbmfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; pbm_readpbminit( ifp, &cols, &rows, &format ); bitrow = pbm_allocrow( cols ); /* Round cols up to the nearest multiple of 8. */ overflow_add(cols, 7); padright = ( ( cols + 7 ) / 8 ) * 8 - cols; putinit( rows, cols ); for ( row = 0; row < rows; ++row ) { pbm_readpbmrow( ifp, bitrow, cols, format ); for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) putbit( *bP ); for ( col = 0; col < padright; ++col ) putbit( 0 ); } pm_close( ifp ); putrest( ); exit( 0 ); } static unsigned char item; static int bitsperitem, bitshift; static void putinit( rows, cols ) int rows, cols; { struct b_header head; head.magic[0] = 'y'; head.magic[1] = 'z'; head.h_wide = ( ( cols >> 6 ) & 0x3f ) + ' '; head.l_wide = ( cols & 0x3f ) + ' '; head.h_high = ( ( rows >> 6 ) & 0x3f ) + ' '; head.l_high = ( rows & 0x3f ) + ' '; head.depth = ( 1 & 0x3f ) + ' '; head._reserved = ' '; fwrite( &head, sizeof(head), 1, stdout ); item = 0; bitsperitem = 0; bitshift = 7; } #if __STDC__ static void putbit( bit b ) #else /*__STDC__*/ static void putbit( b ) bit b; #endif /*__STDC__*/ { if ( bitsperitem == 8 ) putitem( ); ++bitsperitem; if ( b == PBM_BLACK ) item += 1 << bitshift; --bitshift; } static void putrest( ) { if ( bitsperitem > 0 ) putitem( ); } static void putitem( ) { fwrite( &item, sizeof(item), 1, stdout ); item = 0; bitsperitem = 0; bitshift = 7; } netpbm-free-10.0-1/pbm/pbmtonokia.10100644004714500471450000000340407716762513017341 0ustar aba-guestaba-guest.TH pbmtonokia 1 "26 June 2001" .IX pbmtonokia .SH NAME pbmtonokia - convert a portable bitmap to Nokia Smart Messaging Formats .SH SYNOPSIS .B pbmtonokia [options] .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces a Nokia Smart Messaging (hexcode, .nok, .ngg) file as output. .SH OPTIONS .TP .B -fmt Specifies the output format (default is HEX_NOL). .TP HEX_NOL Nokia Operator Logo as (uploadable) hexcode. Use option -net to specify network code. .TP HEX_NGG Nokia Group Graphic as (uploadable) hexcode. .TP HEX_NMP Nokia Picture Message as (uploadable) hexcode. Use option -txt to specify optional text message. .TP NOL Nokia Operator Logo as .nol format. This is editable by the Group-Graphic Editor from Kessler Wireless Design (www.kessler-design.com) .TP NGG Nokia Group Graphic as .ngg format. This is editable by the Group-Graphic Editor from Kessler Wireless Design (www.kessler-design.com) .TP .B -net Specifies the 6 hex-digit operator network code for Operator Logos (Default is 62F210 = D1,Germany). .TP .B -txt Specifies the text message for Picture Messages. Default is no text message. .SH LIMITATIONS Currently limited to rows<=255 and columns<=255. Supports only b/w graphics, not animated. .SH "SEE ALSO" .BR pbm (5), .B Nokia Smart Messaging Specification (http://forum.nokia.com) .SH AUTHOR Copyright (C) 2001 Tim Ruehsen . .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtonokia.c0100644004714500471450000001536007716762513017427 0ustar aba-guestaba-guest/* pbmtonokia.c - convert a portable bitmap to Nokia Smart Messaging Formats (NOL, NGG, HEX) ** Copyright (C)2001 OMS Open Media System GmbH, Tim Rhsen . ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. History 07.06.2001 Created 20.11.2001 Support Picture Messages new option -txt to embed text into Picture Messages new option -net to specify operator network code for Nokia Operator Logos Notes: - limited to rows<=255 and columns<=255 - supports only b/w graphics, not animated Testing: Testing was done with SwissCom SMSC (Switzerland) and IC3S SMSC (Germany). The data was send with EMI/UCP protocol over TCP/IP. - 7.6.2001: tested with Nokia 3210: 72x14 Operator Logo - 7.6.2001: tested with Nokia 6210: 72x14 Operator Logo and 72x14 Group Graphic Todo: - more testing - sendsms compatibility ? - are -fmt NOL and -fmt NGG working ok? */ #include "pbm.h" #include "string.h" #define FMT_HEX_NOL 1 #define FMT_HEX_NGG 2 #define FMT_HEX_NPM 3 #define FMT_NOL 4 #define FMT_NGG 5 static void usage(char *myname) { pm_message("Copyright (C)2001 OMS GmbH"); pm_message("Contact: Tim Ruehsen \n"); pm_usage("[options] [pbmfile]\n" " Options:\n" " -fmt " "Output format (default=HEX_NOL)\n" " -net " "Network code for NOL operator logos\n" " -txt " "Text for NMP picture messages\n"); exit(1); } int main(int argc, char *argv[]) { FILE *fp; bit **image; unsigned int c; int argpos, output=FMT_HEX_NOL, rows, cols, row, col, p, it, len; char header[32], *myname; char *network_code="62F210"; /* default is German D1 net */ char *text=NULL; if ((myname=strrchr(argv[0],'/'))!=NULL) myname++; else myname=argv[0]; pbm_init(&argc, argv); for(argpos=1;argposargpos+1 && isdigit(argv[argpos+1][0])) {argpos++;break;} } else if (!strcmp(argv[argpos],"-fmt") && argc>argpos+1) { ++argpos; if (!strcasecmp(argv[argpos],"HEX_NOL")) output=FMT_HEX_NOL; else if (!strcasecmp(argv[argpos],"HEX_NGG")) output=FMT_HEX_NGG; else if (!strcasecmp(argv[argpos],"HEX_NPM")) output=FMT_HEX_NPM; else if (!strcasecmp(argv[argpos],"NOL")) output=FMT_NOL; else if (!strcasecmp(argv[argpos],"NGG")) output=FMT_NGG; else usage(myname); } else if (!strcmp(argv[argpos],"-net") && argc>argpos+1) { network_code=argv[++argpos]; if ((len=strlen(network_code))!=6) pm_error("Network code must be 6 hex-digits long"); for (it=0;it<6;it++) { if (!isxdigit(network_code[it])) pm_error("Network code must contain hex-digits only"); if (islower(network_code[it])) network_code[it]=toupper(network_code[it]); } } else if (!strcmp(argv[argpos],"-txt") && argc>argpos+1) { text=argv[++argpos]; } else usage(myname); } else break; } if (argpos==argc) { image = pbm_readpbm(stdin, &cols, &rows); } else { fp=pm_openr(argv[argpos]); image = pbm_readpbm(fp, &cols, &rows); pm_close(fp); } memset(header,0,sizeof(header)); switch (output) { case FMT_HEX_NOL: /* header */ printf("06050415820000%s00%02X%02X01",network_code,cols,rows); /* image */ for (row=0;row>p; if (++p==8) { printf("%02X",c); p=c=0; } } if (p) printf("%02X",c); } break; case FMT_HEX_NGG: /* header */ printf("0605041583000000%02X%02X01",cols,rows); /* image */ for (row=0;row>p; if (++p==8) { printf("%02X",c); p=c=0; } } if (p) printf("%02X",c); } break; case FMT_HEX_NPM: /* header */ printf("060504158A0000"); /* text */ if (text!=NULL) { printf("00%04X",(len=strlen(text))); for (it=0;it>p; if (++p==8) { printf("%02X",c); p=c=0; } } if (p) printf("%02X",c); } break; case FMT_NOL: /* header - this is a hack */ header[1]=header[4]=header[5]=header[11]=header[13]=1; header[3]=4; header[7]=cols; header[9]=rows; header[15]=0x53; fwrite(header,17,1,stdout); /* image */ for (row=0;row\n", output); return 1; } return 0; } netpbm-free-10.0-1/pbm/pbmtopi3.10100644004714500471450000000134607716230207016724 0ustar aba-guestaba-guest.TH pbmtopi3 1 "11 March 1990" .IX pbmtopi3 .SH NAME pbmtopi3 - convert a portable bitmap into an Atari Degas .pi3 file .SH SYNOPSIS .B pbmtopi3 .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces an Atari Degas .pi3 file as output. .IX Atari .IX "Degas .pi3" .SH "SEE ALSO" pi3topbm(1), pbm(5), ppmtopi1(1), pi1toppm(1) .SH AUTHOR Copyright (C) 1988 by David Beckemeyer (bdt!david) and Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, .\" provided that the above copyright notice appear in all copies and that .\" both that copyright notice and this permission notice appear in .\" supporting documentation. netpbm-free-10.0-1/pbm/pbmtopi3.c0100644004714500471450000000500407716230207017001 0ustar aba-guestaba-guest/* pbmtopi3.c - read a portable bitmap and produce a Atari Degas .pi3 file ** ** Module created from other pbmplus tools by David Beckemeyer. ** ** Copyright (C) 1988 by David Beckemeyer and Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pbm.h" static void putinit ARGS(( void )); static void putbit ARGS(( bit b )); static void putrest ARGS(( void )); static void putitem ARGS(( void )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int rows, cols, format, padright, row, col; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[pbmfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; pbm_readpbminit( ifp, &cols, &rows, &format ); if (cols > 640) cols = 640; if (rows > 400) rows = 400; bitrow = pbm_allocrow( cols ); /* Compute padding to round cols up to 640 */ padright = 640 - cols; putinit( ); for ( row = 0; row < rows; ++row ) { pbm_readpbmrow( ifp, bitrow, cols, format ); for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) putbit( *bP ); for ( col = 0; col < padright; ++col ) putbit( 0 ); } while (row++ < 400) for ( col = 0; col < 640; ++col) putbit( 0 ); pm_close( ifp ); putrest( ); exit( 0 ); } static char item; static short bitsperitem, bitshift; static void putinit( ) { int i; if (pm_writebigshort (stdout, (short) 2) == -1 || pm_writebigshort (stdout, (short) 0x777) == -1) pm_error ("write error"); for (i = 1; i < 16; i++) if (pm_writebigshort (stdout, (short) 0) == -1) pm_error ("write error"); item = 0; bitsperitem = 0; bitshift = 7; } #if __STDC__ static void putbit( bit b ) #else /*__STDC__*/ static void putbit( b ) bit b; #endif /*__STDC__*/ { if (bitsperitem == 8) putitem( ); ++bitsperitem; if ( b == PBM_BLACK ) item += 1 << bitshift; --bitshift; } static void putrest( ) { if ( bitsperitem > 0 ) putitem( ); } static void putitem( ) { putc (item, stdout); item = 0; bitsperitem = 0; bitshift = 7; } netpbm-free-10.0-1/pbm/pbmtoplot.10100644004714500471450000000144307716230207017205 0ustar aba-guestaba-guest.TH pbmtoplot 1 "1 September 1990" .IX pbmtoplot .SH NAME pbmtoplot - convert a portable bitmap into a Unix plot(5) file .SH SYNOPSIS .B pbmtoplot .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces a Unix .I plot file. .IX plot .PP Note that there is no plottopbm tool - this transformation is one-way. .SH "SEE ALSO" pbm(5), plot(5) .SH AUTHOR Copyright (C) 1990 by Arthur David Olson. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtoplot.c0100644004714500471450000000312007716230207017261 0ustar aba-guestaba-guest/* pbmtoplot.c - read a portable bitmap and produce a UNIX-format plot file. ** ** Copyright (C) 1990 by Arthur David Olson. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pbm.h" static void puttwo ARGS((int i)); static void puttwo( i ) int i; { (void) putchar(i); (void) putchar(i >> 8); } int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; register bit** bits; register int row, col, scol; int rows, cols; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[pbmfile]" ); ifp = (argc == 2) ? pm_openr( argv[1] ) : stdin; bits = pbm_readpbm( ifp, &cols, &rows ); pm_close( ifp ); (void) putchar( 's' ); puttwo( 0 ); puttwo( 0 ); puttwo( rows - 1 ); puttwo( cols - 1 ); for ( row = 0; row < rows; ++row ) { for ( col = 0; col < cols; ++col ) { if ( bits[row][col] == PBM_WHITE ) continue; scol = col; while ( ++col < cols && bits[row][col] == PBM_BLACK ) ; /* nothing */ --col; if ( col == scol ) (void) putchar( 'p' ); else { (void) putchar( 'l' ); puttwo( scol ); puttwo( rows - 1 - row ); } puttwo( col ); puttwo( rows - 1 - row ); } } exit( 0 ); } netpbm-free-10.0-1/pbm/pbmtopsg3.10100644004714500471450000000161407716230207017103 0ustar aba-guestaba-guest.TH pbmtopsg3 "29 June 2001" .SH NAME pbmtopsg3 - convert PBM images to Postscript with G3 fax compression .SH SYNOPSIS .B pbmtopsg3 .RB [ --title=\fItitle ] .RB [ --dpi=\fIdpi ] .RI [ filespec ] .SH DESCRIPTION .PP Converts the PBM images in the input PBM file to pages in a Postscript file encoded with G3 fax compression. If you don't specify .IR filespec , the input is from Standard Input. Remember that you can create a multi-image PBM file simply by concatenating single-image PBM files, so if each page is in a different file, you might do: .B cat faxpage* | pbmtopsg3 >fax.ps .SH OPTIONS .TP .BR -title The Postscript title value. Default is no title. .TP .BR -dpi The resolution of the Postscript output. Default is 72 dpi. .SH "SEE ALSO" .BR pnmtops (1), .BR pstopnm (1), .BR gs (1), .BR pstopnm (1), .BR pbmtolps (1), .BR pbmtoepsi (1), .BR pbmtog3 (1), .BR g3topbm (1), .BR pbm (5) netpbm-free-10.0-1/pbm/pbmtopsg3.c0100644004714500471450000003430407776237374017211 0ustar aba-guestaba-guest/* pbmtopsg3 Reads a series of portable bitmaps and writes a postscript file containing these bitmaps as individual pages with Fax-G3 (CCITT-Fiter) compression. (Useful for combining scanned pages into a comfortably printable document.) Copyright (C) 2001 Kristof Koehler Netpbm adaptation by Bryan Henderson June 2001. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ #include #include #include #include #include "pbm.h" struct cmdline_info { /* All the information the user supplied in the command line, in a form easy for the program to use. */ char * inputFilespec; /* Filespec of input file */ float dpi; /* requested resolution, dpi */ char * title; /* -title option. NULL for none */ }; static void parseCommandLine(int argc, char ** argv, struct cmdline_info *cmdlineP) { optStruct3 opt; unsigned int option_def_index = 0; optEntry *option_def = malloc(100*sizeof(optEntry)); unsigned int dpiSpec, titleSpec; float dpiOpt; char * titleOpt; OPTENT3(0, "dpi", OPT_FLOAT, &dpiOpt, &dpiSpec, 0); OPTENT3(0, "title", OPT_STRING, &titleOpt, &titleSpec, 0); opt.opt_table = option_def; opt.short_allowed = FALSE; opt.allowNegNum = FALSE; pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0); if (argc-1 == 0) cmdlineP->inputFilespec = "-"; else { cmdlineP->inputFilespec = argv[1]; if (argc-1 > 1) pm_error("Too many arguments. The only argument is the input " "file specification"); } cmdlineP->dpi = dpiSpec ? dpiOpt : 72.0; cmdlineP->title = titleSpec ? titleOpt : NULL; } static void write85 ( unsigned int bits, int *col ) { char buf[5] ; if ( bits == 0 ) { fputc ( 'z', stdout ) ; *col += 1 ; } else { buf[4] = bits % 85 + '!' ; bits /= 85 ; buf[3] = bits % 85 + '!' ; bits /= 85 ; buf[2] = bits % 85 + '!' ; bits /= 85 ; buf[1] = bits % 85 + '!' ; bits /= 85 ; buf[0] = bits % 85 + '!' ; fwrite ( buf, 1, 5, stdout ) ; *col += 5 ; } if ( *col > 70 ) { printf ( "\n" ) ; *col = 0 ; } } static void writebits ( unsigned int *outbits, int *outbitsidx, int *col, unsigned int bits, int n ) { int k, m ; unsigned int usedbits ; while ( n > 0 ) { if ( *outbitsidx == 0 ) *outbits = 0 ; k = 32 - *outbitsidx ; m = n > k ? k : n ; usedbits = (bits >> (n-m)) & ((1< 0 ) { write85 ( *outbits, col ) ; *outbitsidx = 0 ; } } struct { unsigned int b, l ; } makeup[40][2] = { { { 0x001b, 5 } /* 11011 */ , { 0x000f,10 } /* 0000001111 */ }, { { 0x0012, 5 } /* 10010 */ , { 0x00c8,12 } /* 000011001000 */ }, { { 0x0017, 6 } /* 010111 */ , { 0x00c9,12 } /* 000011001001 */ }, { { 0x0037, 7 } /* 0110111 */ , { 0x005b,12 } /* 000001011011 */ }, { { 0x0036, 8 } /* 00110110 */ , { 0x0033,12 } /* 000000110011 */ }, { { 0x0037, 8 } /* 00110111 */ , { 0x0034,12 } /* 000000110100 */ }, { { 0x0064, 8 } /* 01100100 */ , { 0x0035,12 } /* 000000110101 */ }, { { 0x0065, 8 } /* 01100101 */ , { 0x006c,13 } /* 0000001101100 */ }, { { 0x0068, 8 } /* 01101000 */ , { 0x006d,13 } /* 0000001101101 */ }, { { 0x0067, 8 } /* 01100111 */ , { 0x004a,13 } /* 0000001001010 */ }, { { 0x00cc, 9 } /* 011001100 */ , { 0x004b,13 } /* 0000001001011 */ }, { { 0x00cd, 9 } /* 011001101 */ , { 0x004c,13 } /* 0000001001100 */ }, { { 0x00d2, 9 } /* 011010010 */ , { 0x004d,13 } /* 0000001001101 */ }, { { 0x00d3, 9 } /* 011010011 */ , { 0x0072,13 } /* 0000001110010 */ }, { { 0x00d4, 9 } /* 011010100 */ , { 0x0073,13 } /* 0000001110011 */ }, { { 0x00d5, 9 } /* 011010101 */ , { 0x0074,13 } /* 0000001110100 */ }, { { 0x00d6, 9 } /* 011010110 */ , { 0x0075,13 } /* 0000001110101 */ }, { { 0x00d7, 9 } /* 011010111 */ , { 0x0076,13 } /* 0000001110110 */ }, { { 0x00d8, 9 } /* 011011000 */ , { 0x0077,13 } /* 0000001110111 */ }, { { 0x00d9, 9 } /* 011011001 */ , { 0x0052,13 } /* 0000001010010 */ }, { { 0x00da, 9 } /* 011011010 */ , { 0x0053,13 } /* 0000001010011 */ }, { { 0x00db, 9 } /* 011011011 */ , { 0x0054,13 } /* 0000001010100 */ }, { { 0x0098, 9 } /* 010011000 */ , { 0x0055,13 } /* 0000001010101 */ }, { { 0x0099, 9 } /* 010011001 */ , { 0x005a,13 } /* 0000001011010 */ }, { { 0x009a, 9 } /* 010011010 */ , { 0x005b,13 } /* 0000001011011 */ }, { { 0x0018, 6 } /* 011000 */ , { 0x0064,13 } /* 0000001100100 */ }, { { 0x009b, 9 } /* 010011011 */ , { 0x0065,13 } /* 0000001100101 */ }, { { 0x0008,11 } /* 00000001000 */ , { 0x0008,11 } /* 00000001000 */ }, { { 0x000c,11 } /* 00000001100 */ , { 0x000c,11 } /* 00000001100 */ }, { { 0x000d,11 } /* 00000001101 */ , { 0x000d,11 } /* 00000001101 */ }, { { 0x0012,12 } /* 000000010010 */ , { 0x0012,12 } /* 000000010010 */ }, { { 0x0013,12 } /* 000000010011 */ , { 0x0013,12 } /* 000000010011 */ }, { { 0x0014,12 } /* 000000010100 */ , { 0x0014,12 } /* 000000010100 */ }, { { 0x0015,12 } /* 000000010101 */ , { 0x0015,12 } /* 000000010101 */ }, { { 0x0016,12 } /* 000000010110 */ , { 0x0016,12 } /* 000000010110 */ }, { { 0x0017,12 } /* 000000010111 */ , { 0x0017,12 } /* 000000010111 */ }, { { 0x001c,12 } /* 000000011100 */ , { 0x001c,12 } /* 000000011100 */ }, { { 0x001d,12 } /* 000000011101 */ , { 0x001d,12 } /* 000000011101 */ }, { { 0x001e,12 } /* 000000011110 */ , { 0x001e,12 } /* 000000011110 */ }, { { 0x001f,12 } /* 000000011111 */ , { 0x001f,12 } /* 000000011111 */ } } ; struct { unsigned int b, l ; } term[64][2] = { { { 0x0035, 8 } /* 00110101 */ , { 0x0037,10 } /* 0000110111 */ }, { { 0x0007, 6 } /* 000111 */ , { 0x0002, 3 } /* 010 */ }, { { 0x0007, 4 } /* 0111 */ , { 0x0003, 2 } /* 11 */ }, { { 0x0008, 4 } /* 1000 */ , { 0x0002, 2 } /* 10 */ }, { { 0x000b, 4 } /* 1011 */ , { 0x0003, 3 } /* 011 */ }, { { 0x000c, 4 } /* 1100 */ , { 0x0003, 4 } /* 0011 */ }, { { 0x000e, 4 } /* 1110 */ , { 0x0002, 4 } /* 0010 */ }, { { 0x000f, 4 } /* 1111 */ , { 0x0003, 5 } /* 00011 */ }, { { 0x0013, 5 } /* 10011 */ , { 0x0005, 6 } /* 000101 */ }, { { 0x0014, 5 } /* 10100 */ , { 0x0004, 6 } /* 000100 */ }, { { 0x0007, 5 } /* 00111 */ , { 0x0004, 7 } /* 0000100 */ }, { { 0x0008, 5 } /* 01000 */ , { 0x0005, 7 } /* 0000101 */ }, { { 0x0008, 6 } /* 001000 */ , { 0x0007, 7 } /* 0000111 */ }, { { 0x0003, 6 } /* 000011 */ , { 0x0004, 8 } /* 00000100 */ }, { { 0x0034, 6 } /* 110100 */ , { 0x0007, 8 } /* 00000111 */ }, { { 0x0035, 6 } /* 110101 */ , { 0x0018, 9 } /* 000011000 */ }, { { 0x002a, 6 } /* 101010 */ , { 0x0017,10 } /* 0000010111 */ }, { { 0x002b, 6 } /* 101011 */ , { 0x0018,10 } /* 0000011000 */ }, { { 0x0027, 7 } /* 0100111 */ , { 0x0008,10 } /* 0000001000 */ }, { { 0x000c, 7 } /* 0001100 */ , { 0x0067,11 } /* 00001100111 */ }, { { 0x0008, 7 } /* 0001000 */ , { 0x0068,11 } /* 00001101000 */ }, { { 0x0017, 7 } /* 0010111 */ , { 0x006c,11 } /* 00001101100 */ }, { { 0x0003, 7 } /* 0000011 */ , { 0x0037,11 } /* 00000110111 */ }, { { 0x0004, 7 } /* 0000100 */ , { 0x0028,11 } /* 00000101000 */ }, { { 0x0028, 7 } /* 0101000 */ , { 0x0017,11 } /* 00000010111 */ }, { { 0x002b, 7 } /* 0101011 */ , { 0x0018,11 } /* 00000011000 */ }, { { 0x0013, 7 } /* 0010011 */ , { 0x00ca,12 } /* 000011001010 */ }, { { 0x0024, 7 } /* 0100100 */ , { 0x00cb,12 } /* 000011001011 */ }, { { 0x0018, 7 } /* 0011000 */ , { 0x00cc,12 } /* 000011001100 */ }, { { 0x0002, 8 } /* 00000010 */ , { 0x00cd,12 } /* 000011001101 */ }, { { 0x0003, 8 } /* 00000011 */ , { 0x0068,12 } /* 000001101000 */ }, { { 0x001a, 8 } /* 00011010 */ , { 0x0069,12 } /* 000001101001 */ }, { { 0x001b, 8 } /* 00011011 */ , { 0x006a,12 } /* 000001101010 */ }, { { 0x0012, 8 } /* 00010010 */ , { 0x006b,12 } /* 000001101011 */ }, { { 0x0013, 8 } /* 00010011 */ , { 0x00d2,12 } /* 000011010010 */ }, { { 0x0014, 8 } /* 00010100 */ , { 0x00d3,12 } /* 000011010011 */ }, { { 0x0015, 8 } /* 00010101 */ , { 0x00d4,12 } /* 000011010100 */ }, { { 0x0016, 8 } /* 00010110 */ , { 0x00d5,12 } /* 000011010101 */ }, { { 0x0017, 8 } /* 00010111 */ , { 0x00d6,12 } /* 000011010110 */ }, { { 0x0028, 8 } /* 00101000 */ , { 0x00d7,12 } /* 000011010111 */ }, { { 0x0029, 8 } /* 00101001 */ , { 0x006c,12 } /* 000001101100 */ }, { { 0x002a, 8 } /* 00101010 */ , { 0x006d,12 } /* 000001101101 */ }, { { 0x002b, 8 } /* 00101011 */ , { 0x00da,12 } /* 000011011010 */ }, { { 0x002c, 8 } /* 00101100 */ , { 0x00db,12 } /* 000011011011 */ }, { { 0x002d, 8 } /* 00101101 */ , { 0x0054,12 } /* 000001010100 */ }, { { 0x0004, 8 } /* 00000100 */ , { 0x0055,12 } /* 000001010101 */ }, { { 0x0005, 8 } /* 00000101 */ , { 0x0056,12 } /* 000001010110 */ }, { { 0x000a, 8 } /* 00001010 */ , { 0x0057,12 } /* 000001010111 */ }, { { 0x000b, 8 } /* 00001011 */ , { 0x0064,12 } /* 000001100100 */ }, { { 0x0052, 8 } /* 01010010 */ , { 0x0065,12 } /* 000001100101 */ }, { { 0x0053, 8 } /* 01010011 */ , { 0x0052,12 } /* 000001010010 */ }, { { 0x0054, 8 } /* 01010100 */ , { 0x0053,12 } /* 000001010011 */ }, { { 0x0055, 8 } /* 01010101 */ , { 0x0024,12 } /* 000000100100 */ }, { { 0x0024, 8 } /* 00100100 */ , { 0x0037,12 } /* 000000110111 */ }, { { 0x0025, 8 } /* 00100101 */ , { 0x0038,12 } /* 000000111000 */ }, { { 0x0058, 8 } /* 01011000 */ , { 0x0027,12 } /* 000000100111 */ }, { { 0x0059, 8 } /* 01011001 */ , { 0x0028,12 } /* 000000101000 */ }, { { 0x005a, 8 } /* 01011010 */ , { 0x0058,12 } /* 000001011000 */ }, { { 0x005b, 8 } /* 01011011 */ , { 0x0059,12 } /* 000001011001 */ }, { { 0x004a, 8 } /* 01001010 */ , { 0x002b,12 } /* 000000101011 */ }, { { 0x004b, 8 } /* 01001011 */ , { 0x002c,12 } /* 000000101100 */ }, { { 0x0032, 8 } /* 00110010 */ , { 0x005a,12 } /* 000001011010 */ }, { { 0x0033, 8 } /* 00110011 */ , { 0x0066,12 } /* 000001100110 */ }, { { 0x0034, 8 } /* 00110100 */ , { 0x0067,12 } /* 000001100111 */ } } ; static void writelength ( unsigned int *outbits, int *outbitsidx, int *col, int bit, int length ) { while ( length >= 64 ) { int m = length / 64 ; if ( m > 40 ) m = 40 ; writebits ( outbits, outbitsidx, col, makeup[m-1][bit].b, makeup[m-1][bit].l ) ; length -= 64*m ; } writebits ( outbits, outbitsidx, col, term[length][bit].b, term[length][bit].l ) ; } static void doPage(FILE * const ifp, int const page, double const dpi) { int cols, rows, format; bit * bitrow; unsigned int row; unsigned int outbits ; int outbitsidx, col ; pbm_readpbminit(ifp, &cols, &rows, &format); bitrow = pbm_allocrow(cols); pm_message("[%u]\n", page); printf ("%%%%Page: %u %u\n", page, page); printf ("%u %u 1 [ %f 0 0 %f 0 %u ]\n" "currentfile /ASCII85Decode filter\n" "<< /Columns %u /Rows %u >> /CCITTFaxDecode filter\n" "image\n", cols, rows, dpi/72.0, -dpi/72.0, rows, cols, rows) ; outbitsidx = col = 0 ; for (row = 0 ; row < rows ; row++ ) { int lastbit, cnt ; unsigned int j; pbm_readpbmrow(ifp, bitrow, cols, format); lastbit = cnt = 0 ; for (j = 0 ; j < cols ; j++, cnt++ ) { if (bitrow[j] != lastbit ) { writelength (&outbits, &outbitsidx, &col, lastbit, cnt ) ; lastbit = 1 ^ lastbit ; cnt = 0 ; } } writelength ( &outbits, &outbitsidx, &col, lastbit, cnt ) ; } flushbits (&outbits, &outbitsidx, &col) ; printf ("~>\nshowpage\n") ; pbm_freerow(bitrow); } static void doPages(FILE * const ifp, int * const pagesP, double const dpi) { bool eof; unsigned int page; *pagesP = 0; /* initial value */ eof= FALSE; for (page = 1; !eof; page++) { doPage(ifp, page, dpi); pbm_nextimage(ifp, &eof); } *pagesP = page-1; } int main (int argc, char *argv[]) { FILE *ifp; int pages; struct cmdline_info cmdline; pbm_init(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifp = pm_openr( cmdline.inputFilespec ); printf ( "%%!PS-Adobe-3.0\n" ) ; if ( cmdline.title != NULL ) printf ( "%%%%Title: %s\n", cmdline.title ) ; printf ( "%%%%Creator: pbmtopsg3, Copyright (C) 2001 Kristof Koehler\n" "%%%%Pages: (atend)\n" "%%%%EndComments\n" ) ; doPages(ifp, &pages, cmdline.dpi); printf ( "%%%%Trailer\n" "%%%%Pages: %u\n" "%%%%EOF\n", pages ) ; pm_close(ifp); pm_close(stdout); return 0 ; } netpbm-free-10.0-1/pbm/pbmtoptx.10100644004714500471450000000147007716230207017042 0ustar aba-guestaba-guest.TH pbmtoptx 1 "31 August 1988" .IX pbmtoptx .SH NAME pbmtoptx - convert a portable bitmap into Printronix printer graphics .SH SYNOPSIS .B pbmtoptx .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces a file of Printronix printer graphics as output. .IX Printronix .PP Note that there is no ptxtopbm tool - this transformation is one way. .SH "SEE ALSO" pbm(5) .SH AUTHOR Copyright (C) 1988 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtoptx.c0100644004714500471450000000363607716230207017132 0ustar aba-guestaba-guest/* pbmtoptx.c - read a portable bitmap and produce a Printronix printer file ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" static void putinit ARGS(( void )); static void putbit ARGS(( bit b )); static void putrest ARGS(( void )); static void putitem ARGS(( void )); int main( argc, argv ) int argc; char *argv[]; { FILE *ifp; register bit *bitrow, *bP; int rows, cols, format, row, col; char *usage = "[pbmfile]"; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( usage ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; pbm_readpbminit( ifp, &cols, &rows, &format ); bitrow = pbm_allocrow( cols ); putinit( ); for ( row = 0; row < rows; row++ ) { pbm_readpbmrow( ifp, bitrow, cols, format ); for ( col = 0, bP = bitrow; col < cols; col++, bP++ ) putbit( *bP ); putrest( ); putchar( 5 ); putchar( '\n' ); } pm_close( ifp ); exit( 0 ); } static char item; static int bitsperitem, bitshift; static void putinit( ) { bitsperitem = 0; item = 64; bitshift = 0; } #if __STDC__ static void putbit( bit b ) #else /*__STDC__*/ static void putbit( b ) bit b; #endif /*__STDC__*/ { if ( bitsperitem == 6 ) putitem( ); if ( b == PBM_BLACK ) item += 1 << bitshift; bitsperitem++; bitshift++; } static void putrest( ) { if ( bitsperitem > 0 ) putitem( ); } static void putitem( ) { putchar( item ); bitsperitem = 0; item = 64; bitshift = 0; } netpbm-free-10.0-1/pbm/pbmtowbmp.10100644004714500471450000000164107721162447017202 0ustar aba-guestaba-guest.TH pbmtowbmp 1 "19 November 1999" .IX pbmtowbmp .SH NAME pbmtowbmp - convert a portable bitmap to a wireless bitmap (wbmp) file .SH SYNOPSIS .B pbmtowbmp .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces a wbmp file as output. .SH LIMITATIONS Currently only WBMP type 0 is generated. This is the only type specified in the WAP 1.1 specifications. .SH "SEE ALSO" .BR pbm (5), .BR wbmptopbm (1), .B Wireless Application Environment Specification. .SH AUTHOR Copyright (C) 1999 Terje Sannum . .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtowbmp.c0100644004714500471450000000333207716762513017267 0ustar aba-guestaba-guest/* pbmtowbmp.c - convert a portable bitmap to a Wireless Bitmap file This is derived for Netpbm from the pbmwbmp package from on 2000.06.06. The specifications for the wbmp format are part of the Wireless Application Environment specification at . ** Copyright (C) 1999 Terje Sannum . ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" static void outputint(int i) { int c = 1; while(i & 0x7f << 7*c) c++; while(c > 1) putchar(0x80 | ((i >> 7*--c) & 0xff)); putchar(i & 0x7f); } int main(int argc, char *argv[]) { FILE *f; bit **image; int rows, cols, row, col; int c, p; pbm_init(&argc, argv); if(argc > 2) { fprintf(stderr, "Copyright (C) 1999 Terje Sannum \n"); pm_usage("[pbmfile]"); } f = argc == 2 ? pm_openr(argv[1]) : stdin; image = pbm_readpbm(f, &cols, &rows); pm_close(f); /* Header */ putchar(0); /* Type 0: B/W, no compression */ putchar(0); /* FixHeaderField */ /* Geometry */ outputint(cols); outputint(rows); /* Image data */ for(row = 0; row < rows; row++) { p = c = 0; for(col = 0; col < cols; col++) { if(image[row][col] == PBM_WHITE) c = c | (1 << (7-p)); if(++p == 8) { putchar(c); p = c = 0; } } if(p) putchar(c); } return 0; } netpbm-free-10.0-1/pbm/pbmtox10bm.10100644004714500471450000000162507716230207017160 0ustar aba-guestaba-guest.TH pbmtox10bm 1 "31 August 1988" .IX pbmtox10bm .SH NAME pbmtox10bm - convert a portable bitmap into an X10 bitmap .SH SYNOPSIS .B pbmtox10bm .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces an X10 bitmap as output. This older format is maintained for compatibility. .IX "X bitmap" .IX "X window system" .PP Note that there is no x10bmtopbm tool, because .I xbmtopbm can read both X11 and X10 bitmaps. .SH "SEE ALSO" pbmtoxbm(1), xbmtopbm(1), pbm(5) .SH AUTHOR Copyright (C) 1988 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtox10bm.c0100644004714500471450000000521607716230207017242 0ustar aba-guestaba-guest/* pbmtox10bm.c - read a portable bitmap and produce an X10 bitmap file ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pbm.h" int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int rows, cols, format, padright, row; register int col; char name[100]; char* cp; int itemsperline; register int bitsperitem; register int item; int firstitem; char* hexchar = "0123456789abcdef"; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[pbmfile]" ); if ( argc == 2 ) { ifp = pm_openr( argv[1] ); strcpy( name, argv[1] ); if ( strcmp( name, "-" ) == 0 ) strcpy( name, "noname" ); if ( ( cp = strchr( name, '.' ) ) != 0 ) *cp = '\0'; } else { ifp = stdin; strcpy( name, "noname" ); } pbm_readpbminit( ifp, &cols, &rows, &format ); bitrow = pbm_allocrow( cols ); /* Compute padding to round cols up to the nearest multiple of 16. */ overflow_add(cols, 15); padright = ( ( cols + 15 ) / 16 ) * 16 - cols; printf( "#define %s_width %d\n", name, cols ); printf( "#define %s_height %d\n", name, rows ); printf( "static short %s_bits[] = {\n", name ); itemsperline = 0; bitsperitem = 0; item = 0; firstitem = 1; #define PUTITEM \ { \ if ( firstitem ) \ firstitem = 0; \ else \ putchar( ',' ); \ if ( itemsperline == 11 ) \ { \ putchar( '\n' ); \ itemsperline = 0; \ } \ if ( itemsperline == 0 ) \ putchar( ' ' ); \ ++itemsperline; \ putchar('0'); \ putchar('x'); \ putchar(hexchar[item >> 12]); \ putchar(hexchar[(item >> 8) & 15]); \ putchar(hexchar[(item >> 4) & 15]); \ putchar(hexchar[item & 15]); \ bitsperitem = 0; \ item = 0; \ } #define PUTBIT(b) \ { \ if ( bitsperitem == 16 ) \ PUTITEM; \ if ( (b) == PBM_BLACK ) \ item += 1 << bitsperitem; \ ++bitsperitem; \ } for ( row = 0; row < rows; ++row ) { pbm_readpbmrow( ifp, bitrow, cols, format ); for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) PUTBIT(*bP); for ( col = 0; col < padright; ++col ) PUTBIT(0); } pm_close( ifp ); if ( bitsperitem > 0 ) PUTITEM; printf( "};\n" ); exit( 0 ); } netpbm-free-10.0-1/pbm/pbmtoxbm.10100644004714500471450000000137207716230207017016 0ustar aba-guestaba-guest.TH pbmtoxbm 1 "31 August 1988" .IX pbmtoxbm .SH NAME pbmtoxbm - convert a portable bitmap into an X11 bitmap .SH SYNOPSIS .B pbmtoxbm .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces an X11 bitmap as output. .IX "X bitmap" .IX "X window system" .SH "SEE ALSO" pbmtox10bm(1), xbmtopbm(1), pbm(5) .SH AUTHOR Copyright (C) 1988 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtoxbm.c0100644004714500471450000001070207716230207017075 0ustar aba-guestaba-guest/* pbmtoxbm.c - read a portable bitmap and produce an X11 bitmap file ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pbm.h" static void generate_name(char filename_arg[], char * const name) { /*---------------------------------------------------------------------------- Generate a name for the image to put in the bitmap file. Derive it from the filename argument filename_arg[] and return it as a null-terminated string in the space pointed to by 'name'. We take the part of the name after the rightmost slash (i.e. filename without the directory path part), stopping before any period. We convert any punctuation to underscores. If the argument is "-", meaning standard input, we return the name "noname". Also, if the argument is null or ends in a slash, we return "noname". -----------------------------------------------------------------------------*/ if (strcmp(filename_arg, "-") == 0) strcpy(name, "noname"); else { int name_index, arg_index; /* indices into the input and output buffers */ /* Start just after the rightmost slash, or at beginning if no slash */ if (strrchr(filename_arg, '/') == 0) arg_index = 0; else arg_index = strrchr(filename_arg, '/') - filename_arg + 1; if (filename_arg[arg_index] == '\0') strcpy(name, "noname"); else { name_index = 0; /* Start at beginning of name buffer */ while (filename_arg[arg_index] != '\0' && filename_arg[arg_index] != '.') { const char filename_char = filename_arg[arg_index++]; name[name_index++] = isalnum(filename_char) ? filename_char : '_'; } name[name_index] = '\0'; } } } int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int rows, cols, format, padright, row; register int col; char name[100]; int itemsperline; register int bitsperitem; register int item; int firstitem; char* hexchar = "0123456789abcdef"; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[pbmfile]" ); if ( argc == 2 ) { ifp = pm_openr( argv[1] ); generate_name(argv[1], name); } else { ifp = stdin; strcpy( name, "noname" ); } pbm_readpbminit( ifp, &cols, &rows, &format ); bitrow = pbm_allocrow( cols ); /* Compute padding to round cols up to the nearest multiple of 8. */ overflow_add(cols, 8); padright = ( ( cols + 7 ) / 8 ) * 8 - cols; printf( "#define %s_width %d\n", name, cols ); printf( "#define %s_height %d\n", name, rows ); printf( "static char %s_bits[] = {\n", name ); itemsperline = 0; bitsperitem = 0; item = 0; firstitem = 1; #define PUTITEM \ { \ if ( firstitem ) \ firstitem = 0; \ else \ putchar( ',' ); \ if ( itemsperline == 15 ) \ { \ putchar( '\n' ); \ itemsperline = 0; \ } \ if ( itemsperline == 0 ) \ putchar( ' ' ); \ ++itemsperline; \ putchar('0'); \ putchar('x'); \ putchar(hexchar[item >> 4]); \ putchar(hexchar[item & 15]); \ bitsperitem = 0; \ item = 0; \ } #define PUTBIT(b) \ { \ if ( bitsperitem == 8 ) \ PUTITEM; \ if ( (b) == PBM_BLACK ) \ item += 1 << bitsperitem; \ ++bitsperitem; \ } for ( row = 0; row < rows; ++row ) { pbm_readpbmrow( ifp, bitrow, cols, format ); for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) PUTBIT(*bP); for ( col = 0; col < padright; ++col ) PUTBIT(0); } if ( ifp != stdin ) fclose( ifp ); if ( bitsperitem > 0 ) PUTITEM; printf( "};\n" ); exit( 0 ); } /* CHANGE HISTORY 99.09.08 bryanh In determining the image name, take only the filename, not the whole filepath. Also, convert any punctuation to underscores. This avoids creating an invalid C variable name, which can make the output unusable. */ netpbm-free-10.0-1/pbm/pbmtoybm.10100644004714500471450000000151507721162447017024 0ustar aba-guestaba-guest.TH pbmtoybm 1 "06 March 1990" .IX pbmtoybm .SH NAME pbmtoybm - convert a portable bitmap into a Bennet Yee "face" file .SH SYNOPSIS .B pbmtoybm .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces as output a file acceptable to the .I face and .I xbm programs by Bennet Yee (bsy+@cs.cmu.edu). .IX face .SH "SEE ALSO" ybmtopbm(1), pbm(5), face(1), face(5), xbm(1) .SH AUTHOR Copyright (C) 1991 by Jamie Zawinski and Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmtoybm.c0100644004714500471450000000462207716230207017102 0ustar aba-guestaba-guest/* pbmtoybm.c - read a pbm and write a file for Bennet Yee's 'xbm' and 'face' ** programs. ** ** Written by Jamie Zawinski based on code (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pbm.h" #define YBM_MAGIC ( ( '!' << 8 ) | '!' ) static void putinit ARGS(( int cols, int rows )); static void putbit ARGS(( bit b )); static void putrest ARGS(( void )); static void putitem ARGS(( void )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int rows, cols, format, padright, row, col; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[pbmfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; pbm_readpbminit( ifp, &cols, &rows, &format ); bitrow = pbm_allocrow( cols ); /* Compute padding to round cols up to the nearest multiple of 16. */ overflow_add(cols, 16); padright = ( ( cols + 15 ) / 16 ) * 16 - cols; putinit( cols, rows ); for ( row = 0; row < rows; ++row ) { pbm_readpbmrow( ifp, bitrow, cols, format ); for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) putbit( *bP ); for ( col = 0; col < padright; ++col ) putbit( 0 ); } if ( ifp != stdin ) fclose( ifp ); putrest( ); exit( 0 ); } static long item; static int bitsperitem, bitshift; static void putinit( cols, rows ) int cols, rows; { pm_writebigshort( stdout, YBM_MAGIC ); pm_writebigshort( stdout, cols ); pm_writebigshort( stdout, rows ); item = 0; bitsperitem = 0; bitshift = 0; } #if __STDC__ static void putbit( bit b ) #else /*__STDC__*/ static void putbit( b ) bit b; #endif /*__STDC__*/ { if ( bitsperitem == 16 ) putitem( ); ++bitsperitem; if ( b == PBM_BLACK ) item += 1 << bitshift; ++bitshift; } static void putrest( ) { if ( bitsperitem > 0 ) putitem( ); } static void putitem( ) { pm_writebigshort( stdout, item ); item = 0; bitsperitem = 0; bitshift = 0; } netpbm-free-10.0-1/pbm/pbmtozinc.10100644004714500471450000000167007716230207017174 0ustar aba-guestaba-guest.TH pbmtozinc l "02 November 1990" .IX pbmtozinc .SH NAME pbmtozinc - convert a portable bitmap into a Zinc bitmap .SH SYNOPSIS .B pbmtozinc .RI [ pbmfile ] .SH DESCRIPTION Reads a portable bitmap as input. Produces a bitmap in the format used by the Zinc Interface Library (ZIL) Version 1.0 as output. .IX "Zinc Interface Library" .SH "SEE ALSO" pbm(5) .SH AUTHOR Copyright (C) 1988 by James Darrell McCauley (jdm5548@diamond.tamu.edu) and Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. .\" .\" Zinc and Zinc Interface Library are trademarks of .\" Zinc Software Inc., Pleasant Grove, Utah. netpbm-free-10.0-1/pbm/pbmtozinc.c0100644004714500471450000000570507716230207017261 0ustar aba-guestaba-guest/* pbmtozinc.c - read a portable bitmap and produce an bitmap file ** in the format used by the Zinc Interface Library (v1.0) ** November 1990. ** ** Author: James Darrell McCauley ** Department of Agricultural Engineering ** Texas A&M University ** College Station, Texas 77843-2117 USA ** ** Copyright (C) 1988 by James Darrell McCauley (jdm5548@diamond.tamu.edu) ** and Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include #include "pbm.h" int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int rows, cols, format, padright, row; register int col; char name[100]; char* cp; int itemsperline; register int bitsperitem; register int item; int firstitem; char* hexchar = "084c2a6e195d3b7f"; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[pbmfile]" ); if ( argc == 2 ) { ifp = pm_openr( argv[1] ); strcpy( name, argv[1] ); if ( strcmp( name, "-" ) == 0 ) strcpy( name, "noname" ); if ( ( cp = strchr( name, '.' ) ) != 0 ) *cp = '\0'; } else { ifp = stdin; strcpy( name, "noname" ); } pbm_readpbminit( ifp, &cols, &rows, &format ); bitrow = pbm_allocrow( cols ); /* Compute padding to round cols up to the nearest multiple of 16. */ overflow_add(cols, 16); padright = ( ( cols + 15 ) / 16 ) * 16 - cols; printf( "USHORT %s[] = {\n",name); printf( " %d\n", cols ); printf( " %d\n", rows ); itemsperline = 0; bitsperitem = 0; item = 0; firstitem = 1; #define PUTITEM \ { \ if ( firstitem ) \ firstitem = 0; \ else \ putchar( ',' ); \ if ( itemsperline == 11 ) \ { \ putchar( '\n' ); \ itemsperline = 0; \ } \ if ( itemsperline == 0 ) \ putchar( ' ' ); \ ++itemsperline; \ putchar('0'); \ putchar('x'); \ putchar(hexchar[item & 15]); \ putchar(hexchar[(item >> 4) & 15]); \ putchar(hexchar[(item >> 8) & 15]); \ putchar(hexchar[item >> 12]); \ bitsperitem = 0; \ item = 0; \ } #define PUTBIT(b) \ { \ if ( bitsperitem == 16 ) \ PUTITEM; \ if ( (b) == PBM_BLACK ) \ item += 1 << bitsperitem; \ ++bitsperitem; \ } for ( row = 0; row < rows; ++row ) { pbm_readpbmrow( ifp, bitrow, cols, format ); for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) PUTBIT( *bP ); for ( col = 0; col < padright; ++col ) PUTBIT( 0 ); } pm_close( ifp ); if ( bitsperitem > 0 ) PUTITEM; printf( "};\n" ); exit( 0 ); } netpbm-free-10.0-1/pbm/pbmupc.10100644004714500471450000000303707716230207016454 0ustar aba-guestaba-guest.TH pbmupc 1 "14 March 1989" .IX pbmupc .SH NAME pbmupc - create a Universal Product Code bitmap .SH SYNOPSIS .B pbmupc .RB [ -s1 | -s2 ] .I type manufac product .SH DESCRIPTION Generates a Universal Product Code symbol. .IX "Universal Product Code" The three arguments are: a one digit product type, a five digit manufacturer code, and a five digit product code. For example, "0 72890 00011" is the code for Heineken. .IX Heineken .PP As presently configured, .I pbmupc produces a bitmap 230 bits wide and 175 bits high. The size can be altered by changing the defines at the beginning of the program, or by running the output through .I pnmenlarge or .IR pnmscale . .SH OPTIONS .PP The .B -s1 and .B -s2 flags select the style of UPC to generate. The default, .BR -s1 , looks more or less like this: .nf |||||||||||||||| |||||||||||||||| |||||||||||||||| |||||||||||||||| 0||12345||67890||5 .fi The other style, .BR -s2 , puts the product type digit higher up, and doesn't display the checksum digit: .nf |||||||||||||||| |||||||||||||||| 0|||||||||||||||| |||||||||||||||| ||12345||67890|| .fi .SH "SEE ALSO" pbm(5) .SH AUTHOR Copyright (C) 1989 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/pbmupc.c0100644004714500471450000004657507725102161016551 0ustar aba-guestaba-guest/* pbmupc.c - create a Universal Product Code bitmap ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" #include #define MARGIN 20 #define DIGIT_WIDTH 14 #define DIGIT_HEIGHT 23 #define LINE1_WIDTH 2 #define LINE2_WIDTH ( 2 * LINE1_WIDTH ) #define LINE3_WIDTH ( 3 * LINE1_WIDTH ) #define LINE4_WIDTH ( 4 * LINE1_WIDTH ) #define LINES_WIDTH ( 7 * LINE1_WIDTH ) #define SHORT_HEIGHT ( 8 * LINES_WIDTH ) #define TALL_HEIGHT ( SHORT_HEIGHT + DIGIT_HEIGHT / 2 ) static int alldig ARGS(( char* cp )); static void putdigit ARGS(( int d, bit** bits, int row0, int col0 )); static int addlines ARGS(( int d, bit** bits, int row0, int col0, int height, bit color )); static int rect ARGS(( bit** bits, int row0, int col0, int height, int width, bit color )); int main( argc, argv ) int argc; char* argv[]; { register bit** bits; int argn, style, rows, cols, row, digrow, col, digcolofs; char* typecode; char* manufcode; char* prodcode; int sum, p, lc0, lc1, lc2, lc3, lc4, rc0, rc1, rc2, rc3, rc4; char* usage = "[-s1|-s2] "; pbm_init( &argc, argv ); argn = 1; style = 1; /* Check for flags. */ while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( pm_keymatch( argv[argn], "-s1", 3 ) ) style = 1; else if ( pm_keymatch( argv[argn], "-s2", 3 ) ) style = 2; else pm_usage( usage ); argn++; } if ( argn + 3 < argc ) pm_usage( usage ); typecode = argv[argn]; manufcode = argv[argn + 1]; prodcode = argv[argn + 2]; argn += 3; if ( argn != argc ) pm_usage( usage ); if ( strlen( typecode ) != 1 || ( ! alldig( typecode ) ) || strlen( manufcode ) != 5 || ( ! alldig ( manufcode ) ) || strlen( prodcode ) != 5 || ( ! alldig ( prodcode ) ) ) pm_error( "type code must be one digit, and\n manufacturer and product codes must be five digits" ); p = typecode[0] - '0'; lc0 = manufcode[0] - '0'; lc1 = manufcode[1] - '0'; lc2 = manufcode[2] - '0'; lc3 = manufcode[3] - '0'; lc4 = manufcode[4] - '0'; rc0 = prodcode[0] - '0'; rc1 = prodcode[1] - '0'; rc2 = prodcode[2] - '0'; rc3 = prodcode[3] - '0'; rc4 = prodcode[4] - '0'; sum = ( 10 - ( ( ( p + lc1 + lc3 + rc0 + rc2 + rc4 ) * 3 + lc0 + lc2 + lc4 + rc1 + rc3 ) % 10 ) ) % 10; rows = 2 * MARGIN + SHORT_HEIGHT + DIGIT_HEIGHT; cols = 2 * MARGIN + 12 * LINES_WIDTH + 11 * LINE1_WIDTH; bits = pbm_allocarray( cols, rows ); (void) rect( bits, 0, 0, rows, cols, PBM_WHITE ); row = MARGIN; digrow = row + SHORT_HEIGHT; col = MARGIN; digcolofs = ( LINES_WIDTH - DIGIT_WIDTH ) / 2; if ( style == 1 ) putdigit( p, bits, digrow, col - DIGIT_WIDTH - LINE1_WIDTH ); else if ( style == 2 ) putdigit( p, bits, row + SHORT_HEIGHT / 2, col - DIGIT_WIDTH - LINE1_WIDTH ); col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK ); col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_WHITE ); col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK ); col = addlines( p, bits, row, col, TALL_HEIGHT, PBM_WHITE ); putdigit( lc0, bits, digrow, col + digcolofs ); col = addlines( lc0, bits, row, col, SHORT_HEIGHT, PBM_WHITE ); putdigit( lc1, bits, digrow, col + digcolofs ); col = addlines( lc1, bits, row, col, SHORT_HEIGHT, PBM_WHITE ); putdigit( lc2, bits, digrow, col + digcolofs ); col = addlines( lc2, bits, row, col, SHORT_HEIGHT, PBM_WHITE ); putdigit( lc3, bits, digrow, col + digcolofs ); col = addlines( lc3, bits, row, col, SHORT_HEIGHT, PBM_WHITE ); putdigit( lc4, bits, digrow, col + digcolofs ); col = addlines( lc4, bits, row, col, SHORT_HEIGHT, PBM_WHITE ); col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_WHITE ); col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK ); col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_WHITE ); col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK ); col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_WHITE ); putdigit( rc0, bits, digrow, col + digcolofs ); col = addlines( rc0, bits, row, col, SHORT_HEIGHT, PBM_BLACK ); putdigit( rc1, bits, digrow, col + digcolofs ); col = addlines( rc1, bits, row, col, SHORT_HEIGHT, PBM_BLACK ); putdigit( rc2, bits, digrow, col + digcolofs ); col = addlines( rc2, bits, row, col, SHORT_HEIGHT, PBM_BLACK ); putdigit( rc3, bits, digrow, col + digcolofs ); col = addlines( rc3, bits, row, col, SHORT_HEIGHT, PBM_BLACK ); putdigit( rc4, bits, digrow, col + digcolofs ); col = addlines( rc4, bits, row, col, SHORT_HEIGHT, PBM_BLACK ); col = addlines( sum, bits, row, col, TALL_HEIGHT, PBM_BLACK ); col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK ); col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_WHITE ); col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK ); if ( style == 1 ) putdigit( sum, bits, digrow, col + LINE1_WIDTH ); pbm_writepbm( stdout, bits, cols, rows, 0 ); pm_close( stdout ); exit( 0 ); } static int alldig( cp ) char* cp; { for ( ; *cp != '\0'; cp++ ) if ( *cp < '0' || *cp > '9' ) return 0; return 1; } static void putdigit( d, bits, row0, col0 ) int d; bit** bits; int row0, col0; { int row, col; static bit digits[10][DIGIT_HEIGHT][DIGIT_WIDTH] = { /* 0 */ { {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,1,1,1,1,1,1,0,0,0,0}, {0,0,0,1,1,1,1,1,1,1,1,0,0,0}, {0,0,1,1,1,0,0,0,0,1,1,1,0,0}, {0,0,1,1,0,0,0,0,0,0,1,1,0,0}, {0,1,1,1,0,0,0,0,0,0,1,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,1,0,0,0,0,0,0,1,1,1,0}, {0,0,1,1,0,0,0,0,0,0,1,1,0,0}, {0,0,1,1,1,0,0,0,0,1,1,1,0,0}, {0,0,0,1,1,1,1,1,1,1,1,0,0,0}, {0,0,0,0,1,1,1,1,1,1,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0} }, /* 1 */ { {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,1,1,1,0,0,0,0,0,0}, {0,0,0,0,1,1,1,1,0,0,0,0,0,0}, {0,0,0,1,1,1,1,1,0,0,0,0,0,0}, {0,0,1,1,1,0,1,1,0,0,0,0,0,0}, {0,0,1,1,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0} }, /* 2 */ { {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,1,1,1,1,0,0,0,0,0}, {0,0,0,1,1,1,1,1,1,1,1,0,0,0}, {0,0,1,1,1,1,0,0,1,1,1,1,0,0}, {0,1,1,1,0,0,0,0,0,0,1,1,0,0}, {0,1,1,0,0,0,0,0,0,0,1,1,1,0}, {0,0,0,0,0,0,0,0,0,0,0,1,1,0}, {0,0,0,0,0,0,0,0,0,0,0,1,1,0}, {0,0,0,0,0,0,0,0,0,0,1,1,1,0}, {0,0,0,0,0,0,0,0,0,1,1,1,0,0}, {0,0,0,0,0,0,0,0,1,1,1,0,0,0}, {0,0,0,0,0,0,0,1,1,1,0,0,0,0}, {0,0,0,0,0,0,1,1,1,0,0,0,0,0}, {0,0,0,0,0,1,1,1,0,0,0,0,0,0}, {0,0,0,0,1,1,1,0,0,0,0,0,0,0}, {0,0,0,1,1,1,0,0,0,0,0,0,0,0}, {0,0,1,1,1,0,0,0,0,0,0,0,0,0}, {0,1,1,1,0,0,0,0,0,0,0,0,0,0}, {0,1,1,1,1,1,1,1,1,1,1,1,1,0}, {0,1,1,1,1,1,1,1,1,1,1,1,1,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0} }, /* 3 */ { {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,1,1,1,1,1,1,1,1,1,1,1,1,0}, {0,1,1,1,1,1,1,1,1,1,1,1,1,0}, {0,0,0,0,0,0,0,0,0,0,1,1,1,0}, {0,0,0,0,0,0,0,0,0,1,1,1,0,0}, {0,0,0,0,0,0,0,0,1,1,1,0,0,0}, {0,0,0,0,0,0,0,1,1,1,0,0,0,0}, {0,0,0,0,0,0,1,1,1,0,0,0,0,0}, {0,0,0,0,0,1,1,1,1,0,0,0,0,0}, {0,0,0,0,0,1,1,1,1,1,1,0,0,0}, {0,0,0,0,0,0,0,0,1,1,1,1,0,0}, {0,0,0,0,0,0,0,0,0,0,1,1,0,0}, {0,0,0,0,0,0,0,0,0,0,1,1,1,0}, {0,0,0,0,0,0,0,0,0,0,0,1,1,0}, {0,0,0,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,1,1,1,0}, {0,1,1,1,0,0,0,0,0,0,1,1,0,0}, {0,0,1,1,1,1,0,0,1,1,1,1,0,0}, {0,0,0,1,1,1,1,1,1,1,1,0,0,0}, {0,0,0,0,0,1,1,1,1,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0} }, /* 4 */ { {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,1,1,1,0,0,0,0,0,0}, {0,0,0,0,0,1,1,0,0,0,0,0,0,0}, {0,0,0,0,1,1,1,0,0,0,0,0,0,0}, {0,0,0,0,1,1,0,0,0,0,0,0,0,0}, {0,0,0,1,1,1,0,0,0,0,0,0,0,0}, {0,0,0,1,1,0,0,0,1,1,0,0,0,0}, {0,0,1,1,1,0,0,0,1,1,0,0,0,0}, {0,0,1,1,0,0,0,0,1,1,0,0,0,0}, {0,1,1,1,0,0,0,0,1,1,0,0,0,0}, {0,1,1,1,1,1,1,1,1,1,1,1,1,0}, {0,1,1,1,1,1,1,1,1,1,1,1,1,0}, {0,0,0,0,0,0,0,0,1,1,0,0,0,0}, {0,0,0,0,0,0,0,0,1,1,0,0,0,0}, {0,0,0,0,0,0,0,0,1,1,0,0,0,0}, {0,0,0,0,0,0,0,0,1,1,0,0,0,0}, {0,0,0,0,0,0,0,0,1,1,0,0,0,0}, {0,0,0,0,0,0,0,0,1,1,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0} }, /* 5 */ { {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,1,1,1,1,1,1,1,1,1,1,1,1,0}, {0,1,1,1,1,1,1,1,1,1,1,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,0,0,0}, {0,1,1,0,0,0,0,0,0,0,0,0,0,0}, {0,1,1,0,0,0,0,0,0,0,0,0,0,0}, {0,1,1,0,0,0,0,0,0,0,0,0,0,0}, {0,1,1,0,0,0,0,0,0,0,0,0,0,0}, {0,1,1,1,1,1,1,1,1,0,0,0,0,0}, {0,1,1,1,1,1,1,1,1,1,1,0,0,0}, {0,0,0,0,0,0,0,0,1,1,1,1,0,0}, {0,0,0,0,0,0,0,0,0,0,1,1,0,0}, {0,0,0,0,0,0,0,0,0,0,1,1,1,0}, {0,0,0,0,0,0,0,0,0,0,0,1,1,0}, {0,0,0,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,1,1,1,0}, {0,1,1,1,0,0,0,0,0,0,1,1,0,0}, {0,0,1,1,1,1,0,0,1,1,1,1,0,0}, {0,0,0,1,1,1,1,1,1,1,1,0,0,0}, {0,0,0,0,0,1,1,1,1,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0} }, /* 6 */ { {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,1,1,0,0,0,0,0}, {0,0,0,0,0,0,1,1,1,0,0,0,0,0}, {0,0,0,0,0,1,1,1,0,0,0,0,0,0}, {0,0,0,0,1,1,1,0,0,0,0,0,0,0}, {0,0,0,1,1,1,0,0,0,0,0,0,0,0}, {0,0,0,1,1,0,0,0,0,0,0,0,0,0}, {0,0,1,1,1,0,0,0,0,0,0,0,0,0}, {0,0,1,1,0,1,1,1,1,0,0,0,0,0}, {0,0,1,1,1,1,1,1,1,1,1,0,0,0}, {0,1,1,1,1,1,0,0,1,1,1,1,0,0}, {0,1,1,1,0,0,0,0,0,0,1,1,0,0}, {0,1,1,1,0,0,0,0,0,0,1,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,1,0,0,0,0,0,0,1,1,1,0}, {0,0,1,1,0,0,0,0,0,0,1,1,0,0}, {0,0,1,1,1,1,0,0,1,1,1,1,0,0}, {0,0,0,1,1,1,1,1,1,1,1,0,0,0}, {0,0,0,0,0,1,1,1,1,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0} }, /* 7 */ { {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,1,1,1,1,1,1,1,1,1,1,1,1,0}, {0,1,1,1,1,1,1,1,1,1,1,1,1,0}, {0,0,0,0,0,0,0,0,0,0,1,1,1,0}, {0,0,0,0,0,0,0,0,0,0,1,1,0,0}, {0,0,0,0,0,0,0,0,0,1,1,1,0,0}, {0,0,0,0,0,0,0,0,0,1,1,0,0,0}, {0,0,0,0,0,0,0,0,1,1,1,0,0,0}, {0,0,0,0,0,0,0,0,1,1,0,0,0,0}, {0,0,0,0,0,0,0,1,1,1,0,0,0,0}, {0,0,0,0,0,0,0,1,1,0,0,0,0,0}, {0,0,0,0,0,0,1,1,1,0,0,0,0,0}, {0,0,0,0,0,0,1,1,0,0,0,0,0,0}, {0,0,0,0,0,1,1,1,0,0,0,0,0,0}, {0,0,0,0,0,1,1,0,0,0,0,0,0,0}, {0,0,0,0,0,1,1,0,0,0,0,0,0,0}, {0,0,0,0,1,1,1,0,0,0,0,0,0,0}, {0,0,0,0,1,1,0,0,0,0,0,0,0,0}, {0,0,0,0,1,1,0,0,0,0,0,0,0,0}, {0,0,0,0,1,1,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0} }, /* 8 */ { {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,1,1,1,1,1,1,1,1,0,0,0}, {0,0,1,1,1,1,1,1,1,1,1,1,0,0}, {0,1,1,1,0,0,0,0,0,0,1,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,1,0,0,0,0,0,0,1,1,1,0}, {0,0,1,1,1,0,0,0,0,1,1,1,0,0}, {0,0,0,1,1,1,0,0,1,1,1,0,0,0}, {0,0,0,0,1,1,1,1,1,1,0,0,0,0}, {0,0,0,0,1,1,1,1,1,1,0,0,0,0}, {0,0,0,1,1,1,0,0,1,1,1,0,0,0}, {0,0,1,1,1,0,0,0,0,1,1,1,0,0}, {0,1,1,1,0,0,0,0,0,0,1,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,1,0,0,0,0,0,0,1,1,1,0}, {0,0,1,1,1,1,1,1,1,1,1,1,0,0}, {0,0,0,1,1,1,1,1,1,1,1,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0} }, /* 9 */ { {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,1,1,1,1,0,0,0,0,0}, {0,0,0,1,1,1,1,1,1,1,1,0,0,0}, {0,0,1,1,1,1,0,0,1,1,1,1,0,0}, {0,0,1,1,0,0,0,0,0,0,1,1,0,0}, {0,1,1,1,0,0,0,0,0,0,1,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,0,0,0,0,0,0,0,0,1,1,0}, {0,1,1,1,0,0,0,0,0,0,1,1,1,0}, {0,0,1,1,0,0,0,0,0,0,1,1,1,0}, {0,0,1,1,1,1,0,0,1,1,1,1,1,0}, {0,0,0,1,1,1,1,1,1,1,1,1,0,0}, {0,0,0,0,0,1,1,1,1,0,1,1,0,0}, {0,0,0,0,0,0,0,0,0,1,1,1,0,0}, {0,0,0,0,0,0,0,0,0,1,1,0,0,0}, {0,0,0,0,0,0,0,0,1,1,1,0,0,0}, {0,0,0,0,0,0,0,1,1,1,0,0,0,0}, {0,0,0,0,0,0,1,1,1,0,0,0,0,0}, {0,0,0,0,0,1,1,1,0,0,0,0,0,0}, {0,0,0,0,0,1,1,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0} } }; for ( row = 0; row < DIGIT_HEIGHT; row++ ) for ( col = 0; col < DIGIT_WIDTH; col++ ) bits[row0 + row][col0 + col] = digits[d][row][col]; } #if __STDC__ static int addlines( int d, bit** bits, int row0, int col0, int height, bit color ) #else /*__STDC__*/ static int addlines( d, bits, row0, col0, height, color ) int d; bit** bits; int row0, col0, height; bit color; #endif /*__STDC__*/ { switch ( d ) { case 0: col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color ); col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color ); break; case 1: col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color ); col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color ); break; case 2: col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color ); col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color ); break; case 3: col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE4_WIDTH, 1 - color ); col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color ); break; case 4: col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color ); col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color ); break; case 5: col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color ); col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color ); break; case 6: col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color ); col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE4_WIDTH, 1 - color ); break; case 7: col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE3_WIDTH, 1 - color ); col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color ); break; case 8: col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color ); col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE3_WIDTH, 1 - color ); break; case 9: col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color ); col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color ); col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color ); break; default: pm_error( "can't happen" ); } return col0; } #if __STDC__ static int rect( bit** bits, int row0, int col0, int height, int width, bit color ) #else /*__STDC__*/ static int rect( bits, row0, col0, height, width, color ) bit** bits; int row0, col0, height, width; bit color; #endif /*__STDC__*/ { int row, col; for ( row = row0; row < row0 + height; row++ ) for ( col = col0; col < col0 + width; col++ ) bits[row][col] = color; return col0 + width; } netpbm-free-10.0-1/pbm/pi3topbm.10100644004714500471450000000135507716230207016724 0ustar aba-guestaba-guest.TH pi3topbm 1 "11 March 1990" .IX pi3topbm .SH NAME pi3topbm - convert an Atari Degas .pi3 file into a portable bitmap .SH SYNOPSIS .B pi3topbm .RI [ pi3file ] .SH DESCRIPTION Reads an Atari Degas .pi3 file as input. .IX Atari .IX "Degas .pi3" Produces a portable bitmap as output. .SH "SEE ALSO" pbmtopi3(1), pbm(5), pi1toppm(1), ppmtopi1(1) .SH AUTHOR Copyright (C) 1988 by David Beckemeyer (bdt!david) and Diomidis D. Spinellis. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, .\" provided that the above copyright notice appear in all copies and that .\" both that copyright notice and this permission notice appear in .\" supporting documentation. netpbm-free-10.0-1/pbm/pi3topbm.c0100644004714500471450000000473307716230207017011 0ustar aba-guestaba-guest/* * Convert a ATARI Degas .pi3 file to a portable bitmap file. * * Author: David Beckemeyer * * This code was derived from the original gemtopbm program written * by Diomidis D. Spinellis. * * (C) Copyright 1988 David Beckemeyer and Diomidis D. Spinellis. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation. * * This file is provided AS IS with no warranties of any kind. The author * shall have no liability with respect to the infringement of copyrights, * trade secrets or any patents by this file or any part thereof. In no * event will the author be liable for any lost revenue or profits or * other special, indirect and consequential damages. */ #include #include "pbm.h" int main(argc, argv) int argc; char *argv[]; { int debug = 0; FILE *f; int x; int i, k; int c; int rows, cols; bit *bitrow; short res; int black, white; char *usage = "[-debug] [pi3file]"; int argn = 1; pbm_init( &argc, argv ); while (argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0') { if (pm_keymatch(argv[1], "-debug", 2)) debug = 1; else pm_usage (usage); ++argn; } if (argn == argc) f = stdin; else { f = pm_openr (argv[argn]); ++argn; } if (argn != argc) pm_usage (usage); if (pm_readbigshort (f, &res) == -1) pm_error ("EOF / read error"); if (debug) pm_message ("resolution is %d", res); /* only handles hi-rez 640x400 */ if (res != 2) pm_error( "bad resolution" ); pm_readbigshort (f, &res); if (res == 0) { black = PBM_WHITE; white = PBM_BLACK; } else { black = PBM_BLACK; white = PBM_WHITE; } for (i = 1; i < 16; i++) if (pm_readbigshort (f, &res) == -1) pm_error ("EOF / read error"); cols = 640; rows = 400; pbm_writepbminit( stdout, cols, rows, 0 ); bitrow = pbm_allocrow( cols ); for (i = 0; i < rows; ++i) { x = 0; while (x < cols) { if ((c = getc(f)) == EOF) pm_error( "end of file reached" ); for (k = 0x80; k; k >>= 1) { bitrow[x] = (k & c) ? black : white; ++x; } } pbm_writepbmrow( stdout, bitrow, cols, 0 ); } pm_close( f ); pm_close( stdout ); exit(0); } netpbm-free-10.0-1/pbm/thinkjettopbm.10100644004714500471450000000212507716230207020045 0ustar aba-guestaba-guest.TH thinkjettopbm 1 "03 April 2001" .SH NAME thinkjettopbm \- convert HP ThinkJet printer commands file to PBM .SH SYNOPSIS .B thinkjettopbm .RI [ -d ] .RI [ thinkjet_file ] .SH DESCRIPTION Reads HP ThinkJet printer commands from the standard input, or .I thinkjet_file if specified, and writes a PBM image to the standard output. Text and non-graphics command sequences are silently ignored. The .B -d option turns on debugging messages which are written to the standard error stream. .SH BUGS Handles only a small subset of ThinkJet command sequences, but enough to convert screen images from older HP test equipment. .SH "SEE ALSO" .BR pbm (5), .BR pjtoppm (1) .SH AUTHOR Copyright (C) 2001 by W. Eric Norum .\" Permission to use, copy, modify, and distribute this software and .\" its documentation for any purpose and without fee is hereby granted, .\" provided that the above copyright notice appear in all copies and .\" that both that copyright notice and this permission notice appear in .\" supporting documentation. This software is provided "as is" without .\" express or implied warranty. netpbm-free-10.0-1/pbm/thinkjettopbm.l0100644004714500471450000001265407716762513020162 0ustar aba-guestaba-guest%pointer /* * $Id: thinkjettopbm.l,v 1.2 2003/08/14 19:38:51 aba-guest Exp $ * * Simple FLEX scanner to convert HP ThinkJet graphics image * to PBM format. * * Implements a small subset of ThinkJet commands. * * Copyright (C) 2001 by W. Eric Norum * * Department of Electrical Engineering * University of Saskatchewan * Saskatoon, Saskatchewan, CANADA * eric.norum@usask.ca * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear in * supporting documentation. This software is provided "as is" without * express or implied warranty. * * Modified 2001.04.05 by Bryan Henderson for inclusion in the Netpbm * package. Now uses Netpbm libraries and, for consistency with other * Netpbm programs, does not have PGM output option. */ %{ #include #include #include #include #include #include "pbm.h" static int yylex(void); static int yywrap(void); struct RowInfo { int length; /* length, in bytes */ char *bits; /* Bitmap */ }; static int maxRowLength; static int rowCount; static int rowCapacity; static struct RowInfo *rows; static int column; const char *progname; int debugFlag; static void debug (const char *format, ...); %} DIG [0-9] %x RASTERMODE ROWMODE %% [\0-\377] { rows[rowCount].bits[column++] = yytext[0]; if (column >= rows[rowCount].length) { rowCount++; debug ("Done %d-byte row %d.\n", column, rowCount); BEGIN (RASTERMODE); } } \033\*b{DIG}+W { int l; if (rowCount >= rowCapacity) { overflow_add(rowCapacity, 100); rowCapacity += 100; overflow2(rowCapacity, sizeof *rows); rows = realloc (rows, rowCapacity * sizeof *rows); if (rows == NULL) pm_error ("Out of memory."); } l = atoi (yytext+3); rows[rowCount].length = l; rows[rowCount].bits = malloc (l); if (rows[rowCount].bits == NULL) pm_error ("Out of memory."); if (l > maxRowLength) maxRowLength = l; debug ("Start %d-byte row.\n", l); column = 0; BEGIN (ROWMODE); } \033\*rB { debug ("Match *rB\n"); BEGIN (0); } [.\0\n] { pm_error ("Unexpected character (%#x) in raster mode.\n", yytext[0]); } \033\&l{DIG}+. { debug ("Match &l\n"); } \033\*r{DIG}+S { debug ("Match *r#S\n"); } \033\*b{DIG}+W { debug ("Match *r#w\n"); } \033\*rA { debug ("Match *rA\n"); BEGIN (RASTERMODE); } [\0-\377] { /* Silently consume all other characters */ } %% /* * Application entry point */ int main (int argc, char **argv) { int c; char *cp; int bad = 0; extern int optind; pbm_init( &argc, argv ); if ((cp = strrchr (argv[0], '/')) != NULL) progname = cp + 1; else progname = argv[0]; while ((c = getopt (argc, argv, "d")) != EOF) { switch (c) { case 'd': debugFlag++; break; default: bad = 1; break; } } if (optind == (argc - 1)) { if (freopen (argv[optind], "rb", stdin) == NULL) { pm_error ("Can't open `%s'. Errno = %d (%s).\n", argv[optind], errno, strerror (errno)); } } else if (optind != argc) bad = 1; if (bad) { pm_error ("Usage: %s [-d] [thinkjet_file]\n", progname); } yylex (); return 0; } /* * Finish at end of file */ static int yywrap (void) { int row; unsigned char * packed_bitrow; debug ("Got %d rows, %d columns\n", rowCount, maxRowLength); /* * Quite simple since ThinkJet bit arrangement matches PBM */ overflow2(maxRowLength, 8); pbm_writepbminit(stdout, maxRowLength*8, rowCount, 0); packed_bitrow = malloc(maxRowLength); if (packed_bitrow == NULL) pm_error("Out of memory"); for (row = 0 ; row < rowCount ; row++) { int col; for (col = 0 ; col < rows[row].length ; col++) packed_bitrow[col] = rows[row].bits[col]; for ( ; col < maxRowLength; col++) packed_bitrow[col] = 0; pbm_writepbmrow_packed(stdout, packed_bitrow, maxRowLength*8, 0); } free(packed_bitrow); return 1; } /* * Print debugging message */ static void debug (const char *format, ...) { va_list args; if (debugFlag) { fprintf (stderr, "%s: ", progname); va_start (args, format); vfprintf (stderr, format, args); va_end (args); } } netpbm-free-10.0-1/pbm/wbmptopbm.10100644004714500471450000000165107716230207017175 0ustar aba-guestaba-guest.TH wbmptopbm 1 "19 November 1999" .IX wbmptopbm .SH NAME wbmptopbm - convert a wireless bitmap (wbmp) file to a portable bitmap (pbm) .SH SYNOPSIS .B wbmptopbm .RI [ wbmpfile ] .SH DESCRIPTION Reads a wbmp file as input. Produces a portable bitmap as output. .SH LIMITATIONS Currently only WBMP type 0 is recognized. This is the only type specified in the WAP 1.1 specifications. .SH "SEE ALSO" .BR pbm (5), .BR pbmtowbmp (1), .B Wireless Application Environment Specification. .SH AUTHOR Copyright (C) 1999 Terje Sannum . .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/wbmptopbm.c0100644004714500471450000000467107716762513017276 0ustar aba-guestaba-guest/* wbmptopbm.c - convert a wbmp file to a portable bitmap This is derived for Netpbm from the pbmwbmp package from on 2000.06.06. The specifications for the wbmp format are part of the Wireless Application Environment specification at . ** Copyright (C) 1999 Terje Sannum . ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pbm.h" static int readc(FILE *f) { int c = fgetc(f); if(c == EOF) pm_error("EOF / read error"); return c; } static int readint(FILE *f) { int c=0, pos=0, sum=0; do { c = readc(f); sum = (sum << 7*pos++) | (c & 0x7f); } while(c & 0x80); return sum; } static void readheader(int h, FILE *f) { int c,i; switch(h & 0x60) { case 0x00: /* Type 00: read multi-byte bitfield */ do c=readc(f); while(c & 0x80); break; case 0x60: /* Type 11: read name/value pair */ for(i=0; i < ((h & 0x70) >> 4) + (h & 0x0f); i++) c=readc(f); break; } } static bit ** readwbmp(FILE *f, int *cols, int *rows) { int i,j,k,row,c; bit **image; /* Type */ c = readint(f); if(c != 0) pm_error("Unsupported WBMP type"); /* Headers */ c = readc(f); /* FixHeaderField */ while(c & 0x80) { /* ExtHeaderFields */ c = readc(f); readheader(c, f); } /* Geometry */ *cols = readint(f); *rows = readint(f); image = pbm_allocarray(*cols, *rows); /* read image */ row = *cols/8; if(*cols%8) row +=1; for(i=0; i<*rows; i++) { for(j=0; j> k) ? PBM_WHITE : PBM_BLACK; } } } return image; } int main(int argc, char *argv[]) { FILE *f; bit **image; int rows, cols; pbm_init(&argc, argv); if(argc > 2) { fprintf(stderr, "Copyright (C) 1999 Terje Sannum \n"); pm_usage("[wbmpfile]"); } f = argc == 2 ? pm_openr(argv[1]) : stdin; image = readwbmp(f, &cols, &rows); pm_close(f); pbm_writepbm(stdout, image, cols, rows, 0); pm_close(stdout); return 0; } netpbm-free-10.0-1/pbm/xbmtopbm.10100644004714500471450000000141307716230207017012 0ustar aba-guestaba-guest.TH xbmtopbm 1 "31 August 1988" .IX xbmtopbm .SH NAME xbmtopbm - convert an X11 or X10 bitmap into a portable bitmap .SH SYNOPSIS .B xbmtopbm .RI [ bitmapfile ] .SH DESCRIPTION Reads an X11 or X10 bitmap as input. Produces a portable bitmap as output. .IX "X bitmap" .IX "X window system" .SH "SEE ALSO" pbmtoxbm(1), pbmtox10bm(1), pbm(5) .SH AUTHOR Copyright (C) 1988 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/xbmtopbm.c0100644004714500471450000001470507716230207017104 0ustar aba-guestaba-guest/* xbmtopbm.c - read an X bitmap file and produce a portable bitmap ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pbm.h" #define TRUE 1 #define FALSE 0 static void ReadBitmapFile ARGS(( FILE* stream, int* widthP, int* heightP, char** dataP )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; int rows, cols, row, col, charcount; char* data; char mask; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[bitmapfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; ReadBitmapFile( ifp, &cols, &rows, &data ); pm_close( ifp ); pbm_writepbminit( stdout, cols, rows, 0 ); bitrow = pbm_allocrow( cols ); for ( row = 0; row < rows; ++row ) { charcount = 0; mask = 1; for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) { if ( charcount >= 8 ) { ++data; charcount = 0; mask = 1; } *bP = ( *data & mask ) ? PBM_BLACK : PBM_WHITE; ++charcount; mask = mask << 1; } ++data; pbm_writepbmrow( stdout, bitrow, cols, 0 ); } pm_close( stdout ); exit( 0 ); } #define MAX_LINE 500 static void ReadBitmapFile( stream, widthP, heightP, dataP ) FILE* stream; int* widthP; int* heightP; char** dataP; { char line[MAX_LINE], name_and_type[MAX_LINE]; char* ptr; char* t; int version10, raster_length, v; register int bytes, bytes_per_line, padding; register int c1, c2, value1, value2; int hex_table[256]; int found_declaration; /* In scanning through the bitmap file, we have found the first line of the C declaration of the array (the "static char ..." or whatever line) */ int eof; /* We've encountered end of file while searching file */ *widthP = *heightP = -1; found_declaration = FALSE; /* Haven't found it yet; haven't even looked*/ eof = FALSE; /* Haven't encountered end of file yet */ while (!found_declaration && !eof) { if ( fgets( line, MAX_LINE, stream ) == NULL ) eof = TRUE; else { if ( strlen( line ) == MAX_LINE - 1 ) pm_error( "line too long" ); if ( sscanf( line, "#define %s %d", name_and_type, &v ) == 2 ) { if ( ( t = strrchr( name_and_type, '_' ) ) == NULL ) t = name_and_type; else ++t; if ( ! strcmp( "width", t ) ) *widthP = v; else if ( ! strcmp( "height", t ) ) *heightP = v; continue; } if ( sscanf( line, "static short %s = {", name_and_type ) == 1 ) { version10 = TRUE; found_declaration = TRUE; } else if ( sscanf( line, "static char %s = {", name_and_type ) == 1 ) { version10 = FALSE; found_declaration = TRUE; } else if (sscanf(line, "static unsigned char %s = {", name_and_type ) == 1 ) { version10 = FALSE; found_declaration = TRUE; } } } if (!found_declaration) pm_error("Unable to find a line in the file containing the start " "of C array declaration (\"static char\" or whatever)"); if ( *widthP == -1 ) pm_error( "invalid width" ); if ( *heightP == -1 ) pm_error( "invalid height" ); padding = 0; if ( ((*widthP % 16) >= 1) && ((*widthP % 16) <= 8) && version10 ) padding = 1; bytes_per_line = (*widthP+7)/8 + padding; raster_length = bytes_per_line * *heightP; *dataP = (char*) malloc( raster_length ); if ( *dataP == (char*) 0 ) pm_error( "out of memory" ); /* Initialize hex_table. */ for ( c1 = 0; c1 < 256; ++c1 ) hex_table[c1] = 256; hex_table['0'] = 0; hex_table['1'] = 1; hex_table['2'] = 2; hex_table['3'] = 3; hex_table['4'] = 4; hex_table['5'] = 5; hex_table['6'] = 6; hex_table['7'] = 7; hex_table['8'] = 8; hex_table['9'] = 9; hex_table['A'] = 10; hex_table['B'] = 11; hex_table['C'] = 12; hex_table['D'] = 13; hex_table['E'] = 14; hex_table['F'] = 15; hex_table['a'] = 10; hex_table['b'] = 11; hex_table['c'] = 12; hex_table['d'] = 13; hex_table['e'] = 14; hex_table['f'] = 15; if ( version10 ) for ( bytes = 0, ptr = *dataP; bytes < raster_length; bytes += 2 ) { while ( ( c1 = getc( stream ) ) != 'x' ) if ( c1 == EOF ) pm_error( "EOF / read error" ); c1 = getc( stream ); c2 = getc( stream ); if ( c1 == EOF || c2 == EOF ) pm_error( "EOF / read error" ); value1 = ( hex_table[c1] << 4 ) + hex_table[c2]; if ( value1 >= 256 ) pm_error( "syntax error" ); c1 = getc( stream ); c2 = getc( stream ); if ( c1 == EOF || c2 == EOF ) pm_error( "EOF / read error" ); value2 = ( hex_table[c1] << 4 ) + hex_table[c2]; if ( value2 >= 256 ) pm_error( "syntax error" ); *ptr++ = value2; if ( ( ! padding ) || ( ( bytes + 2 ) % bytes_per_line ) ) *ptr++ = value1; } else for ( bytes = 0, ptr = *dataP; bytes < raster_length; ++bytes ) { /* ** Skip until digit is found. */ for ( ; ; ) { c1 = getc( stream ); if ( c1 == EOF ) pm_error( "EOF / read error" ); value1 = hex_table[c1]; if ( value1 != 256 ) break; } /* ** Loop on digits. */ for ( ; ; ) { c2 = getc( stream ); if ( c2 == EOF ) pm_error( "EOF / read error" ); value2 = hex_table[c2]; if ( value2 != 256 ) { value1 = (value1 << 4) | value2; if ( value1 >= 256 ) pm_error( "syntax error" ); } else if ( c2 == 'x' || c2 == 'X' ) if ( value1 == 0 ) continue; else pm_error( "syntax error" ); else break; } *ptr++ = value1; } } /* CHANGE HISTORY: 99.09.08 bryanh Recognize "static unsigned char" declaration. */ netpbm-free-10.0-1/pbm/ybmtopbm.10100644004714500471450000000150307716230207017013 0ustar aba-guestaba-guest.TH ybmtopbm 1 "06 March 1990" .IX ybmtopbm .SH NAME ybmtopbm - convert a Bennet Yee "face" file into a portable bitmap .SH SYNOPSIS .B ybmtopbm .RI [ facefile ] .SH DESCRIPTION Reads a file acceptable to the .I face and .I xbm programs by Bennet Yee (bsy+@cs.cmu.edu). .IX face Writes a portable bitmap as output. .SH "SEE ALSO" pbmtoybm(1), pbm(5), face(1), face(5), xbm(1) .SH AUTHOR Copyright (C) 1991 by Jamie Zawinski and Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pbm/ybmtopbm.c0100644004714500471450000000523107716230207017077 0ustar aba-guestaba-guest/* ybmtopbm.c - read a file from Bennet Yee's 'xbm' program and write a pbm. ** ** Written by Jamie Zawinski based on code (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pbm.h" static void getinit ARGS(( FILE* file, short* colsP, short* rowsP, short* depthP, short* padrightP )); static bit getbit ARGS(( FILE* file )); #define YBM_MAGIC ( ( '!' << 8 ) | '!' ) int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; bit* bitrow; register bit* bP; short rows, cols, padright, row, col; short depth; pbm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[ybmfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; getinit( ifp, &cols, &rows, &depth, &padright ); if ( depth != 1 ) pm_error( "YBM file has depth of %d, must be 1", (int) depth ); pbm_writepbminit( stdout, cols, rows, 0 ); bitrow = pbm_allocrow( cols ); for ( row = 0; row < rows; ++row ) { /* Get data. */ for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) *bP = getbit( ifp ); /* Discard line padding */ for ( col = 0; col < padright; ++col ) (void) getbit( ifp ); pbm_writepbmrow( stdout, bitrow, cols, 0 ); } pm_close( ifp ); pm_close( stdout ); exit( 0 ); } static int item; static int bitsperitem, bitshift; static void getinit( file, colsP, rowsP, depthP, padrightP ) FILE* file; short* colsP; short* rowsP; short* depthP; short* padrightP; { short magic; if ( pm_readbigshort( file, &magic ) == -1 ) pm_error( "EOF / read error" ); if ( magic != YBM_MAGIC ) pm_error( "bad magic number in YBM file" ); if ( pm_readbigshort( file, colsP ) == -1 ) pm_error( "EOF / read error" ); if ( pm_readbigshort( file, rowsP ) == -1 ) pm_error( "EOF / read error" ); *depthP = 1; overflow_add(*colsP, 15); *padrightP = ( ( *colsP + 15 ) / 16 ) * 16 - *colsP; bitsperitem = 0; } static bit getbit( file ) FILE* file; { bit b; if ( bitsperitem == 0 ) { item = getc(file) | getc(file)<<8; if ( item == EOF ) pm_error( "EOF / read error" ); bitsperitem = 16; bitshift = 0; } b = ( ( item >> bitshift) & 1 ) ? PBM_BLACK : PBM_WHITE; --bitsperitem; ++bitshift; return b; } netpbm-free-10.0-1/pgm/0040755004714500471450000000000007776237751015132 5ustar aba-guestaba-guestnetpbm-free-10.0-1/pgm/Makefile0100644004714500471450000000154707724372231016560 0ustar aba-guestaba-guestSRCDIR = .. BUILDDIR = .. include $(BUILDDIR)/Makefile.config INCLUDE = -I$(SRCDIR)/shhopt PORTBINARIES = asciitopgm bioradtopgm fstopgm hipstopgm \ lispmtopgm pbmtopgm pgmbentley pgmenhance pgmhist \ pgmnoise pgmramp pgmslice pgmtofs pgmtolispm \ pgmtopbm psidtopgm sbigtopgm MATHBINARIES = pgmcrater pgmedge pgmtexture rawtopgm pgmkernel BINARIES = $(PORTBINARIES) $(MATHBINARIES) OBJECTS = $(patsubst %, %.o, $(BINARIES)) MERGEBINARIES = $(BINARIES) MERGE_OBJECTS = $(patsubst %,%.o2, $(MERGEBINARIES)) LIBOBJECTS = libpgm1.o libpgm2.o MANUALS1 = $(BINARIES) MANUALS3 = libpgm MANUALS5 = pgm MERGENAME = pgmmerge .PHONY: all all: $(PGMLIB) $(BINARIES) $(EXTRA_STATICLIB) .PHONY: merge merge: $(MERGENAME) # LIBRARIES .PHONY: install.merge install.merge: install.merge.common include $(SRCDIR)/Makefile.common .PHONY: clean clean: clean.common FORCE: netpbm-free-10.0-1/pgm/Makefile.depend0100644004714500471450000000000007716230207017772 0ustar aba-guestaba-guestnetpbm-free-10.0-1/pgm/Makefile.dice0100644004714500471450000001473707716230207017465 0ustar aba-guestaba-guest# Makefile for pgm tools, for use with Amiga DICE # # Copyright (C) 1989, 1991 by Jef Poskanzer. # Modified for Amiga DICE by Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, provided # that the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. This software is provided "as is" without express or # implied warranty. # CONFIG: generate executable with debugging information #DEBUG = -s -d1 # CONFIG: use memory pools #MPOOL = -L/amiga -l mpool CC = dcc CFLAGS = -E DCC_ERRORS -ms -mu -gs $(DEBUG) LDFLAGS = $(MPOOL) /amiga/dice_stack.o BINDIR = bin MERGE= pgmmerge # where to install the binaries, libraries and important header files INSTALLBIN = bin:pbmplus INSTALLLIB = dlib:local INSTALLINCL= dinclude:local # install which headers HEADERS= pgm.h /pbmplus.h PBMDIR = /pbm INCLUDEPBM = -I$(PBMDIR) RLIBPBM = $(PBMDIR)/pbmsr.lib RLLIBPBM = $(PBMDIR)/pbmrl.lib SLIBPBM = $(PBMDIR)/pbms.lib SLLIBPBM = $(PBMDIR)/pbml.lib DEFPBM = $(PBMDIR)/pbm.h /pbmplus.h DEFLIBPBM = $(PBMDIR)/libpbm.h INCLUDE = -I/ $(INCLUDEPBM) RALLCFLAGS = $(CFLAGS) $(INCLUDE) -proto -mRR SALLCFLAGS = $(CFLAGS) $(INCLUDE) -proto MALLCFLAGS = $(CFLAGS) $(INCLUDE) -mD -mC RLIBPGM = pgmsr.lib RLLIBPGM = pgmrl.lib SLIBPGM = pgms.lib SLLIBPGM = pgml.lib DEFPGM = pgm.h DEFLIBPGM = libpgm.h LIBRARIES = $(RLIBPGM) $(RLLIBPGM) $(SLIBPGM) $(SLLIBPGM) BINS = hipstopgm lispmtopgm pgmbentley pgmedge pgmenhance \ pgmnoise pgmoil pgmramp pgmtofs pgmtolispm \ psidtopgm rawtopgm asciitopgm bioradtopgm spottopgm \ pbmtopgm MATHBINS = fstopgm pgmcrater pgmhist pgmnorm pgmtexture \ pgmtopbm pgmkernel BINARIES = $(BINS) $(MATHBINS) OBJECTS = fstopgm.om hipstopgm.om lispmtopgm.om pgmbentley.om \ pgmenhance.om pgmhist.om pgmnoise.om pgmnorm.om pgmoil.om \ pgmramp.om pgmtofs.om pgmtolispm.om pgmtopbm.om \ psidtopgm.om rawtopgm.om pgmcrater.om pgmedge.om pgmtexture.om \ asciitopgm.om bioradtopgm.om spottopgm.om pbmtopgm.om pgmkernel.om all: lib binaries bindir: -makedir $(BINDIR) binaries: lib bindir $(BINARIES) lib: $(LIBRARIES) merge: lib bindir $(MERGE) # Rules for merged binary .c.om: $(DEFPGM) $(DEFPBM) $< $(CC) -proto $(MALLCFLAGS) "-Dmain=$*_main" -c $*.c -o $*.om $(MERGE): pgmmerge.c $(OBJECTS) $(SLLIBPGM) $(SLLIBPBM) $(CC) $(MALLCFLAGS) $(LDFLAGS) -o $(BINDIR)/$@ $@.c $(OBJECTS) -l $(SLLIBPGM) -l $(SLLIBPBM) -lm #$(OBJECTS): $(DEFPGM) $(DEFPBM) # $(CC) -mD -mC $(SALLCFLAGS) "-Dmain=$*_main" -c $*.c # Rule for plain programs. $(BINS): $(DEFPGM) $(DEFPBM) $(RLIBPGM) $(RLIBPBM) $(CC) -r $(RALLCFLAGS) $(LDFLAGS) -o $(BINDIR)/$@ $@.c -l $(RLIBPGM) -l $(RLIBPBM) # Rule for math-dependent programs. $(MATHBINS): $(DEFPGM) $(DEFPBM) $(RLIBPGM) $(RLIBPBM) $(CC) -r $(RALLCFLAGS) $(LDFLAGS) -o $(BINDIR)/$@ $@.c -l $(RLIBPGM) -l $(RLIBPBM) -lm # And libraries. #$(LIBPBM): # cd $(PBMDIR) ; make lib # small data version of libpgm $(RLIBPGM): libpgm1.or libpgm2.or -delete $(RLIBPGM) join libpgm1.or libpgm2.or to $(RLIBPGM) libpgm1.or: $(DEFPGM) $(DEFPBM) $(DEFLIBPGM) libpgm1.c $(CC) -r $(RALLCFLAGS) -S -o $@ -c libpgm1.c libpgm2.or: $(DEFPGM) $(DEFPBM) $(DEFLIBPGM) libpgm2.c $(DEFLIBPBM) $(CC) -r $(RALLCFLAGS) -S -o $@ -c libpgm2.c # small data version of libpgm, not registerized (arguments on stack) $(SLIBPGM): libpgm1.os libpgm2.os -delete $(SLIBPGM) join libpgm1.os libpgm2.os to $(SLIBPGM) libpgm1.os: $(DEFPGM) $(DEFPBM) $(DEFLIBPGM) libpgm1.c $(CC) -r $(SALLCFLAGS) -S -o $@ -c libpgm1.c libpgm2.os: $(DEFPGM) $(DEFPBM) $(DEFLIBPGM) libpgm2.c $(DEFLIBPBM) $(CC) -r $(SALLCFLAGS) -S -o $@ -c libpgm2.c # large data version of libpgm $(RLLIBPGM): libpgm1.olr libpgm2.olr -delete $(RLLIBPGM) join libpgm1.olr libpgm2.olr to $(RLLIBPGM) libpgm1.olr: $(DEFPGM) $(DEFPBM) $(DEFLIBPGM) libpgm1.c $(CC) -mD $(RALLCFLAGS) -S -c libpgm1.c -o $@ libpgm2.olr: $(DEFPGM) $(DEFPBM) $(DEFLIBPGM) libpgm2.c $(DEFLIBPBM) $(CC) -mD $(RALLCFLAGS) -S -c libpgm2.c -o $@ # large data version of libpgm, not registerized (arguments on stack) $(SLLIBPGM): libpgm1.ols libpgm2.ols -delete $(SLLIBPGM) join libpgm1.ols libpgm2.ols to $(SLLIBPGM) libpgm1.ols: $(DEFPGM) $(DEFPBM) $(DEFLIBPGM) libpgm1.c $(CC) -mD $(SALLCFLAGS) -S -c libpgm1.c -o $@ libpgm2.ols: $(DEFPGM) $(DEFPBM) $(DEFLIBPGM) libpgm2.c $(DEFLIBPBM) $(CC) -mD $(SALLCFLAGS) -S -c libpgm2.c -o $@ # Other dependencies. fstopgm fstopgm.om: fstopgm.c hipstopgm hipstopgm.om: hipstopgm.c lispmtopgm lispmtopgm.om: lispmtopgm.c pgmbentley pgmbentley.om: pgmbentley.c pgmcrater pgmcrater.om: pgmcrater.c pgmedge pgmedge.om: pgmedge.c pgmenhance pgmenhance.om: pgmenhance.c pgmhist pgmhist.om: pgmhist.c pgmnoise pgmnoise.om: pgmnoise.c pgmnorm pgmnorm.om: pgmnorm.c pgmoil pgmoil.om: pgmoil.c pgmramp pgmramp.om: pgmramp.c pgmtexture pgmtexture.om: pgmtexture.c pgmtopbm pgmtopbm.om: pgmtopbm.c dithers.h $(DEFPBM) pgmtofs pgmtofs.om: pgmtofs.c pgmtolispm pgmtolispm.om: pgmtolispm.c psidtopgm psidtopgm.om: psidtopgm.c rawtopgm rawtopgm.om: rawtopgm.c asciitopgm asciitopgm.om: asciitopgm.c bioradtopgm bioradtopgm.om: bioradtopgm.c spottopgm spottopgm.om: spottopgm.c pbmtopgm pbmtopgm.om: pbmtopgm.c pgmkernel pgmkernel.om: pgmkernel.c clean: -delete \#?.om \#?.os \#?.or \#?.ols \#?.olr DCC_ERRORS cleanall: clean -delete \#?.lib -delete $(BINDIR) all installlib: lib copy $(LIBRARIES) to $(INSTALLLIB) copy $(HEADERS) to $(INSTALLINCL) installbin: binaries copy $(BINDIR) all to $(INSTALLBIN) installall: installlib installbin install: @echo "Please select: installlib, installbin, installall" netpbm-free-10.0-1/pgm/SCOPTIONS0100644004714500471450000000026007716230207016410 0ustar aba-guestaba-guestDATA=FAR OPTIMIZE LINK SMALLCODE STRIPDEBUG NOICONS DEFINE A_STRERROR DEFINE A_RGBENV DEFINE A_FRAGARRAY DEFINE A_SMALLSTACK DEFINE A_FORCEPROTO IGNORE=85 IGNORE=93 IGNORE=304 netpbm-free-10.0-1/pgm/SMakefile0100644004714500471450000001126507716230207016676 0ustar aba-guestaba-guest# Makefile for pgm tools. # # Copyright (C) 1989, 1991 by Jef Poskanzer. # Modified by Robert A. Knop Jr. (rknop@cco.caltech.edu) 940126 for Amiga SAS/C # Merge is not currently supported by this makefile # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, provided # that the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. This software is provided "as is" without express or # implied warranty. # Default values, usually overridden by top-level Makefile. #CC = cc #CC = gcc #CC = gcc -ansi -pedantic -fcombine-regs -fpcc-struct-return CC = sc CFLAGS = #CFLAGS = -g #CFLAGS = -g -O LDFLAGS = -s #LDFLAGS = INSTALLBINARIES = /bin INSTALLMANUALS1 = /man/man1 SUFFIXMANUALS1 = 1 INSTALLMANUALS3 = /man/man3 SUFFIXMANUALS3 = 3 INSTALLMANUALS5 = /man/man5 SUFFIXMANUALS5 = 5 MANCP = copy PBMDIR = /pbm INCLUDEPBM = IDIR=$(PBMDIR) LIBPBM = $(PBMDIR)/libpbm.lib DEFPBM = $(PBMDIR)/pbm.h /pbmplus.h DEFLIBPBM = $(PBMDIR)/libpbm.h #SHELL = /bin/sh INCLUDE = IDIR=/ $(INCLUDEPBM) ALLCFLAGS = $(CFLAGS) $(INCLUDE) LIBPGM = libpgm.lib PORTBINARIES = asciitopgm hipstopgm lispmtopgm \ pbmtopgm pgmbentley pgmnoise \ pgmoil pgmtofs pgmtolispm \ psidtopgm spottopgm MATHBINARIES = pgmcrater pgmedge pgmkernel pgmtexture rawtopgm \ bioradtopgm fstopgm pgmenhance \ pgmhist pgmnorm pgmramp pgmtopbm BINARIES = $(PORTBINARIES) $(MATHBINARIES) OBJECTS = asciitopgm bioradtopgm.o fstopgm.o hipstopgm.o lispmtopgm.o pbmtopgm.o \ pgmbentley.o pgmenhance.o pgmhist.o pgmkernel.o pgmnoise.o \ pgmnorm.o pgmoil.o pgmramp.o pgmtofs.o pgmtolispm.o \ pgmtopbm.o psidtopgm.o spottopgm.o \ rawtopgm.o pgmcrater.o pgmedge.o pgmtexture.o MANUALS1 = $(BINARIES) MANUALS3 = libpgm MANUALS5 = pgm all: binaries #all: merge install: install.bin #install: install.merge binaries: $(BINARIES) install.bin: binaries # cd $(INSTALLBINARIES) ; rm -f $(BINARIES) copy $(BINARIES) TO $(INSTALLBINARIES) CLONE #merge: pgmmerge #pgmmerge: pgmmerge.c $(OBJECTS) $(LIBPGM) $(LIBPBM) # $(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(OBJECTS) -lm $(LIBPGM) $(LIBPBM) # #install.merge: install.pgmmerge #install.pgmmerge: pgmmerge # cd $(INSTALLBINARIES) ; rm -f $(BINARIES) # cp pgmmerge $(INSTALLBINARIES) # cd $(INSTALLBINARIES) ; for i in $(BINARIES) ; do ln pgmmerge $$i ; done # rm -f $(INSTALLBINARIES)/pgmmerge install.man: execute < <(T:install_man.temp) foreach i in $(MANUALS1) delete $(INSTALLMANUALS1)/$${i}.$(SUFFIXMANUALS1) $(MANCP) $${i}.1 $(INSTALLMANUALS1)/$${i}.$(SUFFIXMANUALS1) end < execute < <(T:install_man.temp) foreach i in $(MANUALS3) delete $(INSTALLMANUALS3)/$${i}.$(SUFFIXMANUALS3) $(MANCP) $${i}.3 $(INSTALLMANUALS3)/$${i}.$(SUFFIXMANUALS3) end < execute < <(T:install_man.temp) foreach i in $(MANUALS5) delete $(INSTALLMANUALS5)/$${i}.$(SUFFIXMANUALS5) $(MANCP) $${i}.5 $(INSTALLMANUALS5)/$${i}.$(SUFFIXMANUALS5) end < # Rule for plain programs. $(PORTBINARIES): pgm.h $(DEFPBM) $(LIBPGM) $(LIBPBM) $(CC) $(ALLCFLAGS) $(LDFLAGS) LINK $@.c $(LIBPGM) $(LIBPBM) # Rule for math-dependent programs. $(MATHBINARIES): pgm.h $(DEFPBM) $(LIBPGM) $(LIBPBM) $(CC) $(ALLCFLAGS) $(LDFLAGS) MATH=I LINK $@.c $(LIBPGM) $(LIBPBM) # commented out until merge supported RKNOP 931107 # Rule for objects. #$(OBJECTS): pgm.h $(DEFPBM) # $(CC) $(ALLCFLAGS) "-Dmain=$*_main" -c $*.c # And libraries. $(LIBPBM): execute < <(T:smake_temp.com) cd $(PBMDIR) smake lib < lib: $(LIBPGM) $(LIBPGM): libpgm1.o libpgm2.o -delete $(LIBPGM) oml $(LIBPGM) r libpgm1.o libpgm2.o libpgm1.o: pgm.h $(DEFPBM) libpgm.h libpgm1.c $(CC) $(ALLCFLAGS) MATH=I NOLINK libpgm1.c libpgm2.o: pgm.h $(DEFPBM) libpgm.h libpgm2.c $(DEFLIBPBM) $(CC) $(ALLCFLAGS) MATH=I NOLINK libpgm2.c # Other dependencies. asciitopgm asciitopgm.o: asciitopgm.c bioradtopgm bioradtopgm.o: bioradtopgm.c fstopgm fstopgm.o: fstopgm.c hipstopgm hipstopgm.o: hipstopgm.c lispmtopgm lispmtopgm.o: lispmtopgm.c pbmtopgm pbmtopgm.o: pbmtopgm.c pgmbentley pgmbentley.o: pgmbentley.c pgmcrater pgmcrater.o: pgmcrater.c pgmedge pgmedge.o: pgmedge.c pgmenhance pgmenhance.o: pgmenhance.c pgmhist pgmhist.o: pgmhist.c pgmkernel pgmkernel.o: pgmkernel.c pgmnoise pgmnoise.o: pgmnoise.c pgmnorm pgmnorm.o: pgmnorm.c pgmoil pgmoil.o: pgmoil.c pgmramp pgmramp.o: pgmramp.c pgmtexture pgmtexture.o: pgmtexture.c pgmtopbm pgmtopbm.o: pgmtopbm.c dithers.h $(DEFPBM) pgmtofs pgmtofs.o: pgmtofs.c pgmtolispm pgmtolispm.o: pgmtolispm.c psidtopgm psidtopgm.o: psidtopgm.c rawtopgm rawtopgm.o: rawtopgm.c spottopgm spottopgm.o: spottopgm.c clean: delete *.o *.lib *.lnk $(BINARIES) netpbm-free-10.0-1/pgm/asciitopgm.10100644004714500471450000000253707716230207017336 0ustar aba-guestaba-guest.TH asciitopgm 1 "26 December 1994" .IX asciitopgm .SH NAME asciitopgm - convert ASCII graphics into a portable graymap .SH SYNOPSIS .B asciitopgm .IR [ -d .RI divisor ] .I height width .RI [ asciifile ] .SH DESCRIPTION Reads ASCII data as input. Produces a portable graymap with pixel values which are an approximation of the "brightness" of the ASCII characters, assuming black-on-white printing. In other words, a capital M is very dark, a period is ver light, and a space is white. Input lines which are fewer than .I width characters are automatically padded with spaces. .PP The .I divisor argument is a floating-point number by which the output pixels are divided; the default value is 1.0. This can be used to adjust the brightness of the graymap: for example, if the image is too dim, reduce the divisor. .PP In keeping with (I believe) Fortran line-printer conventions, input lines beginning with a + (plus) character are assumed to "overstrike" the previous line, allowing a larger range of gray values. .PP This tool contradicts the message in the .I pbmtoascii manual: "Note that there is no asciitopbm tool - this transformation is one-way." .SH BUGS The table of ASCII-to-grey values is subject to interpretation, and, of course, depends on the typeface intended for the input. .SH "SEE ALSO" pbmtoascii(1), pgm(5) .SH AUTHOR Wilson H. Bent. Jr. (whb@usc.edu) netpbm-free-10.0-1/pgm/asciitopgm.c0100644004714500471450000001026607716762513017430 0ustar aba-guestaba-guest/* asciitopgm.c - read an ASCII graphics file and produce a portable graymap ** ** Copyright (C) 1989 by Wilson H. Bent, Jr ** ** - Based on fstopgm.c and other works which bear the following notice: ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pgm.h" static char gmap [128] = { /*00 nul-bel*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*08 bs -si */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*10 dle-etb*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*18 can-us */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*20 sp - ' */ 0x00, 0x21, 0x1b, 0x7f, 0x70, 0x25, 0x20, 0x0a, /*28 ( - / */ 0x11, 0x11, 0x2a, 0x2b, 0x0b, 0x13, 0x04, 0x10, /*30 0 - 7 */ 0x30, 0x28, 0x32, 0x68, 0x39, 0x35, 0x39, 0x16, /*38 8 - ? */ 0x38, 0x39, 0x14, 0x15, 0x11, 0x1c, 0x11, 0x3f, /*40 @ - G */ 0x40, 0x49, 0x52, 0x18, 0x44, 0x3c, 0x38, 0x38, /*48 H - O */ 0x55, 0x28, 0x2a, 0x70, 0x16, 0x7f, 0x70, 0x14, /*50 P - W */ 0x60, 0x20, 0x62, 0x53, 0x1a, 0x55, 0x36, 0x57, /*58 X - _ */ 0x50, 0x4c, 0x5a, 0x24, 0x10, 0x24, 0x5e, 0x13, /*60 ` - g */ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /*68 h - o */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x2a, /*70 p - w */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /*78 x -del*/ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, }; static gray maxval = 127; int main( argc, argv ) int argc; char *argv[]; { FILE *ifd; register gray **grays; int argn, row; register int c, i; int rows = 0, cols = 0; int divisor = 1; int warned = 0; int *obuf; char *usage = "[-d ] height width [asciifile]"; pgm_init( &argc, argv ); argn = 1; if ( argc < 3 || argc > 6 ) pm_usage( usage ); if ( argv[argn][0] == '-' ) { if ( strcmp( argv[argn], "-d" ) == 0 ) { if ( argc == argn + 1 ) pm_usage( usage ); if ( sscanf( argv[argn+1], "%d", &divisor ) != 1 ) pm_usage( usage ); argn += 2; } else pm_usage( usage ); } if ( sscanf( argv[argn++], "%d", &rows ) != 1 ) pm_usage( usage ); if ( sscanf( argv[argn++], "%d", &cols ) != 1 ) pm_usage( usage ); if ( rows < 1 ) pm_error( "height is less than 1" ); if ( cols < 1 ) pm_error( "width is less than 1" ); if ( argc > argn + 1 ) pm_usage( usage ); if ( argc == argn + 1 ) ifd = pm_openr( argv[argn] ); else ifd = stdin; /* Here's where the work is done: * - Usually, the graymap value of the input char is summed into grays * - For a 'normal' newline, the current row is adjusted by the divisor * and the current row is incremented * - If the first char in the input line is a '+', then the current row * stays the same to allow 'overstriking' * NOTE that we assume the user specified a sufficiently large width! */ if ((obuf = (int *) malloc2 (cols, sizeof (int))) == NULL) pm_error( "malloc error" ); /* wimpy message! */ memset(obuf, 0, cols *sizeof(int)); grays = pgm_allocarray( cols, rows ); row = i = 0; while ( row < rows ) { switch (c = getc (ifd)) { case EOF: goto line_done; case '\n': if ((c = getc (ifd)) == EOF) goto line_done; if (c == '+') i = 0; else { line_done: for (i = 0; i < cols; ++i) grays[row][i] = maxval - (obuf[i] / divisor); memset (obuf, 0, cols * sizeof (int)); i = 0; ++row; if ( row >= rows ) break; if (c != EOF) obuf[i++] += gmap[c]; } break; default: if (c > 0x7f) /* !isascii(c) */ { if (!warned) { fprintf (stderr, "(Warning: non-ASCII char(s) in input)\n"); warned = 1; } c &= 0x7f; /* toascii(c) */ } obuf[i++] += gmap[c]; break; } } pm_close( ifd ); pgm_writepgm( stdout, grays, cols, rows, maxval, 0 ); exit( 0 ); } netpbm-free-10.0-1/pgm/bioradtopgm.10100644004714500471450000000225307716230207017501 0ustar aba-guestaba-guest.TH bioradtopgm 1 "28 June 1993" .IX bioradtopgm .SH NAME bioradtopgm - convert a Biorad confocal file into a portable graymap .SH SYNOPSIS .B bioradtopgm .RB [ -image# ] .RI [ imagedata ] .SH DESCRIPTION Reads a Biorad confocal file as input. Produces a portable graymap as output. If the resulting image is upside down, run it through .B "pnmflip -tb" . .IX pnmflip .SH OPTIONS .TP .B -image# A Biorad image file may contain more than one image. With this flag, you can specify which image to extract (only one at a time). The first image in the file has number zero. If no image number is supplied, only information about the image size and the number of images in the input is printed out. No output is produced. .SH "SEE ALSO" pgm(5), pnmflip(1) .SH AUTHORS Copyright (C) 1993 by Oliver Trepte .br .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/bioradtopgm.c0100644004714500471450000000703107716230207017562 0ustar aba-guestaba-guest/* bioradtopgm.c - convert a Biorad confocal image into a portable graymap ** ** Copyright (C) 1993 by Oliver Trepte, oliver@fysik4.kth.se ** ** Derived from the pbmplus package, ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pgm.h" #define BYTE unsigned char #define BIORAD_HEADER_LENGTH 76 #define BYTE_TO_WORD(lsb,msb) (((BYTE) lsb) + (((BYTE) msb) << 8)) int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; gray* grayrow; register gray* gP; int argn, row, i; register int col, val, val2; int rows=0, cols=0, image_num= -1, image_count, byte_word, check_word; int maxval; BYTE buf[BIORAD_HEADER_LENGTH]; char* usage = "[-image#] [Bioradfile]"; pgm_init( &argc, argv ); argn = 1; while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( isdigit( argv[argn][1] )) { image_num = atoi( (argv[argn]+1) ); } else pm_usage( usage ); ++argn; } if ( argn < argc ) { ifp = pm_openr( argv[argn] ); ++argn; } else ifp = stdin; if ( argn != argc ) pm_usage( usage ); for ( i = 0; i < BIORAD_HEADER_LENGTH; ++i ) { val = getc( ifp ); if ( val == EOF ) pm_error( "EOF / read error" ); buf[ i ] = val; } cols = BYTE_TO_WORD(buf[0], buf[1]); rows = BYTE_TO_WORD(buf[2], buf[3]); image_count = BYTE_TO_WORD(buf[4], buf[5]); byte_word = BYTE_TO_WORD(buf[14], buf[15]); check_word = BYTE_TO_WORD(buf[54], buf[55]); if ( check_word != 12345 ) pm_error( "Not a Biorad file" ); if ( cols <= 0 ) pm_error( "Strange image size, cols = %d", cols); if ( rows <= 0 ) pm_error( "Strange image size, rows = %d", rows); if ( image_count <= 0 ) pm_error( "Number of images in file is %d", image_count); if ( byte_word ) maxval = 255; else { maxval = 65535; /* Perhaps this should be something else */ } pm_message( "Image size: %d cols, %d rows", cols, rows); pm_message( "%s", (byte_word) ? "Byte image (8 bits)" : "Word image (16 bits)"); if ( image_num < 0 ) pm_message( "Input contains %d image%c", image_count, (image_count > 1) ? 's' : '\0'); else { if ( image_num >= image_count ) pm_error( "Cannot extract image %d, input contains only %d image%s", image_num, image_count, (image_count > 1) ? "s" : "" ); for ( i = (byte_word) ? image_num : image_num*2 ; i > 0 ; --i ) { for ( row = 0; row < rows; ++row) for ( col = 0; col < cols; ++col ) { val = getc( ifp ); if ( val == EOF ) { pm_error( "EOF / read error" ); } } } pgm_writepgminit( stdout, cols, rows, (gray) maxval, 0 ); grayrow = pgm_allocrow( cols ); for ( row = 0; row < rows; ++row) { for ( col = 0, gP = grayrow; col < cols; ++col ) { val = getc( ifp ); if ( val == EOF ) pm_error( "EOF / read error" ); if (byte_word) *gP++ = val; else { val2 = getc( ifp ); if ( val2 == EOF ) pm_error( "EOF / read error" ); *gP++ = BYTE_TO_WORD(val, val2); } } pgm_writepgmrow( stdout, grayrow, cols, (gray) maxval, 0 ); } pm_close( ifp ); pm_close( stdout ); } exit( 0 ); } netpbm-free-10.0-1/pgm/dithers.h0100644004714500471450000000677307716230207016736 0ustar aba-guestaba-guest/* ** dithers.h ** ** Here are some dithering matrices. They are all taken from "Digital ** Halftoning" by Robert Ulichney, MIT Press, ISBN 0-262-21009-6. */ #if 0 /* ** Order-6 ordered dithering matrix. Note that smaller ordered dithers ** have no advantage over larger ones, so use dither8 instead. */ static int dither6[8][8] = { { 1, 59, 15, 55, 2, 56, 12, 52 }, { 33, 17, 47, 31, 34, 18, 44, 28 }, { 9, 49, 5, 63, 10, 50, 6, 60 }, { 41, 25, 37, 21, 42, 26, 38, 22 }, { 3, 57, 13, 53, 0, 58, 14, 54 }, { 35, 19, 45, 29, 32, 16, 46, 30 }, { 11, 51, 7, 61, 8, 48, 4, 62 }, { 43, 27, 39, 23, 40, 24, 36, 20 } }; #endif /* Order-8 ordered dithering matrix. */ static int dither8[16][16] = { { 1,235, 59,219, 15,231, 55,215, 2,232, 56,216, 12,228, 52,212}, { 129, 65,187,123,143, 79,183,119,130, 66,184,120,140, 76,180,116}, { 33,193, 17,251, 47,207, 31,247, 34,194, 18,248, 44,204, 28,244}, { 161, 97,145, 81,175,111,159, 95,162, 98,146, 82,172,108,156, 92}, { 9,225, 49,209, 5,239, 63,223, 10,226, 50,210, 6,236, 60,220}, { 137, 73,177,113,133, 69,191,127,138, 74,178,114,134, 70,188,124}, { 41,201, 25,241, 37,197, 21,255, 42,202, 26,242, 38,198, 22,252}, { 169,105,153, 89,165,101,149, 85,170,106,154, 90,166,102,150, 86}, { 3,233, 57,217, 13,229, 53,213, 0,234, 58,218, 14,230, 54,214}, { 131, 67,185,121,141, 77,181,117,128, 64,186,122,142, 78,182,118}, { 35,195, 19,249, 45,205, 29,245, 32,192, 16,250, 46,206, 30,246}, { 163, 99,147, 83,173,109,157, 93,160, 96,144, 80,174,110,158, 94}, { 11,227, 51,211, 7,237, 61,221, 8,224, 48,208, 4,238, 62,222}, { 139, 75,179,115,135, 71,189,125,136, 72,176,112,132, 68,190,126}, { 43,203, 27,243, 39,199, 23,253, 40,200, 24,240, 36,196, 20,254}, { 171,107,155, 91,167,103,151, 87,168,104,152, 88,164,100,148, 84} }; /* Order-3 clustered dithering matrix. */ static int cluster3[6][6] = { { 9,11,10, 8, 6, 7}, { 12,17,16, 5, 0, 1}, { 13,14,15, 4, 3, 2}, { 8, 6, 7, 9,11,10}, { 5, 0, 1,12,17,16}, { 4, 3, 2,13,14,15} }; /* Order-4 clustered dithering matrix. */ static int cluster4[8][8] = { { 18,20,19,16,13,11,12,15}, { 27,28,29,22, 4, 3, 2, 9}, { 26,31,30,21, 5, 0, 1,10}, { 23,25,24,17, 8, 6, 7,14}, { 13,11,12,15,18,20,19,16}, { 4, 3, 2, 9,27,28,29,22}, { 5, 0, 1,10,26,31,30,21}, { 8, 6, 7,14,23,25,24,17} }; /* Order-8 clustered dithering matrix. */ static int cluster8[16][16] = { { 64, 69, 77, 87, 86, 76, 68, 67, 63, 58, 50, 40, 41, 51, 59, 60}, { 70, 94,100,109,108, 99, 93, 75, 57, 33, 27, 18, 19, 28, 34, 52}, { 78,101,114,116,115,112, 98, 83, 49, 26, 13, 11, 12, 15, 29, 44}, { 88,110,123,124,125,118,107, 85, 39, 17, 4, 3, 2, 9, 20, 42}, { 89,111,122,127,126,117,106, 84, 38, 16, 5, 0, 1, 10, 21, 43}, { 79,102,119,121,120,113, 97, 82, 48, 25, 8, 6, 7, 14, 30, 45}, { 71, 95,103,104,105, 96, 92, 74, 56, 32, 24, 23, 22, 31, 35, 53}, { 65, 72, 80, 90, 91, 81, 73, 66, 62, 55, 47, 37, 36, 46, 54, 61}, { 63, 58, 50, 40, 41, 51, 59, 60, 64, 69, 77, 87, 86, 76, 68, 67}, { 57, 33, 27, 18, 19, 28, 34, 52, 70, 94,100,109,108, 99, 93, 75}, { 49, 26, 13, 11, 12, 15, 29, 44, 78,101,114,116,115,112, 98, 83}, { 39, 17, 4, 3, 2, 9, 20, 42, 88,110,123,124,125,118,107, 85}, { 38, 16, 5, 0, 1, 10, 21, 43, 89,111,122,127,126,117,106, 84}, { 48, 25, 8, 6, 7, 14, 30, 45, 79,102,119,121,120,113, 97, 82}, { 56, 32, 24, 23, 22, 31, 35, 53, 71, 95,103,104,105, 96, 92, 74}, { 62, 55, 47, 37, 36, 46, 54, 61, 65, 72, 80, 90, 91, 81, 73, 66} }; netpbm-free-10.0-1/pgm/fstopgm.10100644004714500471450000000320407716230207016646 0ustar aba-guestaba-guest.TH fstopgm 1 "06 April 89" .IX fstopgm .SH NAME fstopgm - convert a Usenix FaceSaver(tm) file into a portable graymap .SH SYNOPSIS .B fstopgm .RI [ fsfile ] .SH DESCRIPTION Reads a Usenix FaceSaver(tm) file as input. .IX FaceSaver Produces a portable graymap as output. .PP FaceSaver(tm) files sometimes have rectangular pixels. While .I fstopgm won't re-scale them into square pixels for you, it will give you the precise .I pnmscale command that will do the job. Because of this, reading a FaceSaver(tm) image is a two-step process. First you do: .nf fstopgm > /dev/null .fi This will tell you whether you need to use .I pnmscale. Then use one of the following pipelines: .nf fstopgm | pgmnorm fstopgm | pnmscale -whatever | pgmnorm .fi To go to PBM, you want something more like one of these: .nf fstopgm | pnmenlarge 3 | pgmnorm | pgmtopbm fstopgm | pnmenlarge 3 | pnmscale | pgmnorm | pgmtopbm .fi You want to enlarge when going to a bitmap because otherwise you lose information; but enlarging by more than 3 does not look good. .PP FaceSaver is a registered trademark of Metron Computerware Ltd. of Oakland, CA. .SH "SEE ALSO" pgmtofs(1), pgm(5), pgmnorm(1), pnmenlarge(1), pnmscale(1), pgmtopbm(1) .SH AUTHOR Copyright (C) 1989 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/fstopgm.c0100644004714500471450000000644707725102161016741 0ustar aba-guestaba-guest/* fstopgm.c - read a Usenix FaceSaver(tm) file and produce a portable graymap ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pgm.h" #include static int gethexit ARGS(( FILE* ifp )); int main( argc, argv ) int argc; char *argv[]; { FILE *ifp; register gray **grays, *gP; int argn, row; register int col; int maxval; int rows = 0, cols = 0, depth = 0, xrows = 0, xcols = 0, xdepth = 0; #define STRSIZE 1000 char buf[STRSIZE], firstname[STRSIZE], lastname[STRSIZE], email[STRSIZE]; pgm_init( &argc, argv ); argn = 1; if ( argn < argc ) { ifp = pm_openr( argv[argn] ); argn++; } else ifp = stdin; if ( argn != argc ) pm_usage( "[fsfile]" ); /* Read the FaceSaver(tm) header. */ for ( ; ; ) { if ( fgets( buf, STRSIZE, ifp ) == (char *) 0 ) pm_error( "error reading header" ); /* Blank line ends header. */ if ( strlen( buf ) == 1 ) break; if ( sscanf( buf, "FirstName: %[^\n]", firstname ) == 1 ) ; else if ( sscanf( buf, "LastName: %[^\n]", lastname ) == 1 ) ; else if ( sscanf( buf, "E-mail: %[^\n]", email ) == 1 ) ; else if ( sscanf( buf, "PicData: %d %d %d\n", &cols, &rows, &depth ) == 3 ) { if ( depth != 8 ) pm_error( "can't handle 'PicData' depth other than 8" ); } else if ( sscanf( buf, "Image: %d %d %d\n", &xcols, &xrows, &xdepth ) == 3 ) { if ( xdepth != 8 ) pm_error( "can't handle 'Image' depth other than 8" ); } } if ( cols <= 0 || rows <= 0 ) pm_error( "invalid header" ); maxval = pm_bitstomaxval( depth ); if ( maxval > PGM_OVERALLMAXVAL ) pm_error( "depth %d is too large. Our maximum is %d", maxval, PGM_OVERALLMAXVAL); if ( xcols != 0 && xrows != 0 && ( xcols != cols || xrows != rows ) ) { float rowratio, colratio; rowratio = (float) xrows / (float) rows; colratio = (float) xcols / (float) cols; pm_message( "warning, non-square pixels; to fix do a 'pnmscale -%cscale %g'", rowratio > colratio ? 'y' : 'x', rowratio > colratio ? rowratio / colratio : colratio / rowratio ); } /* Now read the hex bits. */ grays = pgm_allocarray( cols, rows ); for ( row = rows - 1; row >= 0; row--) { for ( col = 0, gP = grays[row]; col < cols; col++, gP++ ) { *gP = gethexit( ifp ) << 4; *gP += gethexit( ifp ); } } pm_close( ifp ); /* And write out the graymap. */ pgm_writepgm( stdout, grays, cols, rows, (gray) maxval, 0 ); pm_close( stdout ); exit( 0 ); } static int gethexit( ifp ) FILE *ifp; { register int i; register char c; for ( ; ; ) { i = getc( ifp ); if ( i == EOF ) pm_error( "EOF / read error" ); c = (char) i; if ( c >= '0' && c <= '9' ) return c - '0'; else if ( c >= 'A' && c <= 'F' ) return c - 'A' + 10; else if ( c >= 'a' && c <= 'f' ) return c - 'a' + 10; /* Else ignore - whitespace. */ } } netpbm-free-10.0-1/pgm/hipstopgm.10100644004714500471450000000161407716230207017204 0ustar aba-guestaba-guest.TH hipstopgm 1 "24 August 89" .IX hipstopgm .SH NAME hipstopgm - convert a HIPS file into a portable graymap .SH SYNOPSIS .B hipstopgm .RI [ hipsfile ] .SH DESCRIPTION Reads a HIPS file as input. .IX HIPS Produces a portable graymap as output. .PP If the HIPS file contains more than one frame in sequence, hipstopgm will concatenate all the frames vertically. .PP HIPS is a format developed at the Human Information Processing Laboratory, NYU. .SH "SEE ALSO" pgm(5) .SH AUTHOR Copyright (C) 1989 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/hipstopgm.c0100644004714500471450000001032507725102161017262 0ustar aba-guestaba-guest/* hipstopgm.c - read a HIPS file and produce a portable graymap ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pgm.h" #include struct HIPS_Header { char* orig_name; /* An indication of the originator of this sequence. */ char* seq_name; /* The sequence name. */ int num_frame; /* The number of frames in this sequence. */ char* orig_date; /* The date the sequence was originated. */ int rows; /* The number of rows in each image, the height. */ int cols; /* The number of columns in each image, the width. */ int bits_per_pixel; /* The number of significant bits per pixel. */ int bit_packing; /* Nonzero if the bits were packed such as to eliminate any unused bits resulting from a bits_per_pixel value which was not an even multiple of eight. */ int pixel_format; /* An indication of the format of each pixel. */ char* seq_history; /* A description of the sequence of transformations leading up to the current image. */ char* seq_desc; /* A free form description of the contents of the sequence. */ }; #define HIPS_PFBYTE 0 #define HIPS_PFSHORT 1 #define HIPS_PFINT 2 #define HIPS_PFFLOAT 3 #define HIPS_PFCOMPLEX 4 static void read_hips_header ARGS(( FILE* fd, struct HIPS_Header* hP )); static void read_line ARGS(( FILE* fd, char* buf, int size )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; gray* grayrow; register gray* gP; int argn, row; register int col; int maxval; int rows, cols; struct HIPS_Header h; pgm_init( &argc, argv ); argn = 1; if ( argn < argc ) { ifp = pm_openr( argv[argn] ); argn++; } else ifp = stdin; if ( argn != argc ) pm_usage( "[hipsfile]" ); read_hips_header( ifp, &h ); cols = h.cols; rows = h.rows * h.num_frame; switch ( h.pixel_format ) { case HIPS_PFBYTE: if ( h.bits_per_pixel != 8 ) pm_error( "can't handle unusual bits_per_pixel %d", h.bits_per_pixel ); if ( h.bit_packing != 0 ) pm_error( "can't handle bit_packing" ); maxval = 255; break; default: pm_error( "unknown pixel format %d", h.pixel_format ); } pgm_writepgminit( stdout, cols, rows, (gray) maxval, 0 ); grayrow = pgm_allocrow( cols ); for ( row = 0; row < rows; row++) { for ( col = 0, gP = grayrow; col < cols; col++, gP++ ) { int ich; switch ( h.pixel_format ) { case HIPS_PFBYTE: ich = getc( ifp ); if ( ich == EOF ) pm_error( "EOF / read error" ); *gP = (gray) ich; break; default: pm_error( "can't happen" ); } } pgm_writepgmrow( stdout, grayrow, cols, (gray) maxval, 0 ); } pm_close( ifp ); pm_close( stdout ); exit( 0 ); } static void read_hips_header( fd, hP ) FILE* fd; struct HIPS_Header* hP; { char buf[5000]; /* Read and toss orig_name. */ read_line( fd, buf, 5000 ); /* Read and toss seq_name. */ read_line( fd, buf, 5000 ); /* Read num_frame. */ read_line( fd, buf, 5000 ); hP->num_frame = atoi( buf ); /* Read and toss orig_date. */ read_line( fd, buf, 5000 ); /* Read rows. */ read_line( fd, buf, 5000 ); hP->rows = atoi( buf ); /* Read cols. */ read_line( fd, buf, 5000 ); hP->cols = atoi( buf ); /* Read bits_per_pixel. */ read_line( fd, buf, 5000 ); hP->bits_per_pixel = atoi( buf ); /* Read bit_packing. */ read_line( fd, buf, 5000 ); hP->bit_packing = atoi( buf ); /* Read pixel_format. */ read_line( fd, buf, 5000 ); hP->pixel_format = atoi( buf ); /* Now read and toss lines until we get one with just a period. */ do { read_line( fd, buf, 5000 ); } while ( strcmp( buf, ".\n" ) != 0 ); } static void read_line( fd, buf, size ) FILE* fd; char* buf; int size; { if ( fgets( buf, size, fd ) == NULL ) pm_error( "error reading header" ); } netpbm-free-10.0-1/pgm/libpgm.30100644004714500471450000001266307716230207016454 0ustar aba-guestaba-guest.TH libpgm 3 .SH NAME libpgm - functions to support portable graymap (PGM) programs .SH SYNOPSIS .B #include .B void pgm_init( .BI "int *" argcP , .BI "char *" argv [] .B ); .B gray ** pgm_allocarray( .BI "int " cols , .BI "int " rows " );" .B "gray * pgm_allocrow(" .BI int cols " );" .B void pgm_freearray( .BI "gray **" grays , .BI int rows " );" .B void pgm_freerow( .BI "gray *" grayrow ");" .B void pgm_readpgminit( .BI "FILE *" fp , .BI "int *" colsP , .BI "int *" rowsP , .BI "gray *" maxvalP , .BI "int *" formatP " );" .B void pgm_readpgmrow( .BI "FILE *" fp , .BI "gray *" grayrow , .BI "int " cols , .BI "gray " maxval , .BI "int " format " );" .B gray ** pgm_readpgm( .BI "FILE *" fp , .BI "int *" colsP , .BI "int *" rowsP , .BI "gray *" maxvalP " );" .B void pgm_writepgminit( .B "FILE * " fp , .BI "int " cols , .BI "int " rows , .BI "gray " maxval , .BI "int " forceplain " );" .B void pgm_writepgmrow( .BI "FILE *" fp , .BI "gray *" grayrow , .BI "int "cols , .BI "gray " maxval , .BI "int " forceplain " );" .B void pgm_writepgm( .BI "FILE *" fp , .BI "gray ** " grays , .BI "int " cols , .BI "int " rows , .BI "gray " maxval , .BI "int " forceplain " );" .B void pgm_writepgm( .BI "FILE *" fp , .BI "gray **" grays , .BI "int " cols , .BI "int " rows , .BI "gray " maxval , .BI "int " forceplain " );" .B void pgm_nextimage( .BI "FILE *" file , .BI "int * const " eofP ); .B void pgm_check( .BI "FILE * " file , .BI "const enum pm_check_type " check_type , .BI "const int " format , .BI "const int " cols , .BI "const int " rows , .BI "const int " maxval , .BI "enum pm_check_code * const " retval ); .B typedef ... gray; .B #define PGM_MAXMAXVAL ... .B #define PGM_OVERALLMAXVAL ... .B extern gray pgm_pbmmaxval; .B #define PGM_FORMAT ... .B #define RPGM_FORMAT ... .B #define PGM_TYPE PGM_FORMAT .B #define .BI PGM_FORMAT_TYPE( format ) .B ... .SH DESCRIPTION .SS TYPES AND CONSTANTS Each .B gray should contain only the values between .B 0 and .BR PGM_OVERALLMAXVAL . .B pgm_pbmmaxval is the maxval used when a PGM program reads a PBM file. Normally it is 1; however, for some programs, a larger value gives better results. .B PGM_OVERALLMAXVAL is the maximum value of a maxval in a PGM file. .B PGM_MAXMAXVAL is the maximum value of a maxval in a PGM file that is compatible with the PGM format as it existed before April 2000. It is also the maximum value of a maxval that results in the minimum possible raster size for a particular image. I.e an image with a maxval higher than .B PGM_MAXMAXVAL cannot be read or generated by old PGM processing programs and requires more file space. .B PGM_FORMAT is the format code for a Plain PGM format image file. .B RPGM_FORMAT is the format code for a Raw PGM format image file. .B PGM_TYPE is the format type code for the PGM formats. .B PGM_FORMAT_TYPE is a macro that generates code to compute the format type code of a PBM or PGM format from the format code which is its argument. .SS INITIALIZATION All PGM programs must call .B pgm_init() just after invocation, before they process their arguments. .SS MEMORY MANAGEMENT .B pgm_allocarray() allocates an array of grays. .B pgm_allocrow() allocates a row of the given number of grays. .B pgm_freearray() frees the array allocated with .B pgm_allocarray() containing the given number of rows. .B pgm_freerow() frees a row of grays allocated with .BR pgm_allocrow() . .SS READING FILES If a function in this section is called on a PBM format file, it translates the PBM file into a PGM file on the fly and functions as if it were called on the equivalent PGM file. The .I format value returned by .B pgm_readpgminit() is, however, not translated. It represents the actual format of the PBM file. .B pgm_readpgminit() reads the header of a PGM file, returning all the information from the header and leaving the file positioned just after the header. .B pgm_readpgmrow() reads a row of grays into the .I grayrow array. .IR format , .IR cols , and .I maxval are the values returned by .BR pgm_readpgminit() . .B pgm_readpgm() reads an entire PGM image into memory, returning the allocated array as its return value and returning the information from the header as .IR rows , .IR cols , and .IR maxval . This function combines .BR pgm_readpgminit() , .BR pgm_allocarray() , and .BR pgm_readpgmrow() . .SS WRITING FILES .B pgm_writepgminit() writes the header for a PGM file and leaves it positioned just after the header. .I forceplain is a logical value that tells .B pgm_writepgminit() to write a header for a plain PGM format file, as opposed to a raw PGM format file. .B pgm_writepgmrow() writes the row .I grayrow to a PGM file. For meaningful results, .IR cols , .IR maxval , and .I forceplain must be the same as was used with .BR pgm_writepgminit() . .B pgm_writepgm() write the header and all data for a PGM image. This function combines .B pgm_writepgminit() and .BR pgm_writepgmrow() . .SS MISCELLANEOUS .B pgm_nextimage() positions a PGM input file to the next image in it (so that a subsequent .B pgm_readpgminit() reads its header). .B pgm_nextimage() is analogous to .BR pbm_nextimage() , but works on PGM and PBM files. .B pgm_check() checks for the common file integrity error where the file is the wrong size to contain all the image data. .B pgm_check() is analogous to .BR pbm_check() , but works on PGM and PBM files. .SH "SEE ALSO" .BR libpbm (3), .BR libppm (3), .BR libpnm (3) netpbm-free-10.0-1/pgm/libpgm1.c0100644004714500471450000001344607716762513016627 0ustar aba-guestaba-guest/* libpgm1.c - pgm utility library part 1 ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include #include #include "pgm.h" #include "libpgm.h" #include "pbm.h" #include "libpbm.h" void pgm_init(int * const argcP, char ** const argv) { pbm_init( argcP, argv ); } void pgm_nextimage(FILE * const file, int * const eofP) { pm_nextimage(file, eofP); } void pgm_readpgminitrest(FILE * const file, int * const colsP, int * const rowsP, gray * const maxvalP) { int maxval; /* Read size. */ *colsP = pbm_getint( file ); *rowsP = pbm_getint( file ); /* Read maxval. */ maxval = pbm_getint( file ); if ( maxval > PGM_OVERALLMAXVAL ) pm_error( "maxval is too large. The largest we can handle is %d.", PGM_OVERALLMAXVAL ); *maxvalP = maxval; } void pgm_readpgminit(FILE * const file, int * const colsP, int * const rowsP, gray * const maxvalP, int * const formatP) { /* Check magic number. */ *formatP = pbm_readmagicnumber( file ); switch ( PGM_FORMAT_TYPE(*formatP) ) { case PGM_TYPE: pgm_readpgminitrest( file, colsP, rowsP, maxvalP ); break; case PBM_TYPE: pbm_readpbminitrest( file, colsP, rowsP ); /* Mathematically, it makes the most sense for the maxval of a PBM file seen as a PGM to be 1. But we tried this for a while and found that it causes unexpected results and frequent need for a Pnmdepth stage to convert the maxval to 255. You see, when you transform a PGM file in a way that causes interpolated gray shades, there's no in-between value to use when maxval is 1. It's really hard even to discover that your lack of Pnmdepth is your problem. So we pick 255, which is the most common PGM maxval, and the highest resolution you can get without increasing the size of the PGM image. So this means some programs that are capable of exploiting the bi-level nature of a PBM file must be PNM programs instead of PGM programs. */ *maxvalP = PGM_MAXMAXVAL; break; default: pm_error( "bad magic number - not a pgm or pbm file" ); } } gray pgm_getrawsample(FILE * const file, gray const maxval) { if (maxval < 256) { /* The sample is just one byte. Read it. */ return(pbm_getrawbyte(file)); } else { /* The sample is two bytes. Read both. */ unsigned char byte_pair[2]; size_t pairs_read; pairs_read = fread(&byte_pair, 2, 1, file); if (pairs_read == 0) pm_error("EOF /read error while reading a long sample"); /* This could be a few instructions faster if exploited the internal format (i.e. endianness) of a pixval. Then we might be able to skip the shifting and oring. */ return((byte_pair[0]<<8) | byte_pair[1]); } } void pgm_readpgmrow(FILE* const file, gray* const grayrow, int const cols, gray const maxval, int const format) { switch (format) { case PGM_FORMAT: { int col; for (col = 0; col < cols; ++col) { grayrow[col] = pbm_getint(file); #ifdef DEBUG if (grayrow[col] > maxval) pm_error( "value out of bounds (%u > %u)", grayrow[col], maxval ); #endif /*DEBUG*/ } } break; case RPGM_FORMAT: { int col; for (col = 0; col < cols; ++col) { grayrow[col] = pgm_getrawsample( file, maxval ); #ifdef DEBUG if ( grayrow[col] > maxval ) pm_error( "value out of bounds (%u > %u)", grayrow[col], maxval ); #endif /*DEBUG*/ } } break; case PBM_FORMAT: case RPBM_FORMAT: { bit * bitrow; int col; bitrow = pbm_allocrow(cols); pbm_readpbmrow( file, bitrow, cols, format ); for (col = 0; col < cols; ++col) grayrow[col] = (bitrow[col] == PBM_WHITE ) ? maxval : 0; pbm_freerow(bitrow); } break; default: pm_error( "can't happen" ); } } gray** pgm_readpgm(FILE * const file, int * const colsP, int * const rowsP, gray * const maxvalP) { gray** grays; int row; int format; pgm_readpgminit( file, colsP, rowsP, maxvalP, &format ); grays = pgm_allocarray( *colsP, *rowsP ); for ( row = 0; row < *rowsP; ++row ) pgm_readpgmrow( file, grays[row], *colsP, *maxvalP, format ); return grays; } void pgm_check(FILE * file, const enum pm_check_type check_type, const int format, const int cols, const int rows, const int maxval, enum pm_check_code * const retval_p) { if (check_type != PM_CHECK_BASIC) { if (retval_p) *retval_p = PM_CHECK_UNKNOWN_TYPE; } else if (PGM_FORMAT_TYPE(format) == PBM_TYPE) { pbm_check(file, check_type, format, cols, rows, retval_p); } else if (format != RPGM_FORMAT) { if (retval_p) *retval_p = PM_CHECK_UNCHECKABLE; } else { const unsigned int bytes_per_row = cols * (maxval > 255 ? 2 : 1); const unsigned int need_raster_size = rows * bytes_per_row; pm_check(file, check_type, need_raster_size, retval_p); } } netpbm-free-10.0-1/pgm/libpgm2.c0100644004714500471450000001022507716762513016620 0ustar aba-guestaba-guest/* libpgm2.c - pgm utility library part 2 ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pgm.h" #include "libpgm.h" static void putus ARGS((unsigned short n, FILE* file)); static void pgm_writepgmrowplain ARGS((FILE* file, gray* grayrow, int cols, gray maxval)); static void pgm_writepgmrowraw ARGS((FILE* file, gray* grayrow, int cols, gray maxval)); void pgm_writepgminit(FILE* file, int cols, int rows, gray maxval, int forceplain) { if (maxval > PGM_OVERALLMAXVAL && !forceplain) pm_error("too-large maxval passed to ppm_writeppminit(): %d.\n" "Maximum allowed by the PGM format is %d.", maxval, PGM_OVERALLMAXVAL); fprintf(file, "%c%c\n%d %d\n%d\n", PGM_MAGIC1, forceplain || maxval >= 1<<16 ? PGM_MAGIC2 : RPGM_MAGIC2, cols, rows, maxval ); #ifdef VMS if (!forceplain) set_outfile_binary(); #endif } static void putus(unsigned short n, FILE *file ) { if ( n >= 10 ) putus( n / 10, file ); (void) putc( n % 10 + '0', file ); } void pgm_writerawsample(FILE *file, const gray val, const gray maxval) { if (maxval < 256) { /* Samples fit in one byte, so write just one byte */ int rc; rc = putc(val, file); if (rc == EOF) pm_error("Error writing single byte sample to file"); } else { /* Samples are too big for one byte, so write two */ int n_written; unsigned char outval[2]; /* We could save a few instructions if we exploited the internal format of a gray, i.e. its endianness. Then we might be able to skip the shifting and anding. */ outval[0] = val >> 8; outval[1] = val & 0xFF; n_written = fwrite(&outval, 2, 1, file); if (n_written == 0) pm_error("Error writing double byte sample to file"); } } static void pgm_writepgmrowraw(FILE *file, gray *grayrow, int cols, gray maxval ) { int col; for (col = 0; col < cols; ++col) { #ifdef DEBUG if (grayrow[col] > maxval) pm_error( "value out of bounds (%u > %u)", grayrow[col], maxval); #endif /*DEBUG*/ pgm_writerawsample(file, grayrow[col], maxval); } } static void pgm_writepgmrowplain(FILE *file, gray *grayrow, int cols, gray maxval ) { register int col, charcount; register gray* gP; charcount = 0; for ( col = 0, gP = grayrow; col < cols; ++col, ++gP ) { if ( charcount >= 65 ) { (void) putc( '\n', file ); charcount = 0; } else if ( charcount > 0 ) { (void) putc( ' ', file ); ++charcount; } #ifdef DEBUG if ( *gP > maxval ) pm_error( "value out of bounds (%u > %u)", *gP, maxval ); #endif /*DEBUG*/ putus( (unsigned long) *gP, file ); charcount += 3; } if ( charcount > 0 ) (void) putc( '\n', file ); } #if __STDC__ void pgm_writepgmrow( FILE* file, gray* grayrow, int cols, gray maxval, int forceplain ) #else /*__STDC__*/ void pgm_writepgmrow( file, grayrow, cols, maxval, forceplain ) FILE* file; gray* grayrow; int cols; gray maxval; int forceplain; #endif /*__STDC__*/ { if (forceplain || maxval >= 1<<16) pgm_writepgmrowplain( file, grayrow, cols, maxval ); else pgm_writepgmrowraw( file, grayrow, cols, maxval ); } #if __STDC__ void pgm_writepgm( FILE* file, gray** grays, int cols, int rows, gray maxval, int forceplain ) #else /*__STDC__*/ void pgm_writepgm( file, grays, cols, rows, maxval, forceplain ) FILE* file; gray** grays; int cols, rows; gray maxval; int forceplain; #endif /*__STDC__*/ { int row; pgm_writepgminit( file, cols, rows, maxval, forceplain ); for ( row = 0; row < rows; ++row ) pgm_writepgmrow( file, grays[row], cols, maxval, forceplain ); } netpbm-free-10.0-1/pgm/lispmtopgm.10100644004714500471450000000315307716230207017365 0ustar aba-guestaba-guest.TH lispmtopgm 1 "06 March 1990" .IX lispmtopgm .SH NAME lispmtopgm - convert a Lisp Machine bitmap file into pgm format .SH SYNOPSIS .B lispmtopgm .RI [ lispmfile ] .SH DESCRIPTION Reads a Lisp Machine bitmap as input. .IX "Lisp Machine bitmap" Produces a portable graymap as output. .PP This is the file format written by the tv:write-bit-array-file function on TI Explorer and Symbolics lisp machines. .PP Multi-plane bitmaps on lisp machines are color; but the lispm image file format does not include a color map, so we must treat it as a graymap instead. This is unfortunate. .SH "SEE ALSO" pgmtolispm(1), pgm(5) .SH BUGS The Lispm bitmap file format is a bit quirky; Usually the image in the file has its width rounded up to the next higher multiple of 32, but not always. If the width is not a multiple of 32, we don't deal with it properly, but because of the Lispm microcode, such arrays are probably not image data anyway. .PP Also, the lispm code for saving bitmaps has a bug, in that if you are writing a bitmap which is not mod32 across, the file may be up to 7 bits too short! They round down instead of up, and we don't handle this bug gracefully. .PP No color. .SH AUTHOR Copyright (C) 1991 by Jamie Zawinski and Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/lispmtopgm.c0100644004714500471450000001240107725102161017440 0ustar aba-guestaba-guest/* lispmtopgm.c - read a file written by the tv:write-bit-array-file function ** of TI Explorer and Symbolics Lisp Machines, and write a PGM. ** ** Written by Jamie Zawinski based on code (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. ** ** When one writes a multi-plane bitmap with tv:write-bit-array-file, it is ** usually a color image; but a color map is not written in the file, so we ** treat this as a graymap instead. Since the pgm reader can also read pbms, ** this doesn't matter if you're using only single plane images. */ #include #include #include "pgm.h" #define LISPM_MAGIC "This is a BitMap file" static void getinit ARGS(( FILE* file, short* colsP, short* rowsP, short* depthP, short* padrightP )); static int depth_to_word_size ARGS(( int depth )); static unsigned int getval ARGS(( FILE* file )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; gray* grayrow; register gray* gP; short rows, cols, padright, row, col; short depth; int maxval; pgm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[lispmfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; getinit( ifp, &cols, &rows, &depth, &padright ); maxval = 1 << depth; if ( maxval > PGM_OVERALLMAXVAL ) pm_error( "depth (%d bits) is too large", depth); pgm_writepgminit( stdout, cols, rows, (gray) maxval, 0 ); overflow_add(cols, 7); grayrow = pgm_allocrow( ( cols + 7 ) / 8 * 8 ); for ( row = 0; row < rows; ++row ) { for ( col = 0, gP = grayrow; col < cols; ++col, ++gP ) *gP = getval( ifp ); pgm_writepgmrow( stdout, grayrow, cols, (gray) maxval, 0 ); } pm_close( ifp ); pm_close( stdout ); exit( 0 ); } static long item, bitmask; static unsigned int bitsperitem, maxbitsperitem, bitshift; static void getinit( file, colsP, rowsP, depthP, padrightP ) FILE* file; short* colsP; short* rowsP; short* padrightP; short* depthP; { short cols_32; char magic[sizeof(LISPM_MAGIC)]; int i; for ( i = 0; i < sizeof(magic)-1; ++i ) magic[i] = getc( file ); magic[i]='\0'; if (0 != strcmp(LISPM_MAGIC, magic)) pm_error( "bad id string in Lispm file" ); if ( pm_readlittleshort( file, colsP ) == -1 ) pm_error( "EOF / read error" ); if ( pm_readlittleshort( file, rowsP ) == -1 ) pm_error( "EOF / read error" ); if ( pm_readlittleshort( file, &cols_32 ) == -1 ) pm_error( "EOF / read error" ); *depthP = getc( file ); if ( *depthP == 0 ) *depthP = 1; /* very old file */ overflow_add( *colsP, 31); *padrightP = ( ( *colsP + 31 ) / 32 ) * 32 - *colsP; if ( *colsP != (cols_32 - *padrightP) ) { /* pm_message( "inconsistent input: Width and Width(mod32) fields don't agree" ); */ /* *padrightP = cols_32 - *colsP; */ /* hmmmm.... */ /* This is a dilemma. Usually the output is rounded up to mod32, but not always. * For the Lispm code to not round up, the array size must be the same size as the * portion being written - that is, the array itself must be an odd size, not just * the selected portion. Since arrays that are odd sizes can't be handed to bitblt, * such arrays are probably not image data - so punt on it for now. * * Also, the lispm code for saving bitmaps has a bug, in that if you are writing a * bitmap which is not mod32 across, the file may be up to 7 bits too short! They * round down instead of up. * * The code in 'pgmtolispm.c' always rounds up to mod32, which is totally reasonable. */ } bitsperitem = 0; maxbitsperitem = depth_to_word_size( *depthP ); bitmask = ( 1 << maxbitsperitem ) - 1; /* for depth=3, mask=00000111 */ for ( i = 0; i < 9; ++i ) getc( file ); /* discard bytes reserved for future use */ } static int depth_to_word_size (depth) int depth; /* Lispm architecture specific - if a bitmap is written */ /* out with a depth of 5, it really has a depth of 8, and */ /* is stored that way in the file. */ { if (depth==0 || depth==1) return ( 1); else if (depth == 2) return ( 2); else if (depth <= 4) return ( 4); else if (depth <= 8) return ( 8); else if (depth <= 16) return (16); else if (depth <= 32) return (32); else { pm_error( "depth was %d, which is not in the range 1-32.", depth ); /* Should never reach here */ return(-1); } } static unsigned int getval( file ) FILE* file; { unsigned int b; if ( bitsperitem == 0 ) { if ( pm_readlittlelong( file, &item ) == -1 ) pm_error( "EOF / read error" ); bitsperitem = 32; bitshift = 0; item = ~item; } b = ( ( item >> bitshift ) & bitmask ); bitsperitem = bitsperitem - maxbitsperitem; bitshift = bitshift + maxbitsperitem; return b; } netpbm-free-10.0-1/pgm/pbmtopgm.10100644004714500471450000000311207721162447017020 0ustar aba-guestaba-guest.TH pbmtopgm 1 "03 Sep 2001" .SH NAME pbmtopgm - convert portable bitmap to portable graymap by averaging areas .SH SYNOPSIS .B pbmtopgm .I width .I height .RI [ pbmfile ] .SH DESCRIPTION .B pbmtopgm reads a portable bitmap as input. It outputs a portable graymap in which each pixel's gray level is the average the surrounding black and white input pixels. The surrounding area is a rectangle of .I width by .I height pixels. In other words, this is a convolution. .B pbmtopgm is similar to a special case of .BR pnmconvol . You may need a .B ppmsmooth step after .BR pbmtopgm . .B pbmtopgm has the effect of anti-aliasing bitmaps which contain distinct line features. .B pbmtopgm works best with odd sample width and heights. You don't need .B pbmtopgm just to use a PGM program on a PBM image. Any PGM program (assuming it uses the Netpbm libraries to read the PGM input) takes PBM input as if it were PGM, with only the mininum and maximum gray levels. So unless your convolution rectangle is bigger than one pixel, you're not gaining anything with a .B pbmtopgm step. .SH "SEE ALSO" .BR netpbm (1), .BR pgmtopbm (1), .BR pbm (5) .SH AUTHOR Copyright (C) 1990 by Angus Duggan Copyright (C) 1989 by Jef Poskanzer. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is" without express or implied warranty. netpbm-free-10.0-1/pgm/pbmtopgm.c0100644004714500471450000000322007716230207017074 0ustar aba-guestaba-guest/* pbmtopgm.c - convert bitmap to greymap by totalling pixels over sample area * AJCD 12/12/90 */ #include #include "pgm.h" int main(argc, argv) int argc; char *argv[]; { register gray *outrow, maxval; register int right, left, down, up; register bit **inbits; int rows, cols; FILE *ifd; int col, row, width, height; char *usage = " [pbmfile]"; pgm_init( &argc, argv ); if (argc > 4 || argc < 3) pm_usage(usage); width = atoi(argv[1]); height = atoi(argv[2]); if (width < 1 || height < 1) pm_error("width and height must be > 0"); left=width/2; right=width-left; up=width/2; down=height-up; if (argc == 4) ifd = pm_openr(argv[3]); else ifd = stdin ; inbits = pbm_readpbm(ifd, &cols, &rows) ; if (width > cols || height > rows) pm_error("sample size greater than bitmap size"); outrow = pgm_allocrow(cols) ; overflow2(width, height); maxval = width*height; pgm_writepgminit(stdout, cols, rows, maxval, 0) ; for (row = 0; row < rows; row++) { int t = (row > up) ? (row-up) : 0; int b = (row+down < rows) ? (row+down) : rows; int onv = height - (t-row+up) - (row+down-b); for (col = 0; col < cols; col++) { int l = (col > left) ? (col-left) : 0; int r = (col+right < cols) ? (col+right) : cols; int onh = width - (l-col+left) - (col+right-r); int value = 0, x, y; for (x = l; x < r; x++) for (y = t; y < b; y++) if (inbits[y][x] == PBM_WHITE) value++; outrow[col] = maxval*value/(onh*onv); } pgm_writepgmrow(stdout, outrow, cols, maxval, 0) ; } pm_close(ifd); exit(0); } netpbm-free-10.0-1/pgm/pgm.50100644004714500471450000001364307716762513016000 0ustar aba-guestaba-guest.TH pgm 5 "12 November 1991" .SH NAME pgm - portable graymap file format .SH DESCRIPTION The PGM format is a lowest common denominator grayscale file format. .IX "PGM file format" It is designed to be extremely easy to learn and write programs for. (It's so simple that most people will simply reverse engineer it because it's easier than reading this specification). A PGM image represents a grayscale graphic image. There are many psueudo-PGM formats in use where everything is as specified herein except for the meaning of individual pixel values. For most purposes, a PGM image can just be thought of an array of arbitrary integers, and all the programs in the world that think they're processing a grayscale image can easily be tricked into processing something else. One official variant of PGM is the transparency mask. A transparency mask in Netpbm is represented by a PGM image, except that in place of pixel intensities, there are opaqueness values. See below. .PP The format definition is as follows. .PP A PGM file consists of a sequence of one or more PGM images. There are no data, delimiters, or padding before, after, or between images. .PP Each PGM image consists of the following: .IP - 2 A "magic number" for identifying the file type. A pgm image's magic number is the two characters "P5". .IX "magic numbers" .IP - 2 Whitespace (blanks, TABs, CRs, LFs). .IP - 2 A width, formatted as ASCII characters in decimal. .IP - 2 Whitespace. .IP - 2 A height, again in ASCII decimal. .IP - 2 Whitespace. .IP - 2 The maximum gray value (Maxval), again in ASCII decimal. Must be less than 65536. .IP - 2 Newline or other single whitespace character. .IP - 2 A raster of Width * Height gray values, proceeding through the image in normal English reading order. Each gray value is a number from 0 through Maxval, with 0 being black and Maxval being white. Each gray value is represented in pure binary by either 1 or 2 bytes. If the Maxval is less than 256, it is 1 byte. Otherwise, it is 2 bytes. The most significant byte is first. .IP - 2 Each gray value is a number proportional to the intensity of the pixel, adjusted by the CIE Rec. 709 gamma transfer function. (That transfer function specifies a gamma number of 2.2 and has a linear section for small intensities). A value of zero is therefore black. A value of Maxval represents CIE D65 white and the most intense value in the image and any other image to which the image might be compared. .IP - 2 Note that a common variation on the PGM format is to have the gray value be "linear," i.e. as specified above except without the gamma adjustment. .B pnmgamma takes such a PGM variant as input and produces a true PGM as output. .IP - 2 In the transparency mask variation on PGM, the value represents opaqueness. It is proportional to the fraction of intensity of a pixel that would show in place of an underlying pixel, with the same gamma transfer function mentioned above applied. So what normally means white represents total opaqueness and what normally means black represents total transparency. In between, you would compute the intensity of a composite pixel of an "under" and "over" pixel as under * (1-(alpha/alpha_maxval)) + over * (alpha/alpha_maxval).< .IP - 2 Characters from a "#" to the next end-of-line, before the maxval line, are comments and are ignored. .PP Note that you can use .B pnmdepth To convert between a the format with 1 byte per gray value and the one with 2 bytes per gray value. .PP There is actually another version of the PGM format that is fairly rare: "plain" PGM format. The format above, which generally considered the normal one, is known as the "raw" PGM format. See .BR pbm (5) for some commentary on how plain and raw formats relate to one another. .PP The difference in the plain format is: .IP - 2 There is exactly one image in a file. .IP - 2 The magic number is P2 instead of P5. .IP - 2 Each pixel in the raster is represented as an ASCII decimal number (of arbitrary size). .IP - 2 Each pixel in the raster has white space before and after it. There must be at least one character of white space between any two pixels, but there is no maximum. .IP - 2 No line should be longer than 70 characters. .PP Here is an example of a small graymap in this format: .nf P2 # feep.pgm 24 7 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0 0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0 0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0 0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0 0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .fi .PP Programs that read this format should be as lenient as possible, accepting anything that looks remotely like a graymap. .SH COMPATIBILITY Before April 2000, a raw format PGM file could not have a maxval greater than 255. Hence, it could not have more than one byte per sample. Old programs may depend on this. Before July 2000, there could be at most one image in a PGM file. As a result, most tools to process PGM files ignore (and don't read) any data after the first image. .SH "SEE ALSO" fitstopgm(1), fstopgm(1), hipstopgm(1), lispmtopgm(1), psidtopgm(1), rawtopgm(1), pgmbentley(1), pgmcrater(1), pgmedge(1), pgmenhance(1), pgmhist(1), pgmnorm(1), pgmoil(1), pgmramp(1), pgmtexture(1), pgmtofits(1), pgmtofs(1), pgmtolispm(1), pgmtopbm(1), pnm(5), pbm(5), ppm(5) .SH AUTHOR Copyright (C) 1989, 1991 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/pgmbentley.10100644004714500471450000000164207716230207017341 0ustar aba-guestaba-guest.TH pgmbentley 1 "11 January 1991" .IX pgmbentley .SH NAME pgmbentley - Bentleyize a portable graymap .SH SYNOPSIS .B pgmbentley .RI [ pgmfile ] .SH DESCRIPTION Reads a portable graymap as input. Performs The Bentley Effect, and writes a portable graymap as output. .IX "Bentley Effect" .PP The Bentley Effect is described in "Beyond Photography" by Holzmann, chapter 4, photo 4. It's a vertical smearing based on brightness. .SH "SEE ALSO" pgmoil(1), ppmrelief(1), pgm(5) .SH AUTHOR Copyright (C) 1990 by Wilson Bent (whb@hoh-2.att.com) .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/pgmbentley.c0100644004714500471450000000265307716230207017426 0ustar aba-guestaba-guest/* pgmbentley.c - read a portable graymap and smear it according to brightness ** ** Copyright (C) 1990 by Wilson Bent (whb@hoh-2.att.com) ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pgm.h" int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; gray maxval; gray** gin; gray** gout; int argn, rows, cols, row; register int brow, col; char* usage = "[pgmfile]"; pgm_init( &argc, argv ); argn = 1; if ( argn < argc ) { ifp = pm_openr( argv[argn] ); ++argn; } else ifp = stdin; if ( argn != argc ) pm_usage( usage ); gin = pgm_readpgm( ifp, &cols, &rows, &maxval ); pm_close( ifp ); gout = pgm_allocarray( cols, rows ); #define N 4 for ( row = 0; row < rows; ++row ) for ( col = 0; col < cols; ++col ) { brow = row + (int) (gin[row][col]) / N; if ( brow >= rows ) brow = rows - 1; gout[brow][col] = gin[row][col]; } pgm_writepgm( stdout, gout, cols, rows, maxval, 0 ); pm_close( stdout ); pgm_freearray( gout, rows ); exit( 0 ); } netpbm-free-10.0-1/pgm/pgmcrater.10100644004714500471450000001257107716230207017162 0ustar aba-guestaba-guest.TH pgmcrater 1 "15 October 1991" .IX pgmcrater .IX fractals .IX craters .SH NAME pgmcrater - create cratered terrain by fractal forgery .SH SYNOPSIS .na .B pgmcrater 'ti 15 .RB [ -number .IR n ] .RB [ -height | -ysize .IR s ] .RB [ -width | -xsize .IR s ] .RB [ -gamma .IR g ] .ad .PP All options can be abbreviated to their shortest unique prefix. .SH DESCRIPTION .B pgmcrater creates a PGM image which mimics cratered terrain. The PGM image is created by simulating the impact of a given number of craters with random position and size, then rendering the resulting terrain elevations based on a light source shining from one side of the screen. The size distribution of the craters is based on a power law which results in many more small craters than large ones. The number of craters of a given size varies as the reciprocal of the area as described on pages 31 and 32 of Peitgen and Saupe[1]; cratered bodies in the Solar System are observed to obey this relationship. The formula used to obtain crater radii governed by this law from a uniformly distributed pseudorandom sequence was developed by Rudy Rucker. .PP High resolution images with large numbers of craters often benefit from being piped through .BR pnmsmooth . The averaging performed by this process eliminates some of the jagged pixels and lends a mellow ``telescopic image'' feel to the overall picture. .B pgmcrater simulates only small craters, which are hemispherical in shape (regardless of the incidence angle of the impacting body, as long as the velocity is sufficiently high). Large craters, such as Copernicus and Tycho on the Moon, have a ``walled plain'' shape with a cross-section more like: .nf .ne 2 .cs R 18 /\\ /\\ .br _____/ \\____________/\\____________/ \\_____ .cs R .fi .ss 12 Larger craters should really use this profile, including the central peak, and totally obliterate the pre-existing terrain. .SH OPTIONS .TP 10 .BI -number " n" Causes .I n craters to be generated. If no .B -number specification is given, 50000 craters will be generated. Don't expect to see them all! For every large crater there are many, many more tiny ones which tend simply to erode the landscape. In general, the more craters you specify the more realistic the result; ideally you want the entire terrain to have been extensively turned over again and again by cratering. High resolution images containing five to ten million craters are stunning but take quite a while to create. .TP .BI -height " height" Sets the height of the generated image to .I height pixels. The default height is 256 pixels. .TP .BI -width " width" Sets the width of the generated image to .I width pixels. The default width is 256 pixels. .TP .BI -xsize " width" Sets the width of the generated image to .I width pixels. The default width is 256 pixels. .TP .BI -ysize " height" Sets the height of the generated image to .I height pixels. The default height is 256 pixels. .TP .BI -gamma " factor" The specified .I factor is used to gamma adjust the image in the same manner as performed by .BR pnmgamma . The default value is 1.0, which results in a medium contrast image. Values larger than 1 lighten the image and reduce contrast, while values less than 1 darken the image, increasing contrast. Note that this is separate from the gamma correction that is part of the definition of the PGM format. The image .B pnmgamma generates is a genuine, gamma-corrected PGM image in any case. This option simply changes the contrast and may compensate for a display device that does not correctly render PGM images. .SH DESIGN NOTES The .B -gamma option isn't really necessary since you can achieve the same effect by piping the output from .B pgmcrater through .BR pnmgamma . However, .B pgmcrater performs an internal gamma map anyway in the process of rendering the elevation array into the PGM format, so there's no additional overhead in allowing an additional gamma adjustment. .PP Real craters have two distinct morphologies. .SH "SEE ALSO" .PD .BR pgm (5), .BR pnmgamma (1), .BR pnmsmooth (1) .TP 5 [1] Peitgen, H.-O., and Saupe, D. eds., The Science Of Fractal Images, New York: Springer Verlag, 1988. .ne 10 .SH AUTHOR .RS 5 .nf John Walker Autodesk SA Avenue des Champs-Montants 14b CH-2074 MARIN Suisse/Schweiz/Svizzera/Svizra/Switzerland .PD 0 .TP 9 Usenet: kelvin@Autodesk.com .TP Fax: 038/33 88 15 .TP Voice: 038/33 76 33 .fi .RE .PD .PP Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, without any conditions or restrictions. This software is provided ``as is'' without express or implied warranty. .PP .B PLUGWARE! If you like this kind of stuff, you may also enjoy ``James Gleick's Chaos--The Software'' for MS-DOS, available for $59.95 from your local software store or directly from Autodesk, Inc., Attn: Science Series, 2320 Marinship Way, Sausalito, CA 94965, USA. Telephone: (800) 688-2344 toll-free or, outside the U.S. (415) 332-2344 Ext 4886. Fax: (415) 289-4718. ``Chaos--The Software'' includes a more comprehensive fractal forgery generator which creates three-dimensional landscapes as well as clouds and planets, plus five more modules which explore other aspects of Chaos. The user guide of more than 200 pages includes an introduction by James Gleick and detailed explanations by Rudy Rucker of the mathematics and algorithms used by each program. netpbm-free-10.0-1/pgm/pgmcrater.c0100644004714500471450000002454307716230207017246 0ustar aba-guestaba-guest/* Fractal cratering Designed and implemented in November of 1989 by: John Walker Autodesk SA Avenue des Champs-Montants 14b CH-2074 MARIN Switzerland Usenet: kelvin@Autodesk.com Fax: 038/33 88 15 Voice: 038/33 76 33 The algorithm used to determine crater size is as described on pages 31 and 32 of: Peitgen, H.-O., and Saupe, D. eds., The Science Of Fractal Images, New York: Springer Verlag, 1988. The mathematical technique used to calculate crater radii that obey the proper area law distribution from a uniformly distributed pseudorandom sequence was developed by Rudy Rucker. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, without any conditions or restrictions. This software is provided "as is" without express or implied warranty. PLUGWARE! If you like this kind of stuff, you may also enjoy "James Gleick's Chaos--The Software" for MS-DOS, available for $59.95 from your local software store or directly from Autodesk, Inc., Attn: Science Series, 2320 Marinship Way, Sausalito, CA 94965, USA. Telephone: (800) 688-2344 toll-free or, outside the U.S. (415) 332-2344 Ext 4886. Fax: (415) 289-4718. "Chaos--The Software" includes a more comprehensive fractal forgery generator which creates three-dimensional landscapes as well as clouds and planets, plus five more modules which explore other aspects of Chaos. The user guide of more than 200 pages includes an introduction by James Gleick and detailed explanations by Rudy Rucker of the mathematics and algorithms used by each program. */ /* Modifications by Arjen Bax, 2001-06-21: Remove black vertical line at right * edge. Make craters wrap around the image (enables tiling of image). */ #include #include #include "pgm.h" static void gencraters ARGS((void)); static void initseed ARGS((void)); #ifndef M_PI #define M_PI 3.14159265358979323846 #endif /* Definitions for obtaining random numbers. */ #define Cast(low, high) ((low)+((high)-(low)) * ((rand() & 0x7FFF) / arand)) /* Data types */ typedef int Boolean; #define FALSE 0 #define TRUE 1 #define V (void) /* Display parameters */ #define SCRX screenxsize /* Screen width */ #define SCRY screenysize /* Screen height */ #define SCRGAMMA 1.0 /* Display gamma */ /* Local variables */ #define ImageGamma 0.5 /* Inherent gamma of mapped image */ static int screenxsize = 256; /* Screen X size */ static int screenysize = 256; /* Screen Y size */ static double dgamma = SCRGAMMA; /* Display gamma */ static double arand = 32767.0; /* Random number parameters */ static long ncraters = 50000L; /* Number of craters to generate */ static double CdepthPower = 1.5; /* Crater depth power factor */ static double DepthBias = 0.707107; /* Depth bias */ static int modulo(int t, int n) { int m; assert(n>0); m = t % n; while (m<0) { m+=n; } return m; } /* INITSEED -- Generate initial random seed, if needed. */ static void initseed() { int i; i = time((long *) 0) * 0xF37C; srand(i); for (i = 0; i < 7; i++) { V rand(); } } /* GENCRATERS -- Generate cratered terrain. */ static void gencraters() { int i, j, x, y; long l; unsigned short *aux; int slopemin = -52, slopemax = 52; #define RGBQuant 255 unsigned char *slopemap; /* Slope to pixel map */ gray *pixels; /* Pixel vector */ #define Auxadr(x, y) &aux[modulo(y, SCRY)*SCRX+modulo(x, SCRX)] /* Acquire the elevation array and initialise it to mean surface elevation. */ aux = (unsigned short *) malloc3(SCRX, SCRY, sizeof(short)); if (aux == (unsigned short *) 0) { pm_error("out of memory allocating elevation array"); } /* Acquire the elevation buffer and initialise to mean initial elevation. */ for (i = 0; i < SCRY; i++) { unsigned short *zax = aux + (((long) SCRX) * i); for (j = 0; j < SCRX; j++) { *zax++ = 32767; } } /* Every time we go around this loop we plop another crater on the surface. */ for (l = 0; l < ncraters; l++) { double g; int cx = Cast(0.0, ((double) SCRX - 1)), cy = Cast(0.0, ((double) SCRY - 1)), gx, gy, x, y; unsigned long amptot = 0, axelev; unsigned int npatch = 0; /* Phase 1. Compute the mean elevation of the impact area. We assume the impact area is a fraction of the total crater size. */ /* Thanks, Rudy, for this equation that maps the uniformly distributed numbers from Cast into an area-law distribution as observed on cratered bodies. */ g = sqrt(1 / (M_PI * (1 - Cast(0, 0.9999)))); /* If the crater is tiny, handle it specially. */ #if 0 fprintf(stderr, "crater=%lu ", (unsigned long)l); fprintf(stderr, "cx=%d ", cx); fprintf(stderr, "cy=%d ", cy); fprintf(stderr, "size=%g\n", g); #endif if (g < 3) { /* Set pixel to the average of its Moore neighbourhood. */ for (y = cy - 1; y <= cy + 1; y++) { for (x = cx - 1; x <= cx + 1; x++) { amptot += *Auxadr(x, y); npatch++; } } axelev = amptot / npatch; /* Perturb the mean elevation by a small random factor. */ x = (g >= 1) ? ((rand() >> 8) & 3) - 1 : 0; *Auxadr(cx, cy) = axelev + x; /* Jam repaint sizes to correct patch. */ gx = 1; gy = 0; } else { /* Regular crater. Generate an impact feature of the correct size and shape. */ /* Determine mean elevation around the impact area. */ gx = max(2, (g / 3)); gy = max(2, g / 3); for (y = cy - gy; y <= cy + gy; y++) { for (x = cx-gx; x <= cx + gx; x++) { amptot += *Auxadr(x,y); npatch++; } } axelev = amptot / npatch; gy = max(2, g); g = gy; gx = max(2, g); for (y = cy - gy; y <= cy + gy; y++) { double dy = (cy - y) / (double) gy, dysq = dy * dy; for (x = cx - gx; x <= cx + gx; x++) { double dx = ((cx - x) / (double) gx), cd = (dx * dx) + dysq, cd2 = cd * 2.25, tcz = DepthBias - sqrt(fabs(1 - cd2)), cz = max((cd2 > 1) ? 0.0 : -10, tcz), roll, iroll; unsigned short av; cz *= pow(g, CdepthPower); if (dy == 0 && dx == 0 && ((int) cz) == 0) { cz = cz < 0 ? -1 : 1; } #define rollmin 0.9 roll = (((1 / (1 - min(rollmin, cd))) / (1 / (1 - rollmin))) - (1 - rollmin)) / rollmin; iroll = 1 - roll; av = (axelev + cz) * iroll + (*Auxadr(x,y) + cz) * roll; av = max(1000, min(64000, av)); *Auxadr(x,y) = av; } } } if ((l % 5000) == 4999) { pm_message( "%ld craters generated of %ld (%ld%% done)", l + 1, ncraters, ((l + 1) * 100) / ncraters); } } i = max((slopemax - slopemin) + 1, 1); slopemap = (unsigned char *) malloc2(i, sizeof(unsigned char)); if (slopemap == (unsigned char *) 0) { pm_error("out of memory allocating slope map"); } for (i = slopemin; i <= slopemax; i++) { /* Confused? OK, we're using the left-to-right slope to calculate a shade based on the sine of the angle with respect to the vertical (light incident from the left). Then, with one exponentiation, we account for both the inherent gamma of the image (ad-hoc), and the user-specified display gamma, using the identity: (x^y)^z = (x^(y*z)) */ slopemap[i - slopemin] = i > 0 ? (128 + 127.0 * pow(sin((M_PI / 2) * i / slopemax), dgamma * ImageGamma)) : (128 - 127.0 * pow(sin((M_PI / 2) * i / slopemin), dgamma * ImageGamma)); } /* Generate the screen image. */ pgm_writepgminit(stdout, SCRX, SCRY, RGBQuant, FALSE); pixels = pgm_allocrow(SCRX); for (y = 0; y < SCRY; y++) { gray *pix = pixels; for (x = 0; x < SCRX; x++) { int j = *Auxadr(x+1, y) - *Auxadr(x, y); j = min(max(slopemin, j), slopemax); *pix++ = slopemap[j - slopemin]; } pgm_writepgmrow(stdout, pixels, SCRX, RGBQuant, FALSE); } pm_close(stdout); pgm_freerow(pixels); #undef Auxadr #undef Scradr free((char *) slopemap); free((char *) aux); } /* MAIN -- Main program. */ int main(argc, argv) int argc; char *argv[]; { int i; Boolean gammaspec = FALSE, numspec = FALSE, widspec = FALSE, hgtspec = FALSE; char *usage = "[-number ] [-width|-xsize ]\n\ [-height|-ysize ] [-gamma ]"; DepthBias = sqrt(0.5); /* Get exact value for depth bias */ pgm_init(&argc, argv); i = 1; while ((i < argc) && (argv[i][0] == '-') && (argv[i][1] != '\0')) { if (pm_keymatch(argv[i], "-gamma", 2)) { if (gammaspec) { pm_error("already specified gamma correction"); } i++; if ((i == argc) || (sscanf(argv[i], "%lf", &dgamma) != 1)) pm_usage(usage); if (dgamma <= 0.0) { pm_error("gamma correction must be greater than 0"); } gammaspec = TRUE; } else if (pm_keymatch(argv[i], "-number", 2)) { if (numspec) { pm_error("already specified number of craters"); } i++; if ((i == argc) || (sscanf(argv[i], "%ld", &ncraters) != 1)) pm_usage(usage); if (ncraters <= 0) { pm_error("number of craters must be greater than 0!"); } numspec = TRUE; } else if (pm_keymatch(argv[i], "-xsize", 2) || pm_keymatch(argv[i], "-width", 2)) { if (widspec) { pm_error("already specified a width/xsize"); } i++; if ((i == argc) || (sscanf(argv[i], "%d", &screenxsize) != 1)) pm_usage(usage); if (screenxsize <= 0) { pm_error("screen width must be greater than 0"); } widspec = TRUE; } else if (pm_keymatch(argv[i], "-ysize", 2) || pm_keymatch(argv[i], "-height", 2)) { if (hgtspec) { pm_error("already specified a height/ysize"); } i++; if ((i == argc) || (sscanf(argv[i], "%d", &screenysize) != 1)) pm_usage(usage); if (screenxsize <= 0) { pm_error("screen height must be greater than 0"); } hgtspec = TRUE; } else { pm_usage(usage); } i++; } initseed(); gencraters(); exit(0); } netpbm-free-10.0-1/pgm/pgmedge.10100644004714500471450000000251707716230207016605 0ustar aba-guestaba-guest.TH pgmedge 1 "04 February 1990" .IX pgmedge .SH NAME pgmedge - edge-detect a portable graymap .SH SYNOPSIS .B pgmedge .RI [ pgmfile ] .SH DESCRIPTION Reads a portable graymap as input. Outlines the edges, and writes a portable graymap as output. .IX "edge detection" Piping the result through .B pgmtopbm -threshold and playing with the threshold value will give a bitmap of the edges. .IX thresholding .PP The edge detection technique used is to take the Pythagorean sum of two Sobel gradient operators at 90 degrees to each other. For more details see "Digital Image Processing" by Gonzalez and Wintz, chapter 7. The maxval of the output is the same as the maxval of the input The effect is better with larger maxvals, so you may want to increase the maxval of the input by running it through .B pnmdepth first. .SH "SEE ALSO" .BR pgmenhance (1), .BR pgmtopbm (1), .BR pnmdepth (1), .BR pgm (5), .BR pbm (5) .SH AUTHOR Copyright (C) 1991 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/pgmedge.c0100644004714500471450000000564707716230207016676 0ustar aba-guestaba-guest/* pgmedge.c - edge-detect a portable graymap ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pgm.h" int main(int argc, char *argv[] ) { FILE *ifp; gray *row0, *row1, *row2, *tmprow, *orow; int argn, rows, cols, format, row; register int col; gray maxval; char *usage = "[pgmfile]"; pgm_init( &argc, argv ); argn = 1; if ( argn != argc ) { ifp = pm_openr( argv[argn] ); argn++; } else ifp = stdin; if ( argn != argc ) pm_usage( usage ); pgm_readpgminit( ifp, &cols, &rows, &maxval, &format ); if ( cols < 3 || rows < 3 ) pm_error( "the image is too small" ); row0 = pgm_allocrow( cols ); row1 = pgm_allocrow( cols ); row2 = pgm_allocrow( cols ); orow = pgm_allocrow( cols ); pgm_writepgminit( stdout, cols, rows, maxval, 0 ); /* Read in the first two rows. */ pgm_readpgmrow( ifp, row0, cols, maxval, format ); pgm_readpgmrow( ifp, row1, cols, maxval, format ); /* Write out the first row, all zeros. */ for ( col = 0; col < cols; ++col ) orow[col] = 0; pgm_writepgmrow( stdout, orow, cols, maxval, 0 ); /* Now the rest of the image -- read in the next row, and write ** write out the current row. */ for ( row = 1; row < rows - 1; row++ ) { int col; pgm_readpgmrow( ifp, row2, cols, maxval, format ); for ( col = 1; col < cols - 1; col++ ) { double sum1, sum2, sum; sum1 = (double) row0[col+1] - (double) row0[col-1] + 2.0 * ( (double) row1[col+1] - (double) row1[col-1] ) + (double) row2[col+1] - (double) row2[col-1]; sum2 = ( (double) row2[col-1] + 2.0 * (double) row2[col] + (double) row2[col+1] ) - ( (double) row0[col-1] + 2.0 * (double) row0[col] + (double) row0[col+1] ); sum = sqrt( sum1 * sum1 + sum2 * sum2 ); sum /= 1.8; /* arbitrary scaling factor */ if ( sum > maxval ) sum = maxval; orow[col] = (gray) (sum * + 0.5); } /* Write out a row. */ pgm_writepgmrow( stdout, orow, cols, maxval, 0 ); /* Rotate rows. */ tmprow = row0; row0 = row1; row1 = row2; row2 = tmprow; } pm_close( ifp ); /* And write the last row, zeros again. */ for ( col = 0; col < cols; ++col ) orow[col] = 0; pgm_writepgmrow( stdout, orow, cols, maxval, 0 ); pm_close( stdout ); exit( 0 ); } netpbm-free-10.0-1/pgm/pgmenhance.10100644004714500471450000000230107716230207017271 0ustar aba-guestaba-guest.TH pgmenhance 1 "13 January 1989" .IX pgmenhance .SH NAME pgmenhance - edge-enhance a portable graymap .SH SYNOPSIS .B pgmenhance .RI [ -N ] .RI [ pgmfile ] .SH DESCRIPTION Reads a portable graymap as input. Enhances the edges, and writes a portable graymap as output. .IX "edge enhancement" .PP The edge enhancing technique is taken from Philip R. Thompson's "xim" program, which in turn took it from section 6 of "Digital Halftones by Dot Diffusion", D. E. Knuth, ACM Transaction on Graphics Vol. 6, No. 4, October 1987, which in turn got it from two 1976 papers by J. F. Jarvis et. al. .SH OPTIONS .PP The optional .I -N flag should be a digit from 1 to 9. 1 is the lowest level of enhancement, 9 is the highest, The default is 9. .SH "SEE ALSO" pgmedge(1), pgm(5), pbm(5) .SH AUTHOR Copyright (C) 1989 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/pgmenhance.c0100644004714500471450000000654407716230207017370 0ustar aba-guestaba-guest/* pgmenhance.c - edge-enhance a portable graymap ** ** Copyright (C) 1989, 1991 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pgm.h" int main(int argc, char * argv[] ) { FILE* ifp; gray* prevrow; gray* thisrow; gray* nextrow; gray* temprow; gray* newrow; int argn, n, rows, cols, row, col; float phi, omphi; gray maxval; int format; char* usage = "[-N] [pgmfile] ( 1 <= N <= 9, default = 9 )"; pgm_init( &argc, argv ); argn = 1; n = 9; if ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( sscanf( &(argv[argn][1]), "%d", &n ) != 1 ) pm_usage( usage ); if ( n < 1 || n > 9 ) pm_usage( usage ); ++argn; } if ( argn != argc ) { ifp = pm_openr( argv[argn] ); ++argn; } else ifp = stdin; if ( argn != argc ) pm_usage( usage ); pgm_readpgminit( ifp, &cols, &rows, &maxval, &format ); prevrow = pgm_allocrow( cols ); thisrow = pgm_allocrow( cols ); nextrow = pgm_allocrow( cols ); pgm_writepgminit( stdout, cols, rows, maxval, 0 ); newrow = pgm_allocrow( cols ); /* The edge enhancing technique is taken from Philip R. Thompson's "xim" ** program, which in turn took it from section 6 of "Digital Halftones by ** Dot Diffusion", D. E. Knuth, ACM Transaction on Graphics Vol. 6, No. 4, ** October 1987, which in turn got it from two 1976 papers by J. F. Jarvis ** et. al. */ phi = n / 10.0; omphi = 1.0 - phi; /* First row. */ pgm_readpgmrow( ifp, thisrow, cols, maxval, format ); pgm_writepgmrow( stdout, thisrow, cols, maxval, 0 ); pgm_readpgmrow( ifp, nextrow, cols, maxval, format ); /* Other rows. */ for ( row = 1; row < rows - 1; row++ ) { temprow = prevrow; prevrow = thisrow; thisrow = nextrow; nextrow = temprow; pgm_readpgmrow( ifp, nextrow, cols, maxval, format ); newrow[0] = thisrow[0]; for (col = 1; col < cols - 1; col++) { /* Compute the sum of the neighborhood. */ long sum, newval; sum = (long) prevrow[col-1] + (long) prevrow[col] + (long) prevrow[col+1] + (long) thisrow[col-1] + (long) thisrow[col] + (long) thisrow[col+1] + (long) nextrow[col-1] + (long) nextrow[col] + (long) nextrow[col+1]; /* Now figure new value. */ newval = ( ( thisrow[col] - phi * sum / 9 ) / omphi + 0.5 ); if ( newval < 0 ) newrow[col] = 0; else if ( newval > maxval ) newrow[col] = maxval; else newrow[col] = newval; } newrow[cols - 1] = thisrow[cols - 1]; pgm_writepgmrow( stdout, newrow, cols, maxval, 0 ); } pm_close( ifp ); /* Last row. */ pgm_writepgmrow( stdout, nextrow, cols, maxval, 0 ); pm_close( stdout ); exit( 0 ); } netpbm-free-10.0-1/pgm/pgmhist.10100644004714500471450000000133607716230207016646 0ustar aba-guestaba-guest.TH pgmhist 1 "28 February 1989" .IX pgmhist .SH NAME pgmhist - print a histogram of the values in a portable graymap .SH SYNOPSIS .B pgmhist .RI [ pgmfile ] .SH DESCRIPTION Reads a portable graymap as input. Prints a histogram of the gray values. .SH "SEE ALSO" pgmnorm(1), pgm(5), ppmhist(1) .SH AUTHOR Copyright (C) 1989 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/pgmhist.c0100644004714500471450000000404507716230207016730 0ustar aba-guestaba-guest/* pgmhist.c - print a histogram of the values in a portable graymap ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pgm.h" int main( argc, argv ) int argc; char *argv[]; { FILE *ifp; gray maxval, *grayrow; register gray *gP; int argn, rows, cols, format, row; int i, *hist, *rcount, count, size; register int col; char *usage = "[pgmfile]"; pgm_init( &argc, argv ); argn = 1; if ( argn < argc ) { ifp = pm_openr( argv[argn] ); argn++; } else ifp = stdin; if ( argn != argc ) pm_usage( usage ); pgm_readpgminit( ifp, &cols, &rows, &maxval, &format ); grayrow = pgm_allocrow( cols ); /* Build histogram. */ overflow_add(maxval, 1); hist = (int *) malloc2( ( maxval + 1 ), sizeof(int) ); rcount = (int *) malloc2( ( maxval + 1 ), sizeof(int) ); if ( hist == (int *) 0 || rcount == (int *) 0 ) pm_error( "out of memory" ); for ( i = 0; i <= maxval; i++ ) hist[i] = 0; for ( row = 0; row < rows; row++ ) { pgm_readpgmrow( ifp, grayrow, cols, maxval, format ); for ( col = 0, gP = grayrow; col < cols; col++, gP++ ) hist[(int) *gP]++; } pm_close( ifp ); /* Compute count-down */ count = 0; for ( i = maxval; i >= 0; i-- ) { count += hist[i]; rcount[i] = count; } /* And print it. */ printf( "value\tcount\tb%%\tw%%\n" ); printf( "-----\t-----\t--\t--\n" ); count = 0; size = rows * cols; for ( i = 0; i <= maxval; i++ ) if ( hist[i] > 0 ) { count += hist[i]; printf( "%d\t%d\t%5.3g%%\t%5.3g%%\n", i, hist[i], (float) count * 100.0 / size, (float) rcount[i] * 100.0 / size ); } exit( 0 ); } netpbm-free-10.0-1/pgm/pgmkernel.10100644004714500471450000000212307716230207017152 0ustar aba-guestaba-guest.TH pgmkernel 1 "10 December 1992" .IX pgmkernel .SH NAME pgmkernel - generate a convolution kernel .SH SYNOPSIS .B pgmkernel [ .B \-weight .I w ] .I width [ .I height ] .SH DESCRIPTION Generates a portable graymap array of size .I width x .I height (or .I width x .I width if .I height is not specified) to be used as a convolution file by .BR pnmconvol . The data in the convolution array K are computed according to the formula: .PP K(i,j) = 1 / ( 1 + w * sqrt((i-width/2)^2 + (j-height/2)^2)) .PP where .I w is a coefficient specified via the .I \-weight flag, and .I width and .I height are the X and Y filter sizes. .PP The output PGM file is always written out in ASCII format. .SH OPTIONS The optional .I -weight flag should be a real number greater than -1. The default value is 6.0. .SH BUGS The computation time is proportional to .I width * .IR height . This increases rapidly with the increase of the kernel size. A better approach could be using a FFT in these cases. .SH "SEE ALSO" pnmconvol(1), pnmsmooth(1) .SH AUTHOR Alberto Accomazzi (alberto@cfa.harvard.edu). netpbm-free-10.0-1/pgm/pgmkernel.c0100644004714500471450000000507607716230207017246 0ustar aba-guestaba-guest/* pgmkernel.c - generate a portable graymap convolution kernel ** ** Creates a Portable Graymap file containing a convolution filter ** with max value = 255 and minimum value > 127 that can be used as a ** smoothing kernel for pnmconvol. ** ** Copyright (C) 1992 by Alberto Accomazzi, Smithsonian Astrophysical ** Observatory. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pgm.h" int main ( argc, argv ) int argc; char *argv[]; { register int i, j; int argn = 1, ixsize, iysize, maxval = 255; double fxsize = 0.0, fysize = 0.0, w = 6.0, kxcenter, kycenter, tmax = 0, *fkernel; char *usage = "[-weight f] width [height]"; pgm_init( &argc, argv ); while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( pm_keymatch( argv[argn], "-weight", 2 )) { if (++argn >= argc) pm_usage( usage ); else if (sscanf(argv[argn], "%lf", &w) != 1) pm_usage( usage ); } else pm_usage( usage ); argn++; } if (argn == argc) pm_usage( usage ); if (sscanf(argv[argn], "%lf", &fxsize) != 1) pm_error( "error reading input kernel x size, (%s)\n", argv[argn]); ++argn; if (argn == argc - 1) { if (sscanf(argv[argn], "%lf", &fysize) != 1) pm_error( "error reading input kernel y size, (%s)\n", argv[argn]); } else if (argn == argc) fysize = fxsize; else pm_usage( usage ); if (fxsize <= 1 || fysize <= 1) pm_usage( usage ); kxcenter = (fxsize - 1) / 2.0; kycenter = (fysize - 1) / 2.0; ixsize = fxsize + 0.999; iysize = fysize + 0.999; fkernel = (double *) malloc3 (ixsize, iysize, sizeof(double)); for (i = 0; i < iysize; i++) for (j = 0; j < ixsize; j++) { fkernel[i*ixsize+j] = 1.0 / (1.0 + w * sqrt((double) (i-kycenter)*(i-kycenter)+ (j-kxcenter)*(j-kxcenter))); if (tmax < fkernel[i*ixsize+j]) tmax = fkernel[i*ixsize+j]; } /* output PGM header + data (ASCII format only) */ printf("P2\n%d %d\n%d\n", ixsize, iysize, maxval); for (i = 0; i < iysize; i++, printf("\n")) for (j = 0; j < ixsize; j++) printf(" %3d", (int)(maxval * (fkernel[i*ixsize+j] / (2*tmax) + 0.5))); exit(0); } netpbm-free-10.0-1/pgm/pgmmerge.c0100644004714500471450000000242407716230207017057 0ustar aba-guestaba-guest/* pgmmerge.c - wrapper program for PGM ** ** Copyright (C) 1991 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ /* Note: be careful using any Netpbm library functions in here, since we don't call pgm_init() */ #include #include #include "pgm.h" int main(int argc, char *argv[]) { char* cp; if (strcmp(pm_arg0toprogname(argv[0]), "pgmmerge") == 0) { ++argv; --argc; if (!*argv) { fprintf(stderr, "Usage: pgmmerge pgm_program_name [args ...]\n"); exit(1); } } cp = pm_arg0toprogname(argv[0]); /* merge.h is an automatically generated file that generates code to match the string 'cp' against the name of every program that is part of this merge and, upon finding a match, invoke that program. */ #include "merge.h" fprintf(stderr,"'%s' is a PGM program name unknown to pgmmerge\n", cp ); exit(1); } netpbm-free-10.0-1/pgm/pgmnoise.10100644004714500471450000000150607716230207017013 0ustar aba-guestaba-guest.TH pgmnoise 1 "16 November 1993" .IX pgmnoise .SH NAME pgmnoise - create a graymap made up of white noise .SH SYNOPSIS .B pgmnoise .I width height .SH DESCRIPTION Creates a portable graymap that is made up of random pixels with gray values in the range of 0 to PGM_MAXMAXVAL (depends on the compilation, either 255 or 65535). The graymap has a size of width * height pixels. .SH "SEE ALSO" pgm(5) .SH AUTHOR Copyright (C) 1993 by Frank Neumann .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/pgmnoise.c0100644004714500471450000000403207716230207017072 0ustar aba-guestaba-guest /*********************************************************************/ /* pgmnoise - create a portable graymap with white noise */ /* Frank Neumann, October 1993 */ /* V1.1 16.11.1993 */ /* */ /* version history: */ /* V1.0 12.10.1993 first version */ /* V1.1 16.11.1993 Rewritten to be NetPBM.programming conforming */ /*********************************************************************/ #include "pgm.h" /* global variables */ #ifdef AMIGA static char *version = "$VER: pgmnoise 1.1 (16.11.93)"; /* Amiga version identification */ #endif /**************************/ /* start of main function */ /**************************/ int main(argc, argv) int argc; char *argv[]; { int argn, rows, cols, i, j; gray *destrow; char *usage = "width height\n width and height are picture dimensions in pixels\n"; time_t timenow; /* parse in 'default' parameters */ pgm_init(&argc, argv); argn = 1; /* parse in dim factor */ if (argn == argc) pm_usage(usage); if (sscanf(argv[argn], "%d", &cols) != 1) pm_usage(usage); argn++; if (argn == argc) pm_usage(usage); if (sscanf(argv[argn], "%d", &rows) != 1) pm_usage(usage); if (cols <= 0 || rows <= 0) pm_error("picture dimensions should be positive numbers"); ++argn; if (argn != argc) pm_usage(usage); /* no error checking required here, ppmlib does it all for us */ destrow = pgm_allocrow(cols); pgm_writepgminit(stdout, cols, rows, PGM_MAXMAXVAL, 0); /* get time of day to feed the random number generator */ timenow = time(NULL); srand(timenow); /* create the (gray) noise */ for (i = 0; i < rows; i++) { for (j = 0; j < cols; j++) destrow[j] = rand() % PGM_MAXMAXVAL; /* write out one line of graphic data */ pgm_writepgmrow(stdout, destrow, cols, PGM_MAXMAXVAL, 0); } pgm_freerow(destrow); exit(0); } netpbm-free-10.0-1/pgm/pgmramp.10100644004714500471450000000207207716230207016634 0ustar aba-guestaba-guest.TH pgmramp 1 "24 November 1989" .IX pgmramp .SH NAME pgmramp - generate a grayscale ramp .SH SYNOPSIS .B pgmramp .BR -lr | -tb | .BR -rectangle | -ellipse .I width height .SH DESCRIPTION Generates a graymap of the specified size containing a black-to-white ramp. .IX "generating graymaps" These ramps are useful for multiplying with other images, using the .I pnmarith tool. .IX pnmarith .SH OPTIONS .TP .B -lr A left to right ramp. .TP .B -tb A top to bottom ramp. .TP .B -rectangle A rectangular ramp. .TP .B -ellipse An elliptical ramp. .PP All flags can be abbreviated to their shortest unique prefix. .SH "SEE ALSO" pnmarith(1), pgm(5) .SH AUTHOR Copyright (C) 1989 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/pgmramp.c0100644004714500471450000000454107716230207016721 0ustar aba-guestaba-guest/* pgmramp.c - generate a grayscale ramp ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pgm.h" int main( argc, argv ) int argc; char *argv[]; { gray *grayrow; register gray *gP; int rows, cols, rowso2, colso2, row; register int col; int ramptype; #define RT_LR 1 #define RT_TB 2 #define RT_RECT 3 #define RT_ELLIP 4 char *usage = "-lr|-tb|-rectangle|-ellipse "; pgm_init( &argc, argv ); if ( argc != 4 ) pm_usage( usage ); if ( pm_keymatch( argv[1], "-lr", 2 ) ) ramptype = RT_LR; else if ( pm_keymatch( argv[1], "-tb", 2 ) ) ramptype = RT_TB; else if ( pm_keymatch( argv[1], "-rectangle", 2 ) ) ramptype = RT_RECT; else if ( pm_keymatch( argv[1], "-ellipse", 2 ) ) ramptype = RT_ELLIP; else pm_usage( usage ); if ( sscanf( argv[2], "%d", &cols ) != 1 ) pm_usage( usage ); if ( sscanf( argv[3], "%d", &rows ) != 1 ) pm_usage( usage ); colso2 = cols / 2; rowso2 = rows / 2; pgm_writepgminit( stdout, cols, rows, PGM_MAXMAXVAL, 0 ); grayrow = pgm_allocrow( cols ); for ( row = 0; row < rows; ++row ) { for ( col = 0, gP = grayrow; col < cols; ++col, ++gP ) { switch ( ramptype ) { case RT_LR: *gP = col * PGM_MAXMAXVAL / ((cols == 1) ? 1 : (cols - 1)); break; case RT_TB: *gP = row * PGM_MAXMAXVAL / ((rows == 1) ? 1 : (rows - 1)); break; case RT_RECT: { float r, c; r = abs( rowso2 - row ) / (float) rowso2; c = abs( colso2 - col ) / (float) colso2; *gP = PGM_MAXMAXVAL - ( r + c ) / 2.0 * PGM_MAXMAXVAL; } break; case RT_ELLIP: { float r, c, v; r = abs( rowso2 - row ) / (float) rowso2; c = abs( colso2 - col ) / (float) colso2; v = r * r + c * c; if ( v < 0.0 ) v = 0.0; else if ( v > 1.0 ) v = 1.0; *gP = PGM_MAXMAXVAL - v * PGM_MAXMAXVAL; } break; default: pm_error( "can't happen" ); } } pgm_writepgmrow( stdout, grayrow, cols, PGM_MAXMAXVAL, 0 ); } pm_close( stdout ); exit( 0 ); } netpbm-free-10.0-1/pgm/pgmslice.10100644004714500471450000000177607716230207017006 0ustar aba-guestaba-guest.\" This file Copyright 2000 Jos Dingjan .\" It may be distributed under the GNU Public License, version 2, or .\" any higher version. See section COPYING of the GNU Public license .\" for conditions under which this file may be redistributed. .TH pgmslice 1 "22 May 2000" .SH NAME pgmslice - extract one line of pixel values out of a portable graymap .SH SYNOPSIS .B pgmslice .BR -row | -col .I line .RI [ pgmfile ] .SH DESCRIPTION Extracts one line of pixel values out of a portable graymap and outputs it in a two column ascii format, with the first value being the pixel's position in the line and the second value the pixel's greyscale value. This is useful for making cross sections through, for example, greyscale CCD images. .SH OPTIONS .TP .B -row Extract a row of pixels .TP .B -col Extract a column of pixels .SH "SEE ALSO" pgm(5) .SH AUTHOR pgmslice was written by Jos Dingjan after being unable to find the source code to Marco Beijersbergen's program with the same name. netpbm-free-10.0-1/pgm/pgmslice.c0100644004714500471450000000460707716230207017064 0ustar aba-guestaba-guest/* pgmslice.c - Extract one slice of pixel-values out of a portable graymap * * Copyright (C) 2000 Jos Dingjan * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define ROW 0 /* Extract a row of pixels */ #define COLUMN 1 /* Extract a column of pixels */ #include "pgm.h" int main( int argc, char *argv[] ) { FILE *ifp; gray maxval; gray **grays; int rows, cols, line, col, colstart, collength, row, rowstart, rowlength; int line_type, count; char *usage = "-row|-col [pgmfile]"; pgm_init( &argc, argv ); if (argc < 3 || argc > 4 ) pm_usage( usage ); if ( pm_keymatch( argv[1], "-row", 4) ) line_type = ROW; else if ( pm_keymatch( argv[1], "-col", 4) ) line_type = COLUMN; else pm_usage( usage ); if (! sscanf( argv[2], "%d", &line ) ) pm_usage( usage ); if ( line < 0 ) pm_error( " is less than 0" ); if (argc == 4 ) ifp = pm_openr( argv[3] ); else ifp = stdin; grays = pgm_readpgm( ifp, &cols, &rows, &maxval); if ( (line_type == COLUMN ) && (line >= cols) ) pm_error( " is too large -- the graymap has only %d columns", cols ); if ( (line_type == ROW) && (line >= rows) ) pm_error( " is too large -- the graymap has only %d rows", rows ); if ( line_type == COLUMN ) { colstart = line; collength = 1; rowstart = 0; rowlength = rows; } else if ( line_type == ROW ) { colstart = 0; collength = cols; rowstart = line; rowlength = 1; } count = 0; for ( row = rowstart; row < rowstart + rowlength; row++ ) { for ( col = colstart; col < colstart + collength; col++ ) { fprintf( stdout, "%d %u\n", count++, grays[row][col] ); } } pm_close( ifp ); pm_close( stdout ); exit( 0 ); } netpbm-free-10.0-1/pgm/pgmtexture.10100644004714500471450000000454707716230207017406 0ustar aba-guestaba-guest.TH pgmtexture 1 "22 Aug 1991" .IX pgmtexture .SH NAME pgmtexture - calculate textural features on a portable graymap .SH SYNOPSIS .B pgmtexture .RB [ -d .IR d ] .RI [ pgmfile ] .SH DESCRIPTION Reads a portable graymap as input. Calculates textural features based on spatial dependence matrices at 0, 45, 90, and 135 degrees for a distance .IR d (default = 1). Textural features include: .IP (1) Angular Second Moment, .br (2) Contrast, .br (3) Correlation, .br (4) Variance, .br (5) Inverse Difference Moment, .br (6) Sum Average, .br (7) Sum Variance, .br (8) Sum Entropy, .br (9) Entropy, .br (10) Difference Variance, .br (11) Difference Entropy, .br (12, 13) Information Measures of Correlation, and .br (14) Maximal Correlation Coefficient. .PP Algorithm taken from: .br Haralick, R.M., K. Shanmugam, and I. Dinstein. 1973. Textural features for image classification. .I IEEE Transactions on Systems, Man, .I and Cybertinetics, SMC-3(6):610-621. .SH BUGS The program can run incredibly slow for large images (larger than 64 x 64) and command line options are limited. The method for finding (14) the maximal correlation coefficient, which requires finding the second largest eigenvalue of a matrix Q, does not always converge. .SH REFERENCES .I IEEE Transactions on Systems, Man, .I and Cybertinetics, SMC-3(6):610-621. .SH "SEE ALSO" pgm(5), pnmcut(1) .SH AUTHOR Copyright (C) 1991 by Texas Agricultural Experiment Station, employer for hire of James Darrell McCauley. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. .\" .\" THE TEXAS AGRICULTURAL EXPERIMENT STATION (TAES) AND THE TEXAS A&M .\" UNIVERSITY SYSTEM (TAMUS) MAKE NO EXPRESS OR IMPLIED WARRANTIES .\" (INCLUDING BY WAY OF EXAMPLE, MERCHANTABILITY) WITH RESPECT TO ANY .\" ITEM, AND SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL .\" OR CONSEQUENTAL DAMAGES ARISING OUT OF THE POSESSION OR USE OF .\" ANY SUCH ITEM. LICENSEE AND/OR USER AGREES TO INDEMNIFY AND HOLD .\" TAES AND TAMUS HARMLESS FROM ANY CLAIMS ARISING OUT OF THE USE OR .\" POSSESSION OF SUCH ITEMS. netpbm-free-10.0-1/pgm/pgmtexture.c0100644004714500471450000005577407776237374017522 0ustar aba-guestaba-guest/* pgmtexture.c - calculate textural features on a portable graymap ** ** Author: James Darrell McCauley ** Texas Agricultural Experiment Station ** Department of Agricultural Engineering ** Texas A&M University ** College Station, Texas 77843-2117 USA ** ** Code written partially taken from pgmtofs.c in the PBMPLUS package ** by Jef Poskanzer. ** ** Algorithms for calculating features (and some explanatory comments) are ** taken from: ** ** Haralick, R.M., K. Shanmugam, and I. Dinstein. 1973. Textural features ** for image classification. IEEE Transactions on Systems, Man, and ** Cybertinetics, SMC-3(6):610-621. ** ** Copyright (C) 1991 Texas Agricultural Experiment Station, employer for ** hire of James Darrell McCauley ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. ** ** THE TEXAS AGRICULTURAL EXPERIMENT STATION (TAES) AND THE TEXAS A&M ** UNIVERSITY SYSTEM (TAMUS) MAKE NO EXPRESS OR IMPLIED WARRANTIES ** (INCLUDING BY WAY OF EXAMPLE, MERCHANTABILITY) WITH RESPECT TO ANY ** ITEM, AND SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL ** OR CONSEQUENTAL DAMAGES ARISING OUT OF THE POSESSION OR USE OF ** ANY SUCH ITEM. LICENSEE AND/OR USER AGREES TO INDEMNIFY AND HOLD ** TAES AND TAMUS HARMLESS FROM ANY CLAIMS ARISING OUT OF THE USE OR ** POSSESSION OF SUCH ITEMS. ** ** Modification History: ** 24 Jun 91 - J. Michael Carstensen supplied fix for ** correlation function. */ #include #include "pgm.h" #define RADIX 2.0 #define EPSILON 0.000000001 #define BL "Angle " #define F1 "Angular Second Moment " #define F2 "Contrast " #define F3 "Correlation " #define F4 "Variance " #define F5 "Inverse Diff Moment " #define F6 "Sum Average " #define F7 "Sum Variance " #define F8 "Sum Entropy " #define F9 "Entropy " #define F10 "Difference Variance " #define F11 "Difference Entropy " #define F12 "Meas of Correlation-1 " #define F13 "Meas of Correlation-2 " #define F14 "Max Correlation Coeff " #define SIGN(x,y) ((y)<0 ? -fabs(x) : fabs(x)) #define DOT fprintf(stderr,".") #define SWAP(a,b) {y=(a);(a)=(b);(b)=y;} static float * vector (int nl, int nh) { float *v; overflow_add(nh, 1); if(nh < nl) pm_error("assert: h < l"); v = (float *) malloc2 ((nh - nl + 1), sizeof (float)); if (!v) fprintf (stderr, "memory allocation failure"), exit (1); return v - nl; } static float ** matrix (int nrl, int nrh, int ncl, int nch) /* Allocates a float matrix with range [nrl..nrh][ncl..nch] */ { int i; float **m; /* allocate pointers to rows */ overflow_add(nrh, 1); if(nrh < nrl) pm_error("assert: nrh < nrl"); m = (float **) malloc2(nrh - nrl + 1, sizeof (float *)); if (!m) fprintf (stderr, "memory allocation failure"), exit (1); m -= ncl; if(nch < ncl) pm_error("assert: nch < ncl"); overflow_add(nch, 1); /* allocate rows and set pointers to them */ for (i = nrl; i <= nrh; i++) { m[i] = (float *) malloc2(nch - ncl + 1, sizeof (float)); if (!m[i]) fprintf (stderr, "memory allocation failure"), exit (2); m[i] -= ncl; } /* return pointer to array of pointers to rows */ return m; } static void results (char *c, float *a) { int i; DOT; fprintf (stdout, "%s", c); for (i = 0; i < 4; ++i) fprintf (stdout, "% 1.3e ", a[i]); fprintf (stdout, "% 1.3e\n", (a[0] + a[1] + a[2] + a[3]) / 4); } static void simplesrt (int n, float arr[]) { int i, j; float a; for (j = 2; j <= n; j++) { a = arr[j]; i = j - 1; while (i > 0 && arr[i] > a) { arr[i + 1] = arr[i]; i--; } arr[i + 1] = a; } } static void mkbalanced (float **a, int n) { int last, j, i; float s, r, g, f, c, sqrdx; sqrdx = RADIX * RADIX; last = 0; while (last == 0) { last = 1; for (i = 1; i <= n; i++) { r = c = 0.0; for (j = 1; j <= n; j++) if (j != i) { c += fabs (a[j][i]); r += fabs (a[i][j]); } if (c && r) { g = r / RADIX; f = 1.0; s = c + r; while (c < g) { f *= RADIX; c *= sqrdx; } g = r * RADIX; while (c > g) { f /= RADIX; c /= sqrdx; } if ((c + r) / f < 0.95 * s) { last = 0; g = 1.0 / f; for (j = 1; j <= n; j++) a[i][j] *= g; for (j = 1; j <= n; j++) a[j][i] *= f; } } } } } static void reduction (float **a, int n) { int m, j, i; float y, x; for (m = 2; m < n; m++) { x = 0.0; i = m; for (j = m; j <= n; j++) { if (fabs (a[j][m - 1]) > fabs (x)) { x = a[j][m - 1]; i = j; } } if (i != m) { for (j = m - 1; j <= n; j++) SWAP (a[i][j], a[m][j]) for (j = 1; j <= n; j++) SWAP (a[j][i], a[j][m]) a[j][i] = a[j][i]; } if (x) { for (i = m + 1; i <= n; i++) { if ((y = a[i][m - 1])) { y /= x; a[i][m - 1] = y; for (j = m; j <= n; j++) a[i][j] -= y * a[m][j]; for (j = 1; j <= n; j++) a[j][m] += y * a[j][i]; } } } } } static void hessenberg (float **a, int n, float wr[], float wi[]) { int nn, m, l, k, j, its, i, mmin; float z, y, x, w, v, u, t, s, r, q, p, anorm; anorm = fabs (a[1][1]); for (i = 2; i <= n; i++) for (j = (i - 1); j <= n; j++) anorm += fabs (a[i][j]); nn = n; t = 0.0; while (nn >= 1) { its = 0; do { for (l = nn; l >= 2; l--) { s = fabs (a[l - 1][l - 1]) + fabs (a[l][l]); if (s == 0.0) s = anorm; if ((float) (fabs (a[l][l - 1]) + s) == s) break; } x = a[nn][nn]; if (l == nn) { wr[nn] = x + t; wi[nn--] = 0.0; } else { y = a[nn - 1][nn - 1]; w = a[nn][nn - 1] * a[nn - 1][nn]; if (l == (nn - 1)) { p = 0.5 * (y - x); q = p * p + w; z = sqrt (fabs (q)); x += t; if (q >= 0.0) { z = p + SIGN (z, p); wr[nn - 1] = wr[nn] = x + z; if (z) wr[nn] = x - w / z; wi[nn - 1] = wi[nn] = 0.0; } else { wr[nn - 1] = wr[nn] = x + p; wi[nn - 1] = -(wi[nn] = z); } nn -= 2; } else { if (its == 30) fprintf (stderr, "Too many iterations to required to find %s\ngiving up\n", F14), exit (1); if (its == 10 || its == 20) { t += x; for (i = 1; i <= nn; i++) a[i][i] -= x; s = fabs (a[nn][nn - 1]) + fabs (a[nn - 1][nn - 2]); y = x = 0.75 * s; w = -0.4375 * s * s; } ++its; for (m = (nn - 2); m >= l; m--) { z = a[m][m]; r = x - z; s = y - z; p = (r * s - w) / a[m + 1][m] + a[m][m + 1]; q = a[m + 1][m + 1] - z - r - s; r = a[m + 2][m + 1]; s = fabs (p) + fabs (q) + fabs (r); p /= s; q /= s; r /= s; if (m == l) break; u = fabs (a[m][m - 1]) * (fabs (q) + fabs (r)); v = fabs (p) * (fabs (a[m - 1][m - 1]) + fabs (z) + fabs (a[m + 1][m + 1])); if ((float) (u + v) == v) break; } for (i = m + 2; i <= nn; i++) { a[i][i - 2] = 0.0; if (i != (m + 2)) a[i][i - 3] = 0.0; } for (k = m; k <= nn - 1; k++) { if (k != m) { p = a[k][k - 1]; q = a[k + 1][k - 1]; r = 0.0; if (k != (nn - 1)) r = a[k + 2][k - 1]; if ((x = fabs (p) + fabs (q) + fabs (r))) { p /= x; q /= x; r /= x; } } if ((s = SIGN (sqrt (p * p + q * q + r * r), p))) { if (k == m) { if (l != m) a[k][k - 1] = -a[k][k - 1]; } else a[k][k - 1] = -s * x; p += s; x = p / s; y = q / s; z = r / s; q /= p; r /= p; for (j = k; j <= nn; j++) { p = a[k][j] + q * a[k + 1][j]; if (k != (nn - 1)) { p += r * a[k + 2][j]; a[k + 2][j] -= p * z; } a[k + 1][j] -= p * y; a[k][j] -= p * x; } mmin = nn < k + 3 ? nn : k + 3; for (i = l; i <= mmin; i++) { p = x * a[i][k] + y * a[i][k + 1]; if (k != (nn - 1)) { p += z * a[i][k + 2]; a[i][k + 2] -= p * r; } a[i][k + 1] -= p * q; a[i][k] -= p; } } } } } } while (l < nn - 1); } } static float f1_asm (float **P, int Ng) /* Angular Second Moment */ { int i, j; float sum = 0; for (i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) sum += P[i][j] * P[i][j]; return sum; /* * The angular second-moment feature (ASM) f1 is a measure of homogeneity * of the image. In a homogeneous image, there are very few dominant * gray-tone transitions. Hence the P matrix for such an image will have * fewer entries of large magnitude. */ } static float f2_contrast (float **P, int Ng) /* Contrast */ { int i, j, n; float sum = 0, bigsum = 0; for (n = 0; n < Ng; ++n) { for (i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) if ((i - j) == n || (j - i) == n) sum += P[i][j]; bigsum += n * n * sum; sum = 0; } return bigsum; /* * The contrast feature is a difference moment of the P matrix and is a * measure of the contrast or the amount of local variations present in an * image. */ } static float f3_corr (float **P, int Ng) /* Correlation */ { int i, j; float sum_sqrx = 0, sum_sqry = 0, tmp, *px; float meanx =0 , meany = 0 , stddevx, stddevy; px = vector (0, Ng); for (i = 0; i < Ng; ++i) px[i] = 0; /* * px[i] is the (i-1)th entry in the marginal probability matrix obtained * by summing the rows of p[i][j] */ for (i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) px[i] += P[i][j]; /* Now calculate the means and standard deviations of px and py */ /*- fix supplied by J. Michael Christensen, 21 Jun 1991 */ /*- further modified by James Darrell McCauley, 16 Aug 1991 * after realizing that meanx=meany and stddevx=stddevy */ for (i = 0; i < Ng; ++i) { meanx += px[i]*i; sum_sqrx += px[i]*i*i; } meany = meanx; sum_sqry = sum_sqrx; stddevx = sqrt (sum_sqrx - (meanx * meanx)); stddevy = stddevx; /* Finally, the correlation ... */ for (tmp = 0, i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) tmp += i*j*P[i][j]; return (tmp - meanx * meany) / (stddevx * stddevy); /* * This correlation feature is a measure of gray-tone linear-dependencies * in the image. */ } static float f4_var (float **P, int Ng) /* Sum of Squares: Variance */ { int i, j; float mean = 0, var = 0; /*- Corrected by James Darrell McCauley, 16 Aug 1991 * calculates the mean intensity level instead of the mean of * cooccurrence matrix elements */ for (i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) mean += i * P[i][j]; for (i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) var += (i + 1 - mean) * (i + 1 - mean) * P[i][j]; return var; } static float f5_idm (float **P, int Ng) /* Inverse Difference Moment */ { int i, j; float idm = 0; for (i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) idm += P[i][j] / (1 + (i - j) * (i - j)); return idm; } static float Pxpy[2 * PGM_MAXMAXVAL]; static float f6_savg (float **P, int Ng) /* Sum Average */ { int i, j; float savg = 0; for (i = 0; i <= 2 * Ng; ++i) Pxpy[i] = 0; for (i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) Pxpy[i + j + 2] += P[i][j]; for (i = 2; i <= 2 * Ng; ++i) savg += i * Pxpy[i]; return savg; } static float f7_svar (float **P, int Ng, float S) { /* Sum Variance */ int i, j; float var = 0; for (i = 0; i <= 2 * Ng; ++i) Pxpy[i] = 0; for (i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) Pxpy[i + j + 2] += P[i][j]; for (i = 2; i <= 2 * Ng; ++i) var += (i - S) * (i - S) * Pxpy[i]; return var; } static float f8_sentropy (float **P, int Ng) /* Sum Entropy */ { int i, j; float sentropy = 0; for (i = 0; i <= 2 * Ng; ++i) Pxpy[i] = 0; for (i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) Pxpy[i + j + 2] += P[i][j]; for (i = 2; i <= 2 * Ng; ++i) sentropy -= Pxpy[i] * log10 (Pxpy[i] + EPSILON); return sentropy; } static float f9_entropy (float **P, int Ng) /* Entropy */ { int i, j; float entropy = 0; for (i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) entropy += P[i][j] * log10 (P[i][j] + EPSILON); return -entropy; } static float f10_dvar (float **P, int Ng) /* Difference Variance */ { int i, j, tmp; float sum = 0, sum_sqr = 0, var = 0; for (i = 0; i <= 2 * Ng; ++i) Pxpy[i] = 0; for (i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) Pxpy[abs (i - j)] += P[i][j]; /* Now calculate the variance of Pxpy (Px-y) */ for (i = 0; i < Ng; ++i) { sum += Pxpy[i]; sum_sqr += Pxpy[i] * Pxpy[i]; } tmp = Ng * Ng; var = ((tmp * sum_sqr) - (sum * sum)) / (tmp * tmp); return var; } static float f11_dentropy (float **P, int Ng) /* Difference Entropy */ { int i, j; float sum = 0; for (i = 0; i <= 2 * Ng; ++i) Pxpy[i] = 0; for (i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) Pxpy[abs (i - j)] += P[i][j]; for (i = 0; i < Ng; ++i) sum += Pxpy[i] * log10 (Pxpy[i] + EPSILON); return -sum; } static float f12_icorr (float **P, int Ng) /* Information Measures of Correlation */ { int i, j; float *px, *py; float hx = 0, hy = 0, hxy = 0, hxy1 = 0, hxy2 = 0; px = vector (0, Ng); py = vector (0, Ng); /* * px[i] is the (i-1)th entry in the marginal probability matrix obtained * by summing the rows of p[i][j] */ for (i = 0; i < Ng; ++i) { for (j = 0; j < Ng; ++j) { px[i] += P[i][j]; py[j] += P[i][j]; } } for (i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) { hxy1 -= P[i][j] * log10 (px[i] * py[j] + EPSILON); hxy2 -= px[i] * py[j] * log10 (px[i] * py[j] + EPSILON); hxy -= P[i][j] * log10 (P[i][j] + EPSILON); } /* Calculate entropies of px and py - is this right? */ for (i = 0; i < Ng; ++i) { hx -= px[i] * log10 (px[i] + EPSILON); hy -= py[i] * log10 (py[i] + EPSILON); } /* fprintf(stderr,"hxy1=%f\thxy=%f\thx=%f\thy=%f\n",hxy1,hxy,hx,hy); */ return ((hxy - hxy1) / (hx > hy ? hx : hy)); } static float f13_icorr (float **P, int Ng) /* Information Measures of Correlation */ { int i, j; float *px, *py; float hx = 0, hy = 0, hxy = 0, hxy1 = 0, hxy2 = 0; px = vector (0, Ng); py = vector (0, Ng); /* * px[i] is the (i-1)th entry in the marginal probability matrix obtained * by summing the rows of p[i][j] */ for (i = 0; i < Ng; ++i) { for (j = 0; j < Ng; ++j) { px[i] += P[i][j]; py[j] += P[i][j]; } } for (i = 0; i < Ng; ++i) for (j = 0; j < Ng; ++j) { hxy1 -= P[i][j] * log10 (px[i] * py[j] + EPSILON); hxy2 -= px[i] * py[j] * log10 (px[i] * py[j] + EPSILON); hxy -= P[i][j] * log10 (P[i][j] + EPSILON); } /* Calculate entropies of px and py */ for (i = 0; i < Ng; ++i) { hx -= px[i] * log10 (px[i] + EPSILON); hy -= py[i] * log10 (py[i] + EPSILON); } /* fprintf(stderr,"hx=%f\thxy2=%f\n",hx,hxy2); */ return (sqrt (abs (1 - exp (-2.0 * (hxy2 - hxy))))); } static float f14_maxcorr (float **P, int Ng) /* Returns the Maximal Correlation Coefficient */ { int i, j, k; float *px, *py, **Q; float *x, *iy, tmp; px = vector (0, Ng); py = vector (0, Ng); Q = matrix (1, Ng + 1, 1, Ng + 1); x = vector (1, Ng); iy = vector (1, Ng); /* * px[i] is the (i-1)th entry in the marginal probability matrix obtained * by summing the rows of p[i][j] */ for (i = 0; i < Ng; ++i) { for (j = 0; j < Ng; ++j) { px[i] += P[i][j]; py[j] += P[i][j]; } } /* Find the Q matrix */ for (i = 0; i < Ng; ++i) { for (j = 0; j < Ng; ++j) { Q[i + 1][j + 1] = 0; for (k = 0; k < Ng; ++k) Q[i + 1][j + 1] += P[i][k] * P[j][k] / px[i] / py[k]; } } /* Balance the matrix */ mkbalanced (Q, Ng); /* Reduction to Hessenberg Form */ reduction (Q, Ng); /* Finding eigenvalue for nonsymetric matrix using QR algorithm */ hessenberg (Q, Ng, x, iy); /* simplesrt(Ng,x); */ /* Returns the sqrt of the second largest eigenvalue of Q */ for (i = 2, tmp = x[1]; i <= Ng; ++i) tmp = (tmp > x[i]) ? tmp : x[i]; return sqrt (x[Ng - 1]); } int main (int argc, char *argv[]) { FILE *ifp; register gray **grays; int tone[PGM_MAXMAXVAL], R0, R45, R90, angle, d = 1, x, y; int argn, rows, cols, row, col; int itone, jtone, tones; float **P_matrix0, **P_matrix45, **P_matrix90, **P_matrix135; float ASM[4], contrast[4], corr[4], var[4], idm[4], savg[4]; float sentropy[4], svar[4], entropy[4], dvar[4], dentropy[4]; float icorr[4], maxcorr[4]; gray maxval; char *usage = "[-d ] [pgmfile]"; pgm_init( &argc, argv ); argn = 1; /* Check for flags. */ if ( argn < argc && argv[argn][0] == '-' ) { if ( argv[argn][1] == 'd' ) { ++argn; if ( argn == argc || sscanf( argv[argn], "%d", &d ) != 1 ) pm_usage( usage ); } else pm_usage( usage ); ++argn; } if ( argn < argc ) { ifp = pm_openr( argv[argn] ); ++argn; } else ifp = stdin; if ( argn != argc ) pm_usage( usage ); grays = pgm_readpgm (ifp, &cols, &rows, &maxval); pm_close (ifp); if (maxval > PGM_MAXMAXVAL) pm_error("The maxval of the image (%d) is too high. \n" "This program's maximum is %d.", maxval, PGM_MAXMAXVAL); /* Determine the number of different gray scales (not maxval) */ for (row = PGM_MAXMAXVAL; row >= 0; --row) tone[row] = -1; for (row = rows - 1; row >= 0; --row) for (col = 0; col < cols; ++col) tone[grays[row][col]] = grays[row][col]; for (row = PGM_MAXMAXVAL, tones = 0; row >= 0; --row) if (tone[row] != -1) tones++; fprintf (stderr, "(Image has %d graylevels.)\n", tones); /* Collapse array, taking out all zero values */ for (row = 0, itone = 0; row <= PGM_MAXMAXVAL; row++) if (tone[row] != -1) tone[itone++] = tone[row]; /* Now array contains only the gray levels present (in ascending order) */ /* Allocate memory for gray-tone spatial dependence matrix */ P_matrix0 = matrix (0, tones, 0, tones); P_matrix45 = matrix (0, tones, 0, tones); P_matrix90 = matrix (0, tones, 0, tones); P_matrix135 = matrix (0, tones, 0, tones); for (row = 0; row < tones; ++row) for (col = 0; col < tones; ++col) { P_matrix0[row][col] = P_matrix45[row][col] = 0; P_matrix90[row][col] = P_matrix135[row][col] = 0; } /* Find gray-tone spatial dependence matrix */ fprintf (stderr, "(Computing spatial dependence matrix..."); for (row = 0; row < rows; ++row) for (col = 0; col < cols; ++col) for (x = 0, angle = 0; angle <= 135; angle += 45) { while (tone[x] != grays[row][col]) x++; if (angle == 0 && col + d < cols) { y = 0; while (tone[y] != grays[row][col + d]) y++; P_matrix0[x][y]++; P_matrix0[y][x]++; } if (angle == 90 && row + d < rows) { y = 0; while (tone[y] != grays[row + d][col]) y++; P_matrix90[x][y]++; P_matrix90[y][x]++; } if (angle == 45 && row + d < rows && col - d >= 0) { y = 0; while (tone[y] != grays[row + d][col - d]) y++; P_matrix45[x][y]++; P_matrix45[y][x]++; } if (angle == 135 && row + d < rows && col + d < cols) { y = 0; while (tone[y] != grays[row + d][col + d]) y++; P_matrix135[x][y]++; P_matrix135[y][x]++; } } /* Gray-tone spatial dependence matrices are complete */ /* Find normalizing constants */ R0 = 2 * rows * (cols - 1); R45 = 2 * (rows - 1) * (cols - 1); R90 = 2 * (rows - 1) * cols; /* Normalize gray-tone spatial dependence matrix */ for (itone = 0; itone < tones; ++itone) for (jtone = 0; jtone < tones; ++jtone) { P_matrix0[itone][jtone] /= R0; P_matrix45[itone][jtone] /= R45; P_matrix90[itone][jtone] /= R90; P_matrix135[itone][jtone] /= R45; } fprintf (stderr, " done.)\n"); fprintf (stderr, "(Computing textural features"); fprintf (stdout, "\n"); DOT; fprintf (stdout, "%s 0 45 90 135 Avg\n", BL); ASM[0] = f1_asm (P_matrix0, tones); ASM[1] = f1_asm (P_matrix45, tones); ASM[2] = f1_asm (P_matrix90, tones); ASM[3] = f1_asm (P_matrix135, tones); results (F1, ASM); contrast[0] = f2_contrast (P_matrix0, tones); contrast[1] = f2_contrast (P_matrix45, tones); contrast[2] = f2_contrast (P_matrix90, tones); contrast[3] = f2_contrast (P_matrix135, tones); results (F2, contrast); corr[0] = f3_corr (P_matrix0, tones); corr[1] = f3_corr (P_matrix45, tones); corr[2] = f3_corr (P_matrix90, tones); corr[3] = f3_corr (P_matrix135, tones); results (F3, corr); var[0] = f4_var (P_matrix0, tones); var[1] = f4_var (P_matrix45, tones); var[2] = f4_var (P_matrix90, tones); var[3] = f4_var (P_matrix135, tones); results (F4, var); idm[0] = f5_idm (P_matrix0, tones); idm[1] = f5_idm (P_matrix45, tones); idm[2] = f5_idm (P_matrix90, tones); idm[3] = f5_idm (P_matrix135, tones); results (F5, idm); savg[0] = f6_savg (P_matrix0, tones); savg[1] = f6_savg (P_matrix45, tones); savg[2] = f6_savg (P_matrix90, tones); savg[3] = f6_savg (P_matrix135, tones); results (F6, savg); sentropy[0] = f8_sentropy (P_matrix0, tones); sentropy[1] = f8_sentropy (P_matrix45, tones); sentropy[2] = f8_sentropy (P_matrix90, tones); sentropy[3] = f8_sentropy (P_matrix135, tones); svar[0] = f7_svar (P_matrix0, tones, sentropy[0]); svar[1] = f7_svar (P_matrix45, tones, sentropy[1]); svar[2] = f7_svar (P_matrix90, tones, sentropy[2]); svar[3] = f7_svar (P_matrix135, tones, sentropy[3]); results (F7, svar); results (F8, sentropy); entropy[0] = f9_entropy (P_matrix0, tones); entropy[1] = f9_entropy (P_matrix45, tones); entropy[2] = f9_entropy (P_matrix90, tones); entropy[3] = f9_entropy (P_matrix135, tones); results (F9, entropy); dvar[0] = f10_dvar (P_matrix0, tones); dvar[1] = f10_dvar (P_matrix45, tones); dvar[2] = f10_dvar (P_matrix90, tones); dvar[3] = f10_dvar (P_matrix135, tones); results (F10, dvar); dentropy[0] = f11_dentropy (P_matrix0, tones); dentropy[1] = f11_dentropy (P_matrix45, tones); dentropy[2] = f11_dentropy (P_matrix90, tones); dentropy[3] = f11_dentropy (P_matrix135, tones); results (F11, dentropy); icorr[0] = f12_icorr (P_matrix0, tones); icorr[1] = f12_icorr (P_matrix45, tones); icorr[2] = f12_icorr (P_matrix90, tones); icorr[3] = f12_icorr (P_matrix135, tones); results (F12, icorr); icorr[0] = f13_icorr (P_matrix0, tones); icorr[1] = f13_icorr (P_matrix45, tones); icorr[2] = f13_icorr (P_matrix90, tones); icorr[3] = f13_icorr (P_matrix135, tones); results (F13, icorr); maxcorr[0] = f14_maxcorr (P_matrix0, tones); maxcorr[1] = f14_maxcorr (P_matrix45, tones); maxcorr[2] = f14_maxcorr (P_matrix90, tones); maxcorr[3] = f14_maxcorr (P_matrix135, tones); results (F14, maxcorr); fprintf (stderr, " done.)\n"); exit (0); } netpbm-free-10.0-1/pgm/pgmtofs.10100644004714500471450000000147207716230207016653 0ustar aba-guestaba-guest.TH pgmtofs 1 "18 May 1990" .IX pgmtofs .SH NAME pgmtofs - convert portable graymap to Usenix FaceSaver(tm) format .SH SYNOPSIS .B pgmtofs .RI [ pgmfile ] .SH DESCRIPTION Reads a portable graymap as input. Produces Usenix FaceSaver(tm) format as output. .IX FaceSaver .PP FaceSaver is a registered trademark of Metron Computerware Ltd. of Oakland, CA. .SH "SEE ALSO" fstopgm(1), pgm(5) .SH AUTHOR Copyright (C) 1991 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/pgmtofs.c0100644004714500471450000000636507716230207016743 0ustar aba-guestaba-guest/* pgmtofs.c - convert portable graymap to Usenix FaceSaver(tm) format ** ** Copyright (C) 1991 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pgm.h" static void putinit ARGS(( int cols, int rows, int bps )); static void putitem ARGS(( void )); static void putgray ARGS(( gray g )); static void putrest ARGS(( void )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; gray** grays; register gray* gP; int argn, rows, cols, bps, padright, row, col; gray maxval, nmaxval; char* usage = "[pgmfile]"; pgm_init( &argc, argv ); argn = 1; if ( argn < argc ) { ifp = pm_openr( argv[argn] ); ++argn; } else { ifp = stdin; } if ( argn != argc ) pm_usage( usage ); grays = pgm_readpgm( ifp, &cols, &rows, &maxval ); pm_close( ifp ); /* Figure out bps. */ bps = pm_maxvaltobits( (int) maxval ); if ( bps > 2 && bps < 4 ) bps = 4; else if ( bps > 4 && bps < 8 ) bps = 8; else if ( bps > 8 ) pm_error( "maxval of %d is too large for FaceSaver(tm)", maxval ); nmaxval = pm_bitstomaxval( bps ); /* Compute padding to round cols * bps up to the nearest multiple of 8. */ padright = ( ( cols * bps + 7 ) / 8 ) * 8 - cols * bps; putinit( cols, rows, bps ); for ( row = rows - 1; row >= 0; --row ) { for ( col = 0, gP = grays[row]; col < cols; ++col, ++gP ) { if ( maxval != nmaxval ) *gP = (int) *gP * nmaxval / maxval; putgray( *gP ); } for ( col = 0; col < padright; ++col ) putgray( 0 ); } putrest( ); exit( 0 ); } static int bitspersample, item, bitsperitem, bitshift, itemsperline, items; static void putinit( cols, rows, bps ) int cols, rows, bps; { printf( "FirstName: \n" ); printf( "LastName: \n" ); printf( "E-mail: \n" ); printf( "Telephone: \n" ); printf( "Company: \n" ); printf( "Address1: \n" ); printf( "Address2: \n" ); printf( "CityStateZip: \n" ); printf( "Date: \n" ); printf( "PicData: %d %d %d\n", cols, rows, bps ); printf( "Image: %d %d %d\n", cols, rows, bps ); printf( "\n" ); bitspersample = bps; itemsperline = items = 0; item = 0; bitsperitem = 0; bitshift = 8 - bitspersample; } static void putitem( ) { char* hexits = "0123456789abcdef"; if ( itemsperline == 30 ) { putchar( '\n' ); itemsperline = 0; } putchar( hexits[item >> 4] ); putchar( hexits[item & 15] ); ++itemsperline; ++items; item = 0; bitsperitem = 0; bitshift = 8 - bitspersample; } #if __STDC__ static void putgray( gray g ) #else /*__STDC__*/ static void putgray( g ) gray g; #endif /*__STDC__*/ { if ( bitsperitem == 8 ) putitem( ); item += g << bitshift; bitsperitem += bitspersample; bitshift -= bitspersample; } static void putrest( ) { if ( bitsperitem > 0 ) putitem( ); printf( "\n" ); } netpbm-free-10.0-1/pgm/pgmtolispm.10100644004714500471450000000272507716230207017371 0ustar aba-guestaba-guest.TH pgmtolispm 1 "06 March 1990" .IX pgmtolispm .SH NAME pgmtolispm - convert a portable graymap into Lisp Machine format .SH SYNOPSIS .B pgmtolispm .RI [ pgmfile ] .SH DESCRIPTION Reads a portable graymap as input. Produces a Lisp Machine bitmap as output. .IX "Lisp Machine bitmap" .PP This is the file format read by the tv:read-bit-array-file function on TI Explorer and Symbolics lisp machines. .PP Given a pgm (instead of a pbm) a multi-plane image will be output. This is probably not useful unless you have a color lisp machine. .PP Multi-plane bitmaps on lisp machines are color; but the lispm image file format does not include a color map, so we must treat it as a graymap instead. This is unfortunate. .SH "SEE ALSO" lispmtopgm(1), pgm(5) .SH BUGS Output width is always rounded up to the nearest multiple of 32; this might not always be what you want, but it probably is (arrays which are not modulo 32 cannot be passed to the Lispm BITBLT function, and thus cannot easily be displayed on the screen). .PP No color. .SH AUTHOR Copyright (C) 1991 by Jamie Zawinski and Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/pgmtolispm.c0100644004714500471450000000774507716230207017462 0ustar aba-guestaba-guest/* pgmtolispm.c - read a pgm and write a file acceptable to the ** tv:read-bit-array-file function of TI Explorer and Symbolics Lisp Machines. ** ** Written by Jamie Zawinski based on code (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. ** ** When one writes a multi-plane bitmap with tv:write-bit-array-file, it is ** usually a color image; but a color map is not written in the file, so we ** treat this as a graymap instead. To convert a color image to Lispm ** format, you must convert it to a pgm, and hand-edit a color map... Ick. */ #include #include "pgm.h" #define LISPM_MAGIC "This is a BitMap file" static void putinit ARGS(( int cols, int rows, int depth )); static int depth_to_word_size ARGS(( int depth )); static void putval ARGS(( gray b )); static void putrest ARGS(( void )); static void putitem ARGS(( void )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; gray *grayrow; register gray* gP; int rows, cols, depth, format, padright, row, col; gray maxval; pgm_init( &argc, argv ); if ( argc > 2 ) pm_usage( "[pgmfile]" ); if ( argc == 2 ) ifp = pm_openr( argv[1] ); else ifp = stdin; pgm_readpgminit( ifp, &cols, &rows, &maxval, &format ); grayrow = pgm_allocrow( cols ); depth = pm_maxvaltobits( maxval ); /* Compute padding to round cols up to the nearest multiple of 32. */ padright = ( ( cols + 31 ) / 32 ) * 32 - cols; putinit( cols, rows, depth ); for ( row = 0; row < rows; ++row ) { pgm_readpgmrow( ifp, grayrow, cols, maxval, format ); for ( col = 0, gP = grayrow; col < cols; ++col, ++gP ) putval( *gP ); for ( col = 0; col < padright; ++col ) putval( 0 ); } pm_close( ifp ); putrest( ); exit( 0 ); } static unsigned int item; static unsigned int bitsperitem, maxbitsperitem, bitshift; static void putinit( cols, rows, depth ) int cols, rows, depth; { int i; int cols32 = ( ( cols + 31 ) / 32 ) * 32; /* Lispms are able to write bit files that are not mod32 wide, but we */ /* don't. This should be ok, since bit arrays which are not mod32 wide */ printf(LISPM_MAGIC); /* are pretty useless on a lispm (can't hand them to bitblt). */ pm_writelittleshort( stdout, cols ); pm_writelittleshort( stdout, rows ); pm_writelittleshort( stdout, cols32 ); putchar(depth & 0xFF); for ( i = 0; i < 9; ++i ) putchar( 0 ); /* pad bytes */ item = 0; bitsperitem = 0; maxbitsperitem = depth_to_word_size( depth ); bitshift = 0; } static int depth_to_word_size (depth) /* Lispm architecture specific - if a bitmap is written */ int depth; /* out with a depth of 5, it really has a depth of 8, and */ { /* is stored that way in the file. */ if (depth==0 || depth==1) return ( 1); else if (depth == 2) return ( 2); else if (depth <= 4) return ( 4); else if (depth <= 8) return ( 8); else if (depth <= 16) return (16); else if (depth <= 32) return (32); else { pm_error( "depth was %d, which is not in the range 1-32", depth ); return(-1); /* Should never reach here */ } } #if __STDC__ static void putval( gray b ) #else /*__STDC__*/ static void putval( b ) gray b; #endif /*__STDC__*/ { if ( bitsperitem == 32 ) putitem( ); item = item | ( b << bitshift ); bitsperitem = bitsperitem + maxbitsperitem; bitshift = bitshift + maxbitsperitem; } static void putrest( ) { if ( bitsperitem > 0 ) putitem( ); } static void putitem( ) { pm_writelittlelong( stdout, ~item ); item = 0; bitsperitem = 0; bitshift = 0; } netpbm-free-10.0-1/pgm/pgmtopbm.10100644004714500471450000000736407716230207017027 0ustar aba-guestaba-guest.TH pgmtopbm 1 "26 July 1988" .IX pgmtopbm .SH NAME pgmtopbm - convert a portable graymap into a portable bitmap .SH SYNOPSIS .B pgmtopbm .RB [ -floyd | -fs | -threshold .RB | -hilbert .RB | -dither8 | -d8 | -cluster3 .RB | -c3 | -cluster4 | -c4 .RB | -cluster8 | -c8 ] .RB [ -value .IR val ] .RB [ -clump .IR size ] .RI [ pgmfile ] .SH DESCRIPTION Reads a portable graymap as input. Produces a portable bitmap as output. .IX halftoning .PP Note that there is no pbmtopgm converter. Any program that uses the Netpbm libraries to read PGM files, including virtually all programs in the Netpbm package, will read a PBM file automatically as if it were a PGM file. If you are using a less intelligent program that expects PGM input, use .B pnmdepth to convert the PBM file to PGM. As long as the depth is greater than 1, .B pnmdepth will generate PGM. This less intelligent program quite probably is also not intelligent enough to deal with general maxvals, so you should specify a depth of 255. .SH OPTIONS .PP The default quantization method is boustrophedonic Floyd-Steinberg error diffusion .RB ( -floyd or .BR -fs ). .IX Floyd-Steinberg .IX "error diffusion" Also available are simple thresholding .RB ( -threshold ); .IX thresholding Bayer's ordered dither .RB ( -dither8 ) with a 16x16 matrix; and three different sizes of 45-degree clustered-dot dither .RB ( -cluster3 , .BR -cluster4 , .BR -cluster8 ). A space filling curve halftoning method using the Hilbert curve is also available. .RB ( -hilbert ); .IX dithering .PP Floyd-Steinberg will almost always give the best looking results; however, looking good is not always what you want. For instance, thresholding can be used in a pipeline with the .I pnmconvol .IX pnmconvol tool, for tasks like edge and peak detection. And clustered-dot dithering gives a newspaper-ish look, a useful special effect. .PP The .B -value flag alters the thresholding value for Floyd-Steinberg and simple thresholding. It should be a real number between 0 and 1. Above 0.5 means darker images; below 0.5 means lighter. .PP The Hilbert curve method is useful for processing images before display on devices that do not render individual pixels distinctly (like laser printers). This dithering method can give better results than the dithering usually done by the laser printers themselves. The .B -clump flag alters the number of pixels in a clump. This is usually an integer between 2 and 100 (default 5). Smaller clump sizes smear the image less and are less grainy, but seem to loose some grey scale linearity. Typically a PGM image will have to be scaled to fit on a laser printer page (2400 x 3000 pixels for an A4 300 dpi page), and then dithered to a PBM image before being converted to a postscript file. A printing pipeline might look something like: pnmscale -xysize 2400 3000 image.pgm | pgmtopbm -hil | pnmtops -scale 0.25 > image.ps .PP All flags can be abbreviated to their shortest unique prefix. .SH REFERENCES The only reference you need for this stuff is "Digital Halftoning" by Robert Ulichney, MIT Press, ISBN 0-262-21009-6. .PP The Hilbert curve space filling method is taken from "Digital Halftoning with Space Filling Curves" by Luiz Velho, Computer Graphics Volume 25, Number 4, proceedings of SIGRAPH '91, page 81. ISBN 0-89791-436-8 .SH "SEE ALSO" pbmreduce(1), pgm(5), pbm(5), pnmconvol(1), pnmscale(1), pnmtops(1) .SH AUTHOR Copyright (C) 1989 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/pgmtopbm.c0100644004714500471450000002642507716230207017110 0ustar aba-guestaba-guest/* pgmtopbm.c - read a portable graymap and write a portable bitmap ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pgm.h" #include "dithers.h" static void init_hilbert ARGS((int w, int h)); static int hilbert ARGS((int *px, int *py)); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; gray* grayrow; register gray* gP; bit* bitrow; register bit* bP; int argn, rows, cols, format, row, col, limitcol; float fthreshval; int clump_size; gray maxval; char* usage = "[-floyd|-fs | -hilbert | -threshold | -dither8|-d8 |\n -cluster3|-c3|-cluster4|-c4|-cluster8|-c8] [-value ] [-clump ] [pgmfile]"; int halftone; #define QT_FS 1 #define QT_THRESH 2 #define QT_DITHER8 3 #define QT_CLUSTER3 4 #define QT_CLUSTER4 5 #define QT_CLUSTER8 6 #define QT_HILBERT 7 long threshval, sum; long* thiserr; long* nexterr; long* temperr; #define FS_SCALE 1024 #define HALF_FS_SCALE 512 int fs_direction; pgm_init( &argc, argv ); argn = 1; halftone = QT_FS; /* default quantization is Floyd-Steinberg */ fthreshval = 0.5; clump_size = 5; /* default hilbert curve clump size */ while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( pm_keymatch( argv[argn], "-fs", 2 ) || pm_keymatch( argv[argn], "-floyd", 2 ) ) halftone = QT_FS; else if ( pm_keymatch( argv[argn], "-hilbert", 2 )) halftone = QT_HILBERT; else if ( pm_keymatch( argv[argn], "-threshold", 2 ) ) halftone = QT_THRESH; else if ( pm_keymatch( argv[argn], "-dither8", 2 ) || pm_keymatch( argv[argn], "-d8", 3 ) ) halftone = QT_DITHER8; else if ( pm_keymatch( argv[argn], "-cluster3", 9 ) || pm_keymatch( argv[argn], "-c3", 3 ) ) halftone = QT_CLUSTER3; else if ( pm_keymatch( argv[argn], "-cluster4", 9 ) || pm_keymatch( argv[argn], "-c4", 3 ) ) halftone = QT_CLUSTER4; else if ( pm_keymatch( argv[argn], "-cluster8", 9 ) || pm_keymatch( argv[argn], "-c8", 3 ) ) halftone = QT_CLUSTER8; else if ( pm_keymatch( argv[argn], "-value", 2 ) ) { /* Before 2001-06-08, this strtod() was a sscanf("%f"). Arjen Bax found on his CYGWIN system this causes a comma to be used as a decimal separator. But on 2001-09.03, Charles Wilson found this not to be the case. */ char *ep; ++argn; if ( argn == argc || (fthreshval = strtod(argv[argn], &ep), *ep != 0) || fthreshval < 0.0 || fthreshval > 1.0 ) { pm_usage( usage ); } } else if ( pm_keymatch( argv[argn], "-clump", 2 ) ) { ++argn; if ( argn == argc || sscanf( argv[argn], "%d", &clump_size ) != 1 || clump_size < 2) pm_usage( usage ); } else pm_usage( usage ); ++argn; } if ( argn != argc ) { ifp = pm_openr( argv[argn] ); ++argn; } else ifp = stdin; if ( argn != argc ) pm_usage( usage ); if ( halftone != QT_HILBERT ) { pgm_readpgminit( ifp, &cols, &rows, &maxval, &format ); grayrow = pgm_allocrow( cols ); pbm_writepbminit( stdout, cols, rows, 0 ); bitrow = pbm_allocrow( cols ); /* Initialize. */ switch ( halftone ) { case QT_FS: /* Initialize Floyd-Steinberg error vectors. */ overflow_add(cols, 2); thiserr = (long*) pm_allocrow( cols + 2, sizeof(long) ); nexterr = (long*) pm_allocrow( cols + 2, sizeof(long) ); srand( (int) ( time( 0 ) ^ getpid( ) ) ); for ( col = 0; col < cols + 2; ++col ) thiserr[col] = ( rand( ) % FS_SCALE - HALF_FS_SCALE ) / 4; /* (random errors in [-FS_SCALE/8 .. FS_SCALE/8]) */ fs_direction = 1; threshval = fthreshval * FS_SCALE; break; case QT_HILBERT: break; case QT_THRESH: threshval = fthreshval * maxval + 0.999999; break; case QT_DITHER8: /* Scale dither matrix. */ for ( row = 0; row < 16; ++row ) for ( col = 0; col < 16; ++col ) dither8[row][col] = dither8[row][col] * ( maxval + 1 ) / 256; break; case QT_CLUSTER3: /* Scale order-3 clustered dither matrix. */ for ( row = 0; row < 6; ++row ) for ( col = 0; col < 6; ++col ) cluster3[row][col] = cluster3[row][col] * ( maxval + 1 ) / 18; break; case QT_CLUSTER4: /* Scale order-4 clustered dither matrix. */ for ( row = 0; row < 8; ++row ) for ( col = 0; col < 8; ++col ) cluster4[row][col] = cluster4[row][col] * ( maxval + 1 ) / 32; break; case QT_CLUSTER8: /* Scale order-8 clustered dither matrix. */ for ( row = 0; row < 16; ++row ) for ( col = 0; col < 16; ++col ) cluster8[row][col] = cluster8[row][col] * ( maxval + 1 ) / 128; break; default: pm_error( "can't happen" ); exit( 1 ); } for ( row = 0; row < rows; ++row ) { pgm_readpgmrow( ifp, grayrow, cols, maxval, format ); switch ( halftone ) { case QT_FS: for ( col = 0; col < cols + 2; ++col ) nexterr[col] = 0; if ( fs_direction ) { col = 0; limitcol = cols; gP = grayrow; bP = bitrow; } else { col = cols - 1; limitcol = -1; gP = &(grayrow[col]); bP = &(bitrow[col]); } do { sum = ( (long) *gP * FS_SCALE ) / maxval + thiserr[col + 1]; if ( sum >= threshval ) { *bP = PBM_WHITE; sum = sum - threshval - HALF_FS_SCALE; } else *bP = PBM_BLACK; if ( fs_direction ) { thiserr[col + 2] += ( sum * 7 ) / 16; nexterr[col ] += ( sum * 3 ) / 16; nexterr[col + 1] += ( sum * 5 ) / 16; nexterr[col + 2] += ( sum ) / 16; ++col; ++gP; ++bP; } else { thiserr[col ] += ( sum * 7 ) / 16; nexterr[col + 2] += ( sum * 3 ) / 16; nexterr[col + 1] += ( sum * 5 ) / 16; nexterr[col ] += ( sum ) / 16; --col; --gP; --bP; } } while ( col != limitcol ); temperr = thiserr; thiserr = nexterr; nexterr = temperr; fs_direction = ! fs_direction; break; case QT_THRESH: for ( col = 0, gP = grayrow, bP = bitrow; col < cols; ++col, ++gP, ++bP ) if ( *gP >= threshval ) *bP = PBM_WHITE; else *bP = PBM_BLACK; break; case QT_DITHER8: for ( col = 0, gP = grayrow, bP = bitrow; col < cols; ++col, ++gP, ++bP ) if ( *gP >= dither8[row % 16][col % 16] ) *bP = PBM_WHITE; else *bP = PBM_BLACK; break; case QT_CLUSTER3: for ( col = 0, gP = grayrow, bP = bitrow; col < cols; ++col, ++gP, ++bP ) if ( *gP >= cluster3[row % 6][col % 6] ) *bP = PBM_WHITE; else *bP = PBM_BLACK; break; case QT_CLUSTER4: for ( col = 0, gP = grayrow, bP = bitrow; col < cols; ++col, ++gP, ++bP ) if ( *gP >= cluster4[row % 8][col % 8] ) *bP = PBM_WHITE; else *bP = PBM_BLACK; break; case QT_CLUSTER8: for ( col = 0, gP = grayrow, bP = bitrow; col < cols; ++col, ++gP, ++bP ) if ( *gP >= cluster8[row % 16][col % 16] ) *bP = PBM_WHITE; else *bP = PBM_BLACK; break; default: pm_error( "can't happen" ); exit( 1 ); } pbm_writepbmrow( stdout, bitrow, cols, 0 ); } } else /* else use hilbert space filling curve dithering */ /* * This is taken from the article "Digital Halftoning with * Space Filling Curves" by Luiz Velho, proceedings of * SIGRAPH '91, page 81. * * This is not a terribly efficient or quick version of * this algorithm, but it seems to work. - Graeme Gill. * graeme@labtam.labtam.OZ.AU * */ { gray **grays; bit **bits; int end; int *x,*y; int sum = 0; grays = pgm_readpgm( ifp, &cols,&rows, &maxval ); bits = pbm_allocarray(cols,rows); x = (int *) malloc( sizeof(int) * clump_size); y = (int *) malloc( sizeof(int) * clump_size); if (!x || !y) pm_error( "Run out of memory" ); init_hilbert(cols,rows); end = clump_size; while (end == clump_size) { int i; /* compute the next clust co-ordinates along hilbert path */ for (i = 0; i < end; i++) { if (hilbert(&x[i],&y[i])==0) end = i; /* we reached the end */ } /* sum levels */ for (i = 0; i < end; i++) sum += grays[y[i]][x[i]]; /* dither half and half along path */ for (i = 0; i < end; i++) { if (sum >= maxval) { bits[y[i]][x[i]] = PBM_WHITE; sum -= maxval; } else bits[y[i]][x[i]] = PBM_BLACK; } } pbm_writepbm( stdout, bits, cols, rows, 0 ); } pm_close( ifp ); exit( 0 ); } /* Hilbert curve tracer */ #define MAXORD 18 static int hil_order,hil_ord; static int hil_turn; static int hil_dx,hil_dy; static int hil_x,hil_y; static int hil_stage[MAXORD]; static int hil_width,hil_height; /* Initialise the Hilbert curve tracer */ static void init_hilbert(w,h) int w,h; { int big,ber; hil_width = w; hil_height = h; big = w > h ? w : h; for(ber = 2, hil_order = 1; ber < big; ber <<= 1, hil_order++); if (hil_order > MAXORD) pm_error( "Sorry, hilbert order is too large" ); hil_ord = hil_order; hil_order--; } /* Return non-zero if got another point */ static int hilbert(px,py) int *px,*py; { int temp; if (hil_ord > hil_order) /* have to do first point */ { hil_ord--; hil_stage[hil_ord] = 0; hil_turn = -1; hil_dy = 1; hil_dx = hil_x = hil_y = 0; *px = *py = 0; return 1; } for(;;) /* Operate the state machine */ { switch (hil_stage[hil_ord]) { case 0: hil_turn = -hil_turn; temp = hil_dy; hil_dy = -hil_turn * hil_dx; hil_dx = hil_turn * temp; if (hil_ord > 0) { hil_stage[hil_ord] = 1; hil_ord--; hil_stage[hil_ord]=0; continue; } case 1: hil_x += hil_dx; hil_y += hil_dy; if (hil_x < hil_width && hil_y < hil_height) { hil_stage[hil_ord] = 2; *px = hil_x; *py = hil_y; return 1; } case 2: hil_turn = -hil_turn; temp = hil_dy; hil_dy = -hil_turn * hil_dx; hil_dx = hil_turn * temp; if (hil_ord > 0) /* recurse */ { hil_stage[hil_ord] = 3; hil_ord--; hil_stage[hil_ord]=0; continue; } case 3: hil_x += hil_dx; hil_y += hil_dy; if (hil_x < hil_width && hil_y < hil_height) { hil_stage[hil_ord] = 4; *px = hil_x; *py = hil_y; return 1; } case 4: if (hil_ord > 0) /* recurse */ { hil_stage[hil_ord] = 5; hil_ord--; hil_stage[hil_ord]=0; continue; } case 5: temp = hil_dy; hil_dy = -hil_turn * hil_dx; hil_dx = hil_turn * temp; hil_turn = -hil_turn; hil_x += hil_dx; hil_y += hil_dy; if (hil_x < hil_width && hil_y < hil_height) { hil_stage[hil_ord] = 6; *px = hil_x; *py = hil_y; return 1; } case 6: if (hil_ord > 0) /* recurse */ { hil_stage[hil_ord] = 7; hil_ord--; hil_stage[hil_ord]=0; continue; } case 7: temp = hil_dy; hil_dy = -hil_turn * hil_dx; hil_dx = hil_turn * temp; hil_turn = -hil_turn; /* Return from a recursion */ if (hil_ord < hil_order) hil_ord++; else return 0; } } } netpbm-free-10.0-1/pgm/psidtopgm.10100644004714500471450000000305007716230207017174 0ustar aba-guestaba-guest.TH psidtopgm 1 "02 August 89" .IX psidtopgm .SH NAME psidtopgm - convert PostScript "image" data into a portable graymap .SH SYNOPSIS .B psidtopgm .I width height bits/sample .RI [ imagedata ] .SH DESCRIPTION Reads the "image" data from a PostScript file as input. .IX PostScript Produces a portable graymap as output. .PP This program is obsoleted by .BR pstopnm . What follows was written before .B pstopnm existed. This is a very simple and limited program, and is here only because so many people have asked for it. To use it you have to .B manually extract the readhexstring data portion from your PostScript file, and then give the width, height, and bits/sample on the command line. Before you attempt this, you should .B at least read the description of the "image" operator in the PostScript Language Reference Manual. .PP It would probably not be too hard to write a script that uses this filter to read a specific variety of PostScript image, but the variation is too great to make a general-purpose reader. Unless, of course, you want to write a full-fledged PostScript interpreter... .SH "SEE ALSO" pnmtops(1), pgm(5) .SH AUTHOR Copyright (C) 1989 by Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/psidtopgm.c0100644004714500471450000000546407716762513017303 0ustar aba-guestaba-guest/* psidtopgm.c - convert PostScript "image" data into a portable graymap ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include "pgm.h" static int gethexit ARGS(( FILE* ifp )); int main( argc, argv ) int argc; char* argv[]; { FILE* ifp; gray* grayrow; register gray* gP; int argn, row; register int col, val; int maxval; int rows, cols, bitspersample; char* usage = " [imagedata]"; pgm_init( &argc, argv ); argn = 1; if ( argn + 3 > argc ) pm_usage( usage ); cols = atoi( argv[argn++] ); rows = atoi( argv[argn++] ); bitspersample = atoi( argv[argn++] ); if ( cols <= 0 || rows <= 0 || bitspersample <= 0 ) pm_usage( usage ); if ( argn < argc ) { ifp = pm_openr( argv[argn] ); ++argn; } else ifp = stdin; if ( argn != argc ) pm_usage( usage ); maxval = pm_bitstomaxval( bitspersample ); if ( maxval > PGM_OVERALLMAXVAL ) pm_error( "bits/sample (%d) is too large.", bitspersample ); pgm_writepgminit( stdout, cols, rows, (gray) maxval, 0 ); overflow_add(cols, 7); grayrow = pgm_allocrow( ( cols + 7 ) / 8 * 8 ); for ( row = 0; row < rows; ++row) { for ( col = 0, gP = grayrow; col < cols; ) { val = gethexit( ifp ) << 4; val += gethexit( ifp ); switch ( bitspersample ) { case 1: *gP++ = val >> 7; *gP++ = ( val >> 6 ) & 0x1; *gP++ = ( val >> 5 ) & 0x1; *gP++ = ( val >> 4 ) & 0x1; *gP++ = ( val >> 3 ) & 0x1; *gP++ = ( val >> 2 ) & 0x1; *gP++ = ( val >> 1 ) & 0x1; *gP++ = val & 0x1; col += 8; break; case 2: *gP++ = val >> 6; *gP++ = ( val >> 4 ) & 0x3; *gP++ = ( val >> 2 ) & 0x3; *gP++ = val & 0x3; col += 4; break; case 4: *gP++ = val >> 4; *gP++ = val & 0xf; col += 2; break; case 8: *gP++ = val; ++col; break; default: pm_error( "bitspersample of %d not supported", bitspersample ); } } pgm_writepgmrow( stdout, grayrow, cols, (gray) maxval, 0 ); } pm_close( ifp ); pm_close( stdout ); exit( 0 ); } static int gethexit( ifp ) FILE* ifp; { register int i; register char c; for ( ; ; ) { i = getc( ifp ); if ( i == EOF ) pm_error( "EOF / read error" ); c = (char) i; if ( c >= '0' && c <= '9' ) return c - '0'; else if ( c >= 'A' && c <= 'F' ) return c - 'A' + 10; else if ( c >= 'a' && c <= 'f' ) return c - 'a' + 10; /* Else ignore - whitespace. */ } } netpbm-free-10.0-1/pgm/rawtopgm.10100644004714500471450000001106707716230207017035 0ustar aba-guestaba-guest.TH rawtopgm 1 "14 September 2000" .IX rawtopgm .SH NAME rawtopgm - convert raw grayscale bytes into a portable graymap .SH SYNOPSIS .B rawtopgm .RB [ "-bpp " [ 1 | 2 ]] .RB [ -littleendian ] .RB [ -maxval .IR N ] .RB [ -headerskip .IR N ] .RB [ -rowskip .IR N ] .RB [ -tb | -topbottom ] .RI [ width .IR height ] .RI [ imagefile ] .SH DESCRIPTION Reads raw grayscale values as input. .IX "raw grayscale" Produces a PGM file as output. The input file is just a sequence of pure binary numbers, either one or two bytes each, either bigendian or littleendian, representing gray values. They may be arranged either top to bottom, left to right or bottom to top, left to right. There may be arbitrary header information at the start of the file (to which .B rawtopgm pays no attention at all other than the header's size). Arguments to .B rawtopgm tell how to interpret the pixels (a function that is served by a header in a regular graphics format). The .I width and .I height parameters tell the dimensions of the image. If you omit these parameters, .B rawtopgm assumes it is a quadratic image and bases the dimensions on the size of the input stream. If this size is not a perfect square, .B rawtopgm fails. When you don't specify .I width and .IR height , .B rawtopgm reads the entire input stream into storage at once, which may take a lot of storage. Otherwise, .B rawtopgm ordinarily stores only one row at a time. If you don't specify .IR imagefile , or specify .BR - , the input is from Standard Input. The PGM output is to Standard Output. .SH OPTIONS .TP .B -maxval \fIN .I N is the maxval for the gray values in the input, and is also the maxval of the PGM output image. The default is the maximum value that can be represented in the number of bytes used for each sample (i.e. 255 or 65535). .TP .B -bpp \fR[\fB1\fR|\fB2\fR] tells the number of bytes that represent each sample in the input. If the value is .BR 2 , The most significant byte is first in the stream. The default is 1 byte per sample. .TP .B -littleendian says that the bytes of each input sample are ordered with the least significant byte first. Without this option, .B rawtopgm assumes MSB first. This obviously has no effect when there is only one byte per sample. .TP .B -headerskip \fIN .B rawtopgm skips over .I N bytes at the beginning of the stream and reads the image immediately after. The default is 0. This is useful when the input is actually some graphics format that has a descriptive header followed by an ordinary raster, and you don't have a program that understands the header or you want to ignore the header. .TP .B -rowskip \fIN If there is padding at the ends of the rows, you can skip it with this option. Note that rowskip need not be an integer. Amazingly, I once had an image with 0.376 bytes of padding per row. This turned out to be due to a file-transfer problem, but I was still able to read the image. Skipping a fractional byte per row means skipping one byte per multiple rows. .TP .B -bt -bottomfirst By default, .B rawtopgm assumes the pixels in the input go top to bottom, left to right. If you specify .B -bt or .BR -bottomfirst , .B rawtopgm assumes the pixels go bottom to top, left to right. The Molecular Dynamics and Leica confocal format, for example, use the latter arrangement. If you don't specify .B -bt when you should or vice versa, the resulting image is upside down, which you can correct with .B pnmflip . This option causes .B rawtopgm to read the entire input stream into storage at once, which may take a lot of storage. Ordinarly, .B rawtopgm stores only one row at a time. For backwards compatibility, .B rawtopgm also accepts .B -tb and .B -topbottom to mean exactly the same thing. The reasons these are named backwards is that the original author thought of it as specifying that the wrong results of assuming the data is top to bottom should be corrected by flipping the result top for bottom. Today, we think of it as simply specifying the format of the input data so that there are no wrong results. .SH "SEE ALSO" .BR pgm (5), .BR rawtoppm (1), .BR pnmflip (1) .SH AUTHORS Copyright (C) 1989 by Jef Poskanzer. .br Modified June 1993 by Oliver Trepte, oliver@fysik4.kth.se .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty. netpbm-free-10.0-1/pgm/rawtopgm.c0100644004714500471450000002305407723461056017124 0ustar aba-guestaba-guest/* rawtopgm.c - convert raw grayscale bytes into a portable graymap ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include #include "pgm.h" struct cmdline_info { /* All the information the user supplied in the command line, in a form easy for the program to use. */ char *input_filespec; /* Filespec of input file */ unsigned int headerskip; float rowskip; int bottomfirst; /* the -bottomfirst/-bt option */ int autosize; /* User wants us to figure out the size */ int width; int height; int bpp; /* bytes per pixel in input format. 1 or 2 */ int littleendian; /* logical: samples in input are least significant byte first */ int maxval; /* -maxval option, or -1 if none */ }; static void parse_command_line(int argc, char ** argv, struct cmdline_info *cmdline_p) { /*---------------------------------------------------------------------------- Note that the file spec array we return is stored in the storage that was passed to us as the argv array. -----------------------------------------------------------------------------*/ optStruct *option_def = malloc(100*sizeof(optStruct)); /* Instructions to OptParseOptions2 on how to parse our options. */ optStruct2 opt; unsigned int option_def_index; option_def_index = 0; /* incremented by OPTENTRY */ OPTENTRY(0, "bottomfirst", OPT_FLAG, &cmdline_p->bottomfirst, 0); OPTENTRY(0, "bt", OPT_FLAG, &cmdline_p->bottomfirst, 0); OPTENTRY(0, "topbottom", OPT_FLAG, &cmdline_p->bottomfirst, 0); OPTENTRY(0, "tb", OPT_FLAG, &cmdline_p->bottomfirst, 0); OPTENTRY(0, "headerskip", OPT_UINT, &cmdline_p->headerskip, 0); OPTENTRY(0, "rowskip", OPT_FLOAT, &cmdline_p->rowskip, 0); OPTENTRY(0, "bpp", OPT_INT, &cmdline_p->bpp, 0); OPTENTRY(0, "littleendian", OPT_FLAG, &cmdline_p->littleendian, 0); OPTENTRY(0, "maxval", OPT_UINT, &cmdline_p->maxval, 0); /* Set the defaults */ cmdline_p->bottomfirst = FALSE; cmdline_p->headerskip = 0; cmdline_p->rowskip = 0.0; cmdline_p->bpp = 1; cmdline_p->littleendian = 0; cmdline_p->maxval = -1; opt.opt_table = option_def; opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */ opt.allowNegNum = FALSE; /* We may have parms that are negative numbers */ pm_optParseOptions2(&argc, argv, opt, 0); /* Uses and sets argc, argv, and some of *cmdline_p and others. */ if (argc-1 == 0) { cmdline_p->input_filespec = "-"; cmdline_p->autosize = TRUE; } else if (argc-1 == 1) { cmdline_p->input_filespec = argv[1]; cmdline_p->autosize = TRUE; } else if (argc-1 == 2) { cmdline_p->input_filespec = "-"; cmdline_p->autosize = FALSE; cmdline_p->width = atoi(argv[1]); cmdline_p->height = atoi(argv[2]); } else if (argc-1 == 3) { cmdline_p->input_filespec = argv[3]; cmdline_p->autosize = FALSE; cmdline_p->width = atoi(argv[1]); cmdline_p->height = atoi(argv[2]); } else pm_error("Program takes zero, one, two, or three arguments. You " "specified %d", argc-1); if (cmdline_p->bpp != 1 && cmdline_p->bpp != 2) pm_error("Bytes per pixel (-bpp) must be 1 or 2. You specified %d.", cmdline_p->bpp); if (cmdline_p->maxval == 0) pm_error("Maxval (-maxval) may not be zero."); if (cmdline_p->maxval > 255 && cmdline_p->bpp == 1) pm_error("You have specified one byte per pixel, but a maxval " "too large to fit in one byte: %d", cmdline_p->maxval); if (cmdline_p->maxval > 65535) pm_error("Maxval must be less than 65536. You specified %d.", cmdline_p->maxval); if (!cmdline_p->autosize && (cmdline_p->width <= 0)) /* #199053 */ pm_error("Width must be a positive number."); if (!cmdline_p->autosize && (cmdline_p->height <= 0)) /* #199053 */ pm_error("Height must be a positive number."); if (cmdline_p->rowskip && cmdline_p->autosize) pm_error("If you specify -rowskip, you must also give the image " "dimensions."); if (cmdline_p->rowskip && cmdline_p->bottomfirst) pm_error("You canot specify both -rowskip and -bottomfirst. This is " "a limitation of this program."); } static void compute_image_size(const struct cmdline_info cmdline, const long nread, int * const rows_p, int * const cols_p) { if (cmdline.autosize) { int sqrt_trunc = (int) sqrt((double) (nread-cmdline.headerskip)); if (sqrt_trunc*sqrt_trunc+cmdline.headerskip != nread) pm_error( "You must specify the dimensions of the image unless " "it is a quadratic image. This one is not quadratic: " "The number of " "pixels in the input is %ld, which is not a perfect " "square.", nread-cmdline.headerskip); *rows_p = *cols_p = sqrt_trunc; pm_message( "Image size: %d cols, %d rows", *cols_p, *rows_p); } else { *rows_p = cmdline.height; *cols_p = cmdline.width; } } static void skip_header(FILE *ifp, const int headerskip) { int i; for ( i = 0; i < headerskip; ++i ) { /* Read a byte out of the file */ int val; val = getc( ifp ); if ( val == EOF ) pm_error("EOF / read error reading Byte %d in the header", i ); } } static gray read_from_file(FILE *ifp, const int bpp, const int row, const int col, const int littleendian) { /*---------------------------------------------------------------------------- Return the next sample value from the input file 'ifp', assuming the input stream is 'bpp' bytes per pixel (1 or 2). In the case of two bytes, if 'littleendian', assume least significant byte is first. Otherwise, assume MSB first. In error messages, say this is Column 'col', Row 'row'. Exit program if error. -----------------------------------------------------------------------------*/ gray retval; if (bpp == 1) { int val; val = getc(ifp); if (val == EOF) pm_error( "EOF / read error at Row %d Column %d", row, col); retval = (gray) val; } else { short val; int rc; rc = littleendian ? pm_readlittleshort(ifp, &val) : pm_readbigshort(ifp, &val); if (rc != 0) pm_error( "EOF / read error at Row %d Column %d", row, col); retval = (gray) val; } return retval; } int main(int argc, char *argv[] ) { struct cmdline_info cmdline; FILE* ifp; gray* grayrow; int rows, cols; gray maxval; char* buf; /* pixels_1 and pixels_2 are the array of pixels in the input buffer (assuming we are using an input buffer). pixels_1 is the array as if the pixels are one byte each. pixels_2 is the array as if they are two bytes each. */ unsigned char *pixels_1; unsigned short *pixels_2; long nread; int row; float toskip; pgm_init( &argc, argv ); parse_command_line(argc, argv, &cmdline); ifp = pm_openr(cmdline.input_filespec); if (cmdline.autosize || cmdline.bottomfirst) { buf = pm_read_unknown_size( ifp, &nread ); pixels_1 = (unsigned char *) buf; pixels_2 = (unsigned short *) buf; } else buf = NULL; compute_image_size(cmdline, nread, &rows, &cols); if (!buf) skip_header(ifp, cmdline.headerskip); toskip = 0.00001; if (cmdline.maxval == -1) maxval = (cmdline.bpp == 1 ? (gray) 255 : (gray) 65535); else maxval = (gray) cmdline.maxval; pgm_writepgminit( stdout, cols, rows, maxval, 0 ); grayrow = pgm_allocrow( cols ); for ( row = 0; row < rows; ++row) { int col; unsigned int rowpos; /* index of this row in pixel array */ if (cmdline.bottomfirst) rowpos = (rows-row-1) * cols; else rowpos = row * cols; for ( col = 0; col < cols; ++col ) if (buf) { if (cmdline.bpp == 1) grayrow[col] = pixels_1[rowpos+col]; else grayrow[col] = pixels_2[rowpos+col]; } else { grayrow[col] = read_from_file(ifp, cmdline.bpp, row, col, cmdline.littleendian); } for ( toskip += cmdline.rowskip; toskip >= 1.0; toskip -= 1.0 ) { /* Note that if we're using a buffer, cmdline.rowskip is zero */ int val; val = getc( ifp ); if ( val == EOF ) pm_error( "EOF / read error skipping bytes at the end " "of Row %d.", row); } pgm_writepgmrow( stdout, grayrow, cols, maxval, 0 ); } if (buf) free(buf); pm_close( ifp ); pm_close( stdout ); exit( 0 ); } netpbm-free-10.0-1/pgm/sbigtopgm.10100644004714500471450000000115007716230207017160 0ustar aba-guestaba-guest.TH sbigtopgm 1 "23 January 98" .IX sbigtopgm .SH NAME sbigtopgm \- convert an SBIG CCDOPS file into a portable graymap .SH SYNOPSIS .B sbigtopgm .RI [ sbigfile ] .SH DESCRIPTION Reads an an image file in the native format used by the Santa Barbara Instrument Group (SBIG) astronomical CCD cameras, and produces a portable graymap as output. Additional information on SBIG cameras and documentation of the file format is available at the Web site: .ce 1 .B http://www.sbig.com/ .SH "SEE ALSO" .BR pgm (5) .SH AUTHOR John Walker .RB ( http://www.fourmilab.ch/ ), January 1998. This program is in the public domain. netpbm-free-10.0-1/pgm/sbigtopgm.c0100644004714500471450000001306007716230207017245 0ustar aba-guestaba-guest/* sbigtopgm.c - read a Santa Barbara Instruments Group CCDOPS file Note: All SBIG CCD astronomical cameras produce 14 bits or (the ST-4 and ST-5) or 16 bits (ST-6 and later) per pixel. Copyright (C) 1998 by John Walker http://www.fourmilab.ch/ If you find yourself having to add functionality included subsequent to the implementation of this program, you can probably find documentation of any changes to the SBIG file format on their Web site: http://www.sbig.com/ Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is" without express or implied warranty. */ #include #include "pgm.h" #define SBIG_HEADER_LENGTH 2048 /* File header length */ /* looseCanon -- Canonicalise a line from the file header so items more sloppily formatted than those written by CCDOPS are still accepted. */ static void looseCanon(cp) char *cp; { char *op = cp; char c; while ((c = *cp++) != 0) { if (!isspace(c)) { if (isupper(c)) { c = tolower(c); } *op++ = c; } } *op++ = 0; } int main(argc, argv) int argc; char* argv[]; { FILE *ifp; gray *grayrow; register gray *gP; int argn, row; register int col; int maxval; int comp, rows, cols; char header[SBIG_HEADER_LENGTH]; char *hdr; static char camera[80] = "ST-?"; pgm_init(&argc, argv); argn = 1; if (argn < argc) { ifp = pm_openr(argv[argn]); argn++; } else { ifp = stdin; } if (argn != argc) pm_usage( "[sbigfile]" ); if (fread(header, SBIG_HEADER_LENGTH, 1, ifp) < 1) { pm_error("error reading SBIG file header"); } /* Walk through the header and parse relevant parameters. */ comp = -1; cols = -1; rows = -1; /* The SBIG header specification equivalent to maxval is "Sat_level", the saturation level of the image. This specification is optional, and was not included in files written by early versions of CCDOPS. It was introduced when it became necessary to distinguish 14-bit images with a Sat_level of 16383 from 16-bit images which saturate at 65535. In addition, co-adding images or capturing with Track and Accumulate can increase the saturation level. Since files which don't have a Sat_level line in the header were most probably written by early drivers for the ST-4 or ST-5, it might seem reasonable to make the default for maxval 16383, the correct value for those cameras. I chose instead to use 65535 as the default because the overwhelming majority of cameras in use today are 16 bit, and it's possible some non-SBIG software may omit the "optional" Sat_level specification. Also, no harm is done if a larger maxval is specified than appears in the image--a simple contrast stretch will adjust pixels to use the full 0 to maxval range. The converse, pixels having values greater than maxval, results in an invalid file which may cause problems in programs which attempt to process it. */ maxval = 65535; hdr = header; for (;;) { char *cp = strchr(hdr, '\n'); if (cp == NULL) { pm_error("malformed SBIG file header at character %d", hdr - header); } *cp = 0; if (strncmp(hdr, "ST-", 3) == 0) { char *ep = strchr(hdr + 3, ' '); if (ep != NULL) { *ep = 0; strcpy(camera, hdr); *ep = ' '; } } looseCanon(hdr); if (strncmp(hdr, "st-", 3) == 0) { comp = strstr(hdr, "compressed") != NULL; } else if (strncmp(hdr, "height=", 7) == 0) { rows = atoi(hdr + 7); } else if (strncmp(hdr, "width=", 6) == 0) { cols = atoi(hdr + 6); } else if (strncmp(hdr, "sat_level=", 10) == 0) { maxval = atoi(hdr + 10); } else if (strcmp(hdr, "end") == 0) { break; } hdr = cp + 1; } if ((comp == -1) || (rows == -1) || (cols == -1)) { pm_error("required specification missing from SBIG file header"); } fprintf(stderr, "SBIG %s %dx%d %s image, saturation level = %d.\n", camera, cols, rows, comp ? "compressed" : "uncompressed", maxval); if (maxval > PGM_OVERALLMAXVAL) { pm_error("Saturation level (%d levels) is too large.\n" "This program's limit is %d.", maxval, PGM_OVERALLMAXVAL); } pgm_writepgminit(stdout, cols, rows, (gray) maxval, 0); grayrow = pgm_allocrow(cols); #define DOSINT(fp) ((getc(fp) & 0xFF) | (getc(fp) << 8)) for (row = 0; row < rows; row++) { int compthis = comp; if (comp) { int rowlen = DOSINT(ifp); /* Compressed row length */ /* If compression results in a row length >= the uncompressed row length, that row is output uncompressed. We detect this by observing that the compressed row length is equal to that of an uncompressed row. */ if (rowlen == cols * 2) { compthis = 0; } } for (col = 0, gP = grayrow; col < cols; col++, gP++) { gray g; if (compthis) { if (col == 0) { g = DOSINT(ifp); } else { int delta = getc(ifp); if (delta == 0x80) { g = DOSINT(ifp); } else { g += ((signed char) delta); } } } else { g = DOSINT(ifp); } *gP = g; } pgm_writepgmrow(stdout, grayrow, cols, (gray) maxval, 0); } pm_close(ifp); pm_close(stdout); return 0; } netpbm-free-10.0-1/pnm/0040755004714500471450000000000007776237753015143 5ustar aba-guestaba-guestnetpbm-free-10.0-1/pnm/fiasco/0040755004714500471450000000000007776237753016407 5ustar aba-guestaba-guestnetpbm-free-10.0-1/pnm/fiasco/codec/0040755004714500471450000000000007776237753017464 5ustar aba-guestaba-guestnetpbm-free-10.0-1/pnm/fiasco/codec/Makefile0100644004714500471450000000076407717657506021125 0ustar aba-guestaba-guestSRCDIR=../../.. BUILDDIR = $(SRCDIR) include $(BUILDDIR)/Makefile.config INCLUDE = -I$(SRCDIR)/shhopt -I. -I.. -I../lib -I../input -I../output OBJECTS = approx.o bintree.o coder.o coeff.o \ control.o decoder.o dfiasco.o domain-pool.o ip.o motion.o mwfa.o \ options.o prediction.o subdivide.o tiling.o wfalib.o all: libfiasco_codec.a libfiasco_codec.a: $(OBJECTS) $(AR) -rc $@ $(OBJECTS) $(RANLIB) $@ .PHONY: clean clean: clean.common include $(SRCDIR)/Makefile.common netpbm-free-10.0-1/pnm/fiasco/codec/Makefile.depend0100644004714500471450000000000007716230207022322 0ustar aba-guestaba-guestnetpbm-free-10.0-1/pnm/fiasco/codec/approx.c0100644004714500471450000005260507716230207021123 0ustar aba-guestaba-guest/* * approx.c: Approximation of range images with matching pursuit * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #include #include "types.h" #include "macros.h" #include "error.h" #include "cwfa.h" #include "ip.h" #include "rpf.h" #include "domain-pool.h" #include "misc.h" #include "list.h" #include "approx.h" #include "coeff.h" #include "wfalib.h" /***************************************************************************** local variables *****************************************************************************/ typedef struct mp { word_t exclude [MAXEDGES]; word_t indices [MAXEDGES + 1]; word_t into [MAXEDGES + 1]; real_t weight [MAXEDGES]; real_t matrix_bits; real_t weights_bits; real_t err; real_t costs; } mp_t; /***************************************************************************** prototypes *****************************************************************************/ static void orthogonalize (unsigned index, unsigned n, unsigned level, real_t min_norm, const word_t *domain_blocks, const coding_t *c); static void matching_pursuit (mp_t *mp, bool_t full_search, real_t price, unsigned max_edges, int y_state, const range_t *range, const domain_pool_t *domain_pool, const coeff_t *coeff, const wfa_t *wfa, const coding_t *c); /***************************************************************************** public code *****************************************************************************/ real_t approximate_range (real_t max_costs, real_t price, int max_edges, int y_state, range_t *range, domain_pool_t *domain_pool, coeff_t *coeff, const wfa_t *wfa, const coding_t *c) /* * Approximate image block 'range' by matching pursuit. This functions * calls the matching pursuit algorithm several times (with different * parameters) in order to find the best approximation. Refer to function * 'matching_pursuit()' for more details about parameters. * * Return value: * approximation costs */ { mp_t mp; bool_t success = NO; /* * First approximation attempt: default matching pursuit algorithm. */ mp.exclude [0] = NO_EDGE; matching_pursuit (&mp, c->options.full_search, price, max_edges, y_state, range, domain_pool, coeff, wfa, c); /* * Next approximation attempt: remove domain block mp->indices [0] * from domain pool (vector with smallest costs) and run the * matching pursuit again. */ if (c->options.second_domain_block) { mp_t tmp_mp = mp; tmp_mp.exclude [0] = tmp_mp.indices [0]; tmp_mp.exclude [1] = NO_EDGE; matching_pursuit (&tmp_mp, c->options.full_search, price, max_edges, y_state, range, domain_pool, coeff, wfa, c); if (tmp_mp.costs < mp.costs) /* success */ { success = YES; mp = tmp_mp; } } /* * Next approximation attempt: check whether some coefficients have * been quantized to zero. Vectors causing the underflow are * removed from the domain pool and then the matching pursuit * algorithm is run again (until underflow doesn't occur anymore). */ if (c->options.check_for_underflow) { int iteration = -1; mp_t tmp_mp = mp; do { int i; iteration++; tmp_mp.exclude [iteration] = NO_EDGE; for (i = 0; isdomain (tmp_mp.indices [i]); i++) if (tmp_mp.weight [i] == 0) { tmp_mp.exclude [iteration] = tmp_mp.indices [i]; break; } if (isdomain (tmp_mp.exclude [iteration])) /* try again */ { tmp_mp.exclude [iteration + 1] = NO_EDGE; matching_pursuit (&tmp_mp, c->options.full_search, price, max_edges, y_state, range, domain_pool, coeff, wfa, c); if (tmp_mp.costs < mp.costs) /* success */ { success = YES; mp = tmp_mp; } } } while (isdomain (tmp_mp.exclude [iteration]) && iteration < MAXEDGES - 1); } /* * Next approximation attempt: check whether some coefficients have * been quantized to +/- max-value. Vectors causing the overflow are * removed from the domain pool and then the matching pursuit * algorithm is run again (until overflow doesn't occur anymore). */ if (c->options.check_for_overflow) { int iteration = -1; mp_t tmp_mp = mp; do { int i; iteration++; tmp_mp.exclude [iteration] = NO_EDGE; for (i = 0; isdomain (tmp_mp.indices [i]); i++) { rpf_t *rpf = tmp_mp.indices [i] ? coeff->rpf : coeff->dc_rpf; if (tmp_mp.weight [i] == btor (rtob (200, rpf), rpf) || tmp_mp.weight [i] == btor (rtob (-200, rpf), rpf)) { tmp_mp.exclude [iteration] = tmp_mp.indices [i]; break; } } if (isdomain (tmp_mp.exclude [iteration])) /* try again */ { tmp_mp.exclude [iteration + 1] = NO_EDGE; matching_pursuit (&tmp_mp, c->options.full_search, price, max_edges, y_state, range, domain_pool, coeff, wfa, c); if (tmp_mp.costs < mp.costs) /* success */ { success = YES; mp = tmp_mp; } } } while (isdomain (tmp_mp.exclude [iteration]) && iteration < MAXEDGES - 1); } /* * Finally, check whether the best approximation has costs * smaller than 'max_costs'. */ if (mp.costs < max_costs) { int edge; bool_t overflow = NO; bool_t underflow = NO; int new_index, old_index; new_index = 0; for (old_index = 0; isdomain (mp.indices [old_index]); old_index++) if (mp.weight [old_index] != 0) { rpf_t *rpf = mp.indices [old_index] ? coeff->rpf : coeff->dc_rpf; if (mp.weight [old_index] == btor (rtob (200, rpf), rpf) || mp.weight [old_index] == btor (rtob (-200, rpf), rpf)) overflow = YES; mp.indices [new_index] = mp.indices [old_index]; mp.into [new_index] = mp.into [old_index]; mp.weight [new_index] = mp.weight [old_index]; new_index++; } else underflow = YES; mp.indices [new_index] = NO_EDGE; mp.into [new_index] = NO_EDGE; /* * Update of probability models */ { word_t *domain_blocks = domain_pool->generate (range->level, y_state, wfa, domain_pool->model); domain_pool->update (domain_blocks, mp.indices, range->level, y_state, wfa, domain_pool->model); coeff->update (mp.weight, mp.into, range->level, coeff); Free (domain_blocks); } for (edge = 0; isedge (mp.indices [edge]); edge++) { range->into [edge] = mp.into [edge]; range->weight [edge] = mp.weight [edge]; } range->into [edge] = NO_EDGE; range->matrix_bits = mp.matrix_bits; range->weights_bits = mp.weights_bits; range->err = mp.err; } else { range->into [0] = NO_EDGE; mp.costs = MAXCOSTS; } return mp.costs; } /***************************************************************************** local variables *****************************************************************************/ static real_t norm_ortho_vector [MAXSTATES]; /* * Square-norm of the i-th vector of the orthogonal basis (OB) * ||o_i||^2; i = 0, ... ,n */ static real_t ip_image_ortho_vector [MAXEDGES]; /* * Inner product between the i-th vector of the OB and the given range: * ; i = 0, ... ,n */ static real_t ip_domain_ortho_vector [MAXSTATES][MAXEDGES]; /* * Inner product between the i-th vector of the OB and the image of domain j: * ; j = 0, ... , wfa->states; i = 0, ... ,n, */ static real_t rem_denominator [MAXSTATES]; static real_t rem_numerator [MAXSTATES]; /* * At step n of the orthogonalization the comparitive value * (numerator_i / denominator_i):= ^2 / ||o_n|| , * is computed for every domain i, * where o_n := s_i - \sum(k = 0, ... , n-1) {( / ||o_k||^2) o_k} * To avoid computing the same values over and over again, * the constant (remaining) parts of every domain are * stored in 'rem_numerator' and 'rem_denominator' separately */ static bool_t used [MAXSTATES]; /* * Shows whether a domain image was already used in a * linear combination (YES) or not (NO) */ /***************************************************************************** private code *****************************************************************************/ static void matching_pursuit (mp_t *mp, bool_t full_search, real_t price, unsigned max_edges, int y_state, const range_t *range, const domain_pool_t *domain_pool, const coeff_t *coeff, const wfa_t *wfa, const coding_t *c) /* * Find an approximation of the current 'range' with a linear * combination of vectors of the 'domain_pool'. The linear * combination is generated step by step with the matching pursuit * algorithm. If flag 'full_search' is set then compute complete set * of linear combinations with n = {0, ..., 'max_edges'} vectors and * return the best one. Otherwise abort the computation as soon as * costs (LC (n + 1)) exceed costs ( LC (n)) and return the * sub-optimal solution. 'price' is the langrange multiplier * weighting rate and distortion. 'band' is the current color band * and 'y_state' the corresponding state in the Y component at same * pixel position. 'domain_pool' gives the set of available vectors, * and 'coeff' the model for the linear factors. The number of * elements in the linear combination is limited by 'max_edges'. In * 'mp', vectors may be specified which should be excluded during the * approximation. * * No return value. * * Side effects: * vectors, factors, rate, distortion and costs are stored in 'mp' */ { unsigned n; /* current vector of the OB */ int index; /* best fitting domain image */ unsigned domain; /* counter */ real_t norm; /* norm of range image */ real_t additional_bits; /* bits for mc, nd, and tree */ word_t *domain_blocks; /* current set of domain images */ const real_t min_norm = 2e-3; /* lower bound of norm */ unsigned best_n = 0; unsigned size = size_of_level (range->level); /* * Initialize domain pool and inner product arrays */ domain_blocks = domain_pool->generate (range->level, y_state, wfa, domain_pool->model); for (domain = 0; domain_blocks [domain] >= 0; domain++) { used [domain] = NO; rem_denominator [domain] /* norm of domain */ = get_ip_state_state (domain_blocks [domain], domain_blocks [domain], range->level, c); if (rem_denominator [domain] / size < min_norm) used [domain] = YES; /* don't use domains with small norm */ else rem_numerator [domain] /* inner product */ = get_ip_image_state (range->image, range->address, range->level, domain_blocks [domain], c); if (!used [domain] && fabs (rem_numerator [domain]) < min_norm) used [domain] = YES; } /* * Exclude all domain blocks given in array 'mp->exclude' */ for (n = 0; isdomain (mp->exclude [n]); n++) used [mp->exclude [n]] = YES; /* * Compute the approximation costs if 'range' is approximated with * no linear combination, i.e. the error is equal to the square * of the image norm and the size of the automaton is determined by * storing only zero elements in the current matrix row */ for (norm = 0, n = 0; n < size; n++) norm += square (c->pixels [range->address * size + n]); additional_bits = range->tree_bits + range->mv_tree_bits + range->mv_coord_bits + range->nd_tree_bits + range->nd_weights_bits; mp->err = norm; mp->weights_bits = 0; mp->matrix_bits = domain_pool->bits (domain_blocks, NULL, range->level, y_state, wfa, domain_pool->model); mp->costs = (mp->matrix_bits + mp->weights_bits + additional_bits) * price + mp->err; n = 0; do { /* * Current approximation is: b = d_0 o_0 + ... + d_(n-1) o_(n-1) * with corresponding costs 'range->err + range->bits * p'. * For all remaining state images s_i (used[s_i] == NO) set * o_n : = s_i - \sum(k = 0, ... , n-1) {( / ||o_k||^2) o_k} * and try to beat current costs. * Choose that vector for the next orthogonalization step, * which has minimal costs: s_index. * (No progress is indicated by index == -1) */ real_t min_matrix_bits = 0; real_t min_weights_bits = 0; real_t min_error = 0; real_t min_weight [MAXEDGES]; real_t min_costs = full_search ? MAXCOSTS : mp->costs; for (index = -1, domain = 0; domain_blocks [domain] >= 0; domain++) if (!used [domain]) { real_t matrix_bits, weights_bits; /* * To speed up the search through the domain images, * the costs of using domain image 'domain' as next vector * can be approximated in a first step: * improvement of image quality * <= square (rem_numerator[domain]) / rem_denominator[domain] */ { word_t vectors [MAXEDGES + 1]; word_t states [MAXEDGES + 1]; real_t weights [MAXEDGES + 1]; unsigned i, k; for (i = 0, k = 0; k < n; k++) if (mp->weight [k] != 0) { vectors [i] = mp->indices [k]; states [i] = domain_blocks [vectors [i]]; weights [i] = mp->weight [k]; i++; } vectors [i] = domain; states [i] = domain_blocks [domain]; weights [i] = 0.5; vectors [i + 1] = -1; states [i + 1] = -1; weights_bits = coeff->bits (weights, states, range->level, coeff); matrix_bits = domain_pool->bits (domain_blocks, vectors, range->level, y_state, wfa, domain_pool->model); } if (((matrix_bits + weights_bits + additional_bits) * price + mp->err - square (rem_numerator [domain]) / rem_denominator [domain]) < min_costs) { /* * 1.) Compute the weights (linear factors) c_i of the * linear combination * b = c_0 v_0 + ... + c_(n-1) v_(n-1) + c_n v_'domain' * Use backward substitution to obtain c_i from the linear * factors of the lin. comb. b = d_0 o_0 + ... + d_n o_n * of the corresponding orthogonal vectors {o_0, ..., o_n}. * Vector o_n of the orthogonal basis is obtained by using * vector 'v_domain' in step n of the Gram Schmidt * orthogonalization (see above for definition of o_n). * Recursive formula for the coefficients c_i: * c_n := / ||o_n||^2 * for i = n - 1, ... , 0: * c_i := / ||o_i||^2 + * \sum (k = i + 1, ... , n){ c_k * / ||o_i||^2 } * 2.) Because linear factors are stored with reduced precision * factor c_i is rounded with the given precision in step i * of the recursive formula. */ unsigned k; /* counter */ int l; /* counter */ real_t m_bits; /* number of matrix bits to store */ real_t w_bits; /* number of weights bits to store */ real_t r [MAXEDGES]; /* rounded linear factors */ real_t f [MAXEDGES]; /* linear factors */ int v [MAXEDGES]; /* mapping of domains to vectors */ real_t costs; /* current approximation costs */ real_t m_err; /* current approximation error */ f [n] = rem_numerator [domain] / rem_denominator [domain]; v [n] = domain; /* corresponding mapping */ for (k = 0; k < n; k++) { f [k] = ip_image_ortho_vector [k] / norm_ortho_vector [k]; v [k] = mp->indices [k]; } for (l = n; l >= 0; l--) { rpf_t *rpf = domain_blocks [v [l]] ? coeff->rpf : coeff->dc_rpf; r [l] = f [l] = btor (rtob (f [l], rpf), rpf); for (k = 0; k < (unsigned) l; k++) f [k] -= f [l] * ip_domain_ortho_vector [v [l]][k] / norm_ortho_vector [k] ; } /* * Compute the number of output bits of the linear combination * and store the weights with reduced precision. The * resulting linear combination is * b = r_0 v_0 + ... + r_(n-1) v_(n-1) + r_n v_'domain' */ { word_t vectors [MAXEDGES + 1]; word_t states [MAXEDGES + 1]; real_t weights [MAXEDGES + 1]; int i; for (i = 0, k = 0; k <= n; k++) if (f [k] != 0) { vectors [i] = v [k]; states [i] = domain_blocks [v [k]]; weights [i] = f [k]; i++; } vectors [i] = -1; states [i] = -1; w_bits = coeff->bits (weights, states, range->level, coeff); m_bits = domain_pool->bits (domain_blocks, vectors, range->level, y_state, wfa, domain_pool->model); } /* * To compute the approximation error, the corresponding * linear factors of the linear combination * b = r_0 o_0 + ... + r_(n-1) o_(n-1) + r_n o_'domain' * with orthogonal vectors must be computed with following * formula: * r_i := r_i + * \sum (k = i + 1, ... , n) { r_k * / ||o_i||^2 } */ for (l = 0; (unsigned) l <= n; l++) { /* * compute */ real_t a; a = get_ip_state_state (domain_blocks [v [l]], domain_blocks [domain], range->level, c); for (k = 0; k < n; k++) a -= ip_domain_ortho_vector [v [l]][k] / norm_ortho_vector [k] * ip_domain_ortho_vector [domain][k]; ip_domain_ortho_vector [v [l]][n] = a; } norm_ortho_vector [n] = rem_denominator [domain]; ip_image_ortho_vector [n] = rem_numerator [domain]; for (k = 0; k <= n; k++) for (l = k + 1; (unsigned) l <= n; l++) r [k] += ip_domain_ortho_vector [v [l]][k] * r [l] / norm_ortho_vector [k]; /* * Compute approximation error: * error := ||b||^2 + * \sum (k = 0, ... , n){r_k^2 ||o_k||^2 - 2 r_k } */ m_err = norm; for (k = 0; k <= n; k++) m_err += square (r [k]) * norm_ortho_vector [k] - 2 * r [k] * ip_image_ortho_vector [k]; if (m_err < 0) /* TODO: return MAXCOSTS */ warning ("Negative image norm: %f" " (current domain: %d, level = %d)", (double) m_err, domain, range->level); costs = (m_bits + w_bits + additional_bits) * price + m_err; if (costs < min_costs) /* found a better approximation */ { index = domain; min_costs = costs; min_matrix_bits = m_bits; min_weights_bits = w_bits; min_error = m_err; for (k = 0; k <= n; k++) min_weight [k] = f [k]; } } } if (index >= 0) /* found a better approximation */ { if (min_costs < mp->costs) { unsigned k; mp->costs = min_costs; mp->err = min_error; mp->matrix_bits = min_matrix_bits; mp->weights_bits = min_weights_bits; for (k = 0; k <= n; k++) mp->weight [k] = min_weight [k]; best_n = n + 1; } mp->indices [n] = index; mp->into [n] = domain_blocks [index]; used [index] = YES; /* * Gram-Schmidt orthogonalization step n */ orthogonalize (index, n, range->level, min_norm, domain_blocks, c); n++; } } while (n < max_edges && index >= 0); mp->indices [best_n] = NO_EDGE; mp->costs = (mp->matrix_bits + mp->weights_bits + additional_bits) * price + mp->err; Free (domain_blocks); } static void orthogonalize (unsigned index, unsigned n, unsigned level, real_t min_norm, const word_t *domain_blocks, const coding_t *c) /* * Step 'n' of the Gram-Schmidt orthogonalization procedure: * vector 'index' is orthogonalized with respect to the set * {u_[0], ... , u_['n' - 1]}. The size of the image blocks is given by * 'level'. If the denominator gets smaller than 'min_norm' then * the corresponding domain is excluded from the list of available * domain blocks. * * No return value. * * Side effects: * The remainder values (numerator and denominator) of * all 'domain_blocks' are updated. */ { unsigned domain; ip_image_ortho_vector [n] = rem_numerator [index]; norm_ortho_vector [n] = rem_denominator [index]; /* * Compute inner products between all domain images and * vector n of the orthogonal basis: * for (i = 0, ... , wfa->states) * := - * \sum (k = 0, ... , n - 1){ / ||o_k||^2} * Moreover the denominator and numerator parts of the comparitive * value are updated. */ for (domain = 0; domain_blocks [domain] >= 0; domain++) if (!used [domain]) { unsigned k; real_t tmp = get_ip_state_state (domain_blocks [index], domain_blocks [domain], level, c); for (k = 0; k < n; k++) tmp -= ip_domain_ortho_vector [domain][k] / norm_ortho_vector [k] * ip_domain_ortho_vector [index][k]; ip_domain_ortho_vector [domain][n] = tmp; rem_denominator [domain] -= square (tmp) / norm_ortho_vector [n]; rem_numerator [domain] -= ip_image_ortho_vector [n] / norm_ortho_vector [n] * ip_domain_ortho_vector [domain][n] ; /* * Exclude vectors with small denominator */ if (!used [domain]) if (rem_denominator [domain] / size_of_level (level) < min_norm) used [domain] = YES; } } netpbm-free-10.0-1/pnm/fiasco/codec/approx.h0100644004714500471450000000117207716230207021121 0ustar aba-guestaba-guest/* * approx.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _APPROX_H #define _APPROX_H #include "types.h" #include "cwfa.h" #include "domain-pool.h" real_t approximate_range (real_t max_costs, real_t price, int max_edges, int y_state, range_t *range, domain_pool_t *domain_pool, coeff_t *coeff, const wfa_t *wfa, const coding_t *c); #endif /* not _APPROX_H */ netpbm-free-10.0-1/pnm/fiasco/codec/bintree.c0100644004714500471450000000413007716230207021230 0ustar aba-guestaba-guest/* * bintree.c: Bintree model of WFA tree * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #include "types.h" #include "macros.h" #include "error.h" #include #include "bintree.h" #include "misc.h" #include "cwfa.h" /***************************************************************************** public code *****************************************************************************/ void tree_update (bool_t child, unsigned level, tree_t *model) /* * Update tree model of given 'level'. * * No return value. * * Side effects: * tree model is changed. */ { if (!child) model->total [level]++; else { model->counts [level]++; model->total [level]++; } } real_t tree_bits (bool_t child, unsigned level, const tree_t *model) /* * Compute number of bits needed for coding element 'child' of the bintree. * For each 'level' a different context is used. * * Return value: * # bits */ { real_t prob = model->counts [level] / (real_t) model->total [level]; return child ? - log2 (prob) : - log2 (1 - prob); } void init_tree_model (tree_t *tree_model) /* * Initialize the model for the tree. * Symbol RANGE is synonymous with the '0' symbol and * symbol NO_RANGE is synonymous with the '1' symbol of the binary coder. * The 'count' array counts the number of NO_RANGE symbols. * * No return value. */ { unsigned level; unsigned counts_0 [MAXLEVEL] = {20, 17, 15, 10, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 , 1, 1, 1}; unsigned counts_1 [MAXLEVEL] = {1 , 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 5, 10, 15, 20, 25, 30, 35, 60, 60, 60, 60}; for (level = 0; level < MAXLEVEL ; level++) { tree_model->counts [level] = counts_1 [level]; tree_model->total [level] = counts_0 [level] + counts_1 [level]; } } netpbm-free-10.0-1/pnm/fiasco/codec/bintree.h0100644004714500471450000000201207716230207021232 0ustar aba-guestaba-guest/* * bintree.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _BINTREE_H #define _BINTREE_H #include "wfa.h" #include "types.h" typedef struct tree /* * Used for estimating the number of bits needed for storing the * tree array. For each level a different context is used. * The binary alphabet consists of the two symbols NO_RANGE and RANGE, * which indicate whether there exists a tree edge or not. */ { unsigned counts [MAXLEVEL]; /* # NO_RANGE symbols at given level */ unsigned total [MAXLEVEL]; /* total number of symbols at '' */ } tree_t; real_t tree_bits (bool_t child, unsigned level, const tree_t *model); void init_tree_model (tree_t *tree_model); void tree_update (bool_t child, unsigned level, tree_t *model); #endif /* not _BINTREE_H */ netpbm-free-10.0-1/pnm/fiasco/codec/coder.c0100644004714500471450000006540607776237374020733 0ustar aba-guestaba-guest/* * coder.c: WFA coder toplevel functions * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2004/01/05 10:39:56 $ * $Author: aba-guest $ * $Revision: 1.3 $ * $State: Exp $ */ #include "config.h" #include "pnm.h" #include #include #if HAVE_STRING_H # include #else /* not HAVE_STRING_H */ # include #endif /* not HAVE_STRING_H */ #include "types.h" #include "macros.h" #include "error.h" #include "fiasco.h" #include "cwfa.h" #include "misc.h" #include "control.h" #include "bintree.h" #include "subdivide.h" #include "read.h" #include "write.h" #include "image.h" #include "mwfa.h" #include "list.h" #include "decoder.h" #include "motion.h" #include "wfalib.h" #include "domain-pool.h" #include "coeff.h" #include "coder.h" #include "rpf.h" /***************************************************************************** global variables *****************************************************************************/ const real_t MAXCOSTS = 1e20; /***************************************************************************** prototypes *****************************************************************************/ static coding_t * alloc_coder (char const * const *inputname, const c_options_t *options, wfa_info_t *wi); static void free_coder (coding_t *c); static char * get_input_image_name (char const * const *templptr, unsigned ith_image); static void video_coder (char const * const *image_template, bitfile_t *output, wfa_t *wfa, coding_t *c); static void frame_coder (wfa_t *wfa, coding_t *c, bitfile_t *output); static void print_statistics (char c, real_t costs, const wfa_t *wfa, const image_t *image, const range_t *range); static frame_type_e pattern2type (unsigned frame, const char *pattern); /***************************************************************************** public code *****************************************************************************/ int fiasco_coder (char const * const *inputname, const char *outputname, float quality, const fiasco_c_options_t *options) /* * FIASCO coder. * Encode image or video frames given by the array of filenames `inputname' * and write to the outputfile `outputname'. * If 'inputname' = NULL or * 'inputname [0]' == NULL or * 'inputname [0]' == "-", read standard input. * If 'outputname' == NULL or "-", write on standard output. * 'quality' defines the approximation quality and is 1 (worst) to 100 (best). * * Return value: * 1 on success * 0 otherwise */ { try { char const * const default_input [] = {"-", NULL}; fiasco_c_options_t *default_options = NULL; const c_options_t *cop; char const * const *template; /* * Check parameters */ if (!inputname || !inputname [0] || streq (inputname [0], "-")) template = default_input; else template = inputname; if (quality <= 0) { set_error (_("Compression quality has to be positive.")); return 0; } else if (quality >= 100) { warning (_("Quality typically is 1 (worst) to 100 (best).\n" "Be prepared for a long running time.")); } if (options) { cop = cast_c_options ((fiasco_c_options_t *) options); if (!cop) return 0; } else { default_options = fiasco_c_options_new (); cop = cast_c_options (default_options); } /* * Open output stream and initialize WFA */ { bitfile_t *output = open_bitfile (outputname, "FIASCO_DATA", WRITE_ACCESS); if (!output) { set_error (_("Can't write outputfile `%s'.\n%s"), outputname ? outputname : "", get_system_error ()); if (default_options) fiasco_c_options_delete (default_options); return 0; } else { wfa_t *wfa = alloc_wfa (YES); coding_t *c = alloc_coder (template, cop, wfa->wfainfo); read_basis (cop->basis_name, wfa); append_basis_states (wfa->basis_states, wfa, c); c->price = 128 * 64 / quality; video_coder (template, output, wfa, c); close_bitfile (output); free_wfa (wfa); free_coder (c); if (default_options) fiasco_c_options_delete (default_options); } } return 1; } catch { return 0; } } /***************************************************************************** private code *****************************************************************************/ static coding_t * alloc_coder (char const * const *inputname, const c_options_t *options, wfa_info_t *wi) /* * Coder structure constructor. * Allocate memory for the FIASCO coder structure and * fill in default values specified by 'options'. * * Return value: * pointer to the new coder structure or NULL on error */ { coding_t *c = NULL; /* * Check whether all specified image frames are readable and of same type */ { char *filename; int width, w = 0, height, h = 0; bool_t color, c = NO; unsigned n; for (n = 0; (filename = get_input_image_name (inputname, n)); n++) { FILE *file; xelval maxval; int format; if (filename == NULL) file = stdin; else file = pm_openr(filename); pnm_readpnminit(file, &width, &height, &maxval, &format); color = (PNM_FORMAT_TYPE(format) == PPM_FORMAT) ? TRUE: FALSE; pm_close(file); if (n) { if (w != width || h != height || c != color) { set_error (_("Format of image frame `%s' doesn't match."), filename ? filename : ""); return NULL; } } else { w = width; h = height; c = color; } Free (filename); } wi->frames = n; wi->width = w; wi->height = h; wi->color = c; } /* * Levels ... */ { unsigned lx, ly; lx = (unsigned) (log2 (wi->width - 1) + 1); ly = (unsigned) (log2 (wi->height - 1) + 1); wi->level = max (lx, ly) * 2 - ((ly == lx + 1) ? 1 : 0); } c = Calloc (1, sizeof (coding_t)); c->options = *options; c->options.lc_min_level = max (options->lc_min_level, 3); c->options.lc_max_level = min (options->lc_max_level, wi->level - 1); c->tiling = alloc_tiling (options->tiling_method, options->tiling_exponent, wi->level); if (wi->frames > 1 && c->tiling->exponent > 0) { c->tiling->exponent = 0; warning (_("Image tiling valid only with still image compression.")); } if (c->options.lc_max_level >= wi->level - c->tiling->exponent) { message ("'max_level' changed from %d to %d due to image tiling level.", c->options.lc_max_level, wi->level - c->tiling->exponent - 1); c->options.lc_max_level = wi->level - c->tiling->exponent - 1; } if (c->options.lc_min_level > c->options.lc_max_level) c->options.lc_min_level = c->options.lc_max_level; /* * p_min_level, p_max_level min and max level for ND/MC prediction * [p_min_level, p_max_level] must be a subset of [min_level, max_level] ! */ wi->p_min_level = max (options->p_min_level, c->options.lc_min_level); wi->p_max_level = min (options->p_max_level, c->options.lc_max_level); if (wi->p_min_level > wi->p_max_level) wi->p_min_level = wi->p_max_level; c->options.images_level = min (c->options.images_level, c->options.lc_max_level - 1); c->products_level = max (0, ((signed int) c->options.lc_max_level - (signed int) c->options.images_level - 1)); c->pixels = Calloc (size_of_level (c->options.lc_max_level), sizeof (real_t)); c->images_of_state = Calloc (MAXSTATES, sizeof (real_t *)); c->ip_images_state = Calloc (MAXSTATES, sizeof (real_t *)); c->ip_states_state = Calloc (MAXSTATES * MAXLEVEL, sizeof (real_t *)); debug_message ("Imageslevel :%d, Productslevel :%d", c->options.images_level, c->products_level); debug_message ("Memory : (%d + %d + %d * 'states') * 'states' + %d", size_of_tree (c->options.images_level) * 4, size_of_tree (c->products_level) * 4, (c->options.lc_max_level - c->options.images_level), size_of_level (c->options.lc_max_level)); /* * Domain pools ... */ c->domain_pool = NULL; c->d_domain_pool = NULL; /* * Coefficients model ... */ c->coeff = NULL; c->d_coeff = NULL; /* * Max. number of states and edges */ wi->max_states = max (min (options->max_states, MAXSTATES), 1); c->options.max_elements = max (min (options->max_elements, MAXEDGES), 1); /* * Title and comment strings */ wi->title = strdup (options->title); wi->comment = strdup (options->comment); /* * Reduced precision format */ wi->rpf = alloc_rpf (options->rpf_mantissa, options->rpf_range); wi->dc_rpf = alloc_rpf (options->dc_rpf_mantissa, options->dc_rpf_range); wi->d_rpf = alloc_rpf (options->d_rpf_mantissa, options->d_rpf_range); wi->d_dc_rpf = alloc_rpf (options->d_dc_rpf_mantissa, options->d_dc_rpf_range); /* * Color image options ... */ wi->chroma_max_states = max (1, options->chroma_max_states); /* * Set up motion compensation struct. * p_min_level, p_max_level are also used for ND prediction */ wi->search_range = options->search_range; wi->fps = options->fps; wi->half_pixel = options->half_pixel_prediction; wi->cross_B_search = options->half_pixel_prediction; wi->B_as_past_ref = options->B_as_past_ref; wi->smoothing = options->smoothing; c->mt = alloc_motion (wi); return c; } static void free_coder (coding_t *c) /* * Coder struct destructor: * Free memory of 'coder' struct. * * No return value. * * Side effects: * structure 'coder' is discarded. */ { free_tiling (c->tiling); free_motion (c->mt); Free (c->pixels); Free (c->images_of_state); Free (c->ip_images_state); Free (c->ip_states_state); Free (c); } static char * get_input_image_name (char const * const *templptr, unsigned ith_image) /* * Construct the i-th image-name using templates. * If the template contains a '[' it must be of the form * "prefix[start-end{+,-}step]suffix" * where "{+,-}step" is optional. * Leading zeros of "start" are significant. * * Example: * "image0[12-01-1].pgm" yields image012.pgm, image011.pgm, ..., image001.pgm * * Return value: * ptr to name of image 'ith_image' or NULL if ith_image is out of range. */ { while (*templptr) { const char *template = *templptr++; char *s; if (!(s = strchr (template, '['))) /* no template, just a filename */ { if (ith_image == 0) return strdup (template); else ith_image--; } else /* template parser */ { unsigned n_digits; /* # of digits in image name no. */ char *s2; char *suffix; /* characters after template end */ char prefix [MAXSTRLEN]; /* chars up to the template start */ unsigned first; /* first image number */ unsigned last; /* last image number */ int image_num; /* current image number */ int increment = 1; int dummy; strcpy (prefix, template); prefix [s - template] = '\0'; for (s2 = ++s, n_digits = 0; isdigit (*s2); s2++, n_digits++) ; if (sscanf (s, "%d", &dummy) == 0 || dummy < 0) error ("Input name template conversion failure.\n" "Check spelling of template."); first = (unsigned) dummy; if (*s2++ != '-') error ("Input name template conversion failure.\n" "Check spelling of template."); for (s = s2; isdigit (*s2); s2++) ; if (sscanf (s, "%d", &dummy) == 0 || dummy < 0) error ("Input name template conversion failure.\n" "Check spelling of template."); last = (unsigned) dummy; if (*s2 == '+' || *s2 == '-') { for (s = s2++; isdigit (*s2); s2++) ; if (sscanf (s, "%d", &increment) == 0) error ("Input name template conversion failure.\n" "Check spelling of template."); } if (*s2 != ']') error ("Input name template conversion failure.\n" "Check spelling of template."); suffix = s2 + 1; image_num = first + increment * ith_image; if (image_num < 0) error ("Input name template conversion failure.\n" "Check spelling of template."); if ((increment > 0 && (unsigned) image_num > last) || (increment <= 0 && (unsigned) image_num < last)) { /* TODO: check this */ ith_image -= (last - first) / increment + 1; } else { char formatstr [MAXSTRLEN]; /* format string for image filename */ char image_name [MAXSTRLEN]; /* image file name to be composed */ strcpy (formatstr, "%s%0?d%s"); formatstr [4] = '0' + (char) n_digits; sprintf (image_name, formatstr, prefix, image_num, suffix); return strdup (image_name); } } } return NULL; } static void video_coder (char const * const *image_template, bitfile_t *output, wfa_t *wfa, coding_t *c) /* * Toplevel function to encode a sequence of video frames specified * by 'image_template'. The output is written to stream 'output'. * Coding options are given by 'c'. * * No return value. */ { unsigned display; /* picture number in display order */ int future_display; /* number of future reference */ int frame; /* current frame number */ char *image_name; /* image name of current frame */ image_t *reconst = NULL; /* decoded reference image */ bool_t future_frame = NO; /* YES if last frame was in future */ debug_message ("Generating %d WFA's ...", wfa->wfainfo->frames); future_display = -1; frame = -1; display = 0; while ((image_name = get_input_image_name (image_template, display))) { frame_type_e type; /* current frame type: I, B, P */ /* * Determine type of next frame. * Skip already coded frames (future reference!) */ if (display == 0 && !c->options.reference_filename) type = I_FRAME; /* Force first frame to be intra */ else type = pattern2type (display, c->options.pattern); if (type != I_FRAME && c->options.reference_filename) /* Load reference from disk */ { debug_message ("Reading reference frame `%s'.", c->options.reference_filename); reconst = read_image (c->options.reference_filename); c->options.reference_filename = NULL; } if ((int) display == future_display) /* Skip already coded future ref */ { display++; continue; } else if (type == B_FRAME && (int) display > future_display) { unsigned i = display; /* * Search for future reference */ while (type == B_FRAME) { char *name; /* image name of future frame */ i++; name = get_input_image_name (image_template, i); if (!name) /* Force last valid frame to be 'P' */ { future_display = i - 1; type = P_FRAME; } else { future_display = i; image_name = name; type = pattern2type (i, c->options.pattern); } frame = future_display; } } else { frame = display; display++; } debug_message ("Coding \'%s\' [%c-frame].", image_name, type == I_FRAME ? 'I' : (type == P_FRAME ? 'P' : 'B')); /* * Depending on current frame type update past and future frames * which are needed as reference frames. */ c->mt->frame_type = type; if (type == I_FRAME) { if (c->mt->past) /* discard past frame */ free_image (c->mt->past); c->mt->past = NULL; if (c->mt->future) /* discard future frame */ free_image (c->mt->future); c->mt->future = NULL; if (reconst) /* discard current frame */ free_image (reconst); reconst = NULL; } else if (type == P_FRAME) { if (c->mt->past) /* discard past frame */ free_image (c->mt->past); c->mt->past = reconst; /* past frame <- current frame */ reconst = NULL; if (c->mt->future) /* discard future frame */ free_image (c->mt->future); c->mt->future = NULL; } else /* B_FRAME */ { if (future_frame) /* last frame was future frame */ { if (c->mt->future) /* discard future frame */ free_image (c->mt->future); c->mt->future = reconst; /* future frame <- current frame */ reconst = NULL; } else { if (wfa->wfainfo->B_as_past_ref == YES) { if (c->mt->past) /* discard past frame */ free_image (c->mt->past); c->mt->past = reconst; /* past frame <- current frame */ reconst = NULL; } else { if (reconst) /* discard current frame */ free_image (reconst); reconst = NULL; } } } /* * Start WFA coding of current frame */ future_frame = frame == future_display; c->mt->number = frame; c->mt->original = read_image (image_name); if (c->tiling->exponent && type == I_FRAME) perform_tiling (c->mt->original, c->tiling); frame_coder (wfa, c, output); /* * Regenerate image: * 1. Compute approximation of WFA ranges (real image bintree order) * 2. Generate byte image in rasterscan order * 3. Apply motion compensation */ reconst = decode_image (wfa->wfainfo->width, wfa->wfainfo->height, FORMAT_4_4_4, NULL, wfa); if (type != I_FRAME) restore_mc (0, reconst, c->mt->past, c->mt->future, wfa); if (c->mt->original) free_image (c->mt->original); c->mt->original = NULL; remove_states (wfa->basis_states, wfa); /* Clear WFA structure */ } if (reconst) free_image (reconst); if (c->mt->future) free_image (c->mt->future); if (c->mt->past) free_image (c->mt->past); if (c->mt->original) free_image (c->mt->original); } static frame_type_e pattern2type (unsigned frame, const char *pattern) { int tmp = toupper (pattern [frame % strlen (pattern)]); frame_type_e retval; switch (tmp) { case 'I': retval = I_FRAME; break; case 'B': retval = B_FRAME; break; case 'P': retval = P_FRAME; break; default: error ("Frame type %c not valid. Choose one of I,B or P.", tmp); retval = NONE; } return retval; } static void frame_coder (wfa_t *wfa, coding_t *c, bitfile_t *output) /* * * WFA Coding of next frame. All important coding parameters are * stored in 'c'. The generated 'wfa' is written to stream 'output' * immediately after coding. * * No return value. */ { unsigned state; range_t range; /* first range == the entire image */ real_t costs; /* total costs (minimized quantity) */ unsigned bits; /* number of bits written on disk */ clock_t ptimer; prg_timer (&ptimer, START); bits = bits_processed (output); init_tree_model (&c->tree); init_tree_model (&c->p_tree); c->domain_pool = alloc_domain_pool (c->options.id_domain_pool, wfa->wfainfo->max_states, c->options.max_elements, wfa); c->d_domain_pool = alloc_domain_pool ((c->options.prediction || c->mt->frame_type != I_FRAME) ? c->options.id_d_domain_pool : "constant", wfa->wfainfo->max_states, c->options.max_elements, wfa); c->coeff = alloc_coeff_model (c->options.id_rpf_model, wfa->wfainfo->rpf, wfa->wfainfo->dc_rpf, c->options.lc_min_level, c->options.lc_max_level); c->d_coeff = alloc_coeff_model (c->options.id_d_rpf_model, wfa->wfainfo->d_rpf, wfa->wfainfo->d_dc_rpf, c->options.lc_min_level, c->options.lc_max_level); if (!c->mt->original->color) /* grayscale image */ { memset (&range, 0, sizeof (range_t)); range.level = wfa->wfainfo->level; costs = subdivide (MAXCOSTS, GRAY, RANGE, &range, wfa, c, c->options.prediction || c->mt->frame_type != I_FRAME, NO); if (c->options.progress_meter != FIASCO_PROGRESS_NONE) message (""); if (isrange (range.tree)) /* entire image is approx. by lc? */ error ("No root state generated!"); else wfa->root_state = range.tree; print_statistics ('\0', costs, wfa, c->mt->original, &range); } else { int YCb_node = -1; int tree [3]; /* 3 root states of each color comp. */ color_e band; /* * When compressing color images, the three color components (YCbCr) * are copied into a large image: * [ Y Cr ] * [ Cb 0 ] * I.e. the color components of an image are processed in a row. * After all components are compressed, virtual states are generated * to describe the large image. */ for (band = first_band (YES); band <= last_band (YES) ; band++) { debug_message ("Encoding color component %d", band); tree [band] = RANGE; if (band == Cb) { unsigned min_level; c->domain_pool->chroma (wfa->wfainfo->chroma_max_states, wfa, c->domain_pool->model); /* * Don't use a finer partioning for the chrominancy bands than for * the luminancy band. */ for (min_level = MAXLEVEL, state = wfa->basis_states; state < wfa->states; state++) { unsigned lincomb, label; for (lincomb = 0, label = 0; label < MAXLABELS; label++) lincomb += isrange (wfa->tree [state][label]) ? 1 : 0; if (lincomb) min_level = min (min_level, (unsigned) (wfa->level_of_state [state] - 1)); } c->options.lc_min_level = min_level; if (c->mt->frame_type != I_FRAME) /* subtract mc of luminance */ subtract_mc (c->mt->original, c->mt->past, c->mt->future, wfa); } memset (&range, 0, sizeof (range_t)); range.level = wfa->wfainfo->level; costs = subdivide (MAXCOSTS, band, tree [Y], &range, wfa, c, c->mt->frame_type != I_FRAME && band == Y, NO); if (c->options.progress_meter != FIASCO_PROGRESS_NONE) message (""); { char colors [] = {'Y', 'B', 'R'}; print_statistics (colors [band], costs, wfa, c->mt->original, &range); } if (isrange (range.tree)) /* whole image is approx. by a l.c. */ error ("No root state generated for color component %d!", band); else tree[band] = range.tree; if (band == Cb) { wfa->tree [wfa->states][0] = tree[Y]; wfa->tree [wfa->states][1] = tree[Cb]; YCb_node = wfa->states; append_state (YES, compute_final_distribution (wfa->states, wfa), wfa->wfainfo->level + 1, wfa, c); } } /* * generate two virtual states (*) * * * * / \ * + * * / \ / * Y CbCr */ wfa->tree [wfa->states][0] = tree[Cr]; wfa->tree [wfa->states][1] = RANGE; append_state (YES, compute_final_distribution (wfa->states, wfa), wfa->wfainfo->level + 1, wfa, c); wfa->tree[wfa->states][0] = YCb_node; wfa->tree[wfa->states][1] = wfa->states - 1; append_state (YES, compute_final_distribution (wfa->states, wfa), wfa->wfainfo->level + 2, wfa, c); wfa->root_state = wfa->states - 1; } for (state = wfa->basis_states; state < MAXSTATES; state++) { unsigned level; if (c->images_of_state [state]) { Free (c->images_of_state [state]); c->images_of_state [state] = NULL; } if (c->ip_images_state [state]) { Free (c->ip_images_state [state]); c->ip_images_state [state] = NULL; } for (level = c->options.images_level + 1; level <= c->options.lc_max_level; level++) if (c->ip_states_state [state][level]) { Free (c->ip_states_state [state][level]); c->ip_states_state [state][level] = NULL; } } locate_delta_images (wfa); write_next_wfa (wfa, c, output); bits = bits_processed (output) - bits; debug_message ("Total number of bits written: %d (%d bytes, %5.3f bpp)", bits, bits >> 3, bits / (double) (c->mt->original->height * c->mt->original->width)); debug_message ("Total encoding time (real): %d sec", prg_timer (&ptimer, STOP) / 1000); c->domain_pool->free (c->domain_pool); c->d_domain_pool->free (c->d_domain_pool); c->coeff->free (c->coeff); c->d_coeff->free (c->d_coeff); } static void print_statistics (char c, real_t costs, const wfa_t *wfa, const image_t *image, const range_t *range) { unsigned max_level, min_level, state, label, lincomb; for (max_level = 0, min_level = MAXLEVEL, state = wfa->basis_states; state < wfa->states; state++) { for (lincomb = 0, label = 0; label < MAXLABELS; label++) lincomb += isrange(wfa->tree[state][label]) ? 1 : 0; if (lincomb) { max_level = max (max_level, (unsigned) (wfa->level_of_state [state] - 1)); min_level = min (min_level, (unsigned) (wfa->level_of_state [state] - 1)); } } debug_message ("Image partitioning: maximum level %d , minimum level %d", max_level, min_level); debug_message ("WFA contains %d states (%d basis states).", wfa->states, wfa->basis_states); debug_message ("Estimated error: %.2f (RMSE: %.2f, PSNR: %.2f dB).", (double) range->err, sqrt (range->err / image->width / image->height), 10 * log ( 255.0 * 255.0 / (range->err / image->width / image->height)) / log (10.0)); debug_message ("Estimated filesize: %.0f bits (%.0f bytes).", (double) (range->tree_bits + range->matrix_bits + range->weights_bits + range->mv_tree_bits + range->mv_coord_bits + range->nd_tree_bits + range->nd_weights_bits), (double) (range->tree_bits + range->matrix_bits + range->weights_bits + range->mv_tree_bits + range->mv_coord_bits + range->nd_tree_bits + range->nd_weights_bits) / 8); if (c) debug_message ("(%cT: %.0f, %cM: %.0f, %cW: %.0f, %cMC: %.0f, " "%cMV: %.0f, %cNT: %.0f, %cNW: %.0f.)", c, (double) range->tree_bits, c, (double) range->matrix_bits, c, (double) range->weights_bits, c, (double) range->mv_tree_bits, c, (double) range->mv_coord_bits, c, (double) range->nd_tree_bits, c, (double) range->nd_weights_bits); else debug_message ("(T: %.0f, M: %.0f, W: %.0f, MC: %.0f, MV: %.0f, " "NT: %.0f, NW: %.0f.)", (double) range->tree_bits, (double) range->matrix_bits, (double) range->weights_bits, (double) range->mv_tree_bits, (double) range->mv_coord_bits, (double) range->nd_tree_bits, (double) range->nd_weights_bits); debug_message ("Total costs : %.2f", (double) costs); } netpbm-free-10.0-1/pnm/fiasco/codec/coder.h0100644004714500471450000000063107716230207020703 0ustar aba-guestaba-guest/* * coder.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _CODER_H #define _CODER_H #include "types.h" #include "cwfa.h" #endif /* not _CODER_H */ netpbm-free-10.0-1/pnm/fiasco/codec/coeff.c0100644004714500471450000002456707725102161020677 0ustar aba-guestaba-guest/* * coeff.c: Matching pursuit coefficients probability model * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/09/02 11:52:17 $ * $Author: aba-guest $ * $Revision: 1.2 $ * $State: Exp $ */ #include #include "config.h" #include "types.h" #include "macros.h" #include "error.h" #include "rpf.h" #include "misc.h" #include "coeff.h" /* * Coefficient model interface: * Implementing the coefficients model interface requires the * following steps: * - Add a constructor that initializes the coeff_t structure * - Allocate new model with default_alloc() * - Fill the c_array_t coeff_models[] array with constructor and name * - Write code for methods bits() and update() * - Either use default functions for remaining methods or override them * The new model is automatically registered at the command line. */ /***************************************************************************** uniform distribution coefficients model *****************************************************************************/ static coeff_t * alloc_uniform_coeff_model (rpf_t *rpf, rpf_t *dc_rpf, unsigned min_level, unsigned max_level); static void uniform_update (const real_t *used_coeff, const word_t *used_states, unsigned level, coeff_t *coeff); static real_t uniform_bits (const real_t *used_coeff, const word_t *used_states, unsigned level, const coeff_t *coeff); /***************************************************************************** default functions *****************************************************************************/ static void default_model_free (void *model); static void * default_model_duplicate (const coeff_t *coeff, const void *model); static void default_free (coeff_t *coeff); static coeff_t * default_alloc (rpf_t *rpf, rpf_t *dc_rpf, unsigned min_level, unsigned max_level); /***************************************************************************** adaptive arithmetic coding model *****************************************************************************/ static coeff_t * alloc_aac_coeff_model (rpf_t *rpf, rpf_t *dc_rpf, unsigned min_level, unsigned max_level); static void aac_model_free (void *model); static void * aac_model_alloc (const coeff_t *coeff); static void * aac_model_duplicate (const coeff_t *coeff, const void *model); static void aac_update (const real_t *used_coeff, const word_t *used_states, unsigned level, coeff_t *coeff); static real_t aac_bits (const real_t *used_coeff, const word_t *used_states, unsigned level, const coeff_t *coeff); /***************************************************************************** public code *****************************************************************************/ typedef struct c_array { const char *identifier; coeff_t *(*function) (rpf_t *rpf, rpf_t *dc_rpf, unsigned min_level, unsigned max_level); } c_array_t; c_array_t coeff_models[] = {{"adaptive", alloc_aac_coeff_model}, {"uniform", alloc_uniform_coeff_model}, {NULL, NULL}}; coeff_t * alloc_coeff_model (const char *coeff_model_name, rpf_t *rpf, rpf_t *dc_rpf, unsigned min_level, unsigned max_level) /* * Allocate a new coefficients model which is identified by the string * 'coeff_model_name'. 'rpf' and 'dc_rpf' define the reduced * precision formats the should be used to quantize normal and DC * components, respectively. 'min_level' and 'max_level' define the * range of range approximations. * * Return value: * pointer to the allocated coefficients model * * Note: * Refer to 'coeff.h' for a short description of the member functions. */ { unsigned n; for (n = 0; coeff_models [n].identifier; n++) /* step through all id's */ if (strcaseeq (coeff_models [n].identifier, coeff_model_name)) return coeff_models [n].function (rpf, dc_rpf, min_level, max_level); warning ("Can't initialize coefficients model '%s'. " "Using default value '%s'.", coeff_model_name, coeff_models [0].identifier); return coeff_models [0].function (rpf, dc_rpf, min_level, max_level); } /***************************************************************************** private code *****************************************************************************/ /***************************************************************************** uniform distribution coefficients model *****************************************************************************/ static coeff_t * alloc_uniform_coeff_model (rpf_t *rpf, rpf_t *dc_rpf, unsigned min_level, unsigned max_level) /* * Underlying probability model: uniform distribution. * I.e. each coefficient is written as such with * (1 + exponent_bits + mantissa_bits) bits. */ { coeff_t *coeff = default_alloc (rpf, dc_rpf, min_level, max_level); coeff->bits = uniform_bits; coeff->update = uniform_update; return coeff; } static real_t uniform_bits (const real_t *used_coeff, const word_t *used_states, unsigned level, const coeff_t *coeff) { unsigned edge; real_t bits = 0; /* #bits to store coefficients */ for (edge = 0; isedge (used_states [edge]); edge++) { rpf_t *rpf = used_states [edge] ? coeff->rpf : coeff->dc_rpf; bits += rpf->mantissa_bits + 1; } return bits; } static void uniform_update (const real_t *used_coeff, const word_t *used_states, unsigned level, coeff_t *coeff) { return; /* nothing to do */ } /***************************************************************************** adaptive arithmetic coding model *****************************************************************************/ typedef struct aac_model { word_t *counts; word_t *totals; } aac_model_t; static coeff_t * alloc_aac_coeff_model (rpf_t *rpf, rpf_t *dc_rpf, unsigned min_level, unsigned max_level) /* * Underlying probability model: adaptive arithmetic coding using * the level of a range as context. */ { coeff_t *coeff = default_alloc (rpf, dc_rpf, min_level, max_level); coeff->bits = aac_bits; coeff->update = aac_update; coeff->model_free = aac_model_free; coeff->model_duplicate = aac_model_duplicate; coeff->model = aac_model_alloc (coeff); return coeff; } static real_t aac_bits (const real_t *used_coeff, const word_t *used_states, unsigned level, const coeff_t *coeff) { real_t bits = 0; /* # bits to store coefficients */ unsigned edge; int state; word_t *counts; aac_model_t *model = (aac_model_t *) coeff->model; counts = model->counts + (1 << (1 + coeff->dc_rpf->mantissa_bits)) + ((level - coeff->min_level) * (1 << (1 + coeff->rpf->mantissa_bits))); for (edge = 0; isedge (state = used_states [edge]); edge++) if (state) bits -= log2 (counts [rtob (used_coeff [edge], coeff->rpf)] / (real_t) model->totals [level - coeff->min_level + 1]); else bits -= log2 (model->counts [rtob (used_coeff [edge], coeff->dc_rpf)] / (real_t) model->totals [0]); return bits; } static void aac_update (const real_t *used_coeff, const word_t *used_states, unsigned level, coeff_t *coeff) { unsigned edge; int state; word_t *counts; aac_model_t *model = (aac_model_t *) coeff->model; counts = model->counts + (1 << (1 + coeff->dc_rpf->mantissa_bits)) + ((level - coeff->min_level) * (1 << (1 + coeff->rpf->mantissa_bits))); for (edge = 0; isedge (state = used_states [edge]); edge++) if (state) { counts [rtob (used_coeff [edge], coeff->rpf)]++; model->totals [level - coeff->min_level + 1]++; } else { model->counts [rtob (used_coeff [edge], coeff->dc_rpf)]++; model->totals [0]++; } } static void * aac_model_duplicate (const coeff_t *coeff, const void *model) { aac_model_t *src = (aac_model_t *) model; aac_model_t *dst = aac_model_alloc (coeff); memcpy (dst->counts, src->counts, sizeof (word_t) * ((coeff->max_level - coeff->min_level + 1) * (1 << (1 + coeff->rpf->mantissa_bits)) + (1 << (1 + coeff->dc_rpf->mantissa_bits)))); memcpy (dst->totals, src->totals, sizeof (word_t) * (coeff->max_level - coeff->min_level + 1 + 1)); return dst; } static void * aac_model_alloc (const coeff_t *coeff) { aac_model_t *model; unsigned size = (coeff->max_level - coeff->min_level + 1) * (1 << (1 + coeff->rpf->mantissa_bits)) + (1 << (1 + coeff->dc_rpf->mantissa_bits)); model = Calloc (1, sizeof (aac_model_t)); model->counts = Calloc (size, sizeof (word_t)); model->totals = Calloc (coeff->max_level - coeff->min_level + 1 + 1, sizeof (word_t)); /* * Initialize model */ { unsigned n; word_t *ptr = model->counts; for (n = size; n; n--) *ptr++ = 1; model->totals [0] = 1 << (1 + coeff->dc_rpf->mantissa_bits); for (n = coeff->min_level; n <= coeff->max_level; n++) model->totals [n - coeff->min_level + 1] = 1 << (1 + coeff->rpf->mantissa_bits); } return (void *) model; } static void aac_model_free (void *model) { aac_model_t *aac_model = (aac_model_t *) model; if (aac_model) { Free (aac_model->counts); Free (aac_model->totals); Free (aac_model); } } /***************************************************************************** default functions *****************************************************************************/ static coeff_t * default_alloc (rpf_t *rpf, rpf_t *dc_rpf, unsigned min_level, unsigned max_level) { coeff_t *coeff = Calloc (1, sizeof (coeff_t)); coeff->rpf = rpf; coeff->dc_rpf = dc_rpf; coeff->min_level = min_level; coeff->max_level = max_level; coeff->model = NULL; coeff->bits = NULL; coeff->update = NULL; coeff->free = default_free; coeff->model_free = default_model_free; coeff->model_duplicate = default_model_duplicate; return coeff; } static void default_free (coeff_t *coeff) { coeff->model_free (coeff->model); Free (coeff); } static void * default_model_duplicate (const coeff_t *coeff, const void *model) { return NULL; } static void default_model_free (void *model) { if (model) Free (model); } netpbm-free-10.0-1/pnm/fiasco/codec/coeff.h0100644004714500471450000000324707716230207020677 0ustar aba-guestaba-guest/* * coeff.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _COEFF_H #define _COEFF_H #include "types.h" #include "rpf.h" #include "wfa.h" typedef struct coeff { rpf_t *rpf; /* reduced precision format */ rpf_t *dc_rpf; /* RPF of DC (state 0) component */ unsigned min_level, max_level; /* allocate memory for [min,..,max] */ void *model; /* generic pointer to prob. model */ real_t (*bits) (const real_t *used_coeff, const word_t *used_domains, unsigned level, const struct coeff *coeff); /* * Compute bit-rate of a range approximation with coefficients given by * -1 terminated list 'used_domains'. */ void (*update) (const real_t *used_coeff, const word_t *used_domains, unsigned level, struct coeff *coeff); /* * Update the probability model according to the chosen approximation. * (given by the -1 terminated list 'used_domains'). */ void (*free) (struct coeff *coeff); /* * Discard the given coefficients struct. */ void (*model_free) (void *model); /* * Free given probability model. */ void *(*model_duplicate) (const struct coeff *coeff, const void *model); /* * Duplicate the given probability model (i.e. alloc and copy). */ } coeff_t; coeff_t * alloc_coeff_model (const char *coeff_model_name, rpf_t *rpf, rpf_t *dc_rpf, unsigned min_level, unsigned max_level); #endif /* not _COEFF_H */ netpbm-free-10.0-1/pnm/fiasco/codec/control.c0100644004714500471450000001640107716230207021264 0ustar aba-guestaba-guest/* * control.c: Control unit of WFA structure * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #if HAVE_STRING_H # include #else /* not HAVE_STRING_H */ # include #endif /* not HAVE_STRING_H */ #include "types.h" #include "macros.h" #include "error.h" #include "cwfa.h" #include "ip.h" #include "misc.h" #include "wfalib.h" #include "control.h" /***************************************************************************** prototypes *****************************************************************************/ static void clear_or_alloc (real_t **ptr, size_t size); static void compute_images (unsigned from, unsigned to, const wfa_t *wfa, coding_t *c); /***************************************************************************** public code *****************************************************************************/ void append_state (bool_t auxiliary_state, real_t final, unsigned level_of_state, wfa_t *wfa, coding_t *c) /* * Append a 'wfa' state. If 'auxiliary_state' == YES then * allocate memory for inner products and state images. 'final' is * the final distribution of the new state. 'level_of_state' is the * level of the subimage which is represented by this state * * No return value. * * Side effects: * The WFA information are updated in structure 'wfa' * State images are computed and inner products are cleared (in 'c') */ { wfa->final_distribution [wfa->states] = final; wfa->level_of_state [wfa->states] = level_of_state; if (!auxiliary_state) { unsigned level; wfa->domain_type [wfa->states] = USE_DOMAIN_MASK; /* * Allocate memory for inner products and for state images */ clear_or_alloc (&c->images_of_state [wfa->states], size_of_tree (c->options.images_level)); for (level = c->options.images_level + 1; level <= c->options.lc_max_level; level++) clear_or_alloc (&c->ip_states_state [wfa->states][level], wfa->states + 1); clear_or_alloc (&c->ip_images_state [wfa->states], size_of_tree (c->products_level)); /* * Compute the images of the current state at level 0,..,'imageslevel' */ c->images_of_state [wfa->states][0] = final; compute_images (wfa->states, wfa->states, wfa, c); /* * Compute the inner products between the current state and the * old states 0,...,'states'-1 */ compute_ip_states_state (wfa->states, wfa->states, wfa, c); } else { unsigned level; wfa->domain_type [wfa->states] = 0; /* * Free the allocated memory */ if (c->images_of_state [wfa->states] != NULL) { Free (c->images_of_state [wfa->states]); c->images_of_state [wfa->states] = NULL; } for (level = 0; level <= c->options.lc_max_level; level++) if (c->ip_states_state [wfa->states][level]) { Free (c->ip_states_state [wfa->states][level]); c->ip_states_state [wfa->states][level] = NULL; } if (c->ip_images_state [wfa->states]) { Free (c->ip_images_state [wfa->states]); c->ip_images_state [wfa->states] = NULL; } } wfa->states++; if (wfa->states >= MAXSTATES) error ("Maximum number of states reached!"); } void append_basis_states (unsigned basis_states, wfa_t *wfa, coding_t *c) /* * Append the WFA basis states 0, ... , ('basis_states' - 1). * * No return value. * * Side effects: * The WFA information are updated in structure 'wfa' * State images and inner products are computed (in 'c') */ { unsigned level, state; /* * Allocate memory */ for (state = 0; state < basis_states; state++) { clear_or_alloc (&c->images_of_state [state], size_of_tree (c->options.images_level)); for (level = c->options.images_level + 1; level <= c->options.lc_max_level; level++) clear_or_alloc (&c->ip_states_state [state][level], state + 1); clear_or_alloc (&c->ip_images_state [state], size_of_tree (c->products_level)); c->images_of_state [state][0] = wfa->final_distribution [state]; wfa->level_of_state [state] = -1; } compute_images (0, basis_states - 1, wfa, c); compute_ip_states_state (0, basis_states - 1, wfa, c); wfa->states = basis_states; if (wfa->states >= MAXSTATES) error ("Maximum number of states reached!"); } void append_transitions (unsigned state, unsigned label, const real_t *weight, const word_t *into, wfa_t *wfa) /* * Append the 'wfa' transitions (given by the arrays 'weight' and 'into') * of the range ('state','label'). * * No return value. * * Side effects: * new 'wfa' edges are appended */ { unsigned edge; wfa->y_column [state][label] = 0; for (edge = 0; isedge (into [edge]); edge++) { append_edge (state, into [edge], weight [edge], label, wfa); if (into [edge] == wfa->y_state [state][label]) wfa->y_column [state][label] = 1; } } /***************************************************************************** private code *****************************************************************************/ static void compute_images (unsigned from, unsigned to, const wfa_t *wfa, coding_t *c) /* * Computes the images of the given states 'from', ... , 'to' * at level 0,...,'c->imagelevel'. * Uses the fact that each state image is a linear combination of state * images, i.e. s_i := c_0 s_0 + ... + c_i s_i. */ { unsigned label, level, state; /* * Compute the images Phi(state) * # level = 0 * ## level = 1 * #### level = 2 * ######## level = 3 * ... * ########...## level = imageslevel */ for (level = 1; level <= c->options.images_level; level++) for (state = from; state <= to; state++) for (label = 0; label < MAXLABELS; label++) { real_t *dst, *src; unsigned edge; int domain; /* current domain */ if (ischild (domain = wfa->tree[state][label])) { dst = c->images_of_state [state] + address_of_level (level) + label * size_of_level (level - 1); src = c->images_of_state [domain] + address_of_level (level - 1); memcpy (dst, src, size_of_level (level - 1) * sizeof (real_t)); } for (edge = 0; isedge (domain = wfa->into[state][label][edge]); edge++) { unsigned n; real_t weight = wfa->weight [state][label][edge]; dst = c->images_of_state [state] + address_of_level (level) + label * size_of_level (level - 1); src = c->images_of_state [domain] + address_of_level (level - 1); for (n = size_of_level (level - 1); n; n--) *dst++ += *src++ * weight; } } } static void clear_or_alloc (real_t **ptr, size_t size) /* * if *ptr == NULL allocate memory with Calloc * otherwise fill the real_t-array ptr[] with 0 */ { if (*ptr == NULL) *ptr = Calloc (size, sizeof (real_t)); else memset (*ptr, 0, size * sizeof (real_t)); } netpbm-free-10.0-1/pnm/fiasco/codec/control.h0100644004714500471450000000133407716230207021270 0ustar aba-guestaba-guest/* * control.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _CONTROL_H #define _CONTROL_H #include "cwfa.h" #include "types.h" void append_transitions (unsigned state, unsigned label, const real_t *weight, const word_t *into, wfa_t *wfa); void append_basis_states (unsigned basis_states, wfa_t *wfa, coding_t *c); void append_state (bool_t auxiliary_state, real_t final, unsigned level_of_state, wfa_t *wfa, coding_t *c); #endif /* not _CONTROL_H */ netpbm-free-10.0-1/pnm/fiasco/codec/cwfa.h0100644004714500471450000000705007716230207020531 0ustar aba-guestaba-guest/* * cwfa.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _CWFA_H #define _CWFA_H #include "wfa.h" #include "types.h" #include "tiling.h" #include "rpf.h" #include "domain-pool.h" #include "bintree.h" #include "coeff.h" #include "list.h" #include "wfalib.h" #include "options.h" extern const real_t MAXCOSTS; typedef struct motion { image_t *original; /* Current image */ image_t *past; /* Preceeding image */ image_t *future; /* Succeeding image */ frame_type_e frame_type; /* frame type: B_, P_ I_FRAME */ unsigned number; /* display number of frame */ real_t *xbits; /* # bits for mv x-component */ real_t *ybits; /* # bits for mv y-component */ real_t **mc_forward_norms; /* norms of mcpe */ real_t **mc_backward_norms; /* norms of mcpe */ } motion_t; typedef struct range /* * Information about current range in the original image. * Approximation data (error, encoding bits, approximation type and factors * of the linear combination) are also saved. */ { unsigned global_address; /* We need absolute image addresses for distance calculations. */ unsigned x, y; /* Coordinates of upper left corner */ unsigned image; /* Position in the tree */ unsigned address; /* Address of the pixel data */ unsigned level; /* Level of the range */ real_t weight [MAXEDGES + 1]; /* coeff. of the approximation */ word_t into [MAXEDGES + 1]; /* used domains of the approximation */ int tree; /* == domain : range is approximated with new state 'domain' == RANGE : with a linear comb. */ real_t err; /* approximation error */ real_t tree_bits; /* # bits to encode tree */ real_t matrix_bits; /* # bits to encode matrices */ real_t weights_bits; /* # bits to encode weights */ mv_t mv; /* motion vector */ real_t mv_tree_bits; /* # bits to encode mv tree */ real_t mv_coord_bits; /* # bits to encode mv coordinates */ real_t nd_tree_bits; /* # bits to encode nd tree */ real_t nd_weights_bits; /* # bits to encode nd factors */ bool_t prediction; /* range is predicted? */ } range_t; typedef struct coding /* * All parameters and variables that must be accessible through the coding * process. */ { real_t price; /* determines quality of approx. */ real_t **images_of_state; /* image of state i at level 0, ... , imageslevel */ real_t *(*ip_states_state)[MAXLEVEL]; /* inner products between state i and states 0, ... , i at all image levels */ real_t **ip_images_state; /* inner products between all ranges and state i */ real_t *pixels; /* current image pixels stored in tree order (only leaves are stored) */ unsigned products_level; /* inner products are stored up to this level */ tiling_t *tiling; /* tiling of the entire image */ tree_t tree; /* probability model */ tree_t p_tree; /* prediction probability model */ motion_t *mt; /* motion compensation information */ coeff_t *coeff; coeff_t *d_coeff; domain_pool_t *domain_pool; domain_pool_t *d_domain_pool; c_options_t options; /* global options */ } coding_t; #endif /* not _CWFA_H */ netpbm-free-10.0-1/pnm/fiasco/codec/decoder.c0100644004714500471450000012651107716230207021215 0ustar aba-guestaba-guest/* * decode.c: Decoding of an image represented by a WFA * * Written by: Ullrich Hafner * Michael Unger * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #if HAVE_STRING_H # include #else /* not HAVE_STRING_H */ # include #endif /* not HAVE_STRING_H */ #include "types.h" #include "macros.h" #include "error.h" #include "wfa.h" #include "image.h" #include "misc.h" #include "motion.h" #include "read.h" #include "wfalib.h" #include "decoder.h" /***************************************************************************** prototypes *****************************************************************************/ static void compute_state_images (unsigned frame_level, word_t **simg, const u_word_t *offset, const wfa_t *wfa); static void free_state_images (unsigned max_level, bool_t color, word_t **state_image, u_word_t *offset, const unsigned *root_state, unsigned range_state, format_e format, const wfa_t *wfa); static void alloc_state_images (word_t ***images, u_word_t **offsets, const image_t *frame, const unsigned *root_state, unsigned range_state, unsigned max_level, format_e format, const wfa_t *wfa); static void compute_actual_size (unsigned luminance_root, unsigned *width, unsigned *height, const wfa_t *wfa); static void enlarge_image (int enlarge_factor, format_e format, unsigned y_root, wfa_t *wfa); static word_t * duplicate_state_image (const word_t *domain, unsigned offset, unsigned level); /***************************************************************************** public code *****************************************************************************/ video_t * alloc_video (bool_t store_wfa) /* * Video struct constructor: * Initialize video structure and allocate memory for current, past * and future WFA if flag 'store_wfa' is TRUE. * * Return value: * pointer to the new video structure */ { video_t *video = Calloc (1, sizeof (video_t)); video->future_display = -1; video->display = 0; video->future = video->sfuture = video->past = video->frame = video->sframe = NULL; if (store_wfa) { video->wfa = alloc_wfa (NO); video->wfa_past = alloc_wfa (NO); video->wfa_future = alloc_wfa (NO); } else video->wfa = video->wfa_past = video->wfa_future = NULL; return video; } void free_video (video_t *video) /* * Video struct destructor: * Free memory of given 'video' struct. * * No return value. * * Side effects: * 'video' struct is discarded. */ { if (video->past) free_image (video->past); if (video->future) free_image (video->future); if (video->sfuture) free_image (video->sfuture); if (video->frame) free_image (video->frame); if (video->sframe) free_image (video->sframe); if (video->wfa) free_wfa (video->wfa); if (video->wfa_past) free_wfa (video->wfa_past); if (video->wfa_future) free_wfa (video->wfa_future); Free (video); } image_t * get_next_frame (bool_t store_wfa, int enlarge_factor, int smoothing, const char *reference_frame, format_e format, video_t *video, dectimer_t *timer, wfa_t *orig_wfa, bitfile_t *input) /* * Get next frame of the WFA 'video' from stream 'input'. * 'orig_wfa' is the constant part of the WFA used by all frames. * Depending on values of 'enlarge_factor' and 'smoothing' enlarge and * smooth image, respectively. * If 'store_wfa' is TRUE, then store WFA structure of reference frames * (used by analysis tool xwfa). * If 'reference_frame' is not NULL, then load image 'reference_frame' * from disk. * 'format' gives the color format to be used (either 4:2:0 or 4:4:4). * If 'timer' is not NULL, then accumulate running time statistics. * * Return value: * pointer to decoded frame * * Side effects: * 'video' and 'timer' struct are modified. */ { image_t *frame = NULL; /* current frame */ image_t *sframe = NULL; /* current smoothed frame */ bool_t current_frame_is_future_frame = NO; if (video->future_display == video->display) { /* * Future frame is already computed since it has been used * as reference frame. So just return the stored frame. */ if (video->frame) /* discard current frame */ free_image (video->frame); video->frame = video->future; video->future = NULL; if (video->sframe) /* discard current (smoothed) frame */ free_image (video->sframe); video->sframe = video->sfuture; video->sfuture = NULL; if (store_wfa) copy_wfa (video->wfa, video->wfa_future); video->display++; if (!store_wfa) video->wfa = NULL; } else { do /* compute next frame(s) */ { unsigned frame_number; /* current frame number */ clock_t ptimer; unsigned int stop_timer [3]; wfa_t *tmp_wfa = NULL; if (!store_wfa) video->wfa = orig_wfa; else { tmp_wfa = alloc_wfa (NO); copy_wfa (tmp_wfa, video->wfa); copy_wfa (video->wfa, orig_wfa); } /* * First step: read WFA from disk */ prg_timer (&ptimer, START); frame_number = read_next_wfa (video->wfa, input); stop_timer [0] = prg_timer (&ptimer, STOP); if (timer) { timer->input [video->wfa->frame_type] += stop_timer [0]; timer->frames [video->wfa->frame_type]++; } /* * Read reference frame from disk if required * (i.e., 1st frame is of type B or P) */ if (video->display == 0 && video->wfa->frame_type != I_FRAME) { if (!reference_frame) error ("First frame is %c-frame but no " "reference frame is given.", video->wfa->frame_type == B_FRAME ? 'B' : 'P'); video->frame = read_image (reference_frame); video->sframe = NULL; } /* * Depending on current frame type update past and future frames */ if (video->wfa->frame_type == I_FRAME) { if (video->past) /* discard past frame */ free_image (video->past); video->past = NULL; if (video->future) /* discard future frame */ free_image (video->future); video->future = NULL; if (video->sfuture) /* discard (smoothed) future frame */ free_image (video->sfuture); video->sfuture = NULL; if (video->frame) /* discard current frame */ free_image (video->frame); video->frame = NULL; if (video->sframe) /* discard current (smoothed) frame */ free_image (video->sframe); video->sframe = NULL; } else if (video->wfa->frame_type == P_FRAME) { if (video->past) /* discard past frame */ free_image (video->past); video->past = video->frame; /* past <- current frame */ video->frame = NULL; if (video->sframe) /* discard current (smoothed) frame */ free_image (video->sframe); video->sframe = NULL; if (store_wfa) copy_wfa (video->wfa_past, tmp_wfa); if (video->future) /* discard future frame */ free_image (video->future); video->future = NULL; if (video->sfuture) /* discard (smoothed) future frame */ free_image (video->sfuture); video->sfuture = NULL; } else /* B_FRAME */ { if (current_frame_is_future_frame) { if (video->future) /* discard future frame */ free_image (video->future); video->future = frame; /* future <- current frame */ if (video->sfuture) /* discard (smoothed) future frame */ free_image (video->sfuture); video->sfuture = sframe; /* future <- current (smoothed) */ if (store_wfa) copy_wfa (video->wfa_future, tmp_wfa); if (video->frame) /* discard current frame */ free_image (video->frame); video->frame = NULL; if (video->sframe) /* discard current (smoothed) frame */ free_image (video->sframe); video->sframe = NULL; frame = NULL; sframe = NULL; } else { if (video->wfa->wfainfo->B_as_past_ref == YES) { if (video->past) /* discard past frame */ free_image (video->past); video->past = video->frame; /* past <- current frame */ video->frame = NULL; if (video->sframe) /* discard current (smoothed) frame */ free_image (video->sframe); video->sframe = NULL; if (store_wfa) copy_wfa (video->wfa_past, tmp_wfa); } else { if (video->frame) /* discard current */ free_image (video->frame); video->frame = NULL; if (video->sframe) /* discard current (smoothed) frame */ free_image (video->sframe); video->sframe = NULL; } } } if (tmp_wfa) free_wfa (tmp_wfa); current_frame_is_future_frame = NO; /* * Second step: decode image * Optionally enlarge image if specified by option 'enlarge_factor'. */ { unsigned orig_width, orig_height; stop_timer [0] = stop_timer [1] = stop_timer [2] = 0; enlarge_image (enlarge_factor, format, (video->wfa->wfainfo->color && format == FORMAT_4_2_0) ? video->wfa->tree [video->wfa->tree [video->wfa->root_state][0]][0] : -1, video->wfa); if (enlarge_factor > 0) { orig_width = video->wfa->wfainfo->width << enlarge_factor; orig_height = video->wfa->wfainfo->height << enlarge_factor; } else { orig_width = video->wfa->wfainfo->width >> - enlarge_factor; orig_height = video->wfa->wfainfo->height >> - enlarge_factor; if (orig_width & 1) orig_width++; if (orig_height & 1) orig_height++; } frame = decode_image (orig_width, orig_height, format, timer != NULL ? stop_timer : NULL, video->wfa); if (timer) { timer->preprocessing [video->wfa->frame_type] += stop_timer [0]; timer->decoder [video->wfa->frame_type] += stop_timer [1]; timer->cleanup [video->wfa->frame_type] += stop_timer [2]; } } /* * Third step: restore motion compensation */ if (video->wfa->frame_type != I_FRAME) { prg_timer (&ptimer, START); restore_mc (enlarge_factor, frame, video->past, video->future, video->wfa); stop_timer [0] = prg_timer (&ptimer, STOP); if (timer) timer->motion [video->wfa->frame_type] += stop_timer [0]; } /* * Fourth step: smooth image along partitioning borders */ prg_timer (&ptimer, START); if (smoothing < 0) /* smoothing not changed by user */ smoothing = video->wfa->wfainfo->smoothing; if (smoothing > 0 && smoothing <= 100) { sframe = clone_image (frame); smooth_image (smoothing, video->wfa, sframe); } else sframe = NULL; stop_timer [0] = prg_timer (&ptimer, STOP); if (timer) timer->smooth [video->wfa->frame_type] += stop_timer [0]; if (frame_number == video->display) { video->display++; video->frame = frame; video->sframe = sframe; frame = NULL; sframe = NULL; } else if (frame_number > video->display) { video->future_display = frame_number; current_frame_is_future_frame = YES; } if (!store_wfa) remove_states (video->wfa->basis_states, video->wfa); } while (!video->frame); if (!store_wfa) video->wfa = NULL; } return video->sframe ? video->sframe : video->frame; } image_t * decode_image (unsigned orig_width, unsigned orig_height, format_e format, unsigned *dec_timer, const wfa_t *wfa) /* * Compute image which is represented by the given 'wfa'. * 'orig_width'x'orig_height' gives the resolution of the image at * coding time. Use 4:2:0 subsampling or 4:4:4 'format' for color images. * If 'dec_timer' is given, accumulate running time statistics. * * Return value: * pointer to decoded image * * Side effects: * '*dectimer' is changed if 'dectimer' != NULL. */ { unsigned root_state [3]; /* root of bintree for each band */ unsigned width, height; /* computed image size */ image_t *frame; /* regenerated frame */ word_t **images; /* pointer to array of pointers to state images */ u_word_t *offsets; /* pointer to array of state image offsets */ unsigned max_level; /* max. level of state with approx. */ unsigned state; clock_t ptimer; prg_timer (&ptimer, START); /* * Compute root of bintree for each color band */ if (wfa->wfainfo->color) { root_state [Y] = wfa->tree [wfa->tree [wfa->root_state][0]][0]; root_state [Cb] = wfa->tree [wfa->tree [wfa->root_state][0]][1]; root_state [Cr] = wfa->tree [wfa->tree [wfa->root_state][1]][0]; } else root_state [GRAY] = wfa->root_state; /* * Compute maximum level of a linear combination */ for (max_level = 0, state = wfa->basis_states; state < wfa->states; state++) if (isedge (wfa->into [state][0][0]) || isedge (wfa->into [state][1][0])) max_level = max (max_level, wfa->level_of_state [state]); /* * Allocate frame buffer for decoded image */ compute_actual_size (format == FORMAT_4_2_0 ? root_state [Y] : MAXSTATES, &width, &height, wfa); width = max (width, orig_width); height = max (height, orig_height); frame = alloc_image (width, height, wfa->wfainfo->color, format); /* * Allocate buffers for intermediate state images */ if (wfa->wfainfo->color) { wfa->level_of_state [wfa->root_state] = 128; wfa->level_of_state [wfa->tree[wfa->root_state][0]] = 128; wfa->level_of_state [wfa->tree[wfa->root_state][1]] = 128; } alloc_state_images (&images, &offsets, frame, root_state, 0, max_level, format, wfa); if (dec_timer) dec_timer [0] += prg_timer (&ptimer, STOP); /* * Decode all state images, forming the complete image. */ prg_timer (&ptimer, START); compute_state_images (max_level, images, offsets, wfa); if (dec_timer) dec_timer [1] += prg_timer (&ptimer, STOP); /* * Cleanup buffers used for intermediate state images */ prg_timer (&ptimer, START); free_state_images (max_level, frame->color, images, offsets, root_state, 0, format, wfa); /* * Crop decoded image if the image size differs. */ if (orig_width != width || orig_height != height) { frame->height = orig_height; frame->width = orig_width; if (orig_width != width) { color_e band; /* current color band */ word_t *src, *dst; /* source and destination pointers */ unsigned y; /* current row */ for (band = first_band (frame->color); band <= last_band (frame->color); band++) { src = dst = frame->pixels [band]; for (y = orig_height; y; y--) { memmove (dst, src, orig_width * sizeof (word_t)); dst += orig_width; src += width; } if (format == FORMAT_4_2_0 && band == Y) { orig_width >>= 1; orig_height >>= 1; width >>= 1; } } } } if (dec_timer) dec_timer [2] += prg_timer (&ptimer, STOP); return frame; } image_t * decode_state (unsigned state, unsigned level, wfa_t *wfa) /* * Decode 'state' image of 'wfa' at given 'level'. * * Return value. * pointer to decoded state image * * Side effects: * 'wfa' states > 'state' are removed. */ { word_t *domains [2]; image_t *img = Calloc (1, sizeof (image_t)); /* * Generate a new state with a 1.0 transition to 'state' */ remove_states (state + 1, wfa); append_edge (state + 1, state, 1.0, 0, wfa); wfa->states = state + 2; img->color = NO; img->width = width_of_level (level); img->height = height_of_level (level); img->format = FORMAT_4_4_4; img->pixels [GRAY] = decode_range (state + 1, 0, level, domains, wfa); /* * Copy decoded range to the frame buffer */ { word_t *src, *dst; unsigned y; src = domains [0]; dst = img->pixels [GRAY]; for (y = img->height; y; y--) { memcpy (dst, src, width_of_level (level) * sizeof (word_t)); src += width_of_level (level); dst += img->width; } Free (domains [0]); } return img; } word_t * decode_range (unsigned range_state, unsigned range_label, unsigned range_level, word_t **domain, wfa_t *wfa) /* * Compute 'wfa' image of range (identified by 'state' and 'label') * at 'range_level (works as function decode_image()). * * Return value: * pointer to the pixels in SHORT format * * Side effects: * if 'domain' != NULL then also the domain blocks * of the corresponding range blocks are generated * and returned in domain[] * 'wfa->level_of_state []' is changed */ { unsigned root_state [3]; /* dummy (for alloc_state_images) */ image_t *state_image; /* regenerated state image */ word_t **images; /* pointer to array of pointers to state images */ u_word_t *offsets; /* pointer to array of state image offsets */ word_t *range; enlarge_image (range_level - (wfa->level_of_state [range_state] - 1), FORMAT_4_4_4, -1, wfa); root_state [0] = range_state; state_image = alloc_image (width_of_level (range_level + 1), height_of_level (range_level + 1), NO, FORMAT_4_4_4); alloc_state_images (&images, &offsets, state_image, NULL, range_state, range_level + 1, NO, wfa); compute_state_images (range_level + 1, images, offsets, wfa); range = Calloc (size_of_level (range_level), sizeof (word_t)); if ((range_level & 1) == 0) /* square image */ { memcpy (range, images [range_state + (range_level + 1) * wfa->states] + range_label * size_of_level (range_level), size_of_level (range_level) * sizeof (word_t)); } else /* rectangle */ { word_t *src, *dst; unsigned y; src = images [range_state + (range_level + 1) * wfa->states] + range_label * width_of_level (range_level); dst = range; for (y = height_of_level (range_level); y; y--) { memcpy (dst, src, width_of_level (range_level) * sizeof (word_t)); dst += width_of_level (range_level); src += width_of_level (range_level + 1); } } if (domain != NULL) /* copy domain images */ { int s; /* domain state */ unsigned edge; /* counter */ if (ischild (s = wfa->tree [range_state][range_label])) *domain++ = duplicate_state_image (images [s + (range_level) * wfa->states], offsets [s + (range_level) * wfa->states], range_level); for (edge = 0; isedge (s = wfa->into[range_state][range_label][edge]); edge++) *domain++ = duplicate_state_image (images [s + (range_level) * wfa->states], offsets [s + (range_level) * wfa->states], range_level); *domain = NULL; } free_state_images (range_level + 1, NO, images, offsets, NULL, range_state, NO, wfa); free_image (state_image); return range; } void smooth_image (unsigned sf, const wfa_t *wfa, image_t *image) /* * Smooth 'image' along the partitioning boundaries of the 'wfa' * with factor 's'. * * No return value. * * Side effects: * pixel values of the 'image' are modified with respect to 's' */ { int is, inegs; /* integer factors of s and 1 - s*/ unsigned state; unsigned img_width = image->width; unsigned img_height = image->height; real_t s = 1.0 - sf / 200.0; if (s < 0.5 || s >= 1) /* value out of range */ return; is = s * 512 + .5; /* integer representation of s */ inegs = (1 - s) * 512 + .5; /* integer representation of 1 - s */ for (state = wfa->basis_states; state < (wfa->wfainfo->color ? wfa->tree [wfa->root_state][0] : wfa->states); state++) { word_t *bptr = image->pixels [Y]; /* pointer to right or lower line */ unsigned level = wfa->level_of_state[state]; /* level of state image */ unsigned width = width_of_level (level); /* size of state image */ unsigned height = height_of_level (level); /* size of state image */ if (wfa->y [state][1] >= img_height || wfa->x [state][1] >= img_width) continue; /* outside visible area */ if (level % 2) /* horizontal smoothing */ { unsigned i; /* line counter */ word_t *img1; /* pointer to left or upper line */ word_t *img2; /* pointer to right or lower line */ img1 = bptr + (wfa->y [state][1] - 1) * img_width + wfa->x [state][1]; img2 = bptr + wfa->y [state][1] * img_width + wfa->x [state][1]; for (i = min (width, img_width - wfa->x [state][1]); i; i--, img1++, img2++) { int tmp = *img1; #ifdef HAVE_SIGNED_SHIFT *img1 = (((is * tmp) >> 10) << 1) + (((inegs * (int) *img2) >> 10) << 1); *img2 = (((is * (int) *img2) >> 10) << 1) + (((inegs * tmp) >> 10) << 1); #else /* not HAVE_SIGNED_SHIFT */ *img1 = (((is * tmp) / 1024) * 2) + (((inegs * (int) *img2) / 1024) * 2); *img2 = (((is * (int) *img2) / 1024) * 2) + (((inegs * tmp) / 1024) *2); #endif /* not HAVE_SIGNED_SHIFT */ } } else /* vertical smoothing */ { unsigned i; /* line counter */ word_t *img1; /* pointer to left or upper line */ word_t *img2; /* pointer to right or lower line */ img1 = bptr + wfa->y [state][1] * img_width + wfa->x [state][1] - 1; img2 = bptr + wfa->y [state][1] * img_width + wfa->x [state][1]; for (i = min (height, img_height - wfa->y [state][1]); i; i--, img1 += img_width, img2 += img_width) { int tmp = *img1; #ifdef HAVE_SIGNED_SHIFT *img1 = (((is * tmp) >> 10) << 1) + (((inegs * (int) *img2) >> 10) << 1); *img2 = (((is * (int) *img2) >> 10) << 1) + (((inegs * tmp) >> 10) << 1); #else /* not HAVE_SIGNED_SHIFT */ *img1 = (((is * tmp) / 1024) * 2) + (((inegs * (int) *img2) / 1024) * 2); *img2 = (((is * (int) *img2) / 1024) * 2) + (((inegs * tmp) / 1024) *2); #endif /* not HAVE_SIGNED_SHIFT */ } } } } /***************************************************************************** private code *****************************************************************************/ static void enlarge_image (int enlarge_factor, format_e format, unsigned y_root, wfa_t *wfa) /* * Enlarge or reduce size of state images by factor 2^'enlarge_factor'. * Use 4:2:0 subsampling if specified by 'format', else use 4:4:4 format. * 'wfa' root state of the first chroma band is given by 'y_root' + 1. * * No return value. * * Side effects: * coordinates of ranges and motion blocks in the WFA structure 'wfa' * are modified. */ { if (enlarge_factor != 0 || format == FORMAT_4_2_0) { unsigned state; if (enlarge_factor == 0) { state = y_root + 1; enlarge_factor = -1; } else state = wfa->basis_states; for (; state < wfa->states; state++) { unsigned label, n; wfa->level_of_state [state] = max (wfa->level_of_state [state] + enlarge_factor * 2, 0); for (label = 0; label < MAXLABELS; label++) if (enlarge_factor > 0) { wfa->x [state][label] <<= enlarge_factor; wfa->y [state][label] <<= enlarge_factor; for (n = enlarge_factor; n; n--) { wfa->mv_tree [state][label].fx *= 2; wfa->mv_tree [state][label].fy *= 2; wfa->mv_tree [state][label].bx *= 2; wfa->mv_tree [state][label].by *= 2; } } else /* enlarge_factor < 0 */ { wfa->x [state][label] >>= - enlarge_factor; wfa->y [state][label] >>= - enlarge_factor; for (n = - enlarge_factor; n; n--) { wfa->mv_tree [state][label].fx /= 2; wfa->mv_tree [state][label].fy /= 2; wfa->mv_tree [state][label].bx /= 2; wfa->mv_tree [state][label].by /= 2; } } if (format == FORMAT_4_2_0 && state == y_root) enlarge_factor--; } } } static void compute_actual_size (unsigned luminance_root, unsigned *width, unsigned *height, const wfa_t *wfa) /* * Compute actual size of the frame represented by the given 'wfa'. * (The reconstructed frame may get larger than the original due * to the bintree partitioning.) * If 'luminance_root' < MAXSTATES then the size of chroma ranges (4:2:0). * * Return values: * actual 'width' and 'height' of the decoded frame. */ { unsigned x = 0, y = 0; /* maximum coordinates */ unsigned state; /* counter */ for (state = wfa->basis_states; state < wfa->states; state++) if (isedge (wfa->into [state][0][0]) || isedge (wfa->into [state][1][0])) { unsigned mult = state > luminance_root ? 2 : 1; x = max ((wfa->x [state][0] + width_of_level (wfa->level_of_state [state])) * mult, x); y = max ((wfa->y [state][0] + height_of_level (wfa->level_of_state [state])) * mult, y); } if (x & 1) /* ensure that image size is even */ x++; if (y & 1) y++; *width = x; *height = y; } static void alloc_state_images (word_t ***images, u_word_t **offsets, const image_t *frame, const unsigned *root_state, unsigned range_state, unsigned max_level, format_e format, const wfa_t *wfa) /* * Generate list of 'wfa' state images which have to be computed for * each level to obtain the decoded 'frame'. 'root_state[]' denotes the * state images of the three color bands. * 'max_level' fives the max. level of a linear combination. * Memory is allocated for every required state image. * Use 4:2:0 subsampling or 4:4:4 'format' for color images. * If 'range_state' > 0 then rather compute image of 'range_state' than * image of 'wfa->root_state'. * * Return values: * '*images' Pointer to array of state image pointers * '*offsets' Pointer to array of state image offsets. * * Side effects: * The arrays given above are filled with useful values. */ { word_t **simg; /* ptr to list of state image ptr's */ u_word_t *offs; /* ptr to list of offsets */ unsigned level; /* counter */ simg = Calloc (wfa->states * (max_level + 1), sizeof (word_t *)); offs = Calloc (wfa->states * (max_level + 1), sizeof (u_word_t)); /* * Initialize buffers for those state images which are at 'max_level'. */ if (range_state > 0) /* a range is given */ { simg [range_state + max_level * wfa->states] = frame->pixels [GRAY]; offs [range_state + max_level * wfa->states] = frame->width; } else { unsigned state; for (state = wfa->basis_states; state <= root_state [Y]; state++) if (wfa->level_of_state [state] == max_level) { simg [state + max_level * wfa->states] = (frame->pixels [Y] + wfa->y [state][0] * frame->width + wfa->x [state][0]); offs [state + max_level * wfa->states] = frame->width; } if (frame->color) { unsigned width = format == FORMAT_4_2_0 ? (frame->width >> 1) : frame->width; for (; state < wfa->states; state++) if (wfa->level_of_state [state] == max_level) { simg [state + max_level * wfa->states] = (frame->pixels [state > root_state [Cb] ? Cr : Cb] + wfa->y [state][0] * width + wfa->x [state][0]); offs [state + max_level * wfa->states] = width; } } } /* * Generate list of state images which must be computed at each level */ for (level = max_level; level > 0; level--) { int child, domain; unsigned state, label, edge; /* * Range approximation with child. */ for (state = 1; state < (range_state > 0 ? range_state + 1 : wfa->states); state++) if (simg [state + level * wfa->states]) for (label = 0; label < MAXLABELS; label++) if (ischild (child = wfa->tree[state][label])) { if (isedge (wfa->into[state][label][0])) { /* * Allocate new image block. */ simg [child + (level - 1) * wfa->states] = Calloc (size_of_level (level - 1), sizeof (word_t)); offs [child + (level - 1) * wfa->states] = width_of_level (level - 1); } else { /* * Use image block and offset of parent. */ if (level & 1) /* split vertically */ { simg [child + (level - 1) * wfa->states] = (simg [state + level * wfa->states] + label * (height_of_level (level - 1) * offs [state + level * wfa->states])); } else /* split horizontally */ { simg [child + (level - 1) * wfa->states] = (simg [state + level * wfa->states] + label * width_of_level (level - 1)); } offs [child + (level - 1) * wfa->states] = offs [state + level * wfa->states]; } } /* * Range approximation with linear combination */ for (state = 1; state < (range_state > 0 ? range_state + 1 : wfa->states); state++) if (simg [state + level * wfa->states]) for (label = 0; label < MAXLABELS; label++) for (edge = 0; isedge (domain = wfa->into[state][label][edge]); edge++) { if (domain > 0 /* don't allocate memory for state 0 */ && !simg [domain + (level - 1) * wfa->states]) { simg [domain + (level - 1) * wfa->states] = Calloc (size_of_level (level - 1), sizeof (word_t)); offs [domain + (level - 1) * wfa->states] = width_of_level (level - 1); } } } *images = simg; *offsets = offs; } static void free_state_images (unsigned max_level, bool_t color, word_t **state_image, u_word_t *offset, const unsigned *root_state, unsigned range_state, format_e format, const wfa_t *wfa) /* * Free memory of state images. * For more details refer to the inverse function 'alloc_state_images()'. * * No return value. * * Side effects: * arrays 'state_image' and 'offset' are discarded. */ { word_t marker; /* ptr is required as a marker */ unsigned level; if (range_state > 0) { state_image [range_state + max_level * wfa->states] = ▮ } else { unsigned state; /* * Initialize state image array with states at 'max_level' */ for (state = wfa->basis_states; state <= root_state [Y]; state++) if (wfa->level_of_state [state] == max_level) state_image [state + max_level * wfa->states] = ▮ if (color) { if (format == FORMAT_4_2_0) level = max_level - 2; else level = max_level; for (; state < wfa->states; state++) if (wfa->level_of_state [state] == level) state_image [state + level * wfa->states] = ▮ } } for (level = max_level; level > 0; level--) { int domain, child; unsigned state, label, edge; /* * Range approximation with child. */ for (state = 1; state < (range_state > 0 ? range_state + 1 : wfa->states); state++) if (state_image [state + level * wfa->states]) for (label = 0; label < MAXLABELS; label++) if (ischild (child = wfa->tree[state][label])) { if (isedge (wfa->into[state][label][0]) && (state_image [child + (level - 1) * wfa->states] != &marker)) Free (state_image [child + (level - 1) * wfa->states]); state_image [child + (level - 1) * wfa->states] = ▮ } /* * Range approximation with linear combination */ for (state = 1; state < (range_state > 0 ? range_state + 1 : wfa->states); state++) if (state_image [state + level * wfa->states]) for (label = 0; label < MAXLABELS; label++) for (edge = 0; isedge (domain = wfa->into[state][label][edge]); edge++) if (domain > 0 && (state_image [domain + (level - 1) * wfa->states] != NULL) && (state_image [domain + (level - 1) * wfa->states] != &marker)) { Free (state_image [domain + (level - 1) * wfa->states]); state_image [domain + (level - 1) * wfa->states] = ▮ } } Free (state_image); Free (offset); } static void compute_state_images (unsigned max_level, word_t **simg, const u_word_t *offset, const wfa_t *wfa) /* * Compute all state images of the 'wfa' at level {1, ... , 'max_level'} * which are marked in the array 'simg' (offsets of state images * are given by 'offset'). * * Warning: Several optimizations are used in this function making * it difficult to understand. * * No return value. * * Side effects: * state images (given by pointers in the array 'state_image') * are computed. */ { unsigned level, state; /* * Copy one-pixel images in case state_image pointer != &final distr. */ for (state = 1; state < wfa->states; state++) if (simg [state] != NULL) /* compute image at level 0 */ *simg [state] = (int) (wfa->final_distribution[state] * 8 + .5) * 2; /* * Compute images of states * Integer arithmetics are used rather than floating point operations. * 'weight' gives the weight in integer notation * 'src', 'dst', and 'idst' are pointers to the source and * destination pixels (short or integer format), respectively. * Short format : one operation per register (16 bit mode). * Integer format : two operations per register (32 bit mode). * 'src_offset', 'dst_offset', and 'dst_offset' give the number of * pixels which have to be omitted when jumping to the next image row. */ for (level = 1; level <= max_level; level++) { unsigned label; unsigned width = width_of_level (level - 1); unsigned height = height_of_level (level - 1); for (state = 1; state < wfa->states; state++) if (simg [state + level * wfa->states] != NULL) for (label = 0; label < MAXLABELS; label++) if (isedge (wfa->into [state][label][0])) { unsigned edge; int domain; word_t *range; /* address of current range */ bool_t prediction_used; /* ND prediction found ? */ /* * Compute address of range image */ if (level & 1) /* split vertically */ { range = simg [state + level * wfa->states] + label * (height_of_level (level - 1) * offset [state + level * wfa->states]); } else /* split horizontally */ { range = simg [state + level * wfa->states] + label * width_of_level (level - 1); } /* * Generate the state images by adding the corresponding * weighted state images: * subimage [label] = * weight_1 * image_1 + ... + weight_n * image_n */ if (!ischild (domain = wfa->tree[state][label])) prediction_used = NO; else { unsigned y; word_t *src; word_t *dst; unsigned src_offset; unsigned dst_offset; prediction_used = YES; /* * Copy child image */ src = simg [domain + (level - 1) * wfa->states]; src_offset = offset [domain + (level - 1) * wfa->states] ; dst = range; dst_offset = offset [state + level * wfa->states]; for (y = height; y; y--) { memcpy (dst, src, width * sizeof (word_t)); src += src_offset; dst += dst_offset; } } if (!prediction_used && isedge (domain = wfa->into[state][label][0])) { /* * If prediction is not used then the range is * filled with the first domain. No addition is needed. */ edge = 0; if (domain != 0) { int weight; word_t *src; unsigned src_offset; src = simg [domain + ((level - 1) * wfa->states)]; src_offset = offset [domain + ((level - 1) * wfa->states)] - width; weight = wfa->int_weight [state][label][edge]; if (width == 1) /* can't add two-pixels in a row */ { word_t *dst; unsigned dst_offset; dst = range; dst_offset = offset [state + level * wfa->states] - width; #ifdef HAVE_SIGNED_SHIFT *dst++ = ((weight * (int) *src++) >> 10) << 1; #else /* not HAVE_SIGNED_SHIFT */ *dst++ = ((weight * (int) *src++) / 1024) * 2; #endif /* not HAVE_SIGNED_SHIFT */ if (height == 2) { src += src_offset; dst += dst_offset; #ifdef HAVE_SIGNED_SHIFT *dst++ = ((weight * (int) *src++) >> 10) << 1; #else /* not HAVE_SIGNED_SHIFT */ *dst++ = ((weight * (int) *src++) / 1024) * 2; #endif /* not HAVE_SIGNED_SHIFT */ } } else { unsigned y; int *idst; unsigned idst_offset; idst = (int *) range; idst_offset = (offset [state + level * wfa->states] - width) / 2; for (y = height; y; y--) { int *comp_dst = idst + (width >> 1); for (; idst != comp_dst; ) { int tmp; /* temp. value of adjacent pixels */ #ifdef HAVE_SIGNED_SHIFT # ifndef WORDS_BIGENDIAN tmp = (((weight * (int) src [1]) >> 10) << 17) | (((weight * (int) src [0]) >> 9) & 0xfffe); # else /* not WORDS_BIGENDIAN */ tmp = (((weight * (int) src [0]) >> 10) << 17) | (((weight * (int) src [1]) >> 9) & 0xfffe); # endif /* not WORDS_BIGENDIAN */ #else /* not HAVE_SIGNED_SHIFT */ # ifndef WORDS_BIGENDIAN tmp = (((weight * (int) src [1]) / 1024) * 131072) | (((weight * (int) src [0])/ 512) & 0xfffe); # else /* not WORDS_BIGENDIAN */ tmp = (((weight * (int) src [0]) / 1024) * 131072) | (((weight * (int) src [1]) / 512) & 0xfffe); # endif /* not WORDS_BIGENDIAN */ #endif /* not HAVE_SIGNED_SHIFT */ src += 2; *idst++ = tmp & 0xfffefffe; } src += src_offset; idst += idst_offset; } } } else { int weight = (int) (wfa->weight[state][label][edge] * wfa->final_distribution[0] * 8 + .5) * 2; /* * Range needs domain 0 * (the constant function f(x, y) = 1), * hence a faster algorithm is used. */ if (width == 1) /* can't add two-pixels in a row */ { word_t *dst; unsigned dst_offset; dst = range; dst_offset = offset [state + level * wfa->states] - width; *dst++ = weight; if (height == 2) { dst += dst_offset; *dst++ = weight; } } else { unsigned x, y; int *idst; unsigned idst_offset; weight = (weight * 65536) | (weight & 0xffff); idst = (int *) range; idst_offset = offset [state + level * wfa->states] / 2; for (x = width >> 1; x; x--) *idst++ = weight & 0xfffefffe; idst += (offset [state + level * wfa->states] - width) / 2; for (y = height - 1; y; y--) { memcpy (idst, idst - idst_offset, width * sizeof (word_t)); idst += idst_offset; } } } edge = 1; } else edge = 0; /* * Add remaining weighted domain images to current range */ for (; isedge (domain = wfa->into[state][label][edge]); edge++) { if (domain != 0) { word_t *src; unsigned src_offset; int weight; src = simg [domain + (level - 1) * wfa->states]; src_offset = offset [domain + ((level - 1) * wfa->states)] - width; weight = wfa->int_weight [state][label][edge]; if (width == 1) /* can't add two-pixels in a row */ { word_t *dst; unsigned dst_offset; dst = range; dst_offset = offset [state + level * wfa->states] - width; #ifdef HAVE_SIGNED_SHIFT *dst++ += ((weight * (int) *src++) >> 10) << 1; #else /* not HAVE_SIGNED_SHIFT */ *dst++ += ((weight * (int) *src++) / 1024) * 2; #endif /* not HAVE_SIGNED_SHIFT */ if (height == 2) { src += src_offset; dst += dst_offset; #ifdef HAVE_SIGNED_SHIFT *dst++ += ((weight * (int) *src++) >> 10) << 1; #else /* not HAVE_SIGNED_SHIFT */ *dst++ += ((weight * (int) *src++) / 1024) * 2; #endif /* not HAVE_SIGNED_SHIFT */ } } else { int *idst; unsigned idst_offset; unsigned y; idst = (int *) range; idst_offset = (offset [state + level * wfa->states] - width) / 2; for (y = height; y; y--) { int *comp_dst = idst + (width >> 1); for (; idst != comp_dst;) { int tmp; /* temp. value of adjacent pixels */ #ifdef HAVE_SIGNED_SHIFT # ifndef WORDS_BIGENDIAN tmp = (((weight * (int) src [1]) >> 10) << 17) | (((weight * (int) src [0]) >> 9) & 0xfffe); # else /* not WORDS_BIGENDIAN */ tmp = (((weight * (int)src [0]) >> 10) << 17) | (((weight * (int)src [1]) >> 9) & 0xfffe); # endif /* not WORDS_BIGENDIAN */ #else /* not HAVE_SIGNED_SHIFT */ # ifndef WORDS_BIGENDIAN tmp = (((weight * (int) src [1]) / 1024) * 131072) | (((weight * (int) src [0])/ 512) & 0xfffe); # else /* not WORDS_BIGENDIAN */ tmp = (((weight * (int) src [0]) / 1024) * 131072) | (((weight * (int) src [1])/ 512) & 0xfffe); # endif /* not WORDS_BIGENDIAN */ #endif /* not HAVE_SIGNED_SHIFT */ src += 2; *idst = (*idst + tmp) & 0xfffefffe; idst++; } src += src_offset; idst += idst_offset; } } } else { int weight = (int) (wfa->weight[state][label][edge] * wfa->final_distribution[0] * 8 + .5) * 2; /* * Range needs domain 0 * (the constant function f(x, y) = 1), * hence a faster algorithm is used. */ if (width == 1) /* can't add two-pixels in a row */ { word_t *dst; unsigned dst_offset; dst = range; dst_offset = offset [state + level * wfa->states] - width; *dst++ += weight; if (height == 2) { dst += dst_offset; *dst++ += weight; } } else { int *idst; unsigned idst_offset; unsigned y; weight = (weight * 65536) | (weight & 0xffff); idst = (int *) range; idst_offset = (offset [state + level * wfa->states] - width) /2; for (y = height; y; y--) { int *comp_dst = idst + (width >> 1); for (; idst != comp_dst; ) { *idst = (*idst + weight) & 0xfffefffe; idst++; } idst += idst_offset; } } } } } } } static word_t * duplicate_state_image (const word_t *domain, unsigned offset, unsigned level) /* * Allocate new memory block 'pixels' and copy pixel values of 'domain' * (size and pixel offset are given by 'level' and 'offset') * to the lock 'pixels'. * * Return value: * pointer to the new domain block */ { word_t *dst, *pixels; int y, n; dst = pixels = Calloc (size_of_level (level), sizeof (word_t)); if (domain) for (y = height_of_level (level); y; y--) { memcpy (dst, domain, width_of_level (level) * sizeof (word_t)); dst += width_of_level (level); domain += offset; } else /* state 0 */ for (n = size_of_level (level); n; n--) *dst++ = (int) (128 * 8 + .5) * 2; return pixels; } netpbm-free-10.0-1/pnm/fiasco/codec/decoder.h0100644004714500471450000000354107716230207021217 0ustar aba-guestaba-guest/* * decode.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _DECODE_H #define _DECODE_H #include "types.h" #include "image.h" #include "wfa.h" typedef struct video { unsigned future_display; /* number of a future frame */ unsigned display; /* current display number */ image_t *frame; /* current frame */ image_t *sframe; /* current smoothed frame */ image_t *future; /* future reference */ image_t *sfuture; /* future (smmothed) reference */ image_t *past ; /* past reference */ wfa_t *wfa; /* current wfa */ wfa_t *wfa_future; /* future wfa */ wfa_t *wfa_past; /* past wfa */ } video_t; typedef struct dectimer { unsigned int input [3]; unsigned int preprocessing [3]; unsigned int decoder [3]; unsigned int cleanup [3]; unsigned int motion [3]; unsigned int smooth [3]; unsigned int display [3]; unsigned int frames [3]; } dectimer_t; image_t * get_next_frame (bool_t store_wfa, int enlarge_factor, int smoothing, const char *reference_frame, format_e format, video_t *video, dectimer_t *timer, wfa_t *orig_wfa, bitfile_t *input); image_t * decode_image (unsigned orig_width, unsigned orig_height, format_e format, unsigned *dec_timer, const wfa_t *wfa); word_t * decode_range (unsigned range_state, unsigned range_label, unsigned range_level, word_t **domain, wfa_t *wfa); image_t * decode_state (unsigned state, unsigned level, wfa_t *wfa); void smooth_image (unsigned sf, const wfa_t *wfa, image_t *image); video_t * alloc_video (bool_t store_wfa); void free_video (video_t *video); #endif /* not _DECODE_H */ netpbm-free-10.0-1/pnm/fiasco/codec/dfiasco.c0100644004714500471450000002165007725102161021213 0ustar aba-guestaba-guest/* * dfiasco.c: Decoder public interface * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/09/02 11:52:17 $ * $Author: aba-guest $ * $Revision: 1.2 $ * $State: Exp $ */ #include #include "config.h" #include "types.h" #include "macros.h" #include "error.h" #include "dfiasco.h" #include "wfa.h" #include "read.h" #include "misc.h" #include "bit-io.h" #include "decoder.h" #include "options.h" #include "wfalib.h" /***************************************************************************** prototypes *****************************************************************************/ static dfiasco_t * cast_dfiasco (fiasco_decoder_t *dfiasco); static void free_dfiasco (dfiasco_t *dfiasco); static dfiasco_t * alloc_dfiasco (wfa_t *wfa, video_t *video, bitfile_t *input, int enlarge_factor, int smoothing, format_e image_format); /***************************************************************************** public code *****************************************************************************/ fiasco_decoder_t * fiasco_decoder_new (const char *filename, const fiasco_d_options_t *options) { try { bitfile_t *input; /* pointer to WFA FIASCO stream */ wfa_t *wfa; /* wfa structure */ video_t *video; /* information about decoder state */ const d_options_t *dop; /* decoder additional options */ dfiasco_t *dfiasco; /* decoder internal state */ fiasco_decoder_t *decoder; /* public interface to decoder */ fiasco_d_options_t *default_options = NULL; if (options) { dop = cast_d_options ((fiasco_d_options_t *) options); if (!dop) return NULL; } else { default_options = fiasco_d_options_new (); dop = cast_d_options (default_options); } wfa = alloc_wfa (NO); video = alloc_video (NO); input = open_wfa (filename, wfa->wfainfo); read_basis (wfa->wfainfo->basis_name, wfa); decoder = Calloc (1, sizeof (fiasco_decoder_t)); decoder->delete = fiasco_decoder_delete; decoder->write_frame = fiasco_decoder_write_frame; decoder->get_frame = fiasco_decoder_get_frame; decoder->get_length = fiasco_decoder_get_length; decoder->get_rate = fiasco_decoder_get_rate; decoder->get_width = fiasco_decoder_get_width; decoder->get_height = fiasco_decoder_get_height; decoder->get_title = fiasco_decoder_get_title; decoder->get_comment = fiasco_decoder_get_comment; decoder->is_color = fiasco_decoder_is_color; decoder->private = dfiasco = alloc_dfiasco (wfa, video, input, dop->magnification, dop->smoothing, dop->image_format); if (default_options) fiasco_d_options_delete (default_options); if (dfiasco->enlarge_factor >= 0) { int n; unsigned long pixels = wfa->wfainfo->width * wfa->wfainfo->height; for (n = 1; n <= (int) dfiasco->enlarge_factor; n++) { if (pixels << (n << 1) > 2048 * 2048) { set_error (_("Magnifaction factor `%d' is too large. " "Maximium value is %d."), dfiasco->enlarge_factor, max (0, n - 1)); fiasco_decoder_delete (decoder); return NULL; } } } else { int n; for (n = 0; n <= (int) - dfiasco->enlarge_factor; n++) { if (wfa->wfainfo->width >> n < 32 || wfa->wfainfo->height >> n < 32) { set_error (_("Magnifaction factor `%d' is too small. " "Minimum value is %d."), dfiasco->enlarge_factor, - max (0, n - 1)); fiasco_decoder_delete (decoder); return NULL; } } } return (fiasco_decoder_t *) decoder; } catch { return NULL; } } int fiasco_decoder_write_frame (fiasco_decoder_t *decoder, const char *filename) { dfiasco_t *dfiasco = cast_dfiasco (decoder); if (!dfiasco) return 0; else { try { image_t *frame = get_next_frame (NO, dfiasco->enlarge_factor, dfiasco->smoothing, NULL, FORMAT_4_4_4, dfiasco->video, NULL, dfiasco->wfa, dfiasco->input); write_image (filename, frame); } catch { return 0; } return 1; } } fiasco_image_t * fiasco_decoder_get_frame (fiasco_decoder_t *decoder) { dfiasco_t *dfiasco = cast_dfiasco (decoder); if (!dfiasco) return NULL; else { try { fiasco_image_t *image = Calloc (1, sizeof (fiasco_image_t)); image_t *frame = get_next_frame (NO, dfiasco->enlarge_factor, dfiasco->smoothing, NULL, dfiasco->image_format, dfiasco->video, NULL, dfiasco->wfa, dfiasco->input); frame->reference_count++; /* for motion compensation */ image->private = frame; image->delete = fiasco_image_delete; image->get_width = fiasco_image_get_width; image->get_height = fiasco_image_get_height; image->is_color = fiasco_image_is_color; return image; } catch { return NULL; } } } unsigned fiasco_decoder_get_length (fiasco_decoder_t *decoder) { dfiasco_t *dfiasco = cast_dfiasco (decoder); if (!dfiasco) return 0; else return dfiasco->wfa->wfainfo->frames; } unsigned fiasco_decoder_get_rate (fiasco_decoder_t *decoder) { dfiasco_t *dfiasco = cast_dfiasco (decoder); if (!dfiasco) return 0; else return dfiasco->wfa->wfainfo->fps; } unsigned fiasco_decoder_get_width (fiasco_decoder_t *decoder) { dfiasco_t *dfiasco = cast_dfiasco (decoder); if (!dfiasco) return 0; else { unsigned width; if (dfiasco->enlarge_factor >= 0) width = dfiasco->wfa->wfainfo->width << dfiasco->enlarge_factor; else width = dfiasco->wfa->wfainfo->width >> - dfiasco->enlarge_factor; return width & 1 ? width + 1 : width; } } unsigned fiasco_decoder_get_height (fiasco_decoder_t *decoder) { dfiasco_t *dfiasco = cast_dfiasco (decoder); if (!dfiasco) return 0; else { unsigned height; if (dfiasco->enlarge_factor >= 0) height = dfiasco->wfa->wfainfo->height << dfiasco->enlarge_factor; else height = dfiasco->wfa->wfainfo->height >> - dfiasco->enlarge_factor; return height & 1 ? height + 1 : height; } } const char * fiasco_decoder_get_title (fiasco_decoder_t *decoder) { dfiasco_t *dfiasco = cast_dfiasco (decoder); if (!dfiasco) return NULL; else return dfiasco->wfa->wfainfo->title; } const char * fiasco_decoder_get_comment (fiasco_decoder_t *decoder) { dfiasco_t *dfiasco = cast_dfiasco (decoder); if (!dfiasco) return NULL; else return dfiasco->wfa->wfainfo->comment; } int fiasco_decoder_is_color (fiasco_decoder_t *decoder) { dfiasco_t *dfiasco = cast_dfiasco (decoder); if (!dfiasco) return 0; else return dfiasco->wfa->wfainfo->color; } int fiasco_decoder_delete (fiasco_decoder_t *decoder) { dfiasco_t *dfiasco = cast_dfiasco (decoder); if (!dfiasco) return 1; try { free_wfa (dfiasco->wfa); free_video (dfiasco->video); close_bitfile (dfiasco->input); strcpy (dfiasco->id, " "); Free (decoder); } catch { return 0; } return 1; } /***************************************************************************** private code *****************************************************************************/ static dfiasco_t * alloc_dfiasco (wfa_t *wfa, video_t *video, bitfile_t *input, int enlarge_factor, int smoothing, format_e image_format) /* * FIASCO decoder constructor: * Initialize decoder structure. * * Return value: * pointer to the new decoder structure */ { dfiasco_t *dfiasco = Calloc (1, sizeof (dfiasco_t)); strcpy (dfiasco->id, "DFIASCO"); dfiasco->wfa = wfa; dfiasco->video = video; dfiasco->input = input; dfiasco->enlarge_factor = enlarge_factor; dfiasco->smoothing = smoothing; dfiasco->image_format = image_format; return dfiasco; } static void free_dfiasco (dfiasco_t *dfiasco) /* * FIASCO decoder destructor: * Free memory of given 'decoder' struct. * * No return value. * * Side effects: * 'video' struct is discarded. */ { Free (dfiasco); } static dfiasco_t * cast_dfiasco (fiasco_decoder_t *dfiasco) /* * Cast pointer `dfiasco' to type dfiasco_t. * Check whether `dfiasco' is a valid object of type dfiasco_t. * * Return value: * pointer to dfiasco_t struct on success * NULL otherwise */ { dfiasco_t *this = (dfiasco_t *) dfiasco->private; if (this) { if (!streq (this->id, "DFIASCO")) { set_error (_("Parameter `dfiasco' doesn't match required type.")); return NULL; } } else { set_error (_("Parameter `%s' not defined (NULL)."), "dfiasco"); } return this; } netpbm-free-10.0-1/pnm/fiasco/codec/dfiasco.h0100644004714500471450000000125207716230207021217 0ustar aba-guestaba-guest/* * dfiasco.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _DFIASCO_H #define _DFIASCO_H #include "types.h" #include "bit-io.h" #include "decoder.h" #include "image.h" #include "wfa.h" typedef struct dfiasco { char id [8]; wfa_t *wfa; video_t *video; bitfile_t *input; int enlarge_factor; int smoothing; format_e image_format; } dfiasco_t; #endif /* not _DFIASCO_H */ netpbm-free-10.0-1/pnm/fiasco/codec/domain-pool.c0100644004714500471450000007020107716230207022020 0ustar aba-guestaba-guest/* * domain-pool.c: Domain pool management (probability model) * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #include #if STDC_HEADERS # include #endif /* not STDC_HEADERS */ #if HAVE_STRING_H # include #else /* not HAVE_STRING_H */ # include #endif /* not HAVE_STRING_H */ #include "types.h" #include "macros.h" #include "error.h" #include "misc.h" #include "cwfa.h" #include "wfalib.h" #include "domain-pool.h" /* * Domain pool model interface: * Implementing the domain pool model interface requires the * following steps: * - Add a constructor that initializes the domain_pool_t structure * - Allocate new model with default_alloc() * - Fill the dp_array_t domain_pools array with constructor and name * - Write code for methods bits() and generate() * - Either use default functions for remaining methods or override them * The new model is automatically registered at the command line. */ /***************************************************************************** local variables *****************************************************************************/ static real_t *matrix_0 = NULL; static real_t *matrix_1 = NULL; /***************************************************************************** prototypes *****************************************************************************/ static domain_pool_t * alloc_empty_domain_pool (unsigned max_domains, unsigned max_edges, const wfa_t *wfa); /***************************************************************************** non-adaptive domain pool *****************************************************************************/ static void qac_chroma (unsigned max_domains, const wfa_t *wfa, void *model); static bool_t qac_append (unsigned new_state, unsigned level, const wfa_t *wfa, void *model); static void qac_update (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, void *model); static real_t qac_bits (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, const void *model); static word_t * qac_generate (unsigned level, int y_state, const wfa_t *wfa, const void *model); static void * qac_model_duplicate (const void *src); static void qac_model_free (void *model); static void * qac_model_alloc (unsigned max_domains); static domain_pool_t * alloc_qac_domain_pool (unsigned max_domains, unsigned max_edges, const wfa_t *wfa); /***************************************************************************** run length encoding pool *****************************************************************************/ static domain_pool_t * alloc_rle_no_chroma_domain_pool (unsigned max_domains, unsigned max_edges, const wfa_t *wfa); static void rle_chroma (unsigned max_domains, const wfa_t *wfa, void *model); static bool_t rle_append (unsigned new_state, unsigned level, const wfa_t *wfa, void *model); static void rle_update (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, void *model); static real_t rle_bits (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, const void *model); static word_t * rle_generate (unsigned level, int y_state, const wfa_t *wfa, const void *model); static void * rle_model_duplicate (const void *src); static void rle_model_free (void *model); static void * rle_model_alloc (unsigned max_domains); static domain_pool_t * alloc_rle_domain_pool (unsigned max_domains, unsigned max_edges, const wfa_t *wfa); /***************************************************************************** const domain pool *****************************************************************************/ static real_t const_bits (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, const void *model); static word_t * const_generate (unsigned level, int y_state, const wfa_t *wfa, const void *model); static domain_pool_t * alloc_const_domain_pool (unsigned max_domains, unsigned max_edges, const wfa_t *wfa); /***************************************************************************** basis domain pool *****************************************************************************/ static domain_pool_t * alloc_basis_domain_pool (unsigned max_domains, unsigned max_edges, const wfa_t *wfa); /***************************************************************************** uniform distribution pool *****************************************************************************/ static real_t uniform_bits (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, const void *model); static word_t * uniform_generate (unsigned level, int y_state, const wfa_t *wfa, const void *model); static domain_pool_t * alloc_uniform_domain_pool (unsigned max_domains, unsigned max_edges, const wfa_t *wfa); /***************************************************************************** default functions *****************************************************************************/ static void init_matrix_probabilities (void); static void default_chroma (unsigned max_domains, const wfa_t *wfa, void *model); static bool_t default_append (unsigned new_state, unsigned level, const wfa_t *wfa, void *model); static void default_update (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, void *model); static void default_free (domain_pool_t *pool); static void default_model_free (void *model); static void * default_model_alloc (unsigned max_domains); static void * default_model_duplicate (const void *src); static domain_pool_t * default_alloc (void); /***************************************************************************** public code *****************************************************************************/ typedef struct dp_array { char *identifier; domain_pool_t *(*function) (unsigned max_domains, unsigned max_edges, const wfa_t *wfa); } dp_array_t; dp_array_t domain_pools[] = {{"adaptive", alloc_qac_domain_pool}, {"constant", alloc_const_domain_pool}, {"basis", alloc_basis_domain_pool}, {"uniform", alloc_uniform_domain_pool}, {"rle", alloc_rle_domain_pool}, {"rle-no-chroma", alloc_rle_no_chroma_domain_pool}, {NULL, NULL}}; domain_pool_t * alloc_domain_pool (const char *domain_pool_name, unsigned max_domains, unsigned max_edges, const wfa_t *wfa) /* * Allocate a new domain pool identified by the string * 'domain_pool_name'. Maximum number of domain images (each one * represented by one state of the given 'wfa') is specified by * 'max_domains'. * * Return value: * pointer to the allocated domain pool * * Note: * refer to 'domain-pool.h' for a short description of the member functions. */ { unsigned n; if (!max_domains) { warning ("Can't generate empty domain pool. " "Using at least DC component."); max_domains = 1; } for (n = 0; domain_pools [n].identifier; n++) /* step through all id's */ if (strcaseeq (domain_pools [n].identifier, domain_pool_name)) return domain_pools [n].function (max_domains, max_edges, wfa); warning ("Can't initialize domain pool '%s'. Using default value '%s'.", domain_pool_name, domain_pools [0].identifier); return domain_pools [0].function (max_domains, max_edges, wfa); } /***************************************************************************** private code *****************************************************************************/ static domain_pool_t * alloc_empty_domain_pool (unsigned max_domains, unsigned max_edges, const wfa_t *wfa) /* * Domain pool with no state images available. */ { return default_alloc (); } /***************************************************************************** adaptive domain pool *****************************************************************************/ typedef struct qac_model { word_t *index; /* probability of domains */ word_t *states; /* mapping states -> domains */ u_word_t y_index; /* pointer to prob of Y domain */ u_word_t n; /* number of domains in the pool */ u_word_t max_domains; /* max. number of domains */ } qac_model_t; static domain_pool_t * alloc_qac_domain_pool (unsigned max_domains, unsigned max_edges, const wfa_t *wfa) /* * Domain pool with state images {0, ..., 'max_domains'). * Underlying probability model: quasi arithmetic coding of columns. */ { domain_pool_t *pool; unsigned state; pool = default_alloc (); pool->model = qac_model_alloc (max_domains); pool->generate = qac_generate; pool->bits = qac_bits; pool->update = qac_update; pool->append = qac_append; pool->chroma = qac_chroma; pool->model_free = qac_model_free; pool->model_duplicate = qac_model_duplicate; for (state = 0; state < wfa->basis_states; state++) if (usedomain (state, wfa)) qac_append (state, -1, wfa, pool->model); return pool; } static void * qac_model_alloc (unsigned max_domains) { qac_model_t *model; init_matrix_probabilities (); model = Calloc (1, sizeof (qac_model_t)); model->index = Calloc (max_domains, sizeof (word_t)); model->states = Calloc (max_domains, sizeof (word_t)); model->y_index = 0; model->n = 0; model->max_domains = max_domains; return model; } static void qac_model_free (void *model) { Free (((qac_model_t *) model)->index); Free (((qac_model_t *) model)->states); Free (model); } static void * qac_model_duplicate (const void *src) { qac_model_t *qdst; const qac_model_t *qsrc = (qac_model_t *) src; qdst = qac_model_alloc (qsrc->max_domains); qdst->y_index = qsrc->y_index; qdst->n = qsrc->n; memcpy (qdst->index, qsrc->index, qsrc->n * sizeof (word_t)); memcpy (qdst->states, qsrc->states, qsrc->n * sizeof (word_t)); return qdst; } static word_t * qac_generate (unsigned level, int y_state, const wfa_t *wfa, const void *model) { word_t *domains; unsigned n; qac_model_t *qac_model = (qac_model_t *) model; bool_t y_state_is_domain = NO; if (y_state >= 0 && !usedomain (y_state, wfa)) /* don't use y-state */ y_state = -1; domains = Calloc (qac_model->n + 2, sizeof (word_t)); memcpy (domains, qac_model->states, qac_model->n * sizeof (word_t)); for (n = 0; n < qac_model->n; n++) if (domains [n] == y_state) /* match */ y_state_is_domain = YES; if (y_state_is_domain) domains [qac_model->n] = -1; /* end marker */ else { domains [qac_model->n] = y_state; /* additional y-state */ domains [qac_model->n + 1] = -1; /* end marker */ } return domains; } static real_t qac_bits (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, const void *model) { int domain; /* counter */ real_t bits = 0; /* bit rate R */ qac_model_t *qac_model = (qac_model_t *) model; /* probability model */ if (y_state >= 0 && !usedomain (y_state, wfa)) /* don't use y-state */ y_state = -1; for (domain = 0; domain < qac_model->n; domain++) if (qac_model->states [domain] != y_state) bits += matrix_0 [qac_model->index [domain]]; if (y_state >= 0) bits += matrix_0 [qac_model->y_index]; if (used_domains != NULL) { unsigned edge; for (edge = 0; isedge (domain = used_domains [edge]); edge++) if (domains [domain] == y_state) { bits -= matrix_0 [qac_model->y_index]; bits += matrix_1 [qac_model->y_index]; } else { bits -= matrix_0 [qac_model->index [domain]]; bits += matrix_1 [qac_model->index [domain]]; } } return bits; } static void qac_update (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, void *model) { int domain; unsigned edge; bool_t used_y_state = NO; qac_model_t *qac_model = (qac_model_t *) model; bool_t y_state_is_domain = NO; if (y_state >= 0 && !usedomain (y_state, wfa)) /* don't use y-state */ y_state = -1; for (domain = 0; domain < qac_model->n; domain++) { qac_model->index [domain]++; /* mark domains unused. */ if (qac_model->states [domain] == y_state) /* match */ y_state_is_domain = YES; } for (edge = 0; isedge (domain = used_domains [edge]); edge++) if (domains [domain] == y_state) /* chroma coding */ { if (y_state_is_domain) qac_model->index [domain]--; /* undo */ qac_model->y_index >>= 1; used_y_state = YES; } else /* luminance coding */ { qac_model->index [used_domains [edge]]--; /* undo */ qac_model->index [used_domains [edge]] >>= 1; } if (y_state >= 0 && !used_y_state) qac_model->y_index++; /* update y-state model */ for (domain = 0; domain < qac_model->n; domain++) if (qac_model->index [domain] > 1020) /* check for overflow */ qac_model->index [domain] = 1020; if (qac_model->y_index > 1020) /* check for overflow */ qac_model->y_index = 1020; } static bool_t qac_append (unsigned new_state, unsigned level, const wfa_t *wfa, void *model) { qac_model_t *qac_model = (qac_model_t *) model; /* probability model */ if (qac_model->n >= qac_model->max_domains) return NO; /* don't use state in domain pool */ else { qac_model->index [qac_model->n] = qac_model->n > 0 ? qac_model->index [qac_model->n - 1] : 0; qac_model->states [qac_model->n] = new_state; qac_model->n++; return YES; /* state will be used in domain pool */ } } static void qac_chroma (unsigned max_domains, const wfa_t *wfa, void *model) { qac_model_t *qac_model = (qac_model_t *) model; /* probability model */ if (max_domains < qac_model->n) /* choose most probable domains */ { word_t *domains; unsigned n, new, old; word_t *states = Calloc (max_domains, sizeof (word_t)); word_t *index = Calloc (max_domains, sizeof (word_t)); domains = compute_hits (wfa->basis_states, wfa->states - 1, max_domains, wfa); for (n = 0; n < max_domains && domains [n] >= 0; n++) states [n] = domains [n]; max_domains = min (max_domains, n); Free (domains); for (old = 0, new = 0; new < max_domains && old < qac_model->n; old++) if (qac_model->states [old] == states [new]) index [new++] = qac_model->index [old]; Free (qac_model->states); Free (qac_model->index); qac_model->states = states; qac_model->index = index; qac_model->n = max_domains; qac_model->max_domains = max_domains; } qac_model->y_index = 0; qac_model->max_domains = qac_model->n; } /***************************************************************************** const domain pool *****************************************************************************/ static domain_pool_t * alloc_const_domain_pool (unsigned max_domains, unsigned max_edges, const wfa_t *wfa) /* * Domain pool with state image 0 (constant function f(x, y) = 1). * No probability model is used. */ { domain_pool_t *pool; pool = default_alloc (); pool->generate = const_generate; pool->bits = const_bits; return pool; } static word_t * const_generate (unsigned level, int y_state, const wfa_t *wfa, const void *model) { word_t *domains = Calloc (2, sizeof (word_t)); domains [0] = 0; domains [1] = -1; return domains; } static real_t const_bits (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, const void *model) { return 0; /* 0 bits, either we have a lc or not */ } /***************************************************************************** basis domain pool *****************************************************************************/ static domain_pool_t * alloc_basis_domain_pool (unsigned max_domains, unsigned max_edges, const wfa_t *wfa) /* * Domain pool with state images {0, ..., 'basis_states' - 1). * Underlying probability model: quasi arithmetic coding of columns. * I.e. domain pool = qac_domainpool ('max_domains' == wfa->basis_states) */ { return alloc_qac_domain_pool (wfa->basis_states, max_edges, wfa); } /***************************************************************************** uniform-distribution pool *****************************************************************************/ static domain_pool_t * alloc_uniform_domain_pool (unsigned max_domains, unsigned max_edges, const wfa_t *wfa) /* * Domain pool with state images {0, ..., 'max_domains'). * Underlying probability model: uniform distribution. */ { domain_pool_t *pool; pool = default_alloc (); pool->generate = uniform_generate; pool->bits = uniform_bits; return pool; } static word_t * uniform_generate (unsigned level, int y_state, const wfa_t *wfa, const void *model) { unsigned state, n; word_t *domains = Calloc (wfa->states + 1, sizeof (word_t)); for (state = 0, n = 0; state < wfa->states; state++) if (usedomain (state, wfa)) domains [n++] = state; domains [n] = -1; return domains; } static real_t uniform_bits (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, const void *model) { unsigned state, n; real_t bits = 0; for (state = 0, n = 0; state < wfa->states; state++) if (usedomain (state, wfa)) n++; bits = - n * log2 ((n - 1) / (real_t) n); if (used_domains != NULL) { int edge; for (edge = 0; isedge (used_domains [edge]); edge++) bits -= log2 (1.0 / n); } return bits; } /***************************************************************************** run length encoding pool *****************************************************************************/ typedef struct rle_model { word_t count [MAXEDGES + 1]; u_word_t total; u_word_t n; u_word_t max_domains; u_word_t y_index; /* pointer to prob of Y domain */ word_t *states; /* mapping states -> domains */ qac_model_t *domain_0; } rle_model_t; static domain_pool_t * alloc_rle_domain_pool (unsigned max_domains, unsigned max_edges, const wfa_t *wfa) /* * Domain pool with state images {0, ..., 'max_domains'). * Underlying probability model: rle */ { domain_pool_t *pool; unsigned state; pool = default_alloc (); pool->model = rle_model_alloc (max_domains); pool->model_free = rle_model_free; pool->model_duplicate = rle_model_duplicate; pool->generate = rle_generate; pool->update = rle_update; pool->bits = rle_bits; pool->append = rle_append; pool->chroma = rle_chroma; for (state = 0; state < wfa->basis_states; state++) if (usedomain (state, wfa)) rle_append (state, -1, wfa, pool->model); return pool; } static void * rle_model_alloc (unsigned max_domains) { unsigned m; rle_model_t *model = Calloc (1, sizeof (rle_model_t)); for (m = model->total = 0; m < MAXEDGES + 1; m++, model->total++) model->count [m] = 1; model->domain_0 = qac_model_alloc (1); model->states = Calloc (max_domains, sizeof (word_t)); model->n = 0; model->y_index = 0; model->max_domains = max_domains; return model; } static void rle_model_free (void *model) { qac_model_free (((rle_model_t *) model)->domain_0); Free (((rle_model_t *) model)->states); Free (model); } static void * rle_model_duplicate (const void *src) { const rle_model_t *rle_src = (rle_model_t *) src; rle_model_t *model = Calloc (1, sizeof (rle_model_t)); model->domain_0 = qac_model_duplicate (rle_src->domain_0); model->n = rle_src->n; model->max_domains = rle_src->max_domains; model->states = Calloc (model->max_domains, sizeof (word_t)); model->total = rle_src->total; model->y_index = rle_src->y_index; memcpy (model->states, rle_src->states, model->max_domains * sizeof (word_t)); memcpy (model->count, rle_src->count, (MAXEDGES + 1) * sizeof (word_t)); return model; } static word_t * rle_generate (unsigned level, int y_state, const wfa_t *wfa, const void *model) { word_t *domains; unsigned n; rle_model_t *rle_model = (rle_model_t *) model; bool_t y_state_is_domain = NO; if (y_state >= 0 && !usedomain (y_state, wfa)) /* don't use y-state */ y_state = -1; domains = Calloc (rle_model->n + 2, sizeof (word_t)); memcpy (domains, rle_model->states, rle_model->n * sizeof (word_t)); for (n = 0; n < rle_model->n; n++) if (domains [n] == y_state) /* match */ y_state_is_domain = YES; if (y_state_is_domain) domains [rle_model->n] = -1; /* end marker */ else { domains [rle_model->n] = y_state; /* additional y-state */ domains [rle_model->n + 1] = -1; /* end marker */ } return domains; } static real_t rle_bits (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, const void *model) { unsigned edge; unsigned n = 0; real_t bits = 0; word_t sorted [MAXEDGES + 1]; rle_model_t *rle_model = (rle_model_t *) model; unsigned last; int into; if (y_state >= 0 && !usedomain (y_state, wfa)) /* don't use y-state */ y_state = -1; if (used_domains) { word_t domain; if (y_state >= 0) bits += matrix_0 [rle_model->y_index]; for (edge = n = 0; isedge (domain = used_domains [edge]); edge++) if (domains [domain] != y_state) sorted [n++] = used_domains [edge]; else { bits -= matrix_0 [rle_model->y_index]; bits += matrix_1 [rle_model->y_index]; } if (n > 1) qsort (sorted, n, sizeof (word_t), sort_asc_word); } bits = - log2 (rle_model->count [n] / (real_t) rle_model->total); if (used_domains && n && sorted [0] == 0) { word_t array0 [2] = {0, NO_EDGE}; bits += qac_bits (array0, array0, level, y_state, wfa, rle_model->domain_0); } else { word_t array0 [2] = {NO_EDGE}; bits += qac_bits (array0, array0, level, y_state, wfa, rle_model->domain_0); } last = 1; for (edge = 0; edge < n; edge++) if ((into = sorted [edge]) && rle_model->n - 1 - last) { bits += bits_bin_code (into - last, rle_model->n - 1 - last); last = into + 1; } return bits; } static void rle_update (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, void *model) { rle_model_t *rle_model = (rle_model_t *) model; bool_t state_0 = NO, state_y = NO; word_t array0 [2] = {0, NO_EDGE}; unsigned edge = 0; if (y_state >= 0 && !usedomain (y_state, wfa)) /* don't use y-state */ y_state = -1; if (used_domains) { word_t domain; for (edge = 0; isedge (domain = used_domains [edge]); edge++) if (domains [domain] == 0) state_0 = YES; else if (domains [domain] == y_state) state_y = YES; } rle_model->count [edge]++; rle_model->total++; qac_update (array0, array0 + (state_0 ? 0 : 1), level, y_state, wfa, rle_model->domain_0); if (state_y) rle_model->y_index >>= 1; else rle_model->y_index++; if (rle_model->y_index > 1020) /* check for overflow */ rle_model->y_index = 1020; } static bool_t rle_append (unsigned new_state, unsigned level, const wfa_t *wfa, void *model) { rle_model_t *rle_model = (rle_model_t *) model; /* probability model */ if (rle_model->n >= rle_model->max_domains) return NO; /* don't use state in domain pool */ else { rle_model->states [rle_model->n] = new_state; rle_model->n++; if (new_state == 0) { assert (rle_model->n == 1); qac_append (0, -1, wfa, rle_model->domain_0); } return YES; /* state will be used in domain pool */ } } static void rle_chroma (unsigned max_domains, const wfa_t *wfa, void *model) { rle_model_t *rle_model = (rle_model_t *) model; /* probability model */ if (max_domains < rle_model->n) /* choose most probable domains */ { unsigned n; word_t *states = Calloc (max_domains, sizeof (word_t)); word_t *domains = compute_hits (wfa->basis_states, wfa->states - 1, max_domains, wfa); for (n = 0; n < max_domains && domains [n] >= 0; n++) states [n] = domains [n]; assert (states [0] == 0); max_domains = min (max_domains, n); Free (domains); Free (rle_model->states); rle_model->states = states; rle_model->n = max_domains; } rle_model->y_index = 0; rle_model->max_domains = rle_model->n; } /***************************************************************************** run length encoding pool no special chroma pool *****************************************************************************/ static domain_pool_t * alloc_rle_no_chroma_domain_pool (unsigned max_domains, unsigned max_edges, const wfa_t *wfa) /* * Domain pool with state images {0, ..., 'max_domains'). * Underlying probability model: rle * Domain pool is not changed for chroma bands */ { domain_pool_t *pool = alloc_rle_domain_pool (max_domains, max_edges, wfa); pool->chroma = default_chroma; return pool; } /***************************************************************************** default functions (see domain-pool.h) *****************************************************************************/ static domain_pool_t * default_alloc (void) { domain_pool_t *pool; pool = Calloc (1, sizeof (domain_pool_t)); pool->model = NULL; pool->generate = NULL; pool->bits = NULL; pool->update = default_update; pool->append = default_append; pool->chroma = default_chroma; pool->free = default_free; pool->model_free = default_model_free; pool->model_duplicate = default_model_duplicate; return pool; } static void * default_model_duplicate (const void *src) { return NULL; } static void * default_model_alloc (unsigned max_domains) { return NULL; } static void default_model_free (void *model) { if (model) Free (model); } static void default_free (domain_pool_t *pool) { pool->model_free (pool->model); Free (pool); } static void default_update (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, void *model) { return; /* nothing to do */ } static bool_t default_append (unsigned new_state, unsigned level, const wfa_t *wfa, void *model) { return YES; /* use every state in lin comb */ } static void default_chroma (unsigned max_domains, const wfa_t *wfa, void *model) { return; /* don't alter domain pool */ } static void init_matrix_probabilities (void) /* * Compute the information contents of matrix element '0' and '1' for * each possible probability index 0, ... , 1023. These values are * obtained from the probability model in the quasi arithmetic * coding module. * * No return value. * * Side effects: * local arrays matrix_0 and matrix_1 are initialized if not already done. */ { if (matrix_0 == NULL || matrix_1 == NULL) { unsigned index; unsigned n, exp; matrix_0 = Calloc (1 << (MAX_PROB + 1), sizeof (real_t)); matrix_1 = Calloc (1 << (MAX_PROB + 1), sizeof (real_t)); for (index = 0, n = MIN_PROB; n <= MAX_PROB; n++) for (exp = 0; exp < (unsigned) 1 << n; exp++, index++) { matrix_1 [index] = -log2 (1 / (real_t) (1 << n)); matrix_0 [index] = -log2 (1 - 1 / (real_t) (1 << n)); } } } netpbm-free-10.0-1/pnm/fiasco/codec/domain-pool.h0100644004714500471450000000413007716230207022023 0ustar aba-guestaba-guest/* * domain-pool.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _DOMAIN_POOL_H #define _DOMAIN_POOL_H #include "cwfa.h" #include "types.h" typedef struct domain_pool { void *model; /* probability model */ word_t *(*generate) (unsigned level, int y_state, const wfa_t *wfa, const void *model); /* * Generate set of domain images which may be used for an approximation. * Use parameters 'level', 'y_state' and 'wfa' to make the decision. */ real_t (*bits) (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, const void *model); /* * Compute bit-rate of a range approximation with domains given by * the -1 terminated list 'used_domains'. */ void (*update) (const word_t *domains, const word_t *used_domains, unsigned level, int y_state, const wfa_t *wfa, void *model); /* * Update the probability model according to the chosen approximation. * (given by the -1 terminated list 'used_domains'). */ bool_t (*append) (unsigned state, unsigned level, const wfa_t *wfa, void *model); /* * Try to append a new state to the domain pool. */ void (*chroma) (unsigned max_domains, const wfa_t *wfa, void *model); /* * Derive a new domain pool that will be used for chroma channel * coding */ void (*free) (struct domain_pool *pool); /* * Discard the given domain pool struct. */ void (*model_free) (void *model); /* * Free given probability model. */ void *(*model_duplicate) (const void *src); /* * Duplicate the given probability model (i.e. alloc and copy). */ } domain_pool_t; domain_pool_t * alloc_domain_pool (const char *domain_pool_name, unsigned max_domains, unsigned max_edges, const wfa_t *wfa); #endif /* not _DOMAIN_POOL_H */ netpbm-free-10.0-1/pnm/fiasco/codec/ip.c0100644004714500471450000002072207716230207020215 0ustar aba-guestaba-guest/* * ip.c: Computation of inner products * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #include "types.h" #include "macros.h" #include "error.h" #include "cwfa.h" #include "control.h" #include "ip.h" /***************************************************************************** prototypes *****************************************************************************/ static real_t standard_ip_image_state (unsigned address, unsigned level, unsigned domain, const coding_t *c); static real_t standard_ip_state_state (unsigned domain1, unsigned domain2, unsigned level, const coding_t *c); /***************************************************************************** public code *****************************************************************************/ real_t get_ip_image_state (unsigned image, unsigned address, unsigned level, unsigned domain, const coding_t *c) /* * Return value: * Inner product between 'image' ('address') and * 'domain' at given 'level' */ { if (level <= c->options.images_level) { /* * Compute the inner product in the standard way by multiplying * the pixel-values of the given domain and range image. */ return standard_ip_image_state (address, level, domain, c); } else { /* * Use the already computed inner products stored in 'ip_images_states' */ return c->ip_images_state [domain][image]; } } void compute_ip_images_state (unsigned image, unsigned address, unsigned level, unsigned n, unsigned from, const wfa_t *wfa, coding_t *c) /* * Compute the inner products between all states * 'from', ... , 'wfa->max_states' and the range images 'image' * (and childs) up to given level. * * No return value. * * Side effects: * inner product tables 'c->ip_images_states' are updated */ { if (level > c->options.images_level) { unsigned state, label; if (level > c->options.images_level + 1) /* recursive computation */ compute_ip_images_state (MAXLABELS * image + 1, address * MAXLABELS, level - 1, MAXLABELS * n, from, wfa, c); /* * Compute inner product */ for (label = 0; label < MAXLABELS; label++) for (state = from; state < wfa->states; state++) if (need_image (state, wfa)) { unsigned edge, count; int domain; real_t *dst, *src; if (ischild (domain = wfa->tree [state][label])) { if (level > c->options.images_level + 1) { dst = c->ip_images_state [state] + image; src = c->ip_images_state [domain] + image * MAXLABELS + label + 1; for (count = n; count; count--, src += MAXLABELS) *dst++ += *src; } else { unsigned newadr = address * MAXLABELS + label; dst = c->ip_images_state [state] + image; for (count = n; count; count--, newadr += MAXLABELS) *dst++ += standard_ip_image_state (newadr, level - 1, domain, c); } } for (edge = 0; isedge (domain = wfa->into [state][label][edge]); edge++) { real_t weight = wfa->weight [state][label][edge]; if (level > c->options.images_level + 1) { dst = c->ip_images_state [state] + image; src = c->ip_images_state [domain] + image * MAXLABELS + label + 1; for (count = n; count; count--, src += MAXLABELS) *dst++ += *src * weight; } else { unsigned newadr = address * MAXLABELS + label; dst = c->ip_images_state [state] + image; for (count = n; count; count--, newadr += MAXLABELS) *dst++ += weight * standard_ip_image_state (newadr, level - 1, domain, c); } } } } } real_t get_ip_state_state (unsigned domain1, unsigned domain2, unsigned level, const coding_t *c) /* * Return value: * Inner product between 'domain1' and 'domain2' at given 'level'. */ { if (level <= c->options.images_level) { /* * Compute the inner product in the standard way by multiplying * the pixel-values of both state-images */ return standard_ip_state_state (domain1, domain2, level, c); } else { /* * Use already computed inner products stored in 'ip_images_states' */ if (domain2 < domain1) return c->ip_states_state [domain1][level][domain2]; else return c->ip_states_state [domain2][level][domain1]; } } void compute_ip_states_state (unsigned from, unsigned to, const wfa_t *wfa, coding_t *c) /* * Computes the inner products between the current state 'state1' and the * old states 0,...,'state1'-1 * * No return value. * * Side effects: * inner product tables 'c->ip_states_state' are computed. */ { unsigned level; unsigned state1, state2; /* * Compute inner product */ for (level = c->options.images_level + 1; level <= c->options.lc_max_level; level++) for (state1 = from; state1 <= to; state1++) for (state2 = 0; state2 <= state1; state2++) if (need_image (state2, wfa)) { unsigned label; real_t ip = 0; for (label = 0; label < MAXLABELS; label++) { int domain1, domain2; unsigned edge1, edge2; real_t sum, weight2; if (ischild (domain1 = wfa->tree [state1][label])) { sum = 0; if (ischild (domain2 = wfa->tree [state2][label])) sum = get_ip_state_state (domain1, domain2, level - 1, c); for (edge2 = 0; isedge (domain2 = wfa->into [state2][label][edge2]); edge2++) { weight2 = wfa->weight [state2][label][edge2]; sum += weight2 * get_ip_state_state (domain1, domain2, level - 1, c); } ip += sum; } for (edge1 = 0; isedge (domain1 = wfa->into [state1][label][edge1]); edge1++) { real_t weight1 = wfa->weight [state1][label][edge1]; sum = 0; if (ischild (domain2 = wfa->tree [state2][label])) sum = get_ip_state_state (domain1, domain2, level - 1, c); for (edge2 = 0; isedge (domain2 = wfa->into [state2][label][edge2]); edge2++) { weight2 = wfa->weight [state2][label][edge2]; sum += weight2 * get_ip_state_state (domain1, domain2, level - 1, c); } ip += weight1 * sum; } } c->ip_states_state [state1][level][state2] = ip; } } /***************************************************************************** private code *****************************************************************************/ static real_t standard_ip_image_state (unsigned address, unsigned level, unsigned domain, const coding_t *c) /* * Returns the inner product between the subimage 'address' and the * state image 'domain' at given 'level'. The stored state images * and the image tree are used to compute the inner product in the * standard way by multiplying the corresponding pixel values. * * Return value: * computed inner product */ { unsigned i; real_t ip = 0, *imageptr, *stateptr; if (level > c->options.images_level) error ("Level %d not supported.", level); imageptr = &c->pixels [address * size_of_level (level)]; stateptr = c->images_of_state [domain] + address_of_level (level); for (i = size_of_level (level); i; i--) ip += *imageptr++ * *stateptr++; return ip; } static real_t standard_ip_state_state (unsigned domain1, unsigned domain2, unsigned level, const coding_t *c) /* * Returns the inner product between the subimage 'address' and the * state image 'state' at given 'level'. The stored state images are * used to compute the inner product in the standard way by * multiplying the corresponding pixel values. * * Return value: * computed inner product */ { unsigned i; real_t ip = 0, *state1ptr, *state2ptr; if (level > c->options.images_level) error ("Level %d not supported.", level); state1ptr = c->images_of_state [domain1] + address_of_level (level); state2ptr = c->images_of_state [domain2] + address_of_level (level); for (i = size_of_level (level); i; i--) ip += *state1ptr++ * *state2ptr++; return ip; } netpbm-free-10.0-1/pnm/fiasco/codec/ip.h0100644004714500471450000000152107716230207020216 0ustar aba-guestaba-guest/* * ip.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _IP_H #define _IP_H #include "cwfa.h" void compute_ip_states_state (unsigned from, unsigned to, const wfa_t *wfa, coding_t *c); real_t get_ip_state_state (unsigned domain1, unsigned domain2, unsigned level, const coding_t *c); void compute_ip_images_state (unsigned image, unsigned address, unsigned level, unsigned n, unsigned from, const wfa_t *wfa, coding_t *c); real_t get_ip_image_state (unsigned image, unsigned address, unsigned level, unsigned domain, const coding_t *c); #endif /* not _IP_H */ netpbm-free-10.0-1/pnm/fiasco/codec/motion.c0100644004714500471450000002323407716230207021113 0ustar aba-guestaba-guest/* * motion.c: Motion compensation code * * Written by: Ullrich Hafner * Michael Unger * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #if HAVE_STRING_H # include #else /* not HAVE_STRING_H */ # include #endif /* not HAVE_STRING_H */ #include "types.h" #include "macros.h" #include "error.h" #include "image.h" #include "misc.h" #include "motion.h" /***************************************************************************** public code *****************************************************************************/ void restore_mc (int enlarge_factor, image_t *image, const image_t *past, const image_t *future, const wfa_t *wfa) /* * Restore motion compensated prediction of 'image' represented by 'wfa'. * If 'enlarge_factor' != 0 then enlarge image by given amount. * Reference frames are given by 'past' and 'future'. * * No return values. */ { unsigned state, label; unsigned root_state; word_t *mcblock1, *mcblock2; /* MC blocks */ #define FX(v) ((image->format == FORMAT_4_2_0) && band != Y ? ((v) / 2) : v) mcblock1 = Calloc (size_of_level (max ((int) wfa->wfainfo->p_max_level + 2 * enlarge_factor, 0)), sizeof (word_t)); mcblock2 = Calloc (size_of_level (max ((int) wfa->wfainfo->p_max_level + 2 * enlarge_factor, 0)), sizeof (word_t)); if (!image->color) root_state = wfa->root_state; else root_state = wfa->tree [wfa->tree [wfa->root_state][0]][0]; for (state = wfa->basis_states; state <= root_state; state++) for (label = 0; label < MAXLABELS; label++) if (wfa->mv_tree[state][label].type != NONE) { color_e band; unsigned level = wfa->level_of_state [state] - 1; unsigned width = width_of_level (level); unsigned height = height_of_level (level); unsigned offset = image->width - width; switch (wfa->mv_tree [state][label].type) { case FORWARD: for (band = first_band (image->color); band <= last_band (image->color); band++) { extract_mc_block (mcblock1, FX (width), FX (height), past->pixels [band], FX (past->width), wfa->wfainfo->half_pixel, FX (wfa->x [state][label]), FX (wfa->y [state][label]), FX (wfa->mv_tree [state][label].fx), FX (wfa->mv_tree [state][label].fy)); { word_t *mc1; /* current pixel in MC block */ word_t *orig; /* current pixel in original image */ unsigned x, y; /* pixel coordinates */ mc1 = mcblock1; orig = (word_t *) image->pixels [band] + FX (wfa->x[state][label]) + FX (wfa->y[state][label]) * FX (image->width); for (y = FX (height); y; y--) { for (x = FX (width); x; x--) *orig++ += *mc1++; orig += FX (offset); } } } break; case BACKWARD: for (band = first_band (image->color); band <= last_band (image->color); band++) { extract_mc_block (mcblock1, FX (width), FX (height), future->pixels [band], FX (future->width), wfa->wfainfo->half_pixel, FX (wfa->x [state][label]), FX (wfa->y [state][label]), FX (wfa->mv_tree [state][label].bx), FX (wfa->mv_tree [state][label].by)); { word_t *mc1; /* current pixel in MC block 1 */ word_t *orig; /* current pixel in original image */ unsigned x, y; /* pixel coordinates */ mc1 = mcblock1; orig = (word_t *) image->pixels [band] + FX (wfa->x[state][label]) + FX (wfa->y[state][label]) * FX (image->width); for (y = FX (height); y; y--) { for (x = FX (width); x; x--) *orig++ += *mc1++; orig += FX (offset); } } } break; case INTERPOLATED: for (band = first_band (image->color); band <= last_band (image->color); band++) { extract_mc_block (mcblock1, FX (width), FX (height), past->pixels [band], FX (past->width), wfa->wfainfo->half_pixel, FX (wfa->x[state][label]), FX (wfa->y[state][label]), FX (wfa->mv_tree[state][label].fx), FX (wfa->mv_tree[state][label].fy)); extract_mc_block (mcblock2, FX (width), FX (height), future->pixels [band], FX (future->width), wfa->wfainfo->half_pixel, FX (wfa->x[state][label]), FX (wfa->y[state][label]), FX (wfa->mv_tree[state][label].bx), FX (wfa->mv_tree[state][label].by)); { word_t *mc1; /* current pixel in MC block 1 */ word_t *mc2; /* current pixel in MC block 1 */ word_t *orig; /* current pixel in original image */ unsigned x, y; /* pixel coordinates */ mc1 = mcblock1; mc2 = mcblock2; orig = (word_t *) image->pixels [band] + FX (wfa->x[state][label]) + FX (wfa->y[state][label]) * FX (image->width); for (y = FX (height); y; y--) { for (x = FX (width); x; x--) #ifdef HAVE_SIGNED_SHIFT *orig++ += (*mc1++ + *mc2++) >> 1; #else /* not HAVE_SIGNED_SHIFT */ *orig++ += (*mc1++ + *mc2++) / 2; #endif /* not HAVE_SIGNED_SHIFT */ orig += FX (offset); } } } break; default: break; } } if (image->color) { unsigned n; word_t *ptr; static int *clipping = NULL; unsigned shift = image->format == FORMAT_4_2_0 ? 2 : 0; if (!clipping) /* initialize clipping table */ { int i; clipping = Calloc (256 * 3, sizeof (int)); for (i = -128; i < 128; i++) clipping [256 + i + 128] = i; for (i = 0; i < 256; i++) clipping [i] = clipping [256]; for (i = 512; i < 512 + 256; i++) clipping [i] = clipping [511]; clipping += 256 + 128; } ptr = image->pixels [Cb]; for (n = (image->width * image->height) >> shift; n; n--, ptr++) #ifdef HAVE_SIGNED_SHIFT *ptr = clipping [*ptr >> 4] << 4; #else /* not HAVE_SIGNED_SHIFT */ *ptr = clipping [*ptr / 16] * 16; #endif /* not HAVE_SIGNED_SHIFT */ ptr = image->pixels [Cr]; for (n = (image->width * image->height) >> shift; n; n--, ptr++) #ifdef HAVE_SIGNED_SHIFT *ptr = clipping [*ptr >> 4] << 4; #else /* not HAVE_SIGNED_SHIFT */ *ptr = clipping [*ptr / 16] * 16; #endif /* not HAVE_SIGNED_SHIFT */ } Free (mcblock1); Free (mcblock2); } void extract_mc_block (word_t *mcblock, unsigned width, unsigned height, const word_t *reference, unsigned ref_width, bool_t half_pixel, unsigned xo, unsigned yo, unsigned mx, unsigned my) /* * Extract motion compensation image 'mcblock' of size 'width'x'height' * from 'reference' image (width is given by 'ref_width'). * Coordinates of reference block are given by ('xo' + 'mx', 'yo' + 'my'). * Use 'half_pixel' precision if specified. * * No return value. * * Side effects: * 'mcblock[]' MCPE block is filled with reference pixels */ { if (!half_pixel) /* Fullpixel precision */ { const word_t *rblock; /* pointer to reference image */ unsigned y; /* current row */ rblock = reference + (yo + my) * ref_width + (xo + mx); for (y = height; y; y--) { memcpy (mcblock, rblock, width * sizeof (word_t)); mcblock += width; rblock += ref_width; } } else /* Halfpixel precision */ { unsigned x, y; /* current coordinates */ unsigned offset; /* remaining pixels in row */ const word_t *rblock; /* pointer to reference image */ const word_t *ryblock; /* pointer to next line */ const word_t *rxblock; /* pointer to next column */ const word_t *rxyblock; /* pointer to next column & row */ rblock = reference + (yo + my / 2) * ref_width + (xo + mx / 2); ryblock = rblock + ref_width; /* pixel in next row */ rxblock = rblock + 1; /* pixel in next column */ rxyblock = ryblock + 1; /* pixel in next row & column */ offset = ref_width - width; if ((mx & 1) == 0) { if ((my & 1) == 0) /* Don't use halfpixel refinement */ for (y = height; y; y--) { memcpy (mcblock, rblock, width * sizeof (word_t)); mcblock += width; rblock += ref_width; } else /* Halfpixel in y direction */ for (y = height; y; y--) { for (x = width; x; x--) #ifdef HAVE_SIGNED_SHIFT *mcblock++ = (*rblock++ + *ryblock++) >> 1; #else /* not HAVE_SIGNED_SHIFT */ *mcblock++ = (*rblock++ + *ryblock++) / 2; #endif /* not HAVE_SIGNED_SHIFT */ rblock += offset; ryblock += offset; } } else { if ((my & 1) == 0) /* Halfpixel in x direction */ for (y = height; y; y--) { for (x = width; x; x--) #ifdef HAVE_SIGNED_SHIFT *mcblock++ = (*rblock++ + *rxblock++) >> 1; #else /* not HAVE_SIGNED_SHIFT */ *mcblock++ = (*rblock++ + *rxblock++) / 2; #endif /* not HAVE_SIGNED_SHIFT */ rblock += offset; rxblock += offset; } else /* Halfpixel in xy direction */ for (y = height; y; y--) { for (x = width; x; x--) #ifdef HAVE_SIGNED_SHIFT *mcblock++ = (*rblock++ + *rxblock++ + *ryblock++ + *rxyblock++) >> 2; #else /* not HAVE_SIGNED_SHIFT */ *mcblock++ = (*rblock++ + *rxblock++ + *ryblock++ + *rxyblock++) / 4; #endif /* not HAVE_SIGNED_SHIFT */ rblock += offset; ryblock += offset; rxblock += offset; rxyblock += offset; } } } } netpbm-free-10.0-1/pnm/fiasco/codec/motion.h0100644004714500471450000000140607716230207021115 0ustar aba-guestaba-guest/* * motion.h * * Written by: Ullrich Hafner * Michael Unger * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _MOTION_H #define _MOTION_H #include "wfa.h" #include "types.h" #include "image.h" void restore_mc (int enlarge_factor, image_t *image, const image_t *past, const image_t *future, const wfa_t *wfa); void extract_mc_block (word_t *mcblock, unsigned width, unsigned height, const word_t *reference, unsigned ref_width, bool_t half_pixel, unsigned xo, unsigned yo, unsigned mx, unsigned my); #endif /* not _MOTION_H */ netpbm-free-10.0-1/pnm/fiasco/codec/mwfa.c0100644004714500471450000006336507716230207020551 0ustar aba-guestaba-guest/* * mwfa.c: Initialization of MWFA coder * * Written by: Michael Unger * Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #include #if HAVE_STRING_H # include #else /* not HAVE_STRING_H */ # include #endif /* not HAVE_STRING_H */ #include "types.h" #include "macros.h" #include "error.h" #include "misc.h" #include "cwfa.h" #include "image.h" #include "mwfa.h" #include "motion.h" /***************************************************************************** local variables *****************************************************************************/ unsigned mv_code_table [33][2] = /* * MPEG's huffman code for vector components. Format: code_value, length */ { {0x19, 11}, {0x1b, 11}, {0x1d, 11}, {0x1f, 11}, {0x21, 11}, {0x23, 11}, {0x13, 10}, {0x15, 10}, {0x17, 10}, {0x7, 8}, {0x9, 8}, {0xb, 8}, {0x7, 7}, {0x3, 5}, {0x3, 4}, {0x3, 3}, {0x1, 1}, {0x2, 3}, {0x2, 4}, {0x2, 5}, {0x6, 7}, {0xa, 8}, {0x8, 8}, {0x6, 8}, {0x16, 10}, {0x14, 10}, {0x12, 10}, {0x22, 11}, {0x20, 11}, {0x1e, 11}, {0x1c, 11}, {0x1a, 11}, {0x18, 11} }; static const unsigned local_range = 6; /***************************************************************************** prototypes *****************************************************************************/ static void get_mcpe (word_t *mcpe, const image_t *original, unsigned x0, unsigned y0, unsigned width, unsigned height, const word_t *mcblock1, const word_t *mcblock2); static real_t mcpe_norm (const image_t *original, unsigned x0, unsigned y0, unsigned width, unsigned height, const word_t *mcblock1, const word_t *mcblock2); static real_t find_best_mv (real_t price, const image_t *original, const image_t *reference, unsigned x0, unsigned y0, unsigned width, unsigned height, real_t *bits, int *mx, int *my, const real_t *mc_norms, const wfa_info_t *wi, const motion_t *mt); static real_t find_second_mv (real_t price, const image_t *original, const image_t *reference, const word_t *mcblock1, unsigned xr, unsigned yr, unsigned width, unsigned height, real_t *bits, int *mx, int *my, const wfa_info_t *wi, const motion_t *mt); /***************************************************************************** public code *****************************************************************************/ motion_t * alloc_motion (const wfa_info_t *wi) /* * Motion structure constructor. * Allocate memory for the motion structure and * fill in default values specified by 'wi'. * * Return value: * pointer to the new option structure or NULL on error */ { int dx; /* motion vector coordinate */ unsigned level; unsigned range_size = wi->half_pixel ? square (wi->search_range) : square (2 * wi->search_range); motion_t *mt = Calloc (1, sizeof (motion_t)); mt->original = NULL; mt->past = NULL; mt->future = NULL; mt->xbits = Calloc (2 * wi->search_range, sizeof (real_t)); mt->ybits = Calloc (2 * wi->search_range, sizeof (real_t)); for (dx = -wi->search_range; dx < (int) wi->search_range; dx++) { mt->xbits [dx + wi->search_range] = mt->ybits [dx + wi->search_range] = mv_code_table [dx + wi->search_range][1]; } mt->mc_forward_norms = Calloc (MAXLEVEL, sizeof (real_t *)); mt->mc_backward_norms = Calloc (MAXLEVEL, sizeof (real_t *)); for (level = wi->p_min_level; level <= wi->p_max_level; level++) { mt->mc_forward_norms [level] = Calloc (range_size, sizeof (real_t)); mt->mc_backward_norms [level] = Calloc (range_size, sizeof (real_t)); } return mt; } void free_motion (motion_t *mt) /* * Motion struct destructor: * Free memory of 'motion' struct. * * No return value. * * Side effects: * structure 'motion' is discarded. */ { unsigned level; Free (mt->xbits); Free (mt->ybits); for (level = 0; level < MAXLEVEL; level++) { if (mt->mc_forward_norms [level]) Free (mt->mc_forward_norms [level]); if (mt->mc_backward_norms [level]) Free (mt->mc_backward_norms [level]); } Free (mt->mc_forward_norms); Free (mt->mc_backward_norms); Free (mt); } void subtract_mc (image_t *image, const image_t *past, const image_t *future, const wfa_t *wfa) /* * Subtract motion compensation from chrom channels of 'image'. * Reference frames are given by 'past' and 'future'. * * No return values. */ { unsigned state, label; word_t *mcblock1 = Calloc (size_of_level (wfa->wfainfo->p_max_level), sizeof (word_t)); word_t *mcblock2 = Calloc (size_of_level (wfa->wfainfo->p_max_level), sizeof (word_t)); for (state = wfa->basis_states; state < wfa->states; state++) for (label = 0; label < MAXLABELS; label++) if (wfa->mv_tree [state][label].type != NONE) { color_e band; /* current color band */ unsigned width, height; /* size of mcblock */ unsigned offset; /* remaining pixels in original */ width = width_of_level (wfa->level_of_state [state] - 1); height = height_of_level (wfa->level_of_state [state] - 1); offset = image->width - width; switch (wfa->mv_tree [state][label].type) { case FORWARD: for (band = first_band (image->color) + 1; band <= last_band (image->color); band++) { unsigned y; /* row of block */ word_t *mc1; /* pixel in MC block 1 */ word_t *orig; /* pixel in original image */ extract_mc_block (mcblock1, width, height, past->pixels [band], past->width, wfa->wfainfo->half_pixel, wfa->x [state][label], wfa->y [state][label], (wfa->mv_tree [state][label].fx / 2) * 2, (wfa->mv_tree [state][label].fy / 2) * 2); mc1 = mcblock1; orig = image->pixels [band] + wfa->x [state][label] + wfa->y [state][label] * image->width; for (y = height; y; y--) { unsigned x; /* column of block */ for (x = width; x; x--) *orig++ -= *mc1++; orig += offset; } } break; case BACKWARD: for (band = first_band (image->color) + 1; band <= last_band (image->color); band++) { unsigned y; /* row of block */ word_t *mc1; /* pixel in MC block 1 */ word_t *orig; /* pixel in original image */ extract_mc_block (mcblock1, width, height, future->pixels [band], future->width, wfa->wfainfo->half_pixel, wfa->x [state][label], wfa->y [state][label], (wfa->mv_tree [state][label].bx / 2) * 2, (wfa->mv_tree [state][label].by / 2) * 2); mc1 = mcblock1; orig = image->pixels [band] + wfa->x [state][label] + wfa->y [state][label] * image->width; for (y = height; y; y--) { unsigned x; /* column of block */ for (x = width; x; x--) *orig++ -= *mc1++; orig += offset; } } break; case INTERPOLATED: for (band = first_band (image->color) + 1; band <= last_band (image->color); band++) { unsigned y; /* row of block */ word_t *mc1; /* pixel in MC block 1 */ word_t *mc2; /* pixel in MC block 2 */ word_t *orig; /* pixel in original image */ extract_mc_block (mcblock1, width, height, past->pixels [band], past->width, wfa->wfainfo->half_pixel, wfa->x [state][label], wfa->y [state][label], (wfa->mv_tree[state][label].fx / 2) * 2, (wfa->mv_tree[state][label].fy / 2) * 2); extract_mc_block (mcblock2, width, height, future->pixels [band], future->width, wfa->wfainfo->half_pixel, wfa->x [state][label], wfa->y [state][label], (wfa->mv_tree[state][label].bx / 2) * 2, (wfa->mv_tree[state][label].by / 2) * 2); mc1 = mcblock1; mc2 = mcblock2; orig = image->pixels [band] + wfa->x [state][label] + wfa->y [state][label] * image->width; for (y = height; y; y--) { unsigned x; /* column of block */ for (x = width; x; x--) *orig++ -= (*mc1++ + *mc2++) / 2; orig += offset; } } break; default: break; } } Free (mcblock1); Free (mcblock2); } void find_P_frame_mc (word_t *mcpe, real_t price, range_t *range, const wfa_info_t *wi, const motion_t *mt) /* * Determine best motion vector for P-frame. * * No return value. * * Side effects: * range->mvt_bits (# of mv-tree bits) * range->mvxybits (# of bits for vector components) * mt->mcpe (MCPE in scan-order) */ { unsigned width = width_of_level (range->level); unsigned height = height_of_level (range->level); word_t *mcblock = Calloc (width * height, sizeof (word_t)); range->mv_tree_bits = 1; range->mv.type = FORWARD; /* * Find best matching forward prediction */ find_best_mv (price, mt->original, mt->past, range->x, range->y, width, height, &range->mv_coord_bits, &range->mv.fx, &range->mv.fy, mt->mc_forward_norms [range->level], wi, mt); /* * Compute MCPE */ extract_mc_block (mcblock, width, height, mt->past->pixels [GRAY], mt->past->width, wi->half_pixel, range->x, range->y, range->mv.fx, range->mv.fy); get_mcpe (mcpe, mt->original, range->x, range->y, width, height, mcblock, NULL); Free (mcblock); } void find_B_frame_mc (word_t *mcpe, real_t price, range_t *range, const wfa_info_t *wi, const motion_t *mt) /* * Determines best motion compensation for B-frame. * Steps: * 1) find best forward motion vector * 2) find best backward motion vector * 3) try both motion vectors together (interpolation) * 4) choose best mode (FORWARD, BACKWARD or INTERPOLATED) * Bitcodes: * FORWARD 000 * BACKWARD 001 * INTERPOLATED 01 * * Return values: * range->mvt_bits (# of mv-tree bits) * range->mvxybits (# of bits for vector components) * mt->mcpe (MCPE in scan-order) */ { mc_type_e mctype; /* type of motion compensation */ real_t forward_costs; /* costs of FORWARD mc */ real_t backward_costs; /* costs of BACKWARD mc */ real_t interp_costs; /* costs of INTERPOLATED mc */ real_t forward_bits; /* bits for FORWARD mc */ real_t backward_bits; /* bits for BACKWARD mc */ real_t interp_bits; /* bits for INTERPOLATED mc */ int fx, fy; /* coordinates FORWARD mc */ int bx, by; /* coordinates BACKWARD mc */ int ifx, ify; /* coordinates forw. INTERPOLATED mc */ int ibx, iby; /* coordinates back. INTERPOLATED mc */ unsigned width = width_of_level (range->level); unsigned height = height_of_level (range->level); word_t *mcblock1 = Calloc (width * height, sizeof (word_t)); word_t *mcblock2 = Calloc (width * height, sizeof (word_t)); /* * Forward interpolation: use past frame as reference */ forward_costs = find_best_mv (price, mt->original, mt->past, range->x, range->y, width, height, &forward_bits, &fx, &fy, mt->mc_forward_norms [range->level], wi, mt) + 3 * price; /* code 000 */ /* * Backward interpolation: use future frame as reference */ backward_costs = find_best_mv (price, mt->original, mt->future, range->x, range->y, width, height, &backward_bits, &bx, &by, mt->mc_backward_norms [range->level], wi, mt) + 3 * price; /* code 001 */ /* * Bidirectional interpolation: use both past and future frame as reference */ if (wi->cross_B_search) { real_t icosts1; /* costs interpolation alternative 1 */ real_t icosts2; /* costs interpolation alternative 2 */ real_t ibackward_bits; /* additional bits alternative 1 */ real_t iforward_bits; /* additional bits alternative 1 */ /* * Alternative 1: keep forward mv and vary backward mv locally */ extract_mc_block (mcblock1, width, height, mt->past->pixels [GRAY], mt->past->width, wi->half_pixel, range->x, range->y, fx, fy); ibx = bx; /* start with backward coordinates */ iby = by; icosts1 = find_second_mv (price, mt->original, mt->future, mcblock1, range->x, range->y, width, height, &ibackward_bits, &ibx, &iby, wi, mt) + (forward_bits + 2) * price; /* code 01 */ /* * Alternative 2: Keep backward mv and vary forward mv locally */ extract_mc_block (mcblock1, width, height, mt->future->pixels [GRAY], mt->future->width, wi->half_pixel, range->x, range->y, bx, by); ifx = fx; ify = fy; icosts2 = find_second_mv (price, mt->original, mt->past, mcblock1, range->x, range->y, width, height, &iforward_bits, &ifx, &ify, wi, mt) + (backward_bits + 2) * price; /* code 01 */ /* * Choose best alternative */ if (icosts1 < icosts2) { ifx = fx; ify = fy; interp_bits = forward_bits + ibackward_bits; interp_costs = icosts1; } else { ibx = bx; iby = by; interp_bits = iforward_bits + backward_bits; interp_costs = icosts2; } } else /* local exhaustive search */ { /* * Keep forward and backward mv due to time constraints */ ifx = fx; ify = fy; ibx = bx; iby = by; interp_bits = forward_bits + backward_bits; extract_mc_block (mcblock1, width, height, mt->past->pixels [GRAY], mt->past->width, wi->half_pixel, range->x, range->y, fx, fy); extract_mc_block (mcblock2, width, height, mt->future->pixels [GRAY], mt->future->width, wi->half_pixel, range->x, range->y, bx, by); interp_costs = mcpe_norm (mt->original, range->x, range->y, width, height, mcblock1, mcblock2) + (interp_bits + 2) * price; /* code 01 */ } /* * Choose alternative with smallest costs */ if (forward_costs <= interp_costs) { if (forward_costs <= backward_costs) mctype = FORWARD; else mctype = BACKWARD; } else { if (backward_costs <= interp_costs) mctype = BACKWARD; else mctype = INTERPOLATED; } switch (mctype) { case FORWARD: range->mv_tree_bits = 3; range->mv_coord_bits = forward_bits; range->mv.type = FORWARD; range->mv.fx = fx; range->mv.fy = fy; extract_mc_block (mcblock1, width, height, mt->past->pixels [GRAY], mt->past->width, wi->half_pixel, range->x, range->y, range->mv.fx, range->mv.fy); get_mcpe (mcpe, mt->original, range->x, range->y, width, height, mcblock1, NULL); break; case BACKWARD: range->mv_tree_bits = 3; range->mv_coord_bits = backward_bits; range->mv.type = BACKWARD; range->mv.bx = bx; range->mv.by = by; extract_mc_block (mcblock1, width, height, mt->future->pixels [GRAY], mt->future->width, wi->half_pixel, range->x, range->y, range->mv.bx, range->mv.by); get_mcpe (mcpe, mt->original, range->x, range->y, width, height, mcblock1, NULL); break; case INTERPOLATED: range->mv_tree_bits = 2; range->mv_coord_bits = interp_bits; range->mv.type = INTERPOLATED; range->mv.fx = ifx; range->mv.fy = ify; range->mv.bx = ibx; range->mv.by = iby; extract_mc_block (mcblock1, width, height, mt->past->pixels [GRAY], mt->past->width, wi->half_pixel, range->x, range->y, range->mv.fx, range->mv.fy); extract_mc_block (mcblock2, width, height, mt->future->pixels [GRAY], mt->future->width, wi->half_pixel, range->x, range->y, range->mv.bx, range->mv.by); get_mcpe (mcpe, mt->original, range->x, range->y, width, height, mcblock1, mcblock2); break; default: break; } Free (mcblock1); Free (mcblock2); } void fill_norms_table (unsigned x0, unsigned y0, unsigned level, const wfa_info_t *wi, motion_t *mt) /* * Compute norms of difference images for all possible displacements * in 'mc_forward_norm' and 'mc_backward_norm'. * * No return value. * * Side effects: * 'mt->mc_backward_norms' are computed * 'mt->mc_forward_norms' are computed */ { int mx, my; /* coordinates of motion vector */ unsigned sr; /* mv search range +-'sr' pixels */ unsigned index = 0; /* index of motion vector */ unsigned width = width_of_level (level); unsigned height = height_of_level (level); word_t *mcblock = Calloc (width * height, sizeof (word_t)); sr = wi->half_pixel ? wi->search_range / 2 : wi->search_range; for (my = -sr; my < (int) sr; my++) for (mx = -sr; mx < (int) sr; mx++, index++) { if ((int) x0 + mx < 0 || /* block outside visible area */ x0 + mx + width > mt->original->width || (int) y0 + my < 0 || y0 + my + height > mt->original->height) { mt->mc_forward_norms [level][index] = 0.0; mt->mc_backward_norms [level][index] = 0.0; } else { extract_mc_block (mcblock, width, height, mt->past->pixels [GRAY], mt->past->width, wi->half_pixel, x0, y0, mx, my); mt->mc_forward_norms [level][index] = mcpe_norm (mt->original, x0, y0, width, height, mcblock, NULL); if (mt->frame_type == B_FRAME) { extract_mc_block (mcblock, width, height, mt->future->pixels [GRAY], mt->future->width, wi->half_pixel, x0, y0, mx, my); mt->mc_backward_norms[level][index] = mcpe_norm (mt->original, x0, y0, width, height, mcblock, NULL); } } } Free (mcblock); } /***************************************************************************** private code *****************************************************************************/ static void get_mcpe (word_t *mcpe, const image_t *original, unsigned x0, unsigned y0, unsigned width, unsigned height, const word_t *mcblock1, const word_t *mcblock2) /* * Compute MCPE image 'original' - reference. The reference is either * composed of 'mcblock1' or of ('mcblock1' + 'mcblock2') / 2 (if * 'mcblock2' != NULL). Coordinates of original block are given by * 'x0', 'y0', 'width', and 'height'. * * No return value. * * Side effects: * 'mcpe []' is filled with the delta image */ { const word_t *oblock; /* pointer to original image */ assert (mcpe); oblock = original->pixels [GRAY] + y0 * original->width + x0; if (mcblock2 != NULL) /* interpolated prediction */ { unsigned x, y; /* current coordinates */ for (y = height; y; y--) { for (x = width; x; x--) *mcpe++ = *oblock++ - (*mcblock1++ + *mcblock2++) / 2; oblock += original->width - width; } } else /* forward or backward prediction */ { unsigned x, y; /* current coordinates */ for (y = height; y; y--) { for (x = width; x; x--) *mcpe++ = *oblock++ - *mcblock1++; oblock += original->width - width; } } } static real_t mcpe_norm (const image_t *original, unsigned x0, unsigned y0, unsigned width, unsigned height, const word_t *mcblock1, const word_t *mcblock2) /* * Compute norm of motion compensation prediction error. * Coordinates of 'original' block are given by ('x0', 'y0') * and 'width', 'height'. * Reference blocks are stored in 'mcimage1' and 'mcimage2'. * * Return value: * square of norm of difference image */ { unsigned n; real_t norm = 0; word_t *mcpe = Calloc (width * height, sizeof (word_t)); word_t *ptr = mcpe; get_mcpe (mcpe, original, x0, y0, width, height, mcblock1, mcblock2); for (n = height * width; n; n--, ptr++) norm += square (*ptr / 16); Free (mcpe); return norm; } static real_t find_best_mv (real_t price, const image_t *original, const image_t *reference, unsigned x0, unsigned y0, unsigned width, unsigned height, real_t *bits, int *mx, int *my, const real_t *mc_norms, const wfa_info_t *wi, const motion_t *mt) /* * Find best matching motion vector in image 'reference' to predict * the block ('x0', 'y0') of size 'width'x'height in image 'original'. * * Return values: * prediction costs * * Side effects: * 'mx', 'my' coordinates of motion vector * 'bits' number of bits to encode mv */ { unsigned sr; /* mv search range +/- 'sr' pixels */ unsigned index; /* index of motion vector */ int x, y; /* coordinates of motion vector */ real_t costs; /* costs arising if mv is chosen */ real_t mincosts = MAXCOSTS; /* best costs so far */ unsigned bitshift; /* half_pixel coordinates multiplier */ *mx = *my = 0; /* * Find best fitting motion vector: * Use exhaustive search in the interval x,y +- sr (no halfpixel accuracy) * or x,y +- sr/2 (halfpixel accuracy) */ sr = wi->half_pixel ? wi->search_range / 2 : wi->search_range; bitshift = (wi->half_pixel ? 2 : 1); /* bit0 reserved for halfpixel pred. */ for (index = 0, y = -sr; y < (int) sr; y++) for (x = -sr; x < (int) sr; x++, index++) if ((int) x0 + x >= 0 && (int) y0 + y >= 0 && x0 + x + width <= original->width && y0 + y + height <= original->height) { /* * Block is inside visible area. * Compare current costs with 'mincosts' */ costs = mc_norms [index] + (mt->xbits [(x + sr) * bitshift] + mt->ybits [(y + sr) * bitshift]) * price; if (costs < mincosts) { mincosts = costs; *mx = x * bitshift; *my = y * bitshift; } } /* * Halfpixel prediction: * Compare all nine combinations (-1, y), (0, y), (+1, y) for y = -1,0,+1 */ if (wi->half_pixel) { int rx, ry; /* halfpixel refinement */ unsigned bestrx, bestry; /* coordinates of best mv */ word_t *mcblock = Calloc (width * height, sizeof (word_t)); bestrx = bestry = 0; for (rx = -1; rx <= 1; rx++) for (ry = -1; ry <= 1; ry++) { /* * Check if the new motion vector is in allowed area */ if (rx == 0 && ry == 0) /* already tested */ continue; if ((int) x0 + (*mx / 2) + rx < 0 || /* outside visible area */ x0 + (*mx / 2) + rx + width > original->width || (int) y0 + (*my / 2) + ry < 0 || y0 + (*my / 2) + ry + height > original->height) continue; if (*mx + rx < (int) -sr || *mx + rx >= (int) sr || *my + ry < (int) -sr || *my + ry >= (int) sr) continue; /* out of bounds */ /* * Compute costs of new motion compensation */ extract_mc_block (mcblock, width, height, reference->pixels [GRAY], reference->width, wi->half_pixel, x0, y0, *mx + rx, *my + ry); costs = mcpe_norm (mt->original, x0, y0, width, height, mcblock, NULL) + (mt->xbits [*mx + rx + sr * bitshift] + mt->ybits [*my + ry + sr * bitshift]) * price; if (costs < mincosts) { bestrx = rx; bestry = ry; mincosts = costs; } } *mx += bestrx; *my += bestry; Free (mcblock); } /* halfpixel */ *bits = mt->xbits [*mx + sr * bitshift] + mt->ybits [*my + sr * bitshift]; return mincosts; } static real_t find_second_mv (real_t price, const image_t *original, const image_t *reference, const word_t *mcblock1, unsigned xr, unsigned yr, unsigned width, unsigned height, real_t *bits, int *mx, int *my, const wfa_info_t *wi, const motion_t *mt) /* * Search local area (*mx,*my) for best additional mv. * Overwrite mt->tmpblock. * TODO check sr = search_range * * Return values: * prediction costs * * Side effects: * 'mx','my' coordinates of mv * 'bits' number of bits to encode mv */ { real_t mincosts = MAXCOSTS; /* best costs so far */ unsigned sr; /* MV search range +/- 'sr' pixels */ int x, y; /* coordinates of motion vector */ int y0, y1, x0, x1; /* start/end coord. of search range */ unsigned bitshift; /* half_pixel coordinates multiplier */ word_t *mcblock2 = Calloc (width * height, sizeof (word_t)); sr = wi->search_range; y0 = max ((int) -sr, *my - (int) local_range); y1 = min ((int) sr, *my + (int) local_range); x0 = max ((int) -sr, *mx - (int) local_range); x1 = min ((int) sr, *mx + (int) local_range); *mx = *my = 0; bitshift = (wi->half_pixel ? 2 : 1); /* bit0 reserved for halfpixel pred. */ for (y = y0; y < y1; y++) for (x = x0; x < x1; x++) { real_t costs; /* costs arising if mv is chosen */ /* * Test each mv ('x', 'y') in the given search range: * Get the new motion compensation image from 'reference' and compute * the norm of the motion compensation prediction error * 'original' - 0.5 * ('firstmc' + 'reference') */ if ((int) (xr * bitshift) + x < 0 || /* outside visible area */ xr * bitshift + x > (original->width - width) * bitshift || (int) (yr * bitshift) + y < 0 || yr * bitshift + y > (original->height - height) * bitshift) continue; extract_mc_block (mcblock2, width, height, reference->pixels [GRAY], reference->width, wi->half_pixel, x0, y0, x, y); costs = mcpe_norm (mt->original, x0, y0, width, height, mcblock1, mcblock2) + (mt->xbits [x + sr] + mt->ybits [y + sr]) * price; if (costs < mincosts) { mincosts = costs; *mx = x; *my = y; } } *bits = mt->xbits [*mx + sr] + mt->ybits [*my + sr]; Free (mcblock2); return mincosts; } netpbm-free-10.0-1/pnm/fiasco/codec/mwfa.h0100644004714500471450000000171707716230207020547 0ustar aba-guestaba-guest/* * mwfa.h * * Written by: Michael Unger * Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _MWFA_H #define _MWFA_H #include "types.h" #include "image.h" #include "wfa.h" #include "cwfa.h" void fill_norms_table (unsigned x0, unsigned y0, unsigned level, const wfa_info_t *wi, motion_t *mt); void find_B_frame_mc (word_t *mcpe, real_t price, range_t *range, const wfa_info_t *wi, const motion_t *mt); void find_P_frame_mc (word_t *mcpe, real_t price, range_t *range, const wfa_info_t *wi, const motion_t *mt); void subtract_mc (image_t *image, const image_t *past, const image_t *future, const wfa_t *wfa); void free_motion (motion_t *mt); motion_t * alloc_motion (const wfa_info_t *wi); #endif /* not _MWFA_H */ netpbm-free-10.0-1/pnm/fiasco/codec/options.c0100644004714500471450000005243207716230207021303 0ustar aba-guestaba-guest/* * options.c: FIASCO options handling * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #if HAVE_STRING_H # include #else /* not HAVE_STRING_H */ # include #endif /* not HAVE_STRING_H */ #if STDC_HEADERS # include #endif /* not STDC_HEADERS */ #include #include "types.h" #include "macros.h" #include "error.h" #include "wfa.h" #include "misc.h" #include "bit-io.h" #include "fiasco.h" #include "options.h" fiasco_c_options_t * fiasco_c_options_new (void) /* * FIASCO options constructor. * Allocate memory for the FIASCO coder options structure and * fill in default values. * * Return value: * pointer to the new option structure */ { c_options_t *options = calloc (1, sizeof (c_options_t)); fiasco_c_options_t *public = calloc (1, sizeof (fiasco_c_options_t)); if (!options || !public) { set_error (_("Out of memory.")); return NULL; } public->private = options; public->delete = fiasco_c_options_delete; public->set_tiling = fiasco_c_options_set_tiling; public->set_frame_pattern = fiasco_c_options_set_frame_pattern; public->set_basisfile = fiasco_c_options_set_basisfile; public->set_chroma_quality = fiasco_c_options_set_chroma_quality; public->set_optimizations = fiasco_c_options_set_optimizations; public->set_video_param = fiasco_c_options_set_video_param; public->set_quantization = fiasco_c_options_set_quantization; public->set_progress_meter = fiasco_c_options_set_progress_meter; public->set_smoothing = fiasco_c_options_set_smoothing; public->set_title = fiasco_c_options_set_title; public->set_comment = fiasco_c_options_set_comment; strcpy (options->id, "COFIASCO"); /* * Set default value of fiasco options */ options->basis_name = strdup ("small.fco"); options->lc_min_level = 4; options->lc_max_level = 12; options->p_min_level = 8; options->p_max_level = 10; options->images_level = 5; options->max_states = MAXSTATES; options->chroma_max_states = 40; options->max_elements = MAXEDGES; options->tiling_exponent = 4; options->tiling_method = FIASCO_TILING_VARIANCE_DSC; options->id_domain_pool = strdup ("rle"); options->id_d_domain_pool = strdup ("rle"); options->id_rpf_model = strdup ("adaptive"); options->id_d_rpf_model = strdup ("adaptive"); options->rpf_mantissa = 3; options->rpf_range = FIASCO_RPF_RANGE_1_50; options->dc_rpf_mantissa = 5; options->dc_rpf_range = FIASCO_RPF_RANGE_1_00; options->d_rpf_mantissa = 3; options->d_rpf_range = FIASCO_RPF_RANGE_1_50; options->d_dc_rpf_mantissa = 5; options->d_dc_rpf_range = FIASCO_RPF_RANGE_1_00; options->chroma_decrease = 2.0; options->prediction = NO; options->delta_domains = YES; options->normal_domains = YES; options->search_range = 16; options->fps = 25; options->pattern = strdup ("IPPPPPPPPP"); options->reference_filename = NULL; options->half_pixel_prediction = NO; options->cross_B_search = YES; options->B_as_past_ref = YES; options->check_for_underflow = NO; options->check_for_overflow = NO; options->second_domain_block = NO; options->full_search = NO; options->progress_meter = FIASCO_PROGRESS_NONE; options->smoothing = 70; options->comment = strdup (""); options->title = strdup (""); return public; } void fiasco_c_options_delete (fiasco_c_options_t *options) /* * FIASCO options destructor. * Free memory of FIASCO options struct. * * No return value. * * Side effects: * structure 'options' is discarded. */ { c_options_t *this = cast_c_options (options); if (!this) return; Free (this->id_domain_pool); Free (this->id_d_domain_pool); Free (this->id_rpf_model); Free (this->id_d_rpf_model); Free (this->pattern); Free (this->comment); Free (this->title); Free (this); return; } int fiasco_c_options_set_tiling (fiasco_c_options_t *options, fiasco_tiling_e method, unsigned exponent) /* * Set tiling `method' and `exponent'. * See type `fiasco_tiling_e' for a list of valid tiling `methods'. * The image is subdivied into 2^`exponent' tiles * * Return value: * 1 on success * 0 otherwise */ { c_options_t *this = (c_options_t *) cast_c_options (options); if (!this) { return 0; } switch (method) { case FIASCO_TILING_SPIRAL_ASC: case FIASCO_TILING_SPIRAL_DSC: case FIASCO_TILING_VARIANCE_ASC: case FIASCO_TILING_VARIANCE_DSC: this->tiling_method = method; break; default: set_error (_("Invalid tiling method `%d' specified " "(valid methods are 0, 1, 2, or 3)."), method); return 0; } this->tiling_exponent = exponent; return 1; } int fiasco_c_options_set_frame_pattern (fiasco_c_options_t *options, const char *pattern) /* * Set `pattern' of input frames. * `pattern' has to be a sequence of the following * characters (case insensitive): * 'i' intra frame * 'p' predicted frame * 'b' bidirectional predicted frame * E.g. pattern = 'IBBPBBPBB' * * When coding video frames the prediction type of input frame N is determined * by reading `pattern' [N] (`pattern' is periodically extended). * * Return value: * 1 on success * 0 otherwise */ { c_options_t *this = (c_options_t *) cast_c_options (options); if (!this) { return 0; } else if (!pattern) { set_error (_("Parameter `%s' not defined (NULL)."), "pattern"); return 0; } else if (strlen (pattern) < 1) { set_error (_("Frame type pattern doesn't contain any character.")); return 0; } else { const char *str; bool_t parse_error = NO; int c = 0; for (str = pattern; *str && !parse_error; str++) switch (*str) { case 'i': case 'I': case 'b': case 'B': case 'p': case 'P': break; default: c = *str; parse_error = YES; } if (parse_error) { set_error (_("Frame type pattern contains invalid character `%c' " "(choose I, B or P)."), c); return 0; } else { Free (this->pattern); this->pattern = strdup (pattern); return 1; } } } int fiasco_c_options_set_basisfile (fiasco_c_options_t *options, const char *filename) /* * Set `filename' of FIASCO initial basis. * * Return value: * 1 on success (if the file is readable) * 0 otherwise */ { c_options_t *this = (c_options_t *) cast_c_options (options); if (!this) { return 0; } else if (!filename) { set_error (_("Parameter `%s' not defined (NULL)."), "filename"); return 0; } else { /* Skip this because basis file may be linked with program, not in a separate file. See get_linked_basis(). NETPBM FILE *file = open_file (filename, "FIASCO_DATA", READ_ACCESS); if (file) { fclose (file); return 1; } else { set_error (_("Can't read basis file `%s'.\n%s."), filename, get_system_error ()); return 0; } */ return 1; } } int fiasco_c_options_set_chroma_quality (fiasco_c_options_t *options, float quality_factor, unsigned dictionary_size) /* * Set color compression parameters. * When coding chroma channels (Cb and Cr) * - approximation quality is given by `quality_factor' * `Y quality' and * - `dictionary_size' gives the number of dictionary elements. * * If 'quality' <= 0 then the luminancy coding quality is also during * chroma channel coding. * * Return value: * 1 on success * 0 otherwise */ { c_options_t *this = (c_options_t *) cast_c_options (options); if (!this) { return 0; } else if (!dictionary_size) { set_error (_("Size of chroma compression dictionary has to be " "a positive number.")); return 0; } else if (quality_factor <= 0) { set_error (_("Quality of chroma channel compression has to be " "positive value.")); return 0; } else { this->chroma_decrease = quality_factor; this->chroma_max_states = dictionary_size; return 1; } } int fiasco_c_options_set_optimizations (fiasco_c_options_t *options, unsigned min_block_level, unsigned max_block_level, unsigned max_elements, unsigned dictionary_size, unsigned optimization_level) /* * Set various optimization parameters. * - During compression only image blocks of size * {`min_block_level', ... ,`max_block_level'} are considered. * The smaller this set of blocks is the faster the coder runs * and the worse the image quality will be. * - An individual approximation may use at most `max_elements' * elements of the dictionary which itself contains at most * `dictionary_size' elements. The smaller these values are * the faster the coder runs and the worse the image quality will be. * - `optimization_level' enables some additional low level optimizations. * 0: standard approximation method * 1: significantly increases the approximation quality, * running time is twice as high as with the standard method * 2: hardly increases the approximation quality of method 1, * running time is twice as high as with method 1 * (this method just remains for completeness) * * Return value: * 1 on success * 0 otherwise */ { c_options_t *this = (c_options_t *) cast_c_options (options); if (!this) { return 0; } else if (!dictionary_size) { set_error (_("Size of dictionary has to be a positive number.")); return 0; } else if (!max_elements) { set_error (_("At least one dictionary element has to be used " "in an approximation.")); return 0; } else if (max_block_level < 4) { set_error (_("Maximum image block size has to be at least level 4.")); return 0; } else if (min_block_level < 4) { set_error (_("Minimum image block size has to be at least level 4.")); return 0; } else if (max_block_level < min_block_level) { set_error (_("Maximum block size has to be larger or " "equal minimum block size.")); return 0; } else { this->lc_min_level = min_block_level; this->lc_max_level = max_block_level; this->max_states = dictionary_size; this->max_elements = max_elements; this->second_domain_block = optimization_level > 0 ? YES : NO; this->check_for_overflow = optimization_level > 1 ? YES : NO; this->check_for_underflow = optimization_level > 1 ? YES : NO; this->full_search = optimization_level > 1 ? YES : NO; return 1; } } int fiasco_c_options_set_prediction (fiasco_c_options_t *options, int intra_prediction, unsigned min_block_level, unsigned max_block_level) /* * Set minimum and maximum size of image block prediction to * `min_block_level' and `max_block_level'. * (For either motion compensated prediction of inter frames * or DC based prediction of intra frames) * Prediction of intra frames is only used if `intra_prediction' != 0. * * Return value: * 1 on success * 0 otherwise */ { c_options_t *this = (c_options_t *) cast_c_options (options); if (!this) { return 0; } else if (max_block_level < 6) { set_error (_("Maximum prediction block size has to be " "at least level 6")); return 0; } else if (min_block_level < 6) { set_error (_("Minimum prediction block size has to be " "at least level 6")); return 0; } else if (max_block_level < min_block_level) { set_error (_("Maximum prediction block size has to be larger or " "equal minimum block size.")); return 0; } else { this->p_min_level = min_block_level; this->p_max_level = max_block_level; this->prediction = intra_prediction; return 1; } } int fiasco_c_options_set_video_param (fiasco_c_options_t *options, unsigned frames_per_second, int half_pixel_prediction, int cross_B_search, int B_as_past_ref) /* * Set various parameters used for video compensation. * 'frames_per_second' defines the frame rate which should be * used when the video is decoded. This value has no effect during coding, * it is just passed to the FIASCO output file. * If 'half_pixel_prediction' is not 0 then half pixel precise * motion compensated prediction is used. * If 'cross_B_search' is not 0 then the fast Cross-B-Search algorithm is * used to determine the motion vectors of interpolated prediction. Otherwise * exhaustive search (in the given search range) is used. * If 'B_as_past_ref' is not 0 then B frames are allowed to be used * for B frame predicion. * * Return value: * 1 on success * 0 otherwise */ { c_options_t *this = (c_options_t *) cast_c_options (options); if (!this) { return 0; } else { this->fps = frames_per_second; this->half_pixel_prediction = half_pixel_prediction; this->cross_B_search = cross_B_search; this->B_as_past_ref = B_as_past_ref; return 1; } } int fiasco_c_options_set_quantization (fiasco_c_options_t *options, unsigned mantissa, fiasco_rpf_range_e range, unsigned dc_mantissa, fiasco_rpf_range_e dc_range) /* * Set accuracy of coefficients quantization. * DC coefficients (of the constant dictionary vector f(x,y) = 1) * are quantized to values of the interval [-`dc_range', `dc_range'] using * #`dc_mantissa' bits. All other quantized coefficients are quantized in * an analogous way using the parameters `range' and `mantissa'. * * Return value: * 1 on success * 0 otherwise */ { c_options_t *this = (c_options_t *) cast_c_options (options); if (!this) { return 0; } else if (mantissa < 2 || mantissa > 8 || dc_mantissa < 2 || dc_mantissa > 8) { set_error (_("Number of RPF mantissa bits `%d', `%d' have to be in " "the interval [2,8]."), mantissa, dc_mantissa); return 0; } else { if ((range == FIASCO_RPF_RANGE_0_75 || range == FIASCO_RPF_RANGE_1_00 || range == FIASCO_RPF_RANGE_1_50 || range == FIASCO_RPF_RANGE_2_00) && (dc_range == FIASCO_RPF_RANGE_0_75 || dc_range == FIASCO_RPF_RANGE_1_00 || dc_range == FIASCO_RPF_RANGE_1_50 || dc_range == FIASCO_RPF_RANGE_2_00)) { this->rpf_range = range; this->dc_rpf_range = dc_range; this->rpf_mantissa = mantissa; this->dc_rpf_mantissa = dc_mantissa; return 1; } else { set_error (_("Invalid RPF ranges `%d', `%d' specified."), range, dc_range); return 0; } } } int fiasco_c_options_set_progress_meter (fiasco_c_options_t *options, fiasco_progress_e type) /* * Set type of progress meter. * * Return value: * 1 on success * 0 otherwise */ { c_options_t *this = (c_options_t *) cast_c_options (options); if (!this) { return 0; } switch (type) { case FIASCO_PROGRESS_BAR: case FIASCO_PROGRESS_PERCENT: case FIASCO_PROGRESS_NONE: this->progress_meter = type; break; default: set_error (_("Invalid progress meter `%d' specified " "(valid values are 0, 1, or 2)."), type); return 0; } return 1; } int fiasco_c_options_set_smoothing (fiasco_c_options_t *options, int smoothing) /* * Define `smoothing'-percentage along partitioning borders. * * Return value: * 1 on success * 0 otherwise */ { c_options_t *this = (c_options_t *) cast_c_options (options); if (!this) { return 0; } else if (smoothing < -1 || smoothing > 100) { set_error (_("Smoothing percentage must be in the range [-1, 100].")); return 0; } else { this->smoothing = smoothing; return 1; } } int fiasco_c_options_set_comment (fiasco_c_options_t *options, const char *comment) /* * Define `comment' of FIASCO stream. * * Return value: * 1 on success * 0 otherwise */ { c_options_t *this = (c_options_t *) cast_c_options (options); if (!this) { return 0; } else if (!comment) { set_error (_("Parameter `%s' not defined (NULL)."), "title"); return 0; } else { this->comment = strdup (comment); return 1; } } int fiasco_c_options_set_title (fiasco_c_options_t *options, const char *title) /* * Define `title' of FIASCO stream. * * Return value: * 1 on success * 0 otherwise */ { c_options_t *this = (c_options_t *) cast_c_options (options); if (!this) { return 0; } else if (!title) { set_error (_("Parameter `%s' not defined (NULL)."), "title"); return 0; } else { this->title = strdup (title); return 1; } } c_options_t * cast_c_options (fiasco_c_options_t *options) /* * Cast generic pointer `options' to type c_options_t. * Check whether `options' is a valid object of type c_options_t. * * Return value: * pointer to options struct on success * NULL otherwise */ { c_options_t *this = (c_options_t *) options->private; if (this) { if (!streq (this->id, "COFIASCO")) { set_error (_("Parameter `options' doesn't match required type.")); return NULL; } } else { set_error (_("Parameter `%s' not defined (NULL)."), "options"); } return this; } /************************************************************************** *************************************************************************** DECODER *************************************************************************** **************************************************************************/ fiasco_d_options_t * fiasco_d_options_new (void) /* * FIASCO options constructor. * Allocate memory for the FIASCO coder options structure and * fill in default values. * * Return value: * pointer to the new option structure */ { d_options_t *options = calloc (1, sizeof (d_options_t)); fiasco_d_options_t *public = calloc (1, sizeof (fiasco_d_options_t)); if (!options || !public) { set_error (_("Out of memory.")); return NULL; } public->private = options; public->delete = fiasco_d_options_delete; public->set_smoothing = fiasco_d_options_set_smoothing; public->set_magnification = fiasco_d_options_set_magnification; public->set_4_2_0_format = fiasco_d_options_set_4_2_0_format; strcpy (options->id, "DOFIASCO"); /* * Set default value of fiasco decoder options */ options->smoothing = 70; options->magnification = 0; options->image_format = FORMAT_4_4_4; return public; } void fiasco_d_options_delete (fiasco_d_options_t *options) /* * FIASCO options destructor. * Free memory of FIASCO options struct. * * No return value. * * Side effects: * structure 'options' is discarded. */ { d_options_t *this = cast_d_options (options); if (!this) return; Free (this); return; } int fiasco_d_options_set_smoothing (fiasco_d_options_t *options, int smoothing) /* * Define `smoothing'-percentage along partitioning borders. * * Return value: * 1 on success * 0 otherwise */ { d_options_t *this = (d_options_t *) cast_d_options (options); if (!this) { return 0; } else if (smoothing < -1 || smoothing > 100) { set_error (_("Smoothing percentage must be in the range [-1, 100].")); return 0; } else { this->smoothing = smoothing; return 1; } } int fiasco_d_options_set_magnification (fiasco_d_options_t *options, int level) /* * Set magnification-'level' of decoded image. * 0: width x height of original image * 1: (2 * width) x (2 * height) of original image * -1: (width / 2 ) x (height / 2) of original image * etc. * * Return value: * 1 on success * 0 otherwise */ { d_options_t *this = (d_options_t *) cast_d_options (options); if (!this) { return 0; } else { this->magnification = level; return 1; } } int fiasco_d_options_set_4_2_0_format (fiasco_d_options_t *options, int format) /* * Set image format to 4:2:0 or 4:4:4. * * Return value: * 1 on success * 0 otherwise */ { d_options_t *this = (d_options_t *) cast_d_options (options); if (!this) { return 0; } else { this->image_format = format ? FORMAT_4_2_0 : FORMAT_4_4_4; return 1; } } d_options_t * cast_d_options (fiasco_d_options_t *options) /* * Cast generic pointer `options' to type d_options_t. * Check whether `options' is a valid object of type d_options_t. * * Return value: * pointer to options struct on success * NULL otherwise */ { d_options_t *this = (d_options_t *) options->private; if (this) { if (!streq (this->id, "DOFIASCO")) { set_error (_("Parameter `options' doesn't match required type.")); return NULL; } } else { set_error (_("Parameter `%s' not defined (NULL)."), "options"); } return this; } netpbm-free-10.0-1/pnm/fiasco/codec/options.h0100644004714500471450000000425707716230207021312 0ustar aba-guestaba-guest/* * options.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _OPTIONS_H #define _OPTIONS_H typedef struct c_options { char id [9]; char *basis_name; unsigned lc_min_level; unsigned lc_max_level; unsigned p_min_level; unsigned p_max_level; unsigned images_level; unsigned max_states; unsigned chroma_max_states; unsigned max_elements; unsigned tiling_exponent; fiasco_tiling_e tiling_method; char *id_domain_pool; char *id_d_domain_pool; char *id_rpf_model; char *id_d_rpf_model; unsigned rpf_mantissa; real_t rpf_range; unsigned dc_rpf_mantissa; fiasco_rpf_range_e dc_rpf_range; unsigned d_rpf_mantissa; fiasco_rpf_range_e d_rpf_range; unsigned d_dc_rpf_mantissa; fiasco_rpf_range_e d_dc_rpf_range; real_t chroma_decrease; bool_t prediction; bool_t delta_domains; bool_t normal_domains; unsigned search_range; unsigned fps; char *pattern; char *reference_filename; bool_t half_pixel_prediction; bool_t cross_B_search; bool_t B_as_past_ref; bool_t check_for_underflow; bool_t check_for_overflow; bool_t second_domain_block; bool_t full_search; fiasco_progress_e progress_meter; char *title; char *comment; unsigned smoothing; } c_options_t; typedef struct d_options { char id [9]; unsigned smoothing; unsigned magnification; format_e image_format; } d_options_t; c_options_t * cast_c_options (fiasco_c_options_t *options); d_options_t * cast_d_options (fiasco_d_options_t *options); #endif /* not _OPTIONS_H */ netpbm-free-10.0-1/pnm/fiasco/codec/prediction.c0100644004714500471450000004644507716230207021757 0ustar aba-guestaba-guest/* * prediction.c: Range image prediction with MC or ND * * Written by: Ullrich Hafner * Michael Unger * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #if HAVE_STRING_H # include #else /* not HAVE_STRING_H */ # include #endif /* not HAVE_STRING_H */ #include "types.h" #include "macros.h" #include "error.h" #include "cwfa.h" #include "ip.h" #include "control.h" #include "misc.h" #include "subdivide.h" #include "bintree.h" #include "domain-pool.h" #include "approx.h" #include "wfalib.h" #include "mwfa.h" #include "prediction.h" #include "decoder.h" /***************************************************************************** local variables *****************************************************************************/ typedef struct state_data { real_t final_distribution; byte_t level_of_state; byte_t domain_type; real_t *images_of_state; real_t *inner_products; real_t *ip_states_state [MAXLEVEL]; word_t tree [MAXLABELS]; mv_t mv_tree [MAXLABELS]; word_t y_state [MAXLABELS]; byte_t y_column [MAXLABELS]; byte_t prediction [MAXLABELS]; u_word_t x [MAXLABELS]; u_word_t y [MAXLABELS]; real_t weight [MAXLABELS][MAXEDGES + 1]; word_t int_weight [MAXLABELS][MAXEDGES + 1]; word_t into [MAXLABELS][MAXEDGES + 1]; } state_data_t; /***************************************************************************** prototypes *****************************************************************************/ static real_t nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state, range_t *range, wfa_t *wfa, coding_t *c); static real_t mc_prediction (real_t max_costs, real_t price, unsigned band, int y_state, range_t *range, wfa_t *wfa, coding_t *c); static state_data_t * store_state_data (unsigned from, unsigned to, unsigned max_level, wfa_t *wfa, coding_t *c); static void restore_state_data (unsigned from, unsigned to, unsigned max_level, state_data_t *data, wfa_t *wfa, coding_t *c); /***************************************************************************** public code *****************************************************************************/ real_t predict_range (real_t max_costs, real_t price, range_t *range, wfa_t *wfa, coding_t *c, unsigned band, int y_state, unsigned states, const tree_t *tree_model, const tree_t *p_tree_model, const void *domain_model, const void *d_domain_model, const void *coeff_model, const void *d_coeff_model) { unsigned state; /* counter */ void *rec_domain_model; /* domain model after recursion */ void *rec_d_domain_model; /* p domain model after recursion */ void *rec_coeff_model; /* coeff model after recursion */ void *rec_d_coeff_model; /* d coeff model after recursion */ tree_t rec_tree_model; /* tree_model after '' */ tree_t rec_p_tree_model; /* p_tree_model after '' */ unsigned rec_states; /* wfa->states after '' */ real_t *rec_pixels; /* c->pixels after '' */ state_data_t *rec_state_data; /* state_data struct after '' */ real_t costs; /* current approximation costs */ unsigned level; /* counter */ state_data_t *sd; /* pointer to state_data field */ /* * Store WFA data from state 'lc_states' to 'wfa->states' - 1 and * current state of probability models. */ rec_domain_model = c->domain_pool->model; rec_d_domain_model = c->d_domain_pool->model; rec_coeff_model = c->coeff->model; rec_d_coeff_model = c->d_coeff->model; rec_tree_model = c->tree; rec_p_tree_model = c->p_tree; rec_states = wfa->states; rec_pixels = c->pixels; rec_state_data = store_state_data (states, rec_states - 1, c->options.lc_max_level, wfa, c); /* * Restore probability models to the state before the recursive subdivision * has been started. */ wfa->states = states; c->tree = *tree_model; c->p_tree = *p_tree_model; c->domain_pool->model = c->domain_pool->model_duplicate (domain_model); c->d_domain_pool->model = c->d_domain_pool->model_duplicate (d_domain_model); c->coeff->model = c->coeff->model_duplicate (c->coeff, coeff_model); c->d_coeff->model = c->d_coeff->model_duplicate (c->d_coeff, d_coeff_model); if (c->mt->frame_type == I_FRAME) costs = nd_prediction (max_costs, price, band, y_state, range, wfa, c); else costs = mc_prediction (max_costs, price, band, y_state, range, wfa, c); c->pixels = rec_pixels; if (costs < MAXCOSTS) { /* * Free the memory used by the state_data struct */ for (state = states; state < rec_states; state++) { sd = &rec_state_data [state - states]; for (level = c->options.images_level + 1; level <= c->options.lc_max_level; level++) if (sd->ip_states_state [level] != NULL) Free (sd->ip_states_state [level]); if (sd->images_of_state != NULL) Free (sd->images_of_state); if (sd->inner_products != NULL) Free (sd->inner_products); } if (states < rec_states) Free (rec_state_data); c->domain_pool->model_free (rec_domain_model); c->d_domain_pool->model_free (rec_d_domain_model); c->coeff->model_free (rec_coeff_model); c->d_coeff->model_free (rec_d_coeff_model); costs = (range->tree_bits + range->matrix_bits + range->weights_bits + range->mv_tree_bits + range->mv_coord_bits + range->nd_tree_bits + range->nd_weights_bits) * price + range->err; } else { /* * Restore WFA to state before function was called */ c->domain_pool->model_free (c->domain_pool->model); c->d_domain_pool->model_free (c->d_domain_pool->model); c->coeff->model_free (c->coeff->model); c->d_coeff->model_free (c->d_coeff->model); c->domain_pool->model = rec_domain_model; c->d_domain_pool->model = rec_d_domain_model; c->coeff->model = rec_coeff_model; c->d_coeff->model = rec_d_coeff_model; c->tree = rec_tree_model; c->p_tree = rec_p_tree_model; range->prediction = NO; if (wfa->states != states) remove_states (states, wfa); restore_state_data (states, rec_states - 1, c->options.lc_max_level, rec_state_data, wfa, c); costs = MAXCOSTS; } return costs; } void clear_norms_table (unsigned level, const wfa_info_t *wi, motion_t *mt) /* * Clear norms arrays. * * No return value. */ { unsigned range_size = wi->half_pixel ? square (wi->search_range) : square (2 * wi->search_range); if (level > wi->p_min_level) { memset (mt->mc_forward_norms [level], 0, range_size * sizeof(real_t)); memset (mt->mc_backward_norms [level], 0, range_size * sizeof(real_t)); } } void update_norms_table (unsigned level, const wfa_info_t *wi, motion_t *mt) /* * Norms table of levels larger than the bottom level are computed * by summing up previously calculated displacement costs of lower levels. * * No return value. */ { unsigned range_size = wi->half_pixel ? square (wi->search_range) : square (2 * wi->search_range); if (level > wi->p_min_level) { unsigned index; /* index of motion vector */ for (index = 0; index < range_size; index++) mt->mc_forward_norms [level][index] += mt->mc_forward_norms [level - 1][index]; if (mt->frame_type == B_FRAME) for (index = 0; index < range_size; index++) mt->mc_backward_norms [level][index] += mt->mc_backward_norms [level - 1][index]; } } /***************************************************************************** private code *****************************************************************************/ static real_t mc_prediction (real_t max_costs, real_t price, unsigned band, int y_state, range_t *range, wfa_t *wfa, coding_t *c) { real_t costs; /* current approximation costs */ range_t prange = *range; unsigned width = width_of_level (range->level); unsigned height = height_of_level (range->level); word_t *mcpe = Calloc (width * height, sizeof (word_t)); /* * If we are at the bottom level of the mc tree: * Fill in the norms table */ if (prange.level == wfa->wfainfo->p_min_level) fill_norms_table (prange.x, prange.y, prange.level, wfa->wfainfo, c->mt); /* * Predict 'range' with motion compensation according to frame type. * MCPE is returned in 'c->mcpe' */ if (c->mt->frame_type == P_FRAME) find_P_frame_mc (mcpe, price, &prange, wfa->wfainfo, c->mt); else find_B_frame_mc (mcpe, price, &prange, wfa->wfainfo, c->mt); costs = (prange.mv_tree_bits + prange.mv_coord_bits) * price; if (costs < max_costs) /* motion vector not too expensive */ { unsigned last_state; /* last WFA state before recursion */ real_t *ipi [MAXSTATES]; /* inner products pointers */ unsigned state; real_t mvt, mvc; c->pixels = Calloc (width * height, sizeof (real_t)); cut_to_bintree (c->pixels, mcpe, width, height, 0, 0, width, height); /* * Approximate MCPE recursively. */ last_state = wfa->states - 1; for (state = 0; state <= last_state; state++) if (need_image (state, wfa)) { ipi [state] = c->ip_images_state[state]; c->ip_images_state[state] = Calloc (size_of_tree (c->products_level), sizeof (real_t)); } mvc = prange.mv_coord_bits; mvt = prange.mv_tree_bits; prange.image = 0; prange.address = 0; prange.tree_bits = 0; prange.matrix_bits = 0; prange.weights_bits = 0; prange.mv_coord_bits = 0; prange.mv_tree_bits = 0; prange.nd_weights_bits = 0; prange.nd_tree_bits = 0; compute_ip_images_state (prange.image, prange.address, prange.level, 1, 0, wfa, c); costs += subdivide (max_costs - costs, band, y_state, &prange, wfa, c, NO, YES); if (costs < max_costs) /* use motion compensation */ { unsigned img, adr; /* temp. values */ img = range->image; adr = range->address; *range = prange; range->image = img; range->address = adr; range->mv_coord_bits = mvc; range->mv_tree_bits = mvt; range->prediction = YES; for (state = last_state + 1; state < wfa->states; state++) if (need_image (state, wfa)) memset (c->ip_images_state [state], 0, size_of_tree (c->products_level) * sizeof (real_t)); costs = (range->tree_bits + range->matrix_bits + range->weights_bits + range->mv_tree_bits + range->mv_coord_bits + range->nd_tree_bits + range->nd_weights_bits) * price + range->err; } else costs = MAXCOSTS; for (state = 0; state <= last_state; state++) if (need_image (state, wfa)) { Free (c->ip_images_state[state]); c->ip_images_state[state] = ipi [state]; } Free (c->pixels); } else costs = MAXCOSTS; Free (mcpe); return costs; } static real_t nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state, range_t *range, wfa_t *wfa, coding_t *c) { real_t costs; /* current approximation costs */ range_t lrange = *range; /* * Predict 'range' with DC component approximation */ { real_t x = get_ip_image_state (range->image, range->address, range->level, 0, c); real_t y = get_ip_state_state (0, 0, range->level, c); real_t w = btor (rtob (x / y, c->coeff->dc_rpf), c->coeff->dc_rpf); word_t s [2] = {0, -1}; lrange.into [0] = 0; lrange.into [1] = NO_EDGE; lrange.weight [0] = w; lrange.mv_coord_bits = 0; lrange.mv_tree_bits = 0; lrange.nd_tree_bits = tree_bits (LEAF, lrange.level, &c->p_tree); lrange.nd_weights_bits = 0; lrange.tree_bits = 0; lrange.matrix_bits = 0; lrange.weights_bits = c->coeff->bits (&w, s, range->level, c->coeff); } costs = price * (lrange.weights_bits + lrange.nd_tree_bits); /* * Recursive aproximation of difference image */ if (costs < max_costs) { unsigned state; range_t rrange; /* range: recursive subdivision */ unsigned last_state; /* last WFA state before recursion */ real_t *ipi [MAXSTATES]; /* inner products pointers */ unsigned width = width_of_level (range->level); unsigned height = height_of_level (range->level); real_t *pixels; /* * Generate difference image original - approximation */ { unsigned n; real_t *src, *dst; /* pointers to image data */ real_t w = - lrange.weight [0] * c->images_of_state [0][0]; src = c->pixels + range->address * size_of_level (range->level); dst = c->pixels = pixels = Calloc (width * height, sizeof (real_t)); for (n = width * height; n; n--) *dst++ = *src++ + w; } /* * Approximate difference recursively. */ rrange = *range; rrange.tree_bits = 0; rrange.matrix_bits = 0; rrange.weights_bits = 0; rrange.mv_coord_bits = 0; rrange.mv_tree_bits = 0; rrange.nd_tree_bits = 0; rrange.nd_weights_bits = 0; rrange.image = 0; rrange.address = 0; last_state = wfa->states - 1; for (state = 0; state <= last_state; state++) if (need_image (state, wfa)) { ipi [state] = c->ip_images_state[state]; c->ip_images_state[state] = Calloc (size_of_tree (c->products_level), sizeof (real_t)); } compute_ip_images_state (rrange.image, rrange.address, rrange.level, 1, 0, wfa, c); costs += subdivide (max_costs - costs, band, y_state, &rrange, wfa, c, NO, YES); Free (pixels); if (costs < max_costs && ischild (rrange.tree)) /* use prediction */ { unsigned img, adr; unsigned edge; img = range->image; adr = range->address; *range = rrange; range->image = img; range->address = adr; range->nd_tree_bits += lrange.nd_tree_bits; range->nd_weights_bits += lrange.weights_bits; for (edge = 0; isedge (lrange.into [edge]); edge++) { range->into [edge] = lrange.into [edge]; range->weight [edge] = lrange.weight [edge]; } range->into [edge] = NO_EDGE; range->prediction = edge; for (state = last_state + 1; state < wfa->states; state++) if (need_image (state, wfa)) memset (c->ip_images_state [state], 0, size_of_tree (c->products_level) * sizeof (real_t)); } else costs = MAXCOSTS; for (state = 0; state <= last_state; state++) if (need_image (state, wfa)) { Free (c->ip_images_state [state]); c->ip_images_state [state] = ipi [state]; } } else costs = MAXCOSTS; return costs; } static state_data_t * store_state_data (unsigned from, unsigned to, unsigned max_level, wfa_t *wfa, coding_t *c) /* * Save and remove all states starting from state 'from'. * * Return value: * pointer to array of state_data structs */ { state_data_t *data; /* array of savestates */ state_data_t *sd; /* pointer to current savestates */ unsigned state, label, level; if (to < from) return NULL; /* nothing to do */ data = Calloc (to - from + 1, sizeof (state_data_t)); for (state = from; state <= to; state++) { sd = &data [state - from]; sd->final_distribution = wfa->final_distribution [state]; sd->level_of_state = wfa->level_of_state [state]; sd->domain_type = wfa->domain_type [state]; sd->images_of_state = c->images_of_state [state]; sd->inner_products = c->ip_images_state [state]; wfa->domain_type [state] = 0; c->images_of_state [state] = NULL; c->ip_images_state [state] = NULL; for (label = 0; label < MAXLABELS; label++) { sd->tree [label] = wfa->tree [state][label]; sd->y_state [label] = wfa->y_state [state][label]; sd->y_column [label] = wfa->y_column [state][label]; sd->mv_tree [label] = wfa->mv_tree [state][label]; sd->x [label] = wfa->x [state][label]; sd->y [label] = wfa->y [state][label]; sd->prediction [label] = wfa->prediction [state][label]; memcpy (sd->weight [label], wfa->weight [state][label], sizeof (real_t) * (MAXEDGES + 1)); memcpy (sd->int_weight [label], wfa->int_weight [state][label], sizeof (word_t) * (MAXEDGES + 1)); memcpy (sd->into [label], wfa->into [state][label], sizeof (word_t) * (MAXEDGES + 1)); wfa->into [state][label][0] = NO_EDGE; wfa->tree [state][label] = RANGE; wfa->y_state [state][label] = RANGE; } for (level = c->options.images_level + 1; level <= max_level; level++) { sd->ip_states_state [level] = c->ip_states_state [state][level]; c->ip_states_state [state][level] = NULL; } } return data; } static void restore_state_data (unsigned from, unsigned to, unsigned max_level, state_data_t *data, wfa_t *wfa, coding_t *c) /* * Restore all state data starting from state 'from'. * * No return value. */ { state_data_t *sd; /* pointer to state_data item */ unsigned state, label, level; if (to < from) return; /* nothing to do */ for (state = from; state <= to; state++) { sd = &data [state - from]; wfa->final_distribution [state] = sd->final_distribution; wfa->level_of_state [state] = sd->level_of_state; wfa->domain_type [state] = sd->domain_type; if (c->images_of_state [state] != NULL) Free (c->images_of_state [state]); c->images_of_state [state] = sd->images_of_state; if (c->ip_images_state [state] != NULL) Free (c->ip_images_state [state]); c->ip_images_state [state] = sd->inner_products; for (label = 0; label < MAXLABELS; label++) { wfa->tree [state][label] = sd->tree [label]; wfa->y_state [state][label] = sd->y_state [label]; wfa->y_column [state][label] = sd->y_column [label]; wfa->mv_tree [state][label] = sd->mv_tree [label]; wfa->x [state][label] = sd->x [label]; wfa->y [state][label] = sd->y [label]; wfa->prediction [state][label] = sd->prediction [label]; memcpy (wfa->weight [state][label], sd->weight [label], sizeof(real_t) * (MAXEDGES + 1)); memcpy (wfa->int_weight [state][label], sd->int_weight [label], sizeof(word_t) * (MAXEDGES + 1)); memcpy (wfa->into [state][label], sd->into [label], sizeof(word_t) * (MAXEDGES + 1)); } for (level = c->options.images_level + 1; level <= max_level; level++) { if (c->ip_states_state [state][level] != NULL) Free (c->ip_states_state [state][level]); c->ip_states_state [state][level] = sd->ip_states_state [level]; } } Free (data); wfa->states = to + 1; } netpbm-free-10.0-1/pnm/fiasco/codec/prediction.h0100644004714500471450000000165107716230207021752 0ustar aba-guestaba-guest/* * prediction.h * * Written by: Ullrich Hafner * Michael Unger * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _PREDICTION_H #define _PREDICTION_H #include "types.h" #include "cwfa.h" real_t predict_range (real_t max_costs, real_t price, range_t *range, wfa_t *wfa, coding_t *c, unsigned band, int y_state, unsigned states, const tree_t *tree_model, const tree_t *p_tree_model, const void *domain_model, const void *d_domain_model, const void *coeff_model, const void *d_coeff_model); void update_norms_table (unsigned level, const wfa_info_t *wi, motion_t *mt); void clear_norms_table (unsigned level, const wfa_info_t *wi, motion_t *mt); #endif /* not _PREDICTION_H */ netpbm-free-10.0-1/pnm/fiasco/codec/subdivide.c0100644004714500471450000005306107716230207021565 0ustar aba-guestaba-guest/* * subdivide.c: Recursive subdivision of range images * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #if HAVE_STRING_H # include #else /* not HAVE_STRING_H */ # include #endif /* not HAVE_STRING_H */ #include "types.h" #include "macros.h" #include "error.h" #include "image.h" #include "cwfa.h" #include "approx.h" #include "ip.h" #include "bintree.h" #include "control.h" #include "prediction.h" #include "domain-pool.h" #include "mwfa.h" #include "misc.h" #include "subdivide.h" #include "list.h" #include "coeff.h" #include "wfalib.h" /***************************************************************************** prototypes *****************************************************************************/ static void init_new_state (bool_t auxiliary_state, bool_t delta, range_t *range, const range_t *child, const int *y_state, wfa_t *wfa, coding_t *c); static void init_range (range_t *range, const image_t *image, unsigned band, const wfa_t *wfa, coding_t *c); /***************************************************************************** public code *****************************************************************************/ real_t subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, wfa_t *wfa, coding_t *c, bool_t prediction, bool_t delta) /* * Subdivide the current 'range' recursively and decide whether * a linear combination, a recursive subdivision, or a prediction is * the best choice of approximation. * 'band' is the current color band, 'y_state' is the corresponding * state of the Y color component (color image compression only). * If 'prediction' is TRUE then also test motion compensation or * nondeterministic approximation. * If 'delta' is TRUE then current range is already predicted. * * Return value: * costs of the best approximation or MAXCOSTS if costs exceed 'max_costs' * * Side effects: * 'range' factors and costs of linear combination are modified * 'wfa' new transitions and prediction coefficients are added * 'c' pixels and inner products are updated */ { real_t subdivide_costs; /* Costs arising from approx. the current range with two childs */ real_t lincomb_costs; /* Costs arising from approx. the current range with a linear combination */ int new_y_state [MAXLABELS]; /* Corresponding state of Y */ real_t price; /* Approximation costs multiplier */ bool_t try_mc; /* YES: try MC prediction */ bool_t try_nd; /* YES: try ND prediction */ unsigned states; /* Number of states before the recursive subdivision starts */ void *domain_model; /* copy of domain pool model */ void *d_domain_model; /* copy of delta domain pool model */ void *lc_domain_model; /* copy of domain pool model */ void *lc_d_domain_model; /* copy of delta domain pool model */ void *coeff_model; /* copy of coefficients model */ void *d_coeff_model; /* copy of delta coefficients model */ void *lc_coeff_model; /* copy of coefficients model */ void *lc_d_coeff_model; /* copy of delta coefficients model */ tree_t tree_model; /* copy of tree model */ tree_t p_tree_model; /* copy of pred. tree model */ range_t lrange; /* range of lin. comb. approx. */ range_t rrange; /* range of recursive approx. */ range_t child [MAXLABELS]; /* new childs of the current range */ static unsigned percent = 0; /* status of progress meter */ if (wfa->wfainfo->level == range->level) percent = 0; range->into [0] = NO_EDGE; /* default approximation: empty */ range->tree = RANGE; if (range->level < 3) /* Don't process small ranges */ return MAXCOSTS; /* * If image permutation (tiling) is performed and the tiling level * is reached then get coordinates of the new block. */ if (c->tiling->exponent && range->level == wfa->wfainfo->level - c->tiling->exponent) { unsigned width, height; /* size of range (dummies)*/ if (c->tiling->vorder [range->global_address] < 0) return 0; /* nothing to do */ else locate_subimage (wfa->wfainfo->level, range->level, c->tiling->vorder [range->global_address], &range->x, &range->y, &width, &height); } if (range->x >= c->mt->original->width || range->y >= c->mt->original->height) return 0; /* range is not visible */ /* * Check whether prediction is allowed or not * mc == motion compensation, nd == nondeterminism */ try_mc = (prediction && c->mt->frame_type != I_FRAME && range->level >= wfa->wfainfo->p_min_level && range->level <= wfa->wfainfo->p_max_level && (range->x + width_of_level (range->level) <= c->mt->original->width) && (range->y + height_of_level (range->level) <= c->mt->original->height)); try_nd = (prediction && c->mt->frame_type == I_FRAME && range->level >= wfa->wfainfo->p_min_level && range->level <= wfa->wfainfo->p_max_level); if (try_mc) clear_norms_table (range->level, wfa->wfainfo, c->mt); /* * Check if current range must be initialized. I.e. range pixels must * be copied from entire image to bintree pixel buffer. Moreover, * all inner products tables must be initialized. */ if (range->level == c->options.lc_max_level) init_range (range, c->mt->original, band, wfa, c); price = c->price; if (band != Y) price *= c->options.chroma_decrease; /* less quality for chroma bands */ /* * Compute childs of corresponding state in Y band */ if (band != Y) /* Cb and Cr bands only */ { unsigned label; for (label = 0; label < MAXLABELS; label++) if (ischild (y_state)) new_y_state [label] = wfa->tree [y_state][label]; else new_y_state [label] = RANGE; } else new_y_state [0] = new_y_state [1] = RANGE; /* * Store contents of all models that may get modified during recursion */ domain_model = c->domain_pool->model_duplicate (c->domain_pool->model); d_domain_model = c->d_domain_pool->model_duplicate (c->d_domain_pool->model); coeff_model = c->coeff->model_duplicate (c->coeff, c->coeff->model); d_coeff_model = c->d_coeff->model_duplicate (c->d_coeff, c->d_coeff->model); tree_model = c->tree; p_tree_model = c->p_tree; states = wfa->states; /* * First alternative of range approximation: * Compute costs of linear combination. */ if (range->level <= c->options.lc_max_level) /* range is small enough */ { lrange = *range; lrange.tree = RANGE; lrange.tree_bits = tree_bits (LEAF, lrange.level, &c->tree); lrange.matrix_bits = 0; lrange.weights_bits = 0; lrange.mv_tree_bits = try_mc ? 1 : 0; /* mc allowed but not used */ lrange.mv_coord_bits = 0; lrange.nd_tree_bits = 0; lrange.nd_weights_bits = 0; lrange.prediction = NO; lincomb_costs = approximate_range (max_costs, price, c->options.max_elements, y_state, &lrange, (delta ? c->d_domain_pool : c->domain_pool), (delta ? c->d_coeff : c->coeff), wfa, c); } else lincomb_costs = MAXCOSTS; /* * Store contents of models that have been modified * by approximate_range () above ... */ lc_domain_model = c->domain_pool->model; lc_d_domain_model = c->d_domain_pool->model; lc_coeff_model = c->coeff->model; lc_d_coeff_model = c->d_coeff->model; /* * ... and restore them with values before lc */ c->domain_pool->model = c->domain_pool->model_duplicate (domain_model); c->d_domain_pool->model = c->d_domain_pool->model_duplicate (d_domain_model); c->coeff->model = c->coeff->model_duplicate (c->coeff, coeff_model); c->d_coeff->model = c->d_coeff->model_duplicate (c->d_coeff, d_coeff_model); /* * Second alternative of range approximation: * Compute costs of recursive subdivision. */ if (range->level > c->options.lc_min_level) /* range is large enough */ { unsigned label; memset (&child [0], 0, 2 * sizeof (range_t)); /* initialize childs */ /* * Initialize a new range for recursive approximation */ rrange = *range; rrange.tree_bits = tree_bits (CHILD, rrange.level, &c->tree); rrange.matrix_bits = 0; rrange.weights_bits = 0; rrange.err = 0; rrange.mv_tree_bits = try_mc ? 1 : 0; /* mc allowed but not used */ rrange.mv_coord_bits = 0; rrange.nd_tree_bits = try_nd ? tree_bits (CHILD, lrange.level, &c->p_tree): 0; rrange.nd_weights_bits = 0; rrange.prediction = NO; /* * Initialize the cost function and subdivide the current range. * Every child is approximated by a recursive call of subdivide() */ subdivide_costs = (rrange.tree_bits + rrange.weights_bits + rrange.matrix_bits + rrange.mv_tree_bits + rrange.mv_coord_bits + rrange.nd_tree_bits + rrange.nd_weights_bits) * price; for (label = 0; label < MAXLABELS; label++) { real_t remaining_costs; /* upper limit for next recursion */ child[label].image = rrange.image * MAXLABELS + label + 1; child[label].address = rrange.address * MAXLABELS + label; child[label].global_address = rrange.global_address * MAXLABELS + label; child[label].level = rrange.level - 1; child[label].x = rrange.level & 1 ? rrange.x : (rrange.x + label * width_of_level (rrange.level - 1)); child[label].y = rrange.level & 1 ? (rrange.y + label * height_of_level (rrange.level - 1)) : rrange.y; /* * If neccessary compute the inner products of the new states * (generated during the recursive approximation of child [0]) */ if (label && rrange.level <= c->options.lc_max_level) compute_ip_images_state (child[label].image, child[label].address, child[label].level, 1, states, wfa, c); /* * Call subdivide() for both childs. * Abort the recursion if 'subdivide_costs' exceed 'lincomb_costs' * or 'max_costs'. */ remaining_costs = min (lincomb_costs, max_costs) - subdivide_costs; if (remaining_costs > 0) /* still a way for improvement */ { subdivide_costs += subdivide (remaining_costs, band, new_y_state [label], &child [label], wfa, c, prediction, delta); } else if (try_mc && child[label].level >= wfa->wfainfo->p_min_level) { fill_norms_table (child[label].x, child[label].y, child[label].level, wfa->wfainfo, c->mt); } if (try_mc) update_norms_table (rrange.level, wfa->wfainfo, c->mt); /* * Update of progress meter */ if (c->options.progress_meter != FIASCO_PROGRESS_NONE) { if (c->options.progress_meter == FIASCO_PROGRESS_PERCENT) { unsigned new_percent; /* new status of progress meter */ new_percent = (child[label].global_address + 1) * 100.0 / (1 << (wfa->wfainfo->level - child[label].level)); if (new_percent > percent) { percent = new_percent; info ("%3d%% \r", percent); } } else if (c->options.progress_meter == FIASCO_PROGRESS_BAR) { unsigned new_percent; /* new status of progress meter */ new_percent = (child[label].global_address + 1) * 50.0 / (1 << (wfa->wfainfo->level - child[label].level)); for (; new_percent > percent; percent++) { info ("#"); } } } /* * If costs of subdivision exceed costs of linear combination * then abort recursion. */ if (subdivide_costs >= min (lincomb_costs, max_costs)) { subdivide_costs = MAXCOSTS; break; } rrange.err += child [label].err; rrange.tree_bits += child [label].tree_bits; rrange.matrix_bits += child [label].matrix_bits; rrange.weights_bits += child [label].weights_bits; rrange.mv_tree_bits += child [label].mv_tree_bits; rrange.mv_coord_bits += child [label].mv_coord_bits; rrange.nd_weights_bits += child [label].nd_weights_bits; rrange.nd_tree_bits += child [label].nd_tree_bits; tree_update (ischild (child [label].tree) ? CHILD : LEAF, child [label].level, &c->tree); tree_update (child [label].prediction ? LEAF : CHILD, child [label].level, &c->p_tree); } } else subdivide_costs = MAXCOSTS; /* * Third alternative of range approximation: * Predict range via motion compensation or nondeterminism and * approximate delta image. */ if (try_mc || try_nd) /* try prediction */ { real_t prediction_costs; /* Costs arising from approx. the current range with prediction */ prediction_costs = predict_range (min (min (lincomb_costs, subdivide_costs), max_costs), price, range, wfa, c, band, y_state, states, &tree_model, &p_tree_model, domain_model, d_domain_model, coeff_model, d_coeff_model); if (prediction_costs < MAXCOSTS) /* prediction has smallest costs */ { c->domain_pool->model_free (domain_model); c->d_domain_pool->model_free (d_domain_model); c->domain_pool->model_free (lc_domain_model); c->d_domain_pool->model_free (lc_d_domain_model); c->coeff->model_free (coeff_model); c->d_coeff->model_free (d_coeff_model); c->coeff->model_free (lc_coeff_model); c->d_coeff->model_free (lc_d_coeff_model); return prediction_costs; } } if (lincomb_costs >= MAXCOSTS && subdivide_costs >= MAXCOSTS) { /* * Return MAXCOSTS if neither a linear combination nor a recursive * subdivision yield costs less than 'max_costs' */ c->domain_pool->model_free (c->domain_pool->model); c->d_domain_pool->model_free (c->d_domain_pool->model); c->domain_pool->model_free (lc_domain_model); c->d_domain_pool->model_free (lc_d_domain_model); c->coeff->model_free (c->coeff->model); c->d_coeff->model_free (c->d_coeff->model); c->coeff->model_free (lc_coeff_model); c->d_coeff->model_free (lc_d_coeff_model); c->domain_pool->model = domain_model; c->d_domain_pool->model = d_domain_model; c->coeff->model = coeff_model; c->d_coeff->model = d_coeff_model; c->tree = tree_model; c->p_tree = p_tree_model; if (wfa->states != states) remove_states (states, wfa); return MAXCOSTS; } else if (lincomb_costs < subdivide_costs) { /* * Use the linear combination: The factors of the linear combination * are stored already in 'range', so revert the probability models * only. */ c->domain_pool->model_free (c->domain_pool->model); c->d_domain_pool->model_free (c->d_domain_pool->model); c->domain_pool->model_free (domain_model); c->d_domain_pool->model_free (d_domain_model); c->coeff->model_free (c->coeff->model); c->d_coeff->model_free (c->d_coeff->model); c->coeff->model_free (coeff_model); c->d_coeff->model_free (d_coeff_model); c->domain_pool->model = lc_domain_model; c->d_domain_pool->model = lc_d_domain_model; c->coeff->model = lc_coeff_model; c->d_coeff->model = lc_d_coeff_model; c->tree = tree_model; c->p_tree = p_tree_model; *range = lrange; if (wfa->states != states) remove_states (states, wfa); return lincomb_costs; } else { /* * Use the recursive subdivision: Generate a new state with transitions * given in child[]. * Don't use state in linear combinations in any of the following cases: * - if color component is Cb or Cr * - if level of state > tiling level * - if state is (partially) outside image geometry */ if (band > Y || (c->tiling->exponent && rrange.level > wfa->wfainfo->level - c->tiling->exponent) || (range->x + width_of_level (range->level) > c->mt->original->width) || (range->y + height_of_level (range->level) > c->mt->original->height)) init_new_state (YES, delta, &rrange, child, new_y_state, wfa, c); else init_new_state (NO, delta, &rrange, child, new_y_state, wfa, c); *range = rrange; c->domain_pool->model_free (domain_model); c->d_domain_pool->model_free (d_domain_model); c->domain_pool->model_free (lc_domain_model); c->d_domain_pool->model_free (lc_d_domain_model); c->coeff->model_free (coeff_model); c->d_coeff->model_free (d_coeff_model); c->coeff->model_free (lc_coeff_model); c->d_coeff->model_free (lc_d_coeff_model); return subdivide_costs; } } void cut_to_bintree (real_t *dst, const word_t *src, unsigned src_width, unsigned src_height, unsigned x0, unsigned y0, unsigned width, unsigned height) /* * Cut region ('x0', 'y0', 'width', 'height') of the pixel array 'src'. * Size of image is given by 'src_width' x 'src_height'. * 'dst' pixels are converted to bintree order and real format. * * No return value. * * Side effects: * 'dst []' is filled with corresponding region. */ { const unsigned mask01 = 0x555555; /* binary ...010101010101 */ const unsigned mask10 = 0xaaaaaa; /* binary ...101010101010 */ const unsigned mask01plus1 = mask01 + 1; /* binary ...010101010110 */ const unsigned mask10plus1 = mask10 + 1; /* binary ...101010101011 */ unsigned x, y; /* pixel coordinates */ unsigned xmask, ymask; /* address conversion */ if (width != height && width != (height >> 1)) error ("Bintree cutting requires special type of images."); ymask = 0; for (y = y0; y < y0 + height; y++, ymask = (ymask + mask10plus1) & mask01) { xmask = 0; for (x = x0; x < x0 + width; x++, xmask = (xmask + mask01plus1) & mask10) { if (y >= src_height || x >= src_width) dst [xmask | ymask] = 0; else dst [xmask | ymask] = src [y * src_width + x] / 16; } } } /***************************************************************************** private code *****************************************************************************/ static void init_new_state (bool_t auxiliary_state, bool_t delta, range_t *range, const range_t *child, const int *y_state, wfa_t *wfa, coding_t *c) /* * Initializes a new state with all parameters needed for the encoding step. * If flag 'auxiliary_state' is set then don't insert state into domain pools. * If flag 'delta' is set then state represents a delta image (prediction via * nondeterminism or motion compensation). * 'range' the current range image, * 'child []' the left and right childs of 'range'. * * No return value. * * Side effects: * New state is appended to 'wfa' (and also its inner products and images * are computed and stored in 'c') */ { unsigned label; bool_t state_is_domain = NO; if (!auxiliary_state) { if (!delta || c->options.delta_domains) state_is_domain = c->domain_pool->append (wfa->states, range->level, wfa, c->domain_pool->model); if (delta || c->options.normal_domains) state_is_domain = c->d_domain_pool->append (wfa->states, range->level, wfa, c->d_domain_pool->model) || state_is_domain; } else state_is_domain = NO; range->into [0] = NO_EDGE; range->tree = wfa->states; for (label = 0; label < MAXLABELS; label++) { wfa->tree [wfa->states][label] = child [label].tree; wfa->y_state [wfa->states][label] = y_state [label]; wfa->mv_tree [wfa->states][label] = child [label].mv; wfa->x [wfa->states][label] = child [label].x; wfa->y [wfa->states][label] = child [label].y; wfa->prediction [wfa->states][label] = child [label].prediction; append_transitions (wfa->states, label, child [label].weight, child [label].into, wfa); } wfa->delta_state [wfa->states] = delta; if (range->err < 0) warning ("Negative image norm: %f, %f", child [0].err, child [1].err); /* state_is_domain = YES; */ append_state (!state_is_domain, compute_final_distribution (wfa->states, wfa), range->level, wfa, c); } static void init_range (range_t *range, const image_t *image, unsigned band, const wfa_t *wfa, coding_t *c) /* * Read a new 'range' of the image 'image_name' (current color component * is 'band') and compute the new inner product arrays. * * No return value. * * Side effects: * 'c->pixels' are filled with pixel values of image block * 'c->ip_images_state' are computed with respect to new image block * 'range->address' and 'range->image' are initialized with zero */ { unsigned state; /* * Clear already computed products */ for (state = 0; state < wfa->states; state++) if (need_image (state, wfa)) memset (c->ip_images_state[state], 0, size_of_tree (c->products_level) * sizeof(real_t)); cut_to_bintree (c->pixels, image->pixels [band], image->width, image->height, range->x, range->y, width_of_level (range->level), height_of_level (range->level)); range->address = range->image = 0; compute_ip_images_state (0, 0, range->level, 1, 0, wfa, c); } netpbm-free-10.0-1/pnm/fiasco/codec/subdivide.h0100644004714500471450000000133107716230207021563 0ustar aba-guestaba-guest/* * subdivide.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _SUBDIVIDE_H #define _SUBDIVIDE_H #include "types.h" #include "cwfa.h" real_t subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, wfa_t *wfa, coding_t *c, bool_t prediction, bool_t delta); void cut_to_bintree (real_t *dst, const word_t *src, unsigned src_width, unsigned src_height, unsigned x0, unsigned y0, unsigned width, unsigned height); #endif /* not _SUBDIVIDE_H */ netpbm-free-10.0-1/pnm/fiasco/codec/tiling.c0100644004714500471450000001467407716230207021104 0ustar aba-guestaba-guest/* * tiling.c: Subimage permutation * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #if STDC_HEADERS # include #endif /* not STDC_HEADERS */ #include "types.h" #include "macros.h" #include "error.h" #include "image.h" #include "misc.h" #include "wfalib.h" #include "tiling.h" /***************************************************************************** prototypes *****************************************************************************/ static int cmpdecvar (const void *value1, const void *value2); static int cmpincvar (const void *value1, const void *value2); /***************************************************************************** public code *****************************************************************************/ typedef struct var_list { int address; /* bintree address */ real_t variance; /* variance of tile */ } var_list_t; tiling_t * alloc_tiling (fiasco_tiling_e method, unsigned tiling_exponent, unsigned image_level) /* * Image tiling constructor. * Allocate memory for the tiling_t structure. * `method' defines the tiling method (spiral or variance, * ascending or descending). * In case of invalid parameters, a structure with tiling.exponent == 0 is * returned. * * Return value * pointer to the new tiling structure on success */ { tiling_t *tiling = Calloc (1, sizeof (tiling_t)); if ((int) image_level - (int) tiling_exponent < 6) { tiling_exponent = 6; warning (_("Image tiles must be at least 8x8 pixels large.\n" "Setting tiling size to 8x8 pixels.")); } switch (method) { case FIASCO_TILING_SPIRAL_ASC: case FIASCO_TILING_SPIRAL_DSC: case FIASCO_TILING_VARIANCE_ASC: case FIASCO_TILING_VARIANCE_DSC: tiling_exponent = tiling_exponent; break; default: warning (_("Invalid tiling method specified. Disabling tiling.")); tiling_exponent = 0; break; } return tiling; } void free_tiling (tiling_t *tiling) /* * Tiling struct destructor: * Free memory of 'tiling' struct. * * No return value. * * Side effects: * structure 'tiling' is discarded. */ { if (tiling->vorder) Free (tiling->vorder); Free (tiling); } void perform_tiling (const image_t *image, tiling_t *tiling) /* * Compute image tiling permutation. * The image is split into 2**'tiling->exponent' tiles. * Depending on 'tiling->method', the following algorithms are used: * "VARIANCE_ASC" : Tiles are sorted by variance. * The first tile has the lowest variance * "VARIANCE_DSC" : Tiles are sorted by variance. * The first tile has the largest variance * "SPIRAL_ASC" : Tiles are sorted like a spiral starting * in the middle of the image. * "SPIRAL_DSC" : Tiles are sorted like a spiral starting * in the upper left corner. * * No return value. * * Side effects: * The tiling permutation is stored in 'tiling->vorder'. */ { if (tiling->exponent) { unsigned tiles = 1 << tiling->exponent; /* number of image tiles */ bool_t *tile_valid; /* tile i is in valid range ? */ tiling->vorder = Calloc (tiles, sizeof (int)); tile_valid = Calloc (tiles, sizeof (bool_t)); if (tiling->method == FIASCO_TILING_VARIANCE_ASC || tiling->method == FIASCO_TILING_VARIANCE_DSC) { unsigned address; /* bintree address of tile */ unsigned number; /* number of image tiles */ unsigned lx = log2 (image->width - 1) + 1; /* x level */ unsigned ly = log2 (image->height - 1) + 1; /* y level */ unsigned level = max (lx, ly) * 2 - ((ly == lx + 1) ? 1 : 0); var_list_t *var_list = Calloc (tiles, sizeof (var_list_t)); /* * Compute variances of image tiles */ for (number = 0, address = 0; address < tiles; address++) { unsigned width, height; /* size of image tile */ unsigned x0, y0; /* NW corner of image tile */ locate_subimage (level, level - tiling->exponent, address, &x0, &y0, &width, &height); if (x0 < image->width && y0 < image->height) /* valid range */ { if (x0 + width > image->width) /* outside image area */ width = image->width - x0; if (y0 + height > image->height) /* outside image area */ height = image->height - y0; var_list [number].variance = variance (image->pixels [GRAY], x0, y0, width, height, image->width); var_list [number].address = address; number++; tile_valid [address] = YES; } else tile_valid [address] = NO; } /* * Sort image tiles according to sign of 'tiling->exp' */ if (tiling->method == FIASCO_TILING_VARIANCE_DSC) qsort (var_list, number, sizeof (var_list_t), cmpdecvar); else qsort (var_list, number, sizeof (var_list_t), cmpincvar); for (number = 0, address = 0; address < tiles; address++) if (tile_valid [address]) { tiling->vorder [address] = var_list [number].address; number++; debug_message ("tile number %d has original address %d", number, tiling->vorder [address]); } else tiling->vorder [address] = -1; Free (var_list); } else if (tiling->method == FIASCO_TILING_SPIRAL_DSC || tiling->method == FIASCO_TILING_SPIRAL_ASC) { compute_spiral (tiling->vorder, image->width, image->height, tiling->exponent, tiling->method == FIASCO_TILING_SPIRAL_ASC); } else { warning ("Unsupported image tiling method.\n" "Skipping image tiling step."); tiling->exponent = 0; } } } /***************************************************************************** private code *****************************************************************************/ static int cmpincvar (const void *value1, const void *value2) /* * Sorts by increasing variances (quicksort sorting function). */ { return ((var_list_t *) value1)->variance - ((var_list_t *) value2)->variance; } static int cmpdecvar (const void *value1, const void *value2) /* * Sorts by decreasing variances (quicksort sorting function). */ { return ((var_list_t *) value2)->variance - ((var_list_t *) value1)->variance; } netpbm-free-10.0-1/pnm/fiasco/codec/tiling.h0100644004714500471450000000156107716230207021100 0ustar aba-guestaba-guest/* * tiling.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _TILING_H #define _TILING_H #include "image.h" #include "fiasco.h" typedef struct tiling { unsigned exponent; /* Image is split in 2^exp tiles */ fiasco_tiling_e method; /* Method of Image tiling */ int *vorder; /* Block permutation (size = 2^exp) -1 indicates empty block */ } tiling_t; void perform_tiling (const image_t *image, tiling_t *tiling); tiling_t * alloc_tiling (fiasco_tiling_e method, unsigned tiling_exponent, unsigned image_level); void free_tiling (tiling_t *tiling); #endif /* not _TILING_H */ netpbm-free-10.0-1/pnm/fiasco/codec/wfa.h0100644004714500471450000001155607716230207020374 0ustar aba-guestaba-guest/* * wfa.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _WFA_H #define _WFA_H #define MAXEDGES 5 #define MAXSTATES 6000 #define MAXLABELS 2 /* only bintree supported anymore */ #define MAXLEVEL 22 #define FIASCO_BINFILE_RELEASE 2 #define FIASCO_MAGIC "FIASCO" /* FIASCO magic number */ #define FIASCO_BASIS_MAGIC "Fiasco" /* FIASCO initial basis */ #define NO_EDGE -1 #define RANGE -1 #define NO_RANGE 0 #define CHILD 1 #define LEAF 0 #define MAX_PROB 9 #define MIN_PROB 1 /* * WFA state types: * 0: state is not allowed to be used in an * approximation and it's image is not needed * for ip computations. * AUXILIARY_MASK: state is required for computation of ip's but is not * allowed to be used in an approximation. * USE_DOMAIN_MASK: state is allowed to be used in an approximation. */ enum state_types {AUXILIARY_MASK = 1 << 0, USE_DOMAIN_MASK = 1 << 1}; #define isedge(x) ((x) != NO_EDGE) #define isdomain(x) ((x) != NO_EDGE) #define isrange(x) ((x) == RANGE) #define ischild(x) ((x) != RANGE) #define isauxiliary(d,wfa) ((wfa)->domain_type[d] & AUXILIARY_MASK) #define usedomain(d, wfa) ((wfa)->domain_type[d] & USE_DOMAIN_MASK) #define need_image(d,wfa) (isauxiliary ((d), (wfa)) || usedomain ((d), (wfa))) typedef enum mc_type {NONE, FORWARD, BACKWARD, INTERPOLATED} mc_type_e; typedef enum frame_type {I_FRAME, P_FRAME, B_FRAME} frame_type_e; typedef enum header {HEADER_END, HEADER_TITLE, HEADER_COMMENT} header_type_e; typedef struct mv /* * Motion vector components */ { mc_type_e type; /* motion compensation type */ int fx, fy; /* forward vector coordinates */ int bx, by; /* backward vector coordinates */ } mv_t; typedef struct range_info { unsigned x, y; /* coordinates of upper left corner */ unsigned level; /* bintree level of range */ } range_info_t; #include "image.h" #include "rpf.h" #include "bit-io.h" typedef struct wfa_info { char *wfa_name; /* filename of the WFA */ char *basis_name; /* filename of the initial basis */ char *title; /* title of FIASCO stream */ char *comment; /* comment for FIASCO stream */ unsigned max_states; /* max. cardinality of domain pool */ unsigned chroma_max_states; /* max. cardinality of domain pool for chroma band coding */ bool_t color; /* color image */ unsigned width; /* image width */ unsigned height; /* image height */ unsigned level; /* image level */ rpf_t *rpf; /* Standard reduced precision format */ rpf_t *dc_rpf; /* DC reduced precision format */ rpf_t *d_rpf; /* Delta reduced precision format */ rpf_t *d_dc_rpf; /* Delta DC reduced precision format */ unsigned frames; /* number of frames in the video */ unsigned fps; /* number of frames per second */ unsigned p_min_level; /* min. level of prediction */ unsigned p_max_level; /* max. level of prediction */ unsigned search_range; /* motion vector interval */ bool_t half_pixel; /* usage of half pixel precision */ bool_t cross_B_search; /* usage of Cross-B-Search */ bool_t B_as_past_ref; /* usage of B frames as ref's */ unsigned smoothing; /* smoothing of image along borders */ unsigned release; /* FIASCO file format release */ } wfa_info_t; typedef struct wfa /* * Used to store all informations and data structures of a WFA */ { wfa_info_t *wfainfo; /* misc. information about the WFA */ frame_type_e frame_type; /* intra, predicted, bi-directional */ unsigned states; /* number of states */ unsigned basis_states; /* number of states in the basis */ unsigned root_state; /* root of the tree */ real_t *final_distribution; /* one pixel images */ byte_t *level_of_state; /* level of the image part which is represented by the current state */ byte_t *domain_type; /* Bit_0==1: auxilliary state Bit_1==1: used for Y compr */ mv_t (*mv_tree)[MAXLABELS]; /* motion vectors */ word_t (*tree)[MAXLABELS]; /* bintree partitioning */ u_word_t (*x)[MAXLABELS]; /* range coordinate */ u_word_t (*y)[MAXLABELS]; /* range coordinate */ word_t (*into)[MAXLABELS][MAXEDGES + 1]; /* domain references */ real_t (*weight)[MAXLABELS][MAXEDGES + 1]; /* lin.comb. coefficients */ word_t (*int_weight)[MAXLABELS][MAXEDGES + 1]; /* bin. representation */ word_t (*y_state)[MAXLABELS]; /* bintree of Y component */ byte_t (*y_column)[MAXLABELS]; /* array for Y component references */ byte_t (*prediction)[MAXLABELS]; /* DC prediction */ bool_t (*delta_state); /* delta state */ } wfa_t; #endif /* not _WFA_H */ netpbm-free-10.0-1/pnm/fiasco/codec/wfalib.c0100644004714500471450000005222107716230207021050 0ustar aba-guestaba-guest/* * wfalib.c: Library functions both for encoding and decoding * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #if STDC_HEADERS # include #endif /* not STDC_HEADERS */ #if HAVE_STRING_H # include #else /* not HAVE_STRING_H */ # include #endif /* not HAVE_STRING_H */ #include "types.h" #include "macros.h" #include "error.h" #include "wfa.h" #include "misc.h" #include "wfalib.h" /***************************************************************************** prototypes *****************************************************************************/ static unsigned xy_to_address (unsigned x, unsigned y, unsigned level, unsigned n); /***************************************************************************** public code *****************************************************************************/ wfa_t * alloc_wfa (bool_t coding) /* * WFA constructor: * Initialize the WFA structure 'wfa' and allocate memory. * Flag 'coding' indicates whether WFA is used for coding or decoding. * * Return value: * pointer to the new WFA structure */ { wfa_t *wfa = Calloc (1, sizeof (wfa_t)); /* * Allocate memory */ wfa->final_distribution = Calloc (MAXSTATES, sizeof (real_t)); wfa->level_of_state = Calloc (MAXSTATES, sizeof (byte_t)); wfa->domain_type = Calloc (MAXSTATES, sizeof (byte_t)); wfa->delta_state = Calloc (MAXSTATES, sizeof (bool_t)); wfa->tree = Calloc (MAXSTATES * MAXLABELS, sizeof (word_t)); wfa->x = Calloc (MAXSTATES * MAXLABELS, sizeof (word_t)); wfa->y = Calloc (MAXSTATES * MAXLABELS, sizeof (word_t)); wfa->mv_tree = Calloc (MAXSTATES * MAXLABELS, sizeof (mv_t)); wfa->y_state = Calloc (MAXSTATES * MAXLABELS, sizeof (word_t)); wfa->into = Calloc (MAXSTATES * MAXLABELS * (MAXEDGES + 1), sizeof (word_t)); wfa->weight = Calloc (MAXSTATES * MAXLABELS * (MAXEDGES + 1), sizeof (real_t)); wfa->int_weight = Calloc (MAXSTATES * MAXLABELS * (MAXEDGES + 1), sizeof (word_t)); wfa->wfainfo = Calloc (1, sizeof (wfa_info_t));; wfa->prediction = Calloc (MAXSTATES * MAXLABELS, sizeof (byte_t)); wfa->wfainfo->wfa_name = NULL; wfa->wfainfo->basis_name = NULL; wfa->wfainfo->title = strdup (""); wfa->wfainfo->comment = strdup (""); /* * Initialize structure */ { unsigned state, label; wfa->states = 0; wfa->basis_states = 0; wfa->root_state = 0; for (state = 0; state < MAXSTATES; state++) { wfa->final_distribution [state] = 0; wfa->domain_type [state] = 0; for (label = 0; label < MAXLABELS; label++) { wfa->into [state][label][0] = NO_EDGE; wfa->tree [state][label] = RANGE; wfa->y_state [state][label] = RANGE; } } } if (coding) /* initialize additional variables */ wfa->y_column = Calloc (MAXSTATES * MAXLABELS, sizeof (byte_t)); else wfa->y_column = NULL; return wfa; } void free_wfa (wfa_t *wfa) /* * WFA destructor: * Free memory of given 'wfa'. * * No return value. * * Side effects: * 'wfa' struct is discarded. */ { if (wfa->wfainfo->wfa_name) Free (wfa->wfainfo->wfa_name); if (wfa->wfainfo->basis_name) Free (wfa->wfainfo->basis_name); if (wfa->wfainfo->title) Free (wfa->wfainfo->title); if (wfa->wfainfo->comment) Free (wfa->wfainfo->comment); Free (wfa->final_distribution); Free (wfa->level_of_state); Free (wfa->domain_type); Free (wfa->tree); Free (wfa->x); Free (wfa->y); Free (wfa->mv_tree); Free (wfa->y_state); Free (wfa->into); Free (wfa->weight); Free (wfa->int_weight); Free (wfa->wfainfo); Free (wfa->prediction); Free (wfa->delta_state); if (wfa->y_column) Free (wfa->y_column); Free (wfa); } real_t compute_final_distribution (unsigned state, const wfa_t *wfa) /* * Compute the final distribution of the given 'state'. * Uses the fact that the generated 'wfa' is average preserving. * * Return value: * final distribution */ { unsigned label; real_t final = 0; for (label = 0; label < MAXLABELS; label++) { unsigned edge; int domain; if (ischild (domain = wfa->tree [state][label])) final += wfa->final_distribution [domain]; for (edge = 0; isedge (domain = wfa->into [state][label][edge]); edge++) final += wfa->weight [state][label][edge] * wfa->final_distribution [domain]; } return final / MAXLABELS; } word_t * compute_hits (unsigned from, unsigned to, unsigned n, const wfa_t *wfa) /* * Selects the 'n' most popular domain images of the given 'wfa'. * Consider only linear combinations of state images * {i | 'from' <= i <= 'to'}. I.e. domains are in {i | from <= i < 'to'} * Always ensure that state 0 is among selected states even though from * may be > 0. * * Return value: * pointer to array of the most popular state images * sorted by increasing state numbers and terminated by -1 */ { word_t *domains; unsigned state, label, edge; int domain; pair_t *hits = Calloc (to, sizeof (pair_t)); for (domain = 0; domain < (int) to; domain++) { hits [domain].value = domain; hits [domain].key = 0; } for (state = from; state <= to; state++) for (label = 0; label < MAXLABELS; label++) for (edge = 0; isedge (domain = wfa->into [state][label][edge]); edge++) hits [domain].key++; qsort (hits + 1, to - 1, sizeof (pair_t), sort_desc_pair); n = min (to, n); domains = Calloc (n + 1, sizeof (word_t)); for (domain = 0; domain < (int) n && (!domain || hits [domain].key); domain++) domains [domain] = hits [domain].value; if (n != domain) debug_message ("Only %d domains have been used in the luminance.", domain); n = domain; qsort (domains, n, sizeof (word_t), sort_asc_word); domains [n] = -1; Free (hits); return domains; } void append_edge (unsigned from, unsigned into, real_t weight, unsigned label, wfa_t *wfa) /* * Append an edge from state 'from' to state 'into' with * the given 'label' and 'weight' to the 'wfa'. * * No return value. * * Side effects: * 'wfa' structure is changed. */ { unsigned new; /* position of the new edge */ unsigned edge; /* * First look where to insert the new edge: * edges are sorted by increasing 'into' values */ for (new = 0; (isedge (wfa->into [from][label][new]) && wfa->into [from][label][new] < (int) into); new++) ; /* * Move the edges 'n' to position 'n+1', for n = max, ..., 'new' */ for (edge = new; isedge (wfa->into [from][label][edge]); edge++) ; for (edge++; edge != new; edge--) { wfa->into [from][label][edge] = wfa->into [from][label][edge - 1]; wfa->weight [from][label][edge] = wfa->weight [from][label][edge - 1]; wfa->int_weight [from][label][edge] = wfa->int_weight [from][label][edge - 1]; } /* * Insert the new edge */ wfa->into [from][label][edge] = into; wfa->weight [from][label][edge] = weight; wfa->int_weight [from][label][edge] = weight * 512 + 0.5; } void remove_states (unsigned from, wfa_t *wfa) /* * Remove 'wfa' states 'wfa->basis_states',...,'wfa->states' - 1. * * No return value. * * Side effects: * 'wfa' structure is cleared for the given states. */ { unsigned state; for (state = from; state < wfa->states; state++) { unsigned label; for (label = 0; label < MAXLABELS; label++) { wfa->into [state][label][0] = NO_EDGE; wfa->tree [state][label] = RANGE; wfa->prediction [state][label] = FALSE; wfa->y_state [state][label] = RANGE; wfa->mv_tree [state][label].type = NONE; wfa->mv_tree [state][label].fx = 0; wfa->mv_tree [state][label].fy = 0; wfa->mv_tree [state][label].bx = 0; wfa->mv_tree [state][label].by = 0; } wfa->domain_type [state] = 0; wfa->delta_state [state] = FALSE; } wfa->states = from; } void copy_wfa (wfa_t *dst, const wfa_t *src) /* * Copy WFA struct 'src' to WFA struct 'dst'. * * No return value. * * Side effects: * 'dst' is filled with same data as 'src' * * NOTE: size of WFA 'dst' must be at least size of WFA 'src' */ { unsigned state; memset (dst->final_distribution, 0, MAXSTATES * sizeof (real_t)); memset (dst->level_of_state, 0, MAXSTATES * sizeof (byte_t)); memset (dst->domain_type, 0, MAXSTATES * sizeof (byte_t)); memset (dst->mv_tree, 0, MAXSTATES * MAXLABELS * sizeof (mv_t)); memset (dst->tree, 0, MAXSTATES * MAXLABELS * sizeof (word_t)); memset (dst->x, 0, MAXSTATES * MAXLABELS * sizeof (word_t)); memset (dst->y, 0, MAXSTATES * MAXLABELS * sizeof (word_t)); memset (dst->y_state, 0, MAXSTATES * MAXLABELS * sizeof (word_t)); memset (dst->into, NO_EDGE, MAXSTATES * MAXLABELS * (MAXEDGES + 1) * sizeof (word_t)); memset (dst->weight, 0, MAXSTATES * MAXLABELS * (MAXEDGES + 1) * sizeof (real_t)); memset (dst->int_weight, 0, MAXSTATES * MAXLABELS * (MAXEDGES + 1) * sizeof (word_t)); memset (dst->prediction, 0, MAXSTATES * MAXLABELS * sizeof (byte_t)); memset (dst->delta_state, 0, MAXSTATES * sizeof (bool_t)); if (dst->y_column) memset (dst->y_column, 0, MAXSTATES * MAXLABELS * sizeof (byte_t)); for (state = 0; state < MAXSTATES; state++) /* clear WFA struct */ { unsigned label; for (label = 0; label < MAXLABELS; label++) { dst->into [state][label][0] = NO_EDGE; dst->tree [state][label] = RANGE; dst->mv_tree [state][label].type = NONE; dst->y_state[state][label] = RANGE; } dst->delta_state [state] = NO; dst->domain_type [state] = 0; } dst->frame_type = src->frame_type; dst->states = src->states; dst->basis_states = src->basis_states; dst->root_state = src->root_state; memcpy (dst->wfainfo, src->wfainfo, sizeof (wfa_info_t)); if (dst->states == 0) /* nothing to do */ return; memcpy (dst->final_distribution, src->final_distribution, src->states * sizeof (real_t)); memcpy (dst->level_of_state, src->level_of_state, src->states * sizeof (byte_t)); memcpy (dst->domain_type, src->domain_type, src->states * sizeof (byte_t)); memcpy (dst->delta_state, src->delta_state, src->states * sizeof (bool_t)); memcpy (dst->mv_tree, src->mv_tree, src->states * MAXLABELS * sizeof (mv_t)); memcpy (dst->tree, src->tree, src->states * MAXLABELS * sizeof (word_t)); memcpy (dst->x, src->x, src->states * MAXLABELS * sizeof (word_t)); memcpy (dst->y, src->y, src->states * MAXLABELS * sizeof (word_t)); memcpy (dst->y_state, src->y_state, src->states * MAXLABELS * sizeof (word_t)); memcpy (dst->into, src->into, src->states * MAXLABELS * (MAXEDGES + 1) * sizeof (word_t)); memcpy (dst->weight, src->weight, src->states * MAXLABELS * (MAXEDGES + 1) * sizeof (real_t)); memcpy (dst->int_weight, src->int_weight, src->states * MAXLABELS * (MAXEDGES + 1) * sizeof (word_t)); memcpy (dst->prediction, src->prediction, src->states * MAXLABELS * sizeof (byte_t)); if (dst->y_column) memcpy (dst->y_column, src->y_column, src->states * MAXLABELS * sizeof (byte_t)); } void locate_subimage (unsigned orig_level, unsigned level, unsigned bintree, unsigned *x, unsigned *y, unsigned *width, unsigned *height) /* * Compute pixel coordinates of the subimage which 'bintree' address is given. * The level of the original image is 'orig_level' and the level of the * subimage is 'level'. * * No return value. * * Side effects: * '*x', '*y' coordinates of the upper left corner * '*width', '*height' size of image */ { /* * Compute coordinates of the subimage */ *x = *y = 0; /* start at NW corner */ *width = width_of_level (level); *height = height_of_level (level); if (level > orig_level) { error ("size of tile must be less or equal than image size."); return; } else if (bintree >= (unsigned) (1 << (orig_level - level))) { error ("address out of bounds."); return; } else if (level < orig_level) { unsigned mask; /* mask for bintree -> xy conversion */ bool_t hor; /* 1 next subdivision is horizontal 0 next subdivision is vertical */ unsigned l = orig_level - 1; /* current level */ hor = orig_level % 2; /* start with vertival subdivision for square image and vice versa */ for (mask = 1 << (orig_level - level - 1); mask; mask >>= 1, hor = !hor) { if (bintree & mask) /* change coordinates */ { if (hor) /* horizontal subdivision */ *y += height_of_level (l); else /* vertical subdivision */ *x += width_of_level (l); } l--; } } } void compute_spiral (int *vorder, unsigned image_width, unsigned image_height, unsigned tiling_exp, bool_t inc_spiral) /* * Compute image tiling with spiral order. * 'inc_spiral' specifies whether the spiral starts in the middle * of the image (TRUE) or at the border (FALSE). * 'image_width'x'image_height' define the size of the image. * The image is split into 'tiling->exp' tiles. * * No return value. * * Side effects: * vorder[] is filled with tiling permutation */ { unsigned x, y; /* current position */ unsigned xmin, xmax, ymin, ymax; /* boundaries for current line */ unsigned width, height; /* offset for each tile */ unsigned lx, ly, level; /* level x and y */ unsigned tiles; /* total number of tiles */ unsigned address; /* bintree address */ lx = log2 (image_width - 1) + 1; ly = log2 (image_height - 1) + 1; level = max (lx, ly) * 2 - ((ly == lx + 1) ? 1 : 0); tiles = 1 << tiling_exp; /* Number of image tiles */ width = width_of_level (level - tiling_exp); height = height_of_level (level - tiling_exp); for (address = 0; address < tiles; address++) { unsigned x0, y0, width, height; locate_subimage (level, level - tiling_exp, address, &x0, &y0, &width, &height); vorder [address] = (x0 < image_width && y0 < image_height) ? 0 : -1; } xmin = 0; xmax = width_of_level (level); ymin = 0; ymax = height_of_level (level); address = 0; /* * 1234 * CDE5 Traverse image in spiral order * BGF6 starting at the top left corner * A987 */ while (TRUE) { for (x = xmin, y = ymin; x < xmax; x += width) /* W>E */ { while (vorder [address] == -1) address++; if (x < image_width && y < image_height) /* valid range */ vorder [address++] = xy_to_address (x, y, level, tiling_exp); while (address < tiles && vorder [address] == -1) address++; } ymin += height; if (address >= tiles) break; for (x = xmax - width, y = ymin; y < ymax; y += height) /* N>S */ { while (vorder [address] == -1) address++; if (x <= image_width && y <= image_height) /* valid range */ vorder [address++] = xy_to_address (x, y, level, tiling_exp); while (address < tiles && vorder [address] == -1) address++; } xmax -= width; if (address >= tiles) break; for (x = xmax - width, y = ymax - width; x >= xmin; x -= width) /* E= tiles) break; for (x = xmin, y = ymax - height; y >= ymin; y -= height) /* S>N */ { while (vorder [address] == -1) address++; if (x <= image_width && y <= image_height) /* valid range */ vorder [address++] = xy_to_address (x, y, level, tiling_exp); while (address < tiles && vorder [address] == -1) address++; } xmin += width; if (address >= tiles) break; } if (inc_spiral) { int i = 0, j = tiles - 1; while (i < j) { int tmp; while (vorder [i] == -1) i++; while (vorder [j] == -1) j--; tmp = vorder [i]; vorder [i] = vorder [j]; vorder [j] = tmp; i++; j--; } } /* * Print tiling info */ { unsigned number; for (number = 0, address = 0; address < tiles; address++) if (vorder [address] != -1) debug_message ("number %d: address %d", number++, vorder [address]); } } bool_t find_range (unsigned x, unsigned y, unsigned band, const wfa_t *wfa, unsigned *range_state, unsigned *range_label) /* * Find a range ('*range_state', '*range_label') that contains * pixel ('x', 'y') in the iven color 'band'. * * Return value: * TRUE on success, or FALSE if there is no such range * * Side effects: * '*range_state' and '*range_label' are modified on success. */ { unsigned state, label; unsigned first_state, last_state; bool_t success = NO; first_state = wfa->basis_states; last_state = wfa->states; if (wfa->wfainfo->color) switch (band) { case Y: first_state = wfa->basis_states; last_state = wfa->tree [wfa->tree [wfa->root_state][0]][0]; break; case Cb: first_state = wfa->tree [wfa->tree [wfa->root_state][0]][0] + 1; last_state = wfa->tree [wfa->tree [wfa->root_state][0]][1]; break; case Cr: first_state = wfa->tree [wfa->tree [wfa->root_state][0]][1] + 1; last_state = wfa->states; break; default: error ("unknown color component."); } for (state = first_state; state < last_state; state++) for (label = 0; label < MAXLABELS; label++) if (isrange (wfa->tree [state][label])) if (x >= wfa->x [state][label] && y >= wfa->y [state][label] && x < (unsigned) (wfa->x [state][label] + width_of_level (wfa->level_of_state [state] - 1)) && y < (unsigned) (wfa->y [state][label] + height_of_level (wfa->level_of_state [state] - 1))) { success = YES; *range_state = state; *range_label = label; return success; } return success; } void sort_ranges (unsigned state, unsigned *domain, range_sort_t *rs, const wfa_t *wfa) /* * Generate list of ranges in coder order. * 'state' is the current state of the call tree while 'domain' is the * index of the last added WFA state. * * Side effects: * 'domain' is incremented after recursion returns * 'rs' is filled accordingly * * No return value. */ { unsigned label; for (label = 0; label < MAXLABELS; label++) { if (isrange (wfa->tree [state][label])) rs->range_subdivided [rs->range_no] = NO; else { sort_ranges (wfa->tree [state][label], domain, rs, wfa); rs->range_subdivided [rs->range_no] = YES; } rs->range_state [rs->range_no] = state; rs->range_label [rs->range_no] = label; rs->range_max_domain [rs->range_no] = *domain; while (!usedomain (rs->range_max_domain [rs->range_no], wfa)) rs->range_max_domain [rs->range_no]--; if (label == 1 || !rs->range_subdivided [rs->range_no]) rs->range_no++; } (*domain)++; } bool_t locate_delta_images (wfa_t *wfa) /* * Locate all WFA states that are part of a delta approximation. * I.e., these states are assigned to ranges that have been predicted * via MC or ND. * * Return value: * TRUE at least one state is part of a delta approximation * FALSE no delta approximations in this WFA * * Side effects: * 'wfa->delta [state][label]' is set accordingly. */ { unsigned state, label; bool_t delta = NO; for (state = wfa->root_state; state >= wfa->basis_states; state--) wfa->delta_state [state] = NO; for (state = wfa->root_state; state >= wfa->basis_states; state--) for (label = 0; label < MAXLABELS; label++) if (ischild (wfa->tree [state][label])) if (wfa->mv_tree [state][label].type != NONE || isedge (wfa->into [state][label][0]) || wfa->delta_state [state]) { delta = YES; wfa->delta_state [wfa->tree [state][label]] = YES; } return delta; } /***************************************************************************** private code ******************************************************************************/ static unsigned xy_to_address (unsigned x, unsigned y, unsigned level, unsigned n) /* * Compute bintree address of subimage at coordinates ('x', 'y'). * Size of original image is determined by 'level'. * 'n' specifies number of iterations. * * Return value: * address of subimage */ { unsigned address = 0; while (n--) { address <<= 1; if (--level % 2) { if (x & width_of_level (level)) address++; } else { if (y & height_of_level (level)) address++; } } return address; } netpbm-free-10.0-1/pnm/fiasco/codec/wfalib.h0100644004714500471450000000306707716230207021061 0ustar aba-guestaba-guest/* * wfalib.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _WFALIB_H #define _WFALIB_H #include "types.h" #include "wfa.h" #include "list.h" typedef struct range_sort { u_word_t *range_state; byte_t *range_label; u_word_t *range_max_domain; bool_t *range_subdivided; unsigned range_no; } range_sort_t; bool_t locate_delta_images (wfa_t *wfa); void sort_ranges (unsigned state, unsigned *domain, range_sort_t *rs, const wfa_t *wfa); bool_t find_range (unsigned x, unsigned y, unsigned band, const wfa_t *wfa, unsigned *range_state, unsigned *range_label); void compute_spiral (int *vorder, unsigned image_width, unsigned image_height, unsigned tiling_exp, bool_t inc_spiral); void locate_subimage (unsigned orig_level, unsigned level, unsigned bintree, unsigned *x, unsigned *y, unsigned *width, unsigned *height); void copy_wfa (wfa_t *dst, const wfa_t *src); void remove_states (unsigned from, wfa_t *wfa); void append_edge (unsigned from, unsigned into, real_t weight, unsigned label, wfa_t *wfa); word_t * compute_hits (unsigned from, unsigned to, unsigned n, const wfa_t *wfa); real_t compute_final_distribution (unsigned state, const wfa_t *wfa); wfa_t * alloc_wfa (bool_t coding); void free_wfa (wfa_t *wfa); bool_t locate_delta_images (wfa_t *wfa); #endif /* not _WFALIB_H */ netpbm-free-10.0-1/pnm/fiasco/Makefile0100644004714500471450000000263707724372231020034 0ustar aba-guestaba-guestSRCDIR=../.. BUILDDIR = $(SRCDIR) include $(BUILDDIR)/Makefile.config INCLUDE = -I$(SRCDIR)/shhopt -I. -Icodec -Iinput -Ioutput -Ilib BINARIES = pnmtofiasco fiascotopnm MANUALS1 = $(BINARIES) all: $(BINARIES) pnmtofiasco_OBJECTS = binerror.o cwfa.o getopt.o getopt1.o params.o fiascotopnm_OBJECTS = binerror.o dwfa.o getopt.o getopt1.o params.o OBJECTS = binerror.o cwfa.o getopt.o getopt1.o params.o dwfa.o FIASCOLIBS = codec/libfiasco_codec.a input/libfiasco_input.a \ output/libfiasco_output.a lib/libfiasco_lib.a pnmtofiasco: $(pnmtofiasco_OBJECTS) $(FIASCOLIBS) $(LIBOPT) $(NETPBMLIB) $(LD) $(LDFLAGS) -o $@ $(pnmtofiasco_OBJECTS) \ `$(LIBOPT) $(FIASCOLIBS)` \ -L$(SRCDIR)/lib/share/ $(NETPBMLIB) -lm $(CDEBUG) fiascotopnm: $(fiascotopnm_OBJECTS) $(FIASCOLIBS) $(LIBOPT) $(LD) $(LDFLAGS) -o $@ $(fiascotopnm_OBJECTS) \ `$(LIBOPT) $(FIASCOLIBS)` \ -L$(SRCDIR)/lib/share/ $(NETPBMLIB) -lm $(CDEBUG) $(pnmtofiasco_OBJECTS) $(fiascotopnm_OBJECTS): \ fiasco.h config.h codec/libfiasco_codec.a: FORCE $(MAKE) -C codec libfiasco_codec.a input/libfiasco_input.a: FORCE $(MAKE) -C input libfiasco_input.a output/libfiasco_output.a: FORCE $(MAKE) -C output libfiasco_output.a lib/libfiasco_lib.a: FORCE $(MAKE) -C lib libfiasco_lib.a include $(SRCDIR)/Makefile.common .PHONY: clean clean: clean.common $(MAKE) -C codec clean $(MAKE) -C input clean $(MAKE) -C output clean $(MAKE) -C lib clean FORCE: netpbm-free-10.0-1/pnm/fiasco/Makefile.depend0100644004714500471450000000000007716230207021245 0ustar aba-guestaba-guestnetpbm-free-10.0-1/pnm/fiasco/README.netpbm0100644004714500471450000000340707716230207020531 0ustar aba-guestaba-guestThe 'fiasco' subdirectory of the Netpbm source tree is primarily a copy of the source distribution of the Fiasco package by Ullrich Hafner. Bryan Henderson adapted fiasco-1.0 on July 6, 2000 to netpbm, and then merged in all the updates from fiasco-1.3 on February 9, 2001. The changes are: - Uses Netpbm libraries for input and output of Netpbm format images. - Works with maxvals other than 255 in Netpbm input images. This change also makes a minor correction to the maxval 255 case. Where the Fiasco package multiplies by 16 to convert from 8 bit to 12 bit intensity, the correct factor is 4095/255. - Does not issue warning when system configuration file not found. The location of that file is a compile-time option in 'fiasco', but fixed at /etc in Netpbm. The expectation is that Netpbm users will never have a system configuration file. - Does not fail if basis file small.fco is not found. The Fiasco code already contained facilities for defaulting to a built-in version of small.fco, but it was disabled by an early check for existence of the basis file as an actual file. In Netpbm, that check for existence is simply removed. - Remove WINDOWS config.h configuration macro, which determined whether files would be open with "b" flag (binary). Use "b" flag unconditionally. - Rename internal "log2" function to "Log2" to avoid conflict with existing "log2" macro or function. The original package has conditional compilation to allow it to use the existing log2 when configured for a system that has it. In Netpbm, we always use the private version. - Compilation warnings fixed. - 'bin' subdirectory moved to top level directory. - man pages for programs moved from doc subdirectory to top level directory. - man page of pnmpsnr created. netpbm-free-10.0-1/pnm/fiasco/binerror.c0100644004714500471450000000552307716230207020354 0ustar aba-guestaba-guest/* * error.c: Error handling * * Written by: Stefan Frank * Ullrich Hafner * * Credits: Modelled after variable argument routines from Jef * Poskanzer's pbmplus package. * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #define _ERROR_C #include "config.h" #include #if STDC_HEADERS # include # define VA_START(args, lastarg) va_start(args, lastarg) #else /* not STDC_HEADERS */ # include # define VA_START(args, lastarg) va_start(args) #endif /* not STDC_HEADERS */ #if HAVE_STRING_H # include #else /* not HAVE_STRING_H */ # include #endif /* not HAVE_STRING_H */ #if HAVE_SETJMP_H # include #endif /* HAVE_SETJMP_H */ #include "fiasco.h" #include "binerror.h" /***************************************************************************** global variables *****************************************************************************/ int error_line = 0; char *error_file = NULL; /***************************************************************************** local variables *****************************************************************************/ static char *executable = "(name not initialized)"; /***************************************************************************** public code *****************************************************************************/ void init_error_handling (const char *name) /* * Initialize filename of executable. * * No return value. */ { if (name) executable = strdup (name); } void _error (const char *format, ...) /* * Print error message and exit. * * No return value. */ { va_list args; VA_START (args, format); fprintf (stderr, "%s: %s: line %d:\nError: ", executable, error_file, error_line); #if HAVE_VPRINTF vfprintf (stderr, format, args); #elif HAVE_DOPRNT _doprnt (format, args, stderr); #endif /* HAVE_DOPRNT */ fputc ('\n', stderr); va_end(args); exit (1); } void _file_error (const char *filename) /* * Print file error message and exit. * * No return value. */ { fprintf (stderr, "%s: %s: line %d:\nError: ", executable, error_file, error_line); perror (filename); exit (2); } void _warning (const char *format, ...) /* * Issue a warning and continue execution. * * No return value. */ { va_list args; VA_START (args, format); fprintf (stderr, "%s: %s: line %d:\nWarning: ", executable, error_file, error_line); #if HAVE_VPRINTF vfprintf (stderr, format, args); #elif HAVE_DOPRNT _doprnt (format, args, stderr); #endif /* HAVE_DOPRNT */ fputc ('\n', stderr); va_end (args); } netpbm-free-10.0-1/pnm/fiasco/binerror.h0100644004714500471450000000212007716230207020347 0ustar aba-guestaba-guest/* * error.h * * Written by: Stefan Frank * Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _ERROR_H #define _ERROR_H #define error error_line=__LINE__,error_file=__FILE__,_error #define warning error_line=__LINE__,error_file=__FILE__,_warning #define file_error(fn) error_line=__LINE__,error_file=__FILE__,_file_error(fn) #ifdef _ERROR_C #define _EXTERN_TYPE #else #define _EXTERN_TYPE extern #endif _EXTERN_TYPE int error_line; _EXTERN_TYPE char *error_file; void init_error_handling (const char *name); void _error (const char *format, ...); void _warning (const char *format, ...); void _file_error (const char *filename); #if HAVE_ASSERT_H # include #else /* not HAVE_ASSERT_H */ # define assert(exp) {if (!(exp)) error ("Assertion `" #exp " != NULL' failed.");} #endif /* not HAVE_ASSERT_H */ #endif /* not _ERROR_H */ netpbm-free-10.0-1/pnm/fiasco/buttons.c0100644004714500471450000003600107716230207020223 0ustar aba-guestaba-guest/* * buttons.c: Draw MWFA player buttons in X11 window * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #ifndef X_DISPLAY_MISSING #include #include #include #if STDC_HEADERS # include #endif /* not STDC_HEADERS */ #include "types.h" #include "macros.h" #include "display.h" #include "binerror.h" #include "buttons.h" /***************************************************************************** local variables *****************************************************************************/ static const int EVENT_MASK = (KeyPressMask | ButtonPressMask | ButtonReleaseMask | ExposureMask); /***************************************************************************** prototypes *****************************************************************************/ static void draw_progress_bar (x11_info_t *xinfo, binfo_t *binfo, unsigned n, unsigned n_frames); static void draw_button (x11_info_t *xinfo, binfo_t *binfo, buttons_t button, bool_t pressed); static void draw_control_panel (x11_info_t *xinfo, binfo_t *binfo, unsigned n, unsigned n_frames); /***************************************************************************** public code *****************************************************************************/ binfo_t * init_buttons (x11_info_t *xinfo, unsigned n, unsigned n_frames, unsigned buttons_height, unsigned progbar_height) /* * Initialize a toolbar with the typical collection of video player * buttons (pause, play, record, next, etc.) in the window given by 'xinfo'. * 'n' gives the current frame, 'whereas' n_frames is the total number of * frames of the video stream. * The size of the button toolbar is given by 'buttons_height', * the size of the progressbar is given by 'progbar_height'. * * Return value: * struct managing the toolbar and progressbar information */ { XGCValues values; XEvent event; Colormap cmap; XColor gray, dgray, lgray, red; XColor graye, dgraye, lgraye, rede; buttons_t button; /* counter */ binfo_t *binfo = calloc (1, sizeof (binfo_t)); if (!binfo) error ("Out of memory."); binfo->width = xinfo->ximage->width; binfo->height = buttons_height; binfo->progbar_height = progbar_height; binfo->record_is_rewind = NO; /* * Generate sub-window for control panel */ binfo->window = XCreateSimpleWindow (xinfo->display, xinfo->window, 0, xinfo->ximage->height, binfo->width, binfo->height, 0, BlackPixel (xinfo->display, xinfo->screen), WhitePixel (xinfo->display, xinfo->screen)); XSelectInput(xinfo->display, binfo->window, StructureNotifyMask); XMapWindow (xinfo->display, binfo->window); do { XNextEvent (xinfo->display, &event); } while (event.type != MapNotify || event.xmap.event != binfo->window); XSelectInput (xinfo->display, binfo->window, EVENT_MASK); /* * Generate graphic contexts for different colors. */ cmap = DefaultColormap (xinfo->display, xinfo->screen); XAllocNamedColor (xinfo->display, cmap, "#404040", &dgray, &dgraye); XAllocNamedColor (xinfo->display, cmap, "white", &lgray, &lgraye); XAllocNamedColor (xinfo->display, cmap, "#a8a8a8", &gray, &graye); XAllocNamedColor (xinfo->display, cmap, "red", &red, &rede); values.foreground = BlackPixel (xinfo->display, xinfo->screen); values.background = WhitePixel (xinfo->display, xinfo->screen); binfo->gc [BLACK] = XCreateGC (xinfo->display, RootWindow (xinfo->display, xinfo->screen), (GCForeground | GCBackground), &values); values.foreground = BlackPixel (xinfo->display, xinfo->screen); values.background = WhitePixel (xinfo->display, xinfo->screen); values.line_width = 3; values.join_style = JoinRound; binfo->gc [THICKBLACK] = XCreateGC (xinfo->display, RootWindow (xinfo->display, xinfo->screen), (GCForeground | GCBackground | GCLineWidth | GCJoinStyle), &values); values.foreground = gray.pixel; values.background = WhitePixel (xinfo->display, xinfo->screen); binfo->gc [NGRAY] = XCreateGC (xinfo->display, RootWindow (xinfo->display, xinfo->screen), (GCForeground | GCBackground), &values); values.foreground = lgray.pixel; values.background = WhitePixel (xinfo->display, xinfo->screen); binfo->gc [LGRAY] = XCreateGC (xinfo->display, RootWindow (xinfo->display, xinfo->screen), (GCForeground | GCBackground), &values); values.foreground = dgray.pixel; values.background = WhitePixel (xinfo->display, xinfo->screen); binfo->gc [DGRAY] = XCreateGC (xinfo->display, RootWindow (xinfo->display, xinfo->screen), (GCForeground | GCBackground), &values); values.foreground = red.pixel; values.background = WhitePixel (xinfo->display, xinfo->screen); binfo->gc [RED] = XCreateGC (xinfo->display, RootWindow (xinfo->display, xinfo->screen), (GCForeground | GCBackground), &values); for (button = 0; button < NO_BUTTON; button++) binfo->pressed [button] = NO; draw_control_panel (xinfo, binfo, n, n_frames); return binfo; } void wait_for_input (x11_info_t *xinfo) /* * Wait for key press or mouse click in window 'xinfo'. * Redraw 'image' if event other then ButtonPress or KeyPress occurs. * Enlarge or reduce size of image by factor 2^'enlarge_factor'. * * No return value. * * Side effect: * program is terminated after key press or mouse click. */ { bool_t leave_loop = NO; XSelectInput (xinfo->display, xinfo->window, EVENT_MASK); while (!leave_loop) { XEvent event; XMaskEvent (xinfo->display, EVENT_MASK, &event); switch (event.type) { case ButtonPress: case KeyPress: leave_loop = YES; break; default: display_image (0, 0, xinfo); break; } } } void check_events (x11_info_t *xinfo, binfo_t *binfo, unsigned n, unsigned n_frames) /* * Check the X11 event loop. If the PAUSE buttonin the of panel 'binfo' * is activated wait until next event occurs. * Redraw 'image' if event other then ButtonPress or ButtonRelease occurs. * Enlarge or reduce size of image by factor 2^'enlarge_factor'. * 'n' gives the current frame, 'whereas' n_frames is the total number of * frames of the video stream. * * No return values. * * Side effects: * status of buttons (binfo->pressed [button]) is changed accordingly. */ { bool_t leave_eventloop; leave_eventloop = (!binfo->pressed [PAUSE_BUTTON] && binfo->pressed [PLAY_BUTTON]) || (!binfo->pressed [PAUSE_BUTTON] && binfo->record_is_rewind && binfo->pressed [RECORD_BUTTON]) || binfo->pressed [RECORD_BUTTON]; draw_progress_bar (xinfo, binfo, n, n_frames); if (binfo->pressed [PAUSE_BUTTON] && binfo->pressed [PLAY_BUTTON]) { XFlush (xinfo->display); draw_button (xinfo, binfo, PLAY_BUTTON, NO); /* clear PLAY mode */ XFlush (xinfo->display); } if (binfo->pressed [PAUSE_BUTTON] && binfo->record_is_rewind && binfo->pressed [RECORD_BUTTON]) { XFlush (xinfo->display); draw_button (xinfo, binfo, RECORD_BUTTON, NO); /* clear PLAY mode */ XFlush (xinfo->display); } if (binfo->pressed [STOP_BUTTON]) { XFlush (xinfo->display); draw_button (xinfo, binfo, STOP_BUTTON, NO); /* clear STOP button */ XFlush (xinfo->display); } do { XEvent event; int button; bool_t wait_release = NO; if (XCheckMaskEvent (xinfo->display, EVENT_MASK, &event)) { switch (event.type) { case ButtonPress: wait_release = NO; if (!(binfo->pressed [RECORD_BUTTON] && !binfo->record_is_rewind)) for (button = 0; button < NO_BUTTON; button++) { int x0, y0, x1, y1; /* button coordinates */ x0 = button * (binfo->width / NO_BUTTON); y0 = binfo->progbar_height; x1 = x0 + binfo->width / NO_BUTTON; y1 = y0 + binfo->height - binfo->progbar_height - 1; if (event.xbutton.x > x0 && event.xbutton.x < x1 && event.xbutton.y > y0 && event.xbutton.y < y1) { draw_button (xinfo, binfo, button, !binfo->pressed [button]); wait_release = YES; break; } } break; case ButtonRelease: wait_release = NO; break; default: wait_release = NO; draw_control_panel (xinfo, binfo, n, n_frames); display_image (0, 0, xinfo); break; } leave_eventloop = !wait_release && (binfo->pressed [PLAY_BUTTON] || binfo->pressed [STOP_BUTTON] || binfo->pressed [RECORD_BUTTON] || binfo->pressed [QUIT_BUTTON]); } } while (!leave_eventloop); if ((binfo->pressed [RECORD_BUTTON] && !binfo->record_is_rewind) && n == n_frames - 1) { binfo->record_is_rewind = YES; draw_button (xinfo, binfo, RECORD_BUTTON, NO); } } /***************************************************************************** private code *****************************************************************************/ static void draw_control_panel (x11_info_t *xinfo, binfo_t *binfo, unsigned n, unsigned n_frames) /* * Draw control panel 'binfo' with all buttons and progressbar in * the given 'window'. * 'n' gives the current frame, 'whereas' n_frames is the total number of * frames of the video stream. * * No return value. */ { buttons_t button; XFillRectangle (xinfo->display, binfo->window, binfo->gc [NGRAY], 0, 0, binfo->width, binfo->height); draw_progress_bar (xinfo, binfo, n, n_frames); for (button = 0; button < NO_BUTTON; button++) draw_button (xinfo, binfo, button, binfo->pressed [button]); } static void draw_progress_bar (x11_info_t *xinfo, binfo_t *binfo, unsigned n, unsigned n_frames) /* * Draw progressbar of control panel 'binfo' in the given 'window'. * 'n' gives the current frame, whereas 'n_frames' is the total number of * frames of the video stream. * * No return value. */ { unsigned x, y, width, height; x = 2; y = 1; width = binfo->width - 5; height = binfo->progbar_height - 3; XDrawLine (xinfo->display, binfo->window, binfo->gc [DGRAY], x, y, x + width, y); XDrawLine (xinfo->display, binfo->window, binfo->gc [DGRAY], x, y, x, y + height - 1); XDrawLine (xinfo->display, binfo->window, binfo->gc [LGRAY], x + width, y + 1, x + width, y + height); XDrawLine (xinfo->display, binfo->window, binfo->gc [LGRAY], x, y + height, x + width, y + height); x++; y++; width -= 2; height -= 2; XFillRectangle (xinfo->display, binfo->window, binfo->gc [NGRAY], x, y, width, height); XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK], x + n * max (1, width / n_frames), y, max (1, width / n_frames), height); } static void draw_button (x11_info_t *xinfo, binfo_t *binfo, buttons_t button, bool_t pressed) /* * Draw 'button' of control panel 'binfo' in the given 'window'. * 'pressed' indicates whether the button is pressed or not. * * No return value. */ { grayscale_t top, bottom; /* index of GC */ unsigned x, y, width, height; /* coordinates of button */ x = button * (binfo->width / NO_BUTTON); y = binfo->progbar_height; width = binfo->width / NO_BUTTON; height = binfo->height - binfo->progbar_height - 1; if (width < 4 || height < 4) return; if (pressed) { top = DGRAY; bottom = LGRAY; } else { top = LGRAY; bottom = DGRAY; } x += 2; width -= 4; XDrawLine (xinfo->display, binfo->window, binfo->gc [top], x, y, x + width, y); XDrawLine (xinfo->display, binfo->window, binfo->gc [top], x, y, x, y + height - 1); XDrawLine (xinfo->display, binfo->window, binfo->gc [bottom], x + width, y + 1, x + width, y + height); XDrawLine (xinfo->display, binfo->window, binfo->gc [bottom], x, y + height, x + width, y + height); x++; y++; width -= 2; height -= 2; XFillRectangle (xinfo->display, binfo->window, binfo->gc [NGRAY], x, y, width, height); switch (button) { case STOP_BUTTON: XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK], x + width / 2 - 6, y + height / 2 - 4, 11, 11); if (pressed && !binfo->pressed [STOP_BUTTON]) { draw_button (xinfo, binfo, PLAY_BUTTON, NO); draw_button (xinfo, binfo, PAUSE_BUTTON, NO); draw_button (xinfo, binfo, RECORD_BUTTON, NO); } break; case PAUSE_BUTTON: XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK], x + width / 2 - 6, y + height / 2 - 4, 5, 11); XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK], x + width / 2 + 1, y + height / 2 - 4, 5, 11); break; case PLAY_BUTTON: { XPoint triangle [3]; triangle [0].x = x + width / 2 - 5; triangle [0].y = y + height / 2 - 5; triangle [1].x = 10; triangle [1].y = 6; triangle [2].x = -10; triangle [2].y = 6; XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK], triangle, 3, Convex, CoordModePrevious); if (pressed && !binfo->pressed [PLAY_BUTTON] && binfo->pressed [RECORD_BUTTON]) draw_button (xinfo, binfo, RECORD_BUTTON, NO); } break; case RECORD_BUTTON: if (!binfo->record_is_rewind) { XFillArc (xinfo->display, binfo->window, binfo->gc [RED], x + width / 2 - 5, y + height / 2 - 5, 11, 11, 0, 360 * 64); if (pressed && !binfo->pressed [RECORD_BUTTON]) { draw_button (xinfo, binfo, STOP_BUTTON, YES); draw_button (xinfo, binfo, PLAY_BUTTON, NO); draw_button (xinfo, binfo, PAUSE_BUTTON, NO); } } else { XPoint triangle [3]; triangle [0].x = x + width / 2 + 5; triangle [0].y = y + height / 2 - 5; triangle [1].x = -10; triangle [1].y = 6; triangle [2].x = 10; triangle [2].y = 6; XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK], triangle, 3, Convex, CoordModePrevious); if (pressed && !binfo->pressed [RECORD_BUTTON] && binfo->pressed [PLAY_BUTTON]) draw_button (xinfo, binfo, PLAY_BUTTON, NO); } break; case QUIT_BUTTON: { XPoint triangle [3]; triangle [0].x = x + width / 2 - 6; triangle [0].y = y + height / 2 + 2; triangle [1].x = 6; triangle [1].y = -7; triangle [2].x = 6; triangle [2].y = 7; XFillPolygon (xinfo->display, binfo->window, binfo->gc [BLACK], triangle, 3, Convex, CoordModePrevious); XFillRectangle (xinfo->display, binfo->window, binfo->gc [BLACK], x + width / 2 - 5, y + height / 2 + 4, 11, 3); } break; default: break; } binfo->pressed [button] = pressed; } #endif /* not X_DISPLAY_MISSING */ netpbm-free-10.0-1/pnm/fiasco/buttons.h0100644004714500471450000000216007716230207020227 0ustar aba-guestaba-guest/* * buttons.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _BUTTONS_H #define _BUTTONS_H #ifndef X_DISPLAY_MISSING typedef enum grayscale_e {BLACK, NGRAY, LGRAY, DGRAY, RED, THICKBLACK, NO_GC} grayscale_t; typedef enum buttons_e {STOP_BUTTON, PLAY_BUTTON, PAUSE_BUTTON, RECORD_BUTTON, QUIT_BUTTON, NO_BUTTON} buttons_t; typedef struct buttoninfo { Window window; bool_t pressed [NO_BUTTON]; GC gc [NO_GC]; unsigned width; unsigned height; unsigned progbar_height; bool_t record_is_rewind; } binfo_t; void check_events (x11_info_t *xinfo, binfo_t *binfo, unsigned n, unsigned n_frames); void wait_for_input (x11_info_t *xinfo); binfo_t * init_buttons (x11_info_t *xinfo, unsigned n, unsigned n_frames, unsigned buttons_height, unsigned progbar_height); #endif /* not X_DISPLAY_MISSING */ #endif /* not _BUTTONS_H */ netpbm-free-10.0-1/pnm/fiasco/config.h0100644004714500471450000000524007716230207020000 0ustar aba-guestaba-guest/* config.h. Generated automatically by configure. */ /* But then manually maintained as part of Netpbm! */ /* config.h.in. Generated automatically from configure.in by autoheader. */ /* Define to empty if the keyword does not work. */ /* #undef const */ /* Define if you don't have vprintf but do have _doprnt. */ /* #undef HAVE_DOPRNT */ /* Define if you have the vprintf function. */ #define HAVE_VPRINTF 1 /* Define to `unsigned' if doesn't define. */ /* #undef size_t */ /* Define if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Define if you can safely include both and . */ #define TIME_WITH_SYS_TIME 1 /* Define if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ /* #undef WORDS_BIGENDIAN */ /* Define if the X Window System is missing or not being used. */ #define X_DISPLAY_MISSING 1 /* Define if shifting of signed integers works */ #define HAVE_SIGNED_SHIFT 1 /* Define if you don't have the CLOCKS_PER_SEC define in . */ /* #undef CLOCKS_PER_SEC */ /* The number of bytes in a char. */ #define SIZEOF_CHAR 1 /* The number of bytes in a int. */ #define SIZEOF_INT 4 /* The number of bytes in a short. */ #define SIZEOF_SHORT 2 /* Define if you have the log2 function. */ /* #undef HAVE_LOG2 */ /* For Netpbm, we won't use log2() because it might not exist. In Netpbm, misc.c contains Log2(), so we just define log2 as Log2 here. But first, we include because if we don't it may get included after config.h, and then there could be a redefinition issue with log2. */ #include #undef log2 #define log2 Log2 /* Define if you have the memmove function. */ #define HAVE_MEMMOVE 1 /* Define if you have the strcasecmp function. */ #define HAVE_STRCASECMP 1 /* Define if you have the strdup function. */ #define HAVE_STRDUP 1 /* Define if you have the header file. */ /* #undef HAVE_X11_EXTENSIONS_XSHM_H */ /* Define if you have the header file. */ #define HAVE_ASSERT_H 1 /* Define if you have the header file. */ #define HAVE_FEATURES_H 1 /* Define if you have the header file. */ #define HAVE_SETJMP_H 1 /* Define if you have the header file. */ #define HAVE_STRING_H 1 /* Define if you have the header file. */ #define HAVE_SYS_TIME_H 1 /* Define if you have the header file. */ #define HAVE_UNISTD_H 1 /* Define if you have the m library (-lm). */ #define HAVE_LIBM 1 /* Name of package */ #define PACKAGE "fiasco" /* Version number of package */ #define VERSION "1.0" #define FIASCO_SHARE "/etc/" netpbm-free-10.0-1/pnm/fiasco/cwfa.c0100644004714500471450000003170707776237374017477 0ustar aba-guestaba-guest/* * cwfa.c: FIASCO coder * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2004/01/05 10:39:56 $ * $Author: aba-guest $ * $Revision: 1.2 $ * $State: Exp $ */ #include "config.h" #include "pnm.h" #if STDC_HEADERS # include # include #else /* not STDC_HEADERS */ # if HAVE_STRING_H # include # else /* not HAVE_STRING_H */ # include # endif /* not HAVE_STRING_H */ #endif /* not STDC_HEADERS */ #include "types.h" #include "macros.h" #include "binerror.h" #include "misc.h" #include "params.h" #include "fiasco.h" /***************************************************************************** local variables *****************************************************************************/ static param_t params [] = { /* * Options for standard user */ {"image-name", "FILE", 'i', PSTR, {0}, NULL, "Compress raw PPM/PGM image(s) `%s'."}, {"output-name", "FILE", 'o', PSTR, {0}, "-", "Write automaton to `%s' (`-' means stdout)."}, {"quality", "REAL", 'q', PFLOAT, {0}, "20.0", "Set quality of compression to `%s'."}, {"title", "NAME", 't', PSTR, {0}, "", "Set title of FIASCO stream to `%s'."}, {"comment", "NAME", 'c', PSTR, {0}, "", "Set comment of FIASCO stream to `%s'."}, {"chroma-qfactor", "REAL", '\0', PFLOAT, {0}, "2", "Decrease chroma band quality `%s' times."}, {"basis-name", "FILE", '\0', PSTR, {0}, "small.fco", "Preload basis `%s' into FIASCO."}, {"optimize", "NUM", 'z', PINT, {0}, "0", "Set optimization level to `%s'."}, {"dictionary-size", "NUM", '\0', PINT, {0}, "10000", "Set max# size of dictionary to `%s'."}, {"chroma-dictionary", "NUM", '\0', PINT, {0}, "40", "Set max# size of chroma dictionary to `%s'.."}, {"min-level", "NUM", '\0', PINT, {0}, "6", "Start prediction on block level `%s'."}, {"max-level", "NUM", '\0', PINT, {0}, "10", "Stop prediction on block level `%s'."}, {"tiling-exponent", "NUM", '\0', PINT, {0}, "4", "Set exponent of image permutation to `%s'."}, {"tiling-method", "NAME", '\0', PSTR, {0}, "desc-variance", "Set type of permutation to `%s'."}, {"rpf-range", "REAL", '\0', PFLOAT, {0}, "1.5", "Set quantization range to `%s'."}, {"rpf-mantissa", "NUM", '\0', PINT, {0}, "3", "Set quantization mantissa to `%s' bits."}, {"dc-rpf-range", "REAL", '\0', PFLOAT, {0}, "1", "Set quant. range (DC part) to `%s'."}, {"dc-rpf-mantissa", "NUM", '\0', PINT, {0}, "5", "Set quant. mantissa (DC part) to `%s' bits."}, {"pattern", "NAME", '\0', PSTR, {0}, "ippppppppp", "Set frame type sequence to `%s'."}, {"fps", "NUM", '\0', PINT, {0}, "25", "Set display rate to `%s' frames per second."}, {"half-pixel", NULL, '\0', PFLAG, {0}, "FALSE", "Use half-pixel precision for mc."}, {"cross-B-search", NULL, '\0', PFLAG, {0}, "FALSE", "Use cross-B-search for interpolated mc."}, {"B-as-past-ref", NULL, '\0', PFLAG, {0}, "FALSE", "Use B-frames as reference images." }, {"prediction", NULL, '\0', PFLAG, {0}, "FALSE", "Use additional predictive coding."}, {"progress-meter", "NUM", '\0', PINT, {0}, "2", "Set type of progress meter to `%s'."}, {"smooth", "NUM", '\0', PINT, {0}, "70", "Smooth image(s) by factor `%s' (0-100)"}, #if 0 /* * Options currently not activated (maybe in future versions of FIASCO) */ {"min-level", "NUM", 'm', PINT, {0}, "4", "Start compression on block level `%s'."}, {"max-level", "NUM", 'M', PINT, {0}, "12", "Stop compression on block level `%s'."}, {"max-elements", "NUM", 'N', PINT, {0}, "8", "Set max# of elements in an approx. to `%s'." }, {"domain-pool", "NAME", '\0', PSTR, {0}, "rle", "Set domain pool of r-lc to `%s'."}, {"coeff", "NAME", '\0', PSTR, {0}, "adaptive", "Set coefficients model to `%s'."}, /* DELTA APPROXIATION */ {"d-domain-pool", "NAME", '\0', PSTR, {0}, "rle", "Set domain pool of d-lc to `%s'."}, {"d-coeff", "NAME", '\0', PSTR, {0}, "adaptive", "Set d coefficients model to `%s'."}, {"d-range", "REAL", '\0', PFLOAT, {0}, "1.5", "Set range of RPF for delta lc to `%s'."}, {"d-mantissa", "NUM", '\0', PINT, {0}, "3", "Set #m-bits of RPF for delta lc to `%s'."}, {"d-dc-range", "REAL", '\0', PFLOAT, {0}, "1", "Set DC range of RPF of delta lc to `%s'."}, {"d-dc-mantissa", "NUM", '\0', PINT, {0}, "5", "Set #m-bits of delta RPF for DC domain to `%s'."}, /* ADVANCED */ {"images-level", "NUM", '\0', PINT, {0}, "5", "Compute state images up to level `%s'."}, {"delta-domains", NULL, '\0', PFLAG, {0}, "FALSE", "Use delta domains every time."}, {"normal-domains", NULL, '\0', PFLAG, {0}, "FALSE", "Use normal domains every time."}, /* VIDEO COMPRESSION */ {"smooth", "REAL", 's', PFLOAT, {0}, "1.0", "Smooth frames by factor `%s' (0.5 - 1.0)"}, {"reference-frame", "FILE", '\0', PSTR, {0}, NULL, "Use PPM/PGM image `%s' as reference frame."}, #endif {NULL, NULL, 0, PSTR, {0}, NULL, NULL } }; /***************************************************************************** prototypes *****************************************************************************/ static void checkargs (int argc, char **argv, char const ***image_template, char **wfa_name, float *quality, fiasco_c_options_t **options); /***************************************************************************** public code *****************************************************************************/ int main (int argc, char **argv) { char const **image_template; /* template for input image files */ char *wfa_name; /* filename of output WFA */ float quality; /* approximation quality */ fiasco_c_options_t *options; /* additional coder options */ pnm_init(&argc, argv); init_error_handling (argv [0]); checkargs (argc, argv, &image_template, &wfa_name, &quality, &options); if (fiasco_coder (image_template, wfa_name, quality, options)) return 0; else { fprintf (stderr, fiasco_get_error_message ()); fprintf (stderr, "\n"); return 1; } } /***************************************************************************** private code *****************************************************************************/ static void checkargs (int argc, char **argv, char const ***image_template, char **wfa_name, float *quality, fiasco_c_options_t **options) /* * Check validness of command line parameters and of the parameter files. * * Return value: * 1 on success * 0 otherwise * * * Side effects: * 'image_template', 'wfa_name', 'quality' and 'options' are set. */ { int optind; /* last processed commandline param */ char *image_name; /* filename given by option '-i' */ int i; /* counter */ optind = parseargs (params, argc, argv, "Compress raw PPM/PGM image FILEs to a FIASCO file.", "With no image FILE, or if FILE is -, " "read standard input.\n" "FILE must be either a filename" " or an image template of the form:\n" "`prefix[start-end{+,-}step]suffix'\n" "e.g., img0[12-01-1].pgm is substituted by" " img012.pgm ... img001.pgm\n\n" "Environment:\n" "FIASCO_DATA Search and save path for FIASCO files. " "Default: ./\n" "FIASCO_IMAGES Search path for image files. " "Default: ./", " [FILE]...", FIASCO_SHARE, "system.fiascorc", ".fiascorc"); /* * Default options ... */ image_name = (char *) parameter_value (params, "image-name"); *wfa_name = (char *) parameter_value (params, "output-name"); for (;;) { *quality = * (float *) parameter_value (params, "quality"); if (*quality > 100) fprintf (stderr, "Typical range of quality: (0,100].\n" "Expect some trouble on slow machines.\n"); if (*quality > 0) break; ask_and_set (params, "quality", "Please enter coding quality 'q' ('q' > 0): "); } if (optind < argc) /* Additional command line param */ { if (image_name) error ("Multiple image_template arguments." "\nOption -i %s already specified!", image_name); *image_template = calloc (argc - optind + 1, sizeof (char *)); if (!*image_template) error ("Out of memory."); for (i = 0; optind < argc; i++, optind++) (*image_template) [i] = argv [optind]; (*image_template) [i] = NULL; } else /* option -i image_name */ { *image_template = calloc (2, sizeof (char *)); if (!*image_template) error ("Out of memory."); (*image_template) [0] = image_name; (*image_template) [1] = NULL; } /* * Additional options ... (have to be set with the fiasco_set_... methods) */ { *options = fiasco_c_options_new (); { char *pattern = (char *) parameter_value (params, "pattern"); if (!fiasco_c_options_set_frame_pattern (*options, pattern)) error (fiasco_get_error_message ()); } { char *basis = (char *) parameter_value (params, "basis-name"); if (!fiasco_c_options_set_basisfile (*options, basis)) error (fiasco_get_error_message ()); } { int n = * (int *) parameter_value (params, "chroma-dictionary"); float q = * (float *) parameter_value (params, "chroma-qfactor"); if (!fiasco_c_options_set_chroma_quality (*options, q, max (0, n))) error (fiasco_get_error_message ()); } { int n = *((int *) parameter_value (params, "smooth")); if (!fiasco_c_options_set_smoothing (*options, max (0, n))) error (fiasco_get_error_message ()); } { int n = * (int *) parameter_value (params, "progress-meter"); fiasco_progress_e type = (n < 0) ? FIASCO_PROGRESS_NONE : (fiasco_progress_e) n; if (!fiasco_c_options_set_progress_meter (*options, type)) error (fiasco_get_error_message ()); } { char *t = (char *) parameter_value (params, "title"); if (strlen (t) > 0 && !fiasco_c_options_set_title (*options, t)) error (fiasco_get_error_message ()); } { char *c = (char *) parameter_value (params, "comment"); if (strlen (c) > 0 && !fiasco_c_options_set_comment (*options, c)) error (fiasco_get_error_message ()); } { fiasco_tiling_e method = FIASCO_TILING_VARIANCE_DSC; int e = * (int *) parameter_value (params, "tiling-exponent"); char *m = (char *) parameter_value (params, "tiling-method"); if (strcaseeq (m, "desc-variance")) method = FIASCO_TILING_VARIANCE_DSC; else if (strcaseeq (m, "asc-variance")) method = FIASCO_TILING_VARIANCE_ASC; else if (strcaseeq (m, "asc-spiral")) method = FIASCO_TILING_SPIRAL_ASC; else if (strcaseeq (m, "dsc-spiral")) method = FIASCO_TILING_SPIRAL_DSC; else error (_("Invalid tiling method `%s' specified."), m); if (!fiasco_c_options_set_tiling (*options, method, max (0, e))) error (fiasco_get_error_message ()); } { int M/* = * (int *) parameter_value (params, "max-level") */; int m/* = * (int *) parameter_value (params, "min-level") */; int N/* = * (int *) parameter_value (params, "max-elements") */; int D = * (int *) parameter_value (params, "dictionary-size"); int o = * (int *) parameter_value (params, "optimize"); if (o <= 0) { o = 0; M = 10; m = 6; N = 3; } else { o -= 1; M = 12; m = 4; N = 5; } if (!fiasco_c_options_set_optimizations (*options, m, M, N, max (0, D), o)) error (fiasco_get_error_message ()); } { int M = * (int *) parameter_value (params, "max-level"); int m = * (int *) parameter_value (params, "min-level"); int p = * (int *) parameter_value (params, "prediction"); if (!fiasco_c_options_set_prediction (*options, p, max (0, m), max (0, M))) error (fiasco_get_error_message ()); } { float r = * (float *) parameter_value (params, "rpf-range"); float dc_r = * (float *) parameter_value (params, "dc-rpf-range"); int m = * (int *) parameter_value (params, "rpf-mantissa"); int dc_m = * (int *) parameter_value (params, "dc-rpf-mantissa"); fiasco_rpf_range_e range, dc_range; if (r < 1) range = FIASCO_RPF_RANGE_0_75; else if (r < 1.5) range = FIASCO_RPF_RANGE_1_00; else if (r < 2.0) range = FIASCO_RPF_RANGE_1_50; else range = FIASCO_RPF_RANGE_2_00; if (dc_r < 1) dc_range = FIASCO_RPF_RANGE_0_75; else if (dc_r < 1.5) dc_range = FIASCO_RPF_RANGE_1_00; else if (dc_r < 2.0) dc_range = FIASCO_RPF_RANGE_1_50; else dc_range = FIASCO_RPF_RANGE_2_00; if (!fiasco_c_options_set_quantization (*options, max (0, m), range, max (0, dc_m), dc_range)) error (fiasco_get_error_message ()); } if (fiasco_get_verbosity () == FIASCO_ULTIMATE_VERBOSITY) write_parameters (params, stderr); } } netpbm-free-10.0-1/pnm/fiasco/display.c0100644004714500471450000002530307716230207020175 0ustar aba-guestaba-guest/* * display.c: X11 display of frames * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner * * Based on mpeg2decode, (C) 1994, MPEG Software Simulation Group * and mpeg2play, (C) 1994 Stefan Eckart * * and tmndec (C) 1995, 1996 Telenor R&D, Norway */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #ifndef X_DISPLAY_MISSING #include #include #include #if STDC_HEADERS # include # include #else /* not STDC_HEADERS */ # if HAVE_STRING_H # include # else /* not HAVE_STRING_H */ # include # endif /* not HAVE_STRING_H */ #endif /* not STDC_HEADERS */ #include "types.h" #include "macros.h" #include "display.h" #include "binerror.h" /***************************************************************************** shared memory functions (if USE_SHM is defined) *****************************************************************************/ #ifdef USE_SHM #ifdef HAVE_FEATURES_H #include #endif #include #include #include #include int XShmQueryExtension (Display *dpy); int XShmGetEventBase (Display *dpy); static int HandleXError (Display *dpy, XErrorEvent *event); static void InstallXErrorHandler (x11_info_t *xinfo); static void DeInstallXErrorHandler (x11_info_t *xinfo); static int shmem_flag; static XShmSegmentInfo shminfo1, shminfo2; static int gXErrorFlag; static int CompletionType = -1; static int HandleXError (Display *dpy, XErrorEvent *event) { gXErrorFlag = 1; return 0; } static void InstallXErrorHandler (x11_info_t *xinfo) { XSetErrorHandler (HandleXError); XFlush (xinfo->display); } static void DeInstallXErrorHandler (x11_info_t *xinfo) { XSetErrorHandler (NULL); XFlush (xinfo->display); } #endif /* USE_SHM */ /***************************************************************************** public code *****************************************************************************/ void display_image (unsigned x0, unsigned y0, x11_info_t *xinfo) /* * Display 'image' at pos ('x0', 'y0') in the current window * (given by 'xinfo->window'). * * No return value. */ { int byte_order_check = 1; /* * Always work in native bit and byte order. This tells Xlib to * reverse bit and byte order if necessary when crossing a * network. Frankly, this part of XImages is somewhat * underdocumented, so this may not be exactly correct. */ if (*(char *) & byte_order_check == 1) { xinfo->ximage->byte_order = LSBFirst; xinfo->ximage->bitmap_bit_order = LSBFirst; } else { xinfo->ximage->byte_order = MSBFirst; xinfo->ximage->bitmap_bit_order = MSBFirst; } /* Display dithered image */ #ifdef USE_SHM if (shmem_flag) { XEvent xev; XShmPutImage (xinfo->display, xinfo->window, xinfo->gc, xinfo->ximage, 0, 0, x0, y0, xinfo->ximage->width, xinfo->ximage->height, True); XFlush (xinfo->display); while (!XCheckTypedEvent (xinfo->display, CompletionType, &xev)) ; } else #endif /* USE_SHM */ { xinfo->ximage->data = (char *) xinfo->pixels; XPutImage (xinfo->display, xinfo->window, xinfo->gc, xinfo->ximage, 0, 0, x0, y0, xinfo->ximage->width, xinfo->ximage->height); } } void close_window (x11_info_t *xinfo) { #ifdef USE_SHM if (shmem_flag && xinfo->ximage) { XShmDetach (xinfo->display, &shminfo1); XDestroyImage (xinfo->ximage); xinfo->ximage = NULL; shmdt (shminfo1.shmaddr); } else #endif /* USE_SHM */ if (xinfo->ximage) { XDestroyImage (xinfo->ximage); xinfo->ximage = NULL; } if (xinfo->display) { XCloseDisplay (xinfo->display); xinfo->display = NULL; } } x11_info_t * open_window (const char *titlename, const char *iconname, unsigned width, unsigned height) /* * Open a X11 window of size 'width'x'height'. * If 'color' is false then allocate a colormap with grayscales. * Window and icon titles are given by 'titlename' and 'iconname', * respectively. * * Return value: * X11 info struct containing display, gc, window ID and colormap. */ { XVisualInfo visual_template; /* template for XGetVisualInfo() */ XVisualInfo visual_info; /* return value of XGetVisualInfo() */ int visual_n; /* # of matches of XGetVisualInfo */ XEvent xev; XSizeHints hint; XSetWindowAttributes xswa; unsigned int fg, bg; /* foreground and background color */ unsigned int mask; /* event mask */ x11_info_t *xinfo = calloc (1, sizeof (x11_info_t)); long visual_mask; if (!xinfo) error ("Out of memory"); /* * Initialization of display */ xinfo->display = XOpenDisplay (NULL); if (xinfo->display == NULL) error ("Can't open display.\n" "Make sure that your environment variable DISPLAY " "is set correctly."); xinfo->screen = DefaultScreen (xinfo->display); xinfo->gc = DefaultGC (xinfo->display, xinfo->screen); { unsigned depth [] = {32, 24, 16}; int class [] = {TrueColor, PseudoColor}; const char *class_text [] = {"TrueColor", "PseudoColor"}; Status found = 0; unsigned d, c; for (d = 0; !found && d < sizeof (depth) / sizeof (unsigned); d++) for (c = 0; !found && c < sizeof (class) / sizeof (int); c++) { found = XMatchVisualInfo (xinfo->display, xinfo->screen, depth [d], class [c], &visual_info); if (found) fprintf (stderr, "%s : %d bit colordepth.\n", class_text [c], depth [d]); } if (!found && fiasco_get_verbosity ()) error ("Can't find a 16/24/32 bit TrueColor/DirectColor display"); } /* Width and height of the display window */ hint.x = hint.y = 0; hint.min_width = hint.max_width = hint.width = width; hint.min_height = hint.max_height = hint.height = height; hint.flags = PSize | PMinSize | PMaxSize; /* Get some colors */ bg = WhitePixel (xinfo->display, xinfo->screen); fg = BlackPixel (xinfo->display, xinfo->screen); /* Make the window */ mask = CWBackPixel | CWBorderPixel; if (visual_info.depth >= 16) { mask |= CWColormap; xswa.colormap = XCreateColormap (xinfo->display, DefaultRootWindow (xinfo->display), visual_info.visual, AllocNone); } xswa.background_pixel = bg; xswa.border_pixel = fg; xinfo->window = XCreateWindow (xinfo->display, DefaultRootWindow (xinfo->display), 0, 0, width, height, 1, visual_info.depth, InputOutput, visual_info.visual, mask, &xswa); XSelectInput (xinfo->display, xinfo->window, StructureNotifyMask); /* Tell other applications about this window */ XSetStandardProperties (xinfo->display, xinfo->window, titlename, iconname, None, NULL, 0, &hint); /* Map window. */ XMapWindow (xinfo->display, xinfo->window); /* Wait for map. */ do { XNextEvent (xinfo->display, &xev); } while (xev.type != MapNotify || xev.xmap.event != xinfo->window); /* Allocate colors */ return xinfo; } void alloc_ximage (x11_info_t *xinfo, unsigned width, unsigned height) /* * Allocate ximage of size 'width'x'height'. * If USE_SHM is defined then use shared memory extensions. * * No return value. * * Side effects: * 'ximage->ximage' and 'ximage->pixels' are set to useful values. */ { char dummy; #ifdef USE_SHM if (XShmQueryExtension(xinfo->display)) { if (fiasco_get_verbosity ()) fprintf (stderr, "Trying shared memory.\n"); shmem_flag = 1; } else { shmem_flag = 0; if (fiasco_get_verbosity ()) fprintf (stderr, "Shared memory not supported\nReverting to normal Xlib.\n"); } if (shmem_flag) CompletionType = XShmGetEventBase (xinfo->display) + ShmCompletion; InstallXErrorHandler (xinfo); if (shmem_flag) { xinfo->ximage = XShmCreateImage (xinfo->display, DefaultVisual (xinfo->display, xinfo->screen), DefaultDepth (xinfo->display, xinfo->screen), ZPixmap, NULL, &shminfo1, width, height); /* If no go, then revert to normal Xlib calls. */ if (xinfo->ximage == NULL) { if (fiasco_get_verbosity ()) fprintf (stderr, "Shared memory error, disabling (Ximage error).\n"); goto shmemerror; } /* Success here, continue. */ shminfo1.shmid = shmget (IPC_PRIVATE, xinfo->ximage->bytes_per_line * xinfo->ximage->height, IPC_CREAT | 0777); if (shminfo1.shmid < 0) { XDestroyImage (xinfo->ximage); if (fiasco_get_verbosity ()) fprintf (stderr, "Shared memory error, disabling (seg id error).\n"); goto shmemerror; } shminfo1.shmaddr = (char *) shmat (shminfo1.shmid, 0, 0); shminfo2.shmaddr = (char *) shmat (shminfo2.shmid, 0, 0); if (shminfo1.shmaddr == ((char *) -1)) { XDestroyImage (xinfo->ximage); if (shminfo1.shmaddr != ((char *) -1)) shmdt (shminfo1.shmaddr); if (fiasco_get_verbosity ()) fprintf (stderr, "Shared memory error, disabling (address error).\n"); goto shmemerror; } xinfo->ximage->data = shminfo1.shmaddr; xinfo->pixels = (byte_t *) xinfo->ximage->data; shminfo1.readOnly = False; XShmAttach (xinfo->display, &shminfo1); XSync (xinfo->display, False); if (gXErrorFlag) { /* Ultimate failure here. */ XDestroyImage (xinfo->ximage); shmdt (shminfo1.shmaddr); if (fiasco_get_verbosity ()) fprintf (stderr, "Shared memory error, disabling.\n"); gXErrorFlag = 0; goto shmemerror; } else shmctl (shminfo1.shmid, IPC_RMID, 0); if (fiasco_get_verbosity ()) fprintf (stderr, "Sharing memory.\n"); } else { shmemerror: shmem_flag = 0; #endif /* USE_SHM */ xinfo->ximage = XCreateImage (xinfo->display, DefaultVisual (xinfo->display, xinfo->screen), DefaultDepth (xinfo->display, xinfo->screen), ZPixmap, 0, &dummy, width, height, 8, 0); xinfo->pixels = calloc (width * height, xinfo->ximage->depth <= 8 ? sizeof (byte_t) : (xinfo->ximage->depth <= 16 ? sizeof (u_word_t) : sizeof (unsigned int))); if (!xinfo->pixels) error ("Out of memory."); #ifdef USE_SHM } DeInstallXErrorHandler (xinfo); #endif /* USE_SHM */ } #endif /* not X_DISPLAY_MISSING */ netpbm-free-10.0-1/pnm/fiasco/display.h0100644004714500471450000000172007716230207020177 0ustar aba-guestaba-guest/* * display.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _DISPLAY_H #define _DISPLAY_H #ifndef X_DISPLAY_MISSING #include #include "types.h" #include "image.h" typedef struct x11_info { Display *display; int screen; /* default screen number */ Window window; XImage *ximage; GC gc; byte_t *pixels; } x11_info_t; void display_image (unsigned x0, unsigned y0, x11_info_t *xinfo); void close_window (x11_info_t *xinfo); x11_info_t * open_window (const char *titlename, const char *iconname, unsigned width, unsigned height); void alloc_ximage (x11_info_t *xinfo, unsigned width, unsigned height); #endif /* X_DISPLAY_MISSING */ #endif /* not _DISPLAY_H */ netpbm-free-10.0-1/pnm/fiasco/dwfa.c0100644004714500471450000003307107776237374017474 0ustar aba-guestaba-guest/* * dwfa.c: Decoding of WFA-files * * Written by: Ullrich Hafner * Michael Unger * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2004/01/05 10:39:56 $ * $Author: aba-guest $ * $Revision: 1.2 $ * $State: Exp $ */ #include "config.h" #include "pnm.h" #if STDC_HEADERS # include # include #else /* not STDC_HEADERS */ # if HAVE_STRING_H # include # else /* not HAVE_STRING_H */ # include # endif /* not HAVE_STRING_H */ #endif /* not STDC_HEADERS */ #include #include "types.h" #include "macros.h" #include #include "binerror.h" #include "misc.h" #include "params.h" #include "fiasco.h" #ifndef X_DISPLAY_MISSING # include "display.h" # include "buttons.h" static x11_info_t *xinfo = NULL; #endif /* not X_DISPLAY_MISSING */ /***************************************************************************** prototypes *****************************************************************************/ static int checkargs (int argc, char **argv, bool_t *double_resolution, bool_t *panel, int *fps, char **image_name, fiasco_d_options_t **options); static void video_decoder (const char *wfa_name, const char *image_name, bool_t panel, bool_t double_resolution, int fps, fiasco_d_options_t *options); static void get_output_template (const char *image_name, const char *wfa_name, bool_t color, char **basename, char **suffix); #ifndef X_DISPLAY_MISSING static void show_stored_frames (unsigned char * const *frame_buffer, int last_frame, x11_info_t *xinfo, binfo_t *binfo, size_t size, unsigned frame_time); #endif /* not X_DISPLAY_MISSING */ /***************************************************************************** public code *****************************************************************************/ int main (int argc, char **argv) { char *image_name = NULL; /* output filename */ bool_t double_resolution = NO; /* double resolution of image */ bool_t panel = NO; /* control panel */ int fps = -1; /* frame display rate */ fiasco_d_options_t *options = NULL; /* additional coder options */ int last_arg; /* last processed cmdline parameter */ init_error_handling (argv[0]); last_arg = checkargs (argc, argv, &double_resolution, &panel, &fps, &image_name, &options); if (last_arg >= argc) video_decoder ("-", image_name, panel, double_resolution, fps, options); else while (last_arg++ < argc) video_decoder (argv [last_arg - 1], image_name, panel, double_resolution, fps, options); return 0; } /***************************************************************************** private code *****************************************************************************/ static param_t params [] = { #ifdef X_DISPLAY_MISSING {"output", "FILE", 'o', PSTR, {0}, "-", "Write raw PNM frame(s) to `%s'."}, #else /* not X_DISPLAY_MISSING */ {"output", "FILE", 'o', POSTR, {0}, NULL, "Write raw PNM frame(s) to INPUT.ppm/pgm [or `%s']."}, #endif /* not X_DISPLAY_MISSING */ {"double", NULL, 'd', PFLAG, {0}, "FALSE", "Interpolate images to double size before display."}, {"fast", NULL, 'r', PFLAG, {0}, "FALSE", "Use 4:2:0 format for fast, low quality output."}, {"panel", NULL, 'p', PFLAG, {0}, "FALSE", "Display control panel."}, {"magnify", "NUM", 'm', PINT, {0}, "0", "Magnify/reduce image size by a factor of 4^`%s'."}, {"framerate", "NUM", 'F', PINT, {0}, "-1", "Set display rate to `%s' frames per second."}, {"smoothing", "NUM", 's', PINT, {0}, "-1", "Smooth image(s) by factor `%s' (0-100)"}, {NULL, NULL, 0, 0, {0}, NULL, NULL } }; static int checkargs (int argc, char **argv, bool_t *double_resolution, bool_t *panel, int *fps, char **image_name, fiasco_d_options_t **options) /* * Check validness of command line parameters and of the parameter files. * * Return value. * index in argv of the first argv-element that is not an option. * * Side effects: * 'double_resolution', 'panel', 'fps', 'image_name' and 'options' * are modified. */ { int optind; /* last processed commandline param */ optind = parseargs (params, argc, argv, #ifdef X_DISPLAY_MISSING "Decode FIASCO-FILEs and write frame(s) to disk.", #else /* not X_DISPLAY_MISSING */ "Decode and display FIASCO-FILEs using X11.", #endif /* not X_DISPLAY_MISSING */ "With no FIASCO-FILE, or if FIASCO-FILE is -, " "read standard input.\n" #ifndef X_DISPLAY_MISSING "With --output=[FILE] specified, " "write frames without displaying them.\n\n" #endif /* not X_DISPLAY_MISSING */ "Environment:\n" "FIASCO_DATA Search path for automata files. " "Default: ./\n" "FIASCO_IMAGES Save path for image files. " "Default: ./", " [FIASCO-FILE]...", FIASCO_SHARE, "system.fiascorc", ".fiascorc"); *image_name = (char *) parameter_value (params, "output"); *double_resolution = *((bool_t *) parameter_value (params, "double")); *panel = *((bool_t *) parameter_value (params, "panel")); *fps = *((int *) parameter_value (params, "framerate")); /* * Additional options ... (have to be set with the fiasco_set_... methods) */ *options = fiasco_d_options_new (); { int n = *((int *) parameter_value (params, "smoothing")); if (!fiasco_d_options_set_smoothing (*options, max (-1, n))) error (fiasco_get_error_message ()); } { int n = *((int *) parameter_value (params, "magnify")); if (!fiasco_d_options_set_magnification (*options, n)) error (fiasco_get_error_message ()); } { bool_t n = *((bool_t *) parameter_value (params, "fast")); if (!fiasco_d_options_set_4_2_0_format (*options, n > 0 ? YES : NO)) error (fiasco_get_error_message ()); } return optind; } static void video_decoder (const char *wfa_name, const char *image_name, bool_t panel, bool_t double_resolution, int fps, fiasco_d_options_t *options) { #ifndef X_DISPLAY_MISSING fiasco_renderer_t *renderer = NULL; unsigned char **frame_buffer = NULL; binfo_t *binfo = NULL; /* buttons info */ #endif /* not X_DISPLAY_MISSING */ do { unsigned width, height, frames, n; fiasco_decoder_t *decoder_state; char *filename; char *basename; /* basename of decoded frame */ char *suffix; /* suffix of decoded frame */ unsigned frame_time; if (!(decoder_state = fiasco_decoder_new (wfa_name, options))) error (fiasco_get_error_message ()); if (fps <= 0) /* then use value of FIASCO file */ fps = fiasco_decoder_get_rate (decoder_state); frame_time = fps ? (1000 / fps) : (1000 / 25); if (!(width = fiasco_decoder_get_width (decoder_state))) error (fiasco_get_error_message ()); if (!(height = fiasco_decoder_get_height (decoder_state))) error (fiasco_get_error_message ()); if (!(frames = fiasco_decoder_get_length (decoder_state))) error (fiasco_get_error_message ()); get_output_template (image_name, wfa_name, fiasco_decoder_is_color (decoder_state), &basename, &suffix); filename = calloc (strlen (basename) + strlen (suffix) + 2 + 10 + (int) (log10 (frames) + 1), sizeof (char)); if (!filename) error ("Out of memory."); for (n = 0; n < frames; n++) { clock_t fps_timer; /* frames per second timer struct */ prg_timer (&fps_timer, START); if (image_name) /* just write frame to disk */ { if (frames == 1) /* just one image */ { if (streq (image_name, "-")) strcpy (filename, "-"); else sprintf (filename, "%s.%s", basename, suffix); } else { fprintf (stderr, "Decoding frame %d to file `%s.%0*d.%s\n", n, basename, (int) (log10 (frames - 1) + 1), n, suffix); sprintf (filename, "%s.%0*d.%s", basename, (int) (log10 (frames - 1) + 1), n, suffix); } if (!fiasco_decoder_write_frame (decoder_state, filename)) error (fiasco_get_error_message ()); } #ifndef X_DISPLAY_MISSING else { fiasco_image_t *frame; if (!(frame = fiasco_decoder_get_frame (decoder_state))) error (fiasco_get_error_message ()); if (frames == 1) panel = NO; if (xinfo == NULL) /* initialize X11 window */ { const char *title = fiasco_decoder_get_title (decoder_state); char titlename [MAXSTRLEN]; sprintf (titlename, "dfiasco " VERSION ": %s", strlen (title) > 0 ? title : wfa_name); xinfo = open_window (titlename, "dfiasco", (width << (double_resolution ? 1 : 0)), (height << (double_resolution ? 1 : 0)) + (panel ? 30 : 0)); alloc_ximage (xinfo, width << (double_resolution ? 1 : 0), height << (double_resolution ? 1 : 0)); if (panel) /* initialize button panel */ binfo = init_buttons (xinfo, n, frames, 30, 10); renderer = fiasco_renderer_new (xinfo->ximage->red_mask, xinfo->ximage->green_mask, xinfo->ximage->blue_mask, xinfo->ximage->bits_per_pixel, double_resolution); if (!renderer) error (fiasco_get_error_message ()); } renderer->render (renderer, xinfo->pixels, frame); frame->delete (frame); if (frame_buffer != NULL) /* store next frame */ { size_t size = (width << (double_resolution ? 1 : 0)) * (height << (double_resolution ? 1 : 0)) * (xinfo->ximage->depth <= 8 ? sizeof (byte_t) : (xinfo->ximage->depth <= 16 ? sizeof (u_word_t) : sizeof (unsigned int))); frame_buffer [n] = malloc (size); if (!frame_buffer [n]) error ("Out of memory."); memcpy (frame_buffer [n], xinfo->pixels, size); if (n == frames - 1) { show_stored_frames (frame_buffer, frames - 1, xinfo, binfo, size, frame_time); break; } } display_image (0, 0, xinfo); if (frames == 1) wait_for_input (xinfo); else if (panel) { check_events (xinfo, binfo, n, frames); if (binfo->pressed [QUIT_BUTTON]) /* start from beginning */ break; if (binfo->pressed [STOP_BUTTON]) /* start from beginning */ n = frames; if (binfo->pressed [RECORD_BUTTON] && frame_buffer == NULL) { n = frames; frame_buffer = calloc (frames, sizeof (unsigned char *)); if (!frame_buffer) error ("Out of memory."); } } while (prg_timer (&fps_timer, STOP) < frame_time) /* wait */ ; } #endif /* not X_DISPLAY_MISSING */ } free (filename); fiasco_decoder_delete (decoder_state); } while (panel #ifndef X_DISPLAY_MISSING && !binfo->pressed [QUIT_BUTTON] #endif /* not X_DISPLAY_MISSING */ ); #ifndef X_DISPLAY_MISSING if (renderer) renderer->delete (renderer); if (!image_name) { close_window (xinfo); free (xinfo); xinfo = NULL; if (binfo) free (binfo); } #endif /* not X_DISPLAY_MISSING */ } static void get_output_template (const char *image_name, const char *wfa_name, bool_t color, char **basename, char **suffix) /* * Generate image filename template for output of image sequences. * 'wfa_name' is the filename of the WFA stream. * Images are either saved with filename 'basename'.'suffix' (still images) * or 'basename'.%03d.'suffix' (videos). * * No return value. * * Side effects: * '*basename' and '*suffix' is set. */ { if (!wfa_name || streq (wfa_name, "-")) wfa_name = "stdin"; /* * Generate filename template */ if (!image_name || streq (image_name, "") || streq (image_name, "-")) { *basename = strdup (wfa_name); *suffix = NULL; } else { *basename = strdup (image_name); *suffix = strrchr (*basename, '.'); } if (*suffix) /* found name 'basename.suffix' */ { **suffix = 0; /* remove dot */ (*suffix)++; if (**suffix == 0) *suffix = strdup (color ? "ppm" : "pgm"); } else /* no suffix found, generate one */ *suffix = strdup (color ? "ppm" : "pgm"); } #ifndef X_DISPLAY_MISSING static void show_stored_frames (unsigned char * const *frame_buffer, int last_frame, x11_info_t *xinfo, binfo_t *binfo, size_t size, unsigned frame_time) /* * After a WFA video stream has been saved, all frames have been * decoded and stored in memory. These frames are then displayed * in an endless loop. * * This function never returns, the program is terminated if the * STOP button is pressed. */ { int n = last_frame; /* frame number */ while (1) { clock_t fps_timer; /* frames per second timer struct */ prg_timer (&fps_timer, START); display_image (0, 0, xinfo); check_events (xinfo, binfo, n, last_frame + 1); if (binfo->pressed [STOP_BUTTON]) n = 0; else if (binfo->pressed [QUIT_BUTTON]) break; else if (binfo->pressed [PLAY_BUTTON]) n++; else if (binfo->pressed [RECORD_BUTTON]) /* REWIND is mapped RECORD */ n--; if (n < 0) n = last_frame; if (n > last_frame) n = 0; memcpy (xinfo->pixels, frame_buffer [n], size); while (prg_timer (&fps_timer, STOP) < frame_time) /* wait */ ; }; } #endif /* not X_DISPLAY_MISSING */ netpbm-free-10.0-1/pnm/fiasco/fiasco.h0100644004714500471450000003445707716230207020013 0ustar aba-guestaba-guest/* * fiasco.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #undef __BEGIN_DECLS #undef __END_DECLS #ifdef __cplusplus # define __BEGIN_DECLS extern "C" { # define __END_DECLS } #else # define __BEGIN_DECLS /* empty */ # define __END_DECLS /* empty */ #endif #ifndef _FIASCO_H #define _FIASCO_H 1 __BEGIN_DECLS /**************************************************************************** FIASCO data types ****************************************************************************/ /* * Verbosity level: * FIASCO_NO_VERBOSITY: No output at all. * FIASCO_SOME_VERBOSITY: Show progress meter during coding * FIASCO_ULTIMATE_VERBOSITY: Show debugging output */ typedef enum {FIASCO_NO_VERBOSITY, FIASCO_SOME_VERBOSITY, FIASCO_ULTIMATE_VERBOSITY} fiasco_verbosity_e; /* * Image tiling methods: * VARIANCE_ASC: Tiles are sorted by variance. * The first tile has the lowest variance. * VARIANCE_DSC: Tiles are sorted by variance. * The first tile has the largest variance. * SPIRAL_ASC: Tiles are sorted like a spiral starting * in the middle of the image. * SPIRAL_DSC: Tiles are sorted like a spiral starting * in the upper left corner. */ typedef enum {FIASCO_TILING_SPIRAL_ASC, FIASCO_TILING_SPIRAL_DSC, FIASCO_TILING_VARIANCE_ASC, FIASCO_TILING_VARIANCE_DSC} fiasco_tiling_e; /* * Range of reduced precision format: * FIASCO_RPF_RANGE_0_75: use interval [-0.75,0.75] * FIASCO_RPF_RANGE_1_00: use interval [-1.00,1.00] * FIASCO_RPF_RANGE_1_50: use interval [-1.50,0.75] * FIASCO_RPF_RANGE_2_00: use interval [-2.00,2.00] */ typedef enum {FIASCO_RPF_RANGE_0_75, FIASCO_RPF_RANGE_1_00, FIASCO_RPF_RANGE_1_50, FIASCO_RPF_RANGE_2_00} fiasco_rpf_range_e; /* * Type of progress meter to be used during coding * FIASCO_PROGRESS_NONE: no output at all * FIASCO_PROGRESS_BAR: RPM style progress bar using 50 hash marks ###### * FIASCO_PROGRESS_PERCENT: percentage meter 50% */ typedef enum {FIASCO_PROGRESS_NONE, FIASCO_PROGRESS_BAR, FIASCO_PROGRESS_PERCENT} fiasco_progress_e; /* * Class to encapsulate FIASCO images. */ typedef struct fiasco_image { void (*delete) (struct fiasco_image *image); unsigned (*get_width) (struct fiasco_image *image); unsigned (*get_height) (struct fiasco_image *image); int (*is_color) (struct fiasco_image *image); void *private; } fiasco_image_t; /* * Class to store internal state of decoder. */ typedef struct fiasco_decoder { int (*delete) (struct fiasco_decoder *decoder); int (*write_frame) (struct fiasco_decoder *decoder, const char *filename); fiasco_image_t * (*get_frame) (struct fiasco_decoder *decoder); unsigned (*get_length) (struct fiasco_decoder *decoder); unsigned (*get_rate) (struct fiasco_decoder *decoder); unsigned (*get_width) (struct fiasco_decoder *decoder); unsigned (*get_height) (struct fiasco_decoder *decoder); const char * (*get_title) (struct fiasco_decoder *decoder); const char * (*get_comment) (struct fiasco_decoder *decoder); int (*is_color) (struct fiasco_decoder *decoder); void *private; } fiasco_decoder_t; /* * Class to encapsulate advanced coder options. */ typedef struct fiasco_c_options { void (*delete) (struct fiasco_c_options *options); int (*set_tiling) (struct fiasco_c_options *options, fiasco_tiling_e method, unsigned exponent); int (*set_frame_pattern) (struct fiasco_c_options *options, const char *pattern); int (*set_basisfile) (struct fiasco_c_options *options, const char *filename); int (*set_chroma_quality) (struct fiasco_c_options *options, float quality_factor, unsigned dictionary_size); int (*set_optimizations) (struct fiasco_c_options *options, unsigned min_block_level, unsigned max_block_level, unsigned max_elements, unsigned dictionary_size, unsigned optimization_level); int (*set_prediction) (struct fiasco_c_options *options, int intra_prediction, unsigned min_block_level, unsigned max_block_level); int (*set_video_param) (struct fiasco_c_options *options, unsigned frames_per_second, int half_pixel_prediction, int cross_B_search, int B_as_past_ref); int (*set_quantization) (struct fiasco_c_options *options, unsigned mantissa, fiasco_rpf_range_e range, unsigned dc_mantissa, fiasco_rpf_range_e dc_range); int (*set_progress_meter) (struct fiasco_c_options *options, fiasco_progress_e type); int (*set_smoothing) (struct fiasco_c_options *options, int smoothing); int (*set_comment) (struct fiasco_c_options *options, const char *comment); int (*set_title) (struct fiasco_c_options *options, const char *title); void *private; } fiasco_c_options_t; /* * Class to encapsulate advanced decoder options. */ typedef struct fiasco_d_options { void (*delete) (struct fiasco_d_options *options); int (*set_smoothing) (struct fiasco_d_options *options, int smoothing); int (*set_magnification) (struct fiasco_d_options *options, int level); int (*set_4_2_0_format) (struct fiasco_d_options *options, int format); void *private; } fiasco_d_options_t; /* * Class to convert internal FIASCO image structure to a XImage structure. * Method `renderer()' is used to convert internal image to XImage. * Method `delete()' is used to delete and free internal image. */ typedef struct fiasco_renderer { int (*render) (const struct fiasco_renderer *this, unsigned char *data, const fiasco_image_t *fiasco_image); void (*delete) (struct fiasco_renderer *this); void *private; } fiasco_renderer_t; /**************************************************************************** miscellaneous functions ****************************************************************************/ /* Get last error message of FIASCO library */ const char *fiasco_get_error_message (void); /* Set verbosity of FIASCO library */ void fiasco_set_verbosity (fiasco_verbosity_e level); /* Get verbosity of FIASCO library */ fiasco_verbosity_e fiasco_get_verbosity (void); /**************************************************************************** decoder functions ****************************************************************************/ /* Decode FIASCO image or sequence */ fiasco_decoder_t *fiasco_decoder_new (const char *filename, const fiasco_d_options_t *options); /* Flush and discard FIASCO decoder */ int fiasco_decoder_delete (fiasco_decoder_t *decoder); /* Decode next FIASCO frame and write to PNM image 'filename' */ int fiasco_decoder_write_frame (fiasco_decoder_t *decoder, const char *filename); /* Decode next FIASCO frame to FIASCO image structure */ fiasco_image_t *fiasco_decoder_get_frame (fiasco_decoder_t *decoder); /* Get width of FIASCO image or sequence */ unsigned fiasco_decoder_get_width (fiasco_decoder_t *decoder); /* Get height of FIASCO image or sequence */ unsigned fiasco_decoder_get_height (fiasco_decoder_t *decoder); /* Get width of FIASCO image or sequence */ int fiasco_decoder_is_color (fiasco_decoder_t *decoder); /* Get frame rate of FIASCO sequence */ unsigned fiasco_decoder_get_rate (fiasco_decoder_t *decoder); /* Get number of frames of FIASCO file */ unsigned fiasco_decoder_get_length (fiasco_decoder_t *decoder); /* Get title of FIASCO file */ const char * fiasco_decoder_get_title (fiasco_decoder_t *decoder); /* Get comment of FIASCO file */ const char * fiasco_decoder_get_comment (fiasco_decoder_t *decoder); /**************************************************************************** image functions ****************************************************************************/ /* Read FIASCO image (raw ppm or pgm format) */ fiasco_image_t * fiasco_image_new (const char *filename); /* Discard FIASCO image */ void fiasco_image_delete (fiasco_image_t *image); /* Get width of FIASCO image or sequence */ unsigned fiasco_image_get_width (fiasco_image_t *image); /* Get height of FIASCO image or sequence */ unsigned fiasco_image_get_height (fiasco_image_t *image); /* Get width of FIASCO image or sequence */ int fiasco_image_is_color (fiasco_image_t *image); /**************************************************************************** renderer functions ****************************************************************************/ /* Constructor of FIASCO image structure to a XImage renderer */ fiasco_renderer_t * fiasco_renderer_new (unsigned long red_mask, unsigned long green_mask, unsigned long blue_mask, unsigned bpp, int double_resolution); /* Destructor of FIASCO image structure to a XImage renderer */ void fiasco_renderer_delete (fiasco_renderer_t *renderer); /* FIASCO image structure to a XImage renderer */ int fiasco_renderer_render (const fiasco_renderer_t *renderer, unsigned char *ximage, const fiasco_image_t *fiasco_image); /**************************************************************************** coder functions ****************************************************************************/ /* Encode image or sequence by FIASCO */ int fiasco_coder (char const * const *inputname, const char *outputname, float quality, const fiasco_c_options_t *options); /**************************************************************************** coder options functions ****************************************************************************/ /* FIASCO additional options constructor */ fiasco_c_options_t *fiasco_c_options_new (void); /* FIASCO additional options destructor */ void fiasco_c_options_delete (fiasco_c_options_t *options); /* Define `smoothing'-percentage along partitioning borders.*/ int fiasco_c_options_set_smoothing (fiasco_c_options_t *options, int smoothing); /* Set type of frame prediction for sequence of frames */ int fiasco_c_options_set_frame_pattern (fiasco_c_options_t *options, const char *pattern); /* Set method and number of tiles for image tiling */ int fiasco_c_options_set_tiling (fiasco_c_options_t *options, fiasco_tiling_e method, unsigned exponent); /* Set FIASCO initial basis file */ int fiasco_c_options_set_basisfile (fiasco_c_options_t *options, const char *filename); /* Set quality and dictionary size of chroma compression */ int fiasco_c_options_set_chroma_quality (fiasco_c_options_t *options, float quality_factor, unsigned dictionary_size); /* * Since FIASCO internally works with binary trees, all functions * (which are handling image geometry) rather expect the `level' of * the corresponding binary tree than the traditional `width' and * `height' arguments. Refer to following table to convert these * values: * * level | width | height * ------+-------+-------- * 0 | 1 | 1 * 1 | 1 | 2 * 2 | 2 | 2 * 3 | 2 | 4 * 4 | 4 | 4 * 5 | 4 | 8 * 6 | 8 | 8 * 7 | 8 | 16 * */ /* Set various optimization parameters. */ int fiasco_c_options_set_optimizations (fiasco_c_options_t *options, unsigned min_block_level, unsigned max_block_level, unsigned max_elements, unsigned dictionary_size, unsigned optimization_level); /* Set minimum and maximum size of image block prediction */ int fiasco_c_options_set_prediction (fiasco_c_options_t *options, int intra_prediction, unsigned min_block_level, unsigned max_block_level); /* Set various parameters used for video compensation */ int fiasco_c_options_set_video_param (fiasco_c_options_t *options, unsigned frames_per_second, int half_pixel_prediction, int cross_B_search, int B_as_past_ref); /* Set accuracy of coefficients quantization */ int fiasco_c_options_set_quantization (fiasco_c_options_t *options, unsigned mantissa, fiasco_rpf_range_e range, unsigned dc_mantissa, fiasco_rpf_range_e dc_range); /* Set type of progress meter */ int fiasco_c_options_set_progress_meter (fiasco_c_options_t *options, fiasco_progress_e type); /* Set comment of FIASCO stream */ int fiasco_c_options_set_comment (fiasco_c_options_t *options, const char *comment); /* Set title of FIASCO stream */ int fiasco_c_options_set_title (fiasco_c_options_t *options, const char *title); /**************************************************************************** decoder options functions ****************************************************************************/ /* FIASCO additional options constructor */ fiasco_d_options_t *fiasco_d_options_new (void); /* FIASCO additional options destructor */ void fiasco_d_options_delete (fiasco_d_options_t *options); /* Define `smoothing'-percentage along partitioning borders.*/ int fiasco_d_options_set_smoothing (fiasco_d_options_t *options, int smoothing); /* Set magnification-'level' of decoded image */ int fiasco_d_options_set_magnification (fiasco_d_options_t *options, int level); /* Set image format to 4:2:0 or 4:4:4 */ int fiasco_d_options_set_4_2_0_format (fiasco_d_options_t *options, int format); __END_DECLS #endif /* not _FIASCO_H */ netpbm-free-10.0-1/pnm/fiasco/fiascotopnm.10100644004714500471450000001160207721162447020773 0ustar aba-guestaba-guest.TH fiascotopnm 1 "July 12, 2000" .SH NAME fiascotopnm - Convert compressed FIASCO image to PGM, or PPM .SH SYNOPSIS .B fiascotopnm .RI [ option ]... .RI [ filename ]... .ad b .hy 1 .SH DESCRIPTION .B fiascotopnm decompresses the named FIASCO files, or the Standard Input if no file is named, and writes the images as PGM, or PPM files, depending on whether the FIASCO image is black and white or color. .SH OPTIONS All option names may be abbreviated; for example, --output may be written --outp or --ou. For all options an one letter short option is provided. Mandatory or optional arguments to long options are mandatory or optional for short options, too. Both short and long options are case sensitive. .TP \fB\-o\fP[\fIname\fP], \fB\-\-output=\fP[\fIname\fP] Write decompressed image to the file \fIname\fP.ppm (if PPM) or \fIname\fP.pgm (if PGM). If \fIname\fP=- then produce the image file on the standard output. The optional argument \fIname\fP can be omitted, then the input filename is used as basename with the suffix .ppm or .pgm. In case of video streams, the frames are stored in the files \fIname\fP.\fBN\fP.ppm where \fBN\fP is the frame number (of the form 00..0 - 99..9); output on the standard output is not possible with video streams. If \fIname\fP is a relative path and the environment variable \fBFIASCO_IMAGES\fP is a (colon-separated) list of directories, then the output file(s) are written to the first (writable) directory of this list. Otherwise, the current directory is used to store the output file(s). .TP \fB\-z\fP, \fB\-\-fast\fP Decompress images in the 4:2:0 format; i.e., each chroma channel is decompressed to an image of halved width and height. Use this option on slow machines when the desired frame rate is not achieved; the output quality is only slightly decreased. .TP \fB\-d\fP, \fB\-\-double\fP Double the size of the X11 window both in width and height; no pixel interpolation is used, each pixel is just replaced by four identical pixels. .TP \fB\-p\fP, \fB\-\-panel\fP Show a panel with play, stop, pause, record and exit buttons to control the display of videos. When pressing the record button, all frames are decompressed and stored in memory. The other buttons work in the usual way. .TP \fB\-m\fP \fIN\fP, \fB\-\-magnify=\fIN\fP Set magnification of the decompressed image. Positive values enlarge and negative values reduce the image width and height by a factor of 2^|\fIN\fP|. .TP \fB\-s\fP \fIN\fP, \fB\-\-smooth=\fIN\fP Smooth decompressed image(s) along the partitioning borders by the given amount \fIN\fP. \fIN\fP is 1 (minimum) to 100 (maximum); default is 70. When \fIN\fP=0, then the smoothing amount specified in the FIASCO file is used (defined by the FIASCO coder). .TP \fB\-F\fP \fIN\fP, \fB\-\-fps=\fIN\fP Set number of frames per second to \fIN\fP. When using this option, the frame rate specified in the FIASCO file is overridden. .TP \fB\-v\fP, \fB\-\-version Print .B fiascotopnm version number, then exit. .TP \fB\-f\fP \fIname\fP, \fB\-\-config=\fIname\fP Load parameter file \fIname\fP to initialize the options of .BR fiascotopnm . See file .B system.fiascorc for an example of the syntax. Options of .B fiascotopnm are set by any of the following methods (in the specified order): 1) Global ressource file .B /etc/system.fiascorc 2) .RB $HOME /.fiascorc 3) command line 4) --config=\fIname\fP .TP \fB\-h\fP, \fB\-\-info Print brief help, then exit. .TP \fB\-H\fP, \fB\-\-help Print detailed help, then exit. .SH EXAMPLES .TP fiascotopnm foo.wfa >foo.ppm Decompress the FIASCO file "foo.wfa" and store it as "foo.ppm". .TP fiascotopnm -o foo1.wfa foo2.wfa Decompress the FIASCO files "foo1.wfa" and "foo2.wfa" and write the frames to the image files "foo1.wfa.ppm" and "foo2.wfa.ppm". .TP fiascotopnm -oimage foo1.wfa Decompress the FIASCO file "foo1.wfa" and write all 15 frames to the image files "image.00.ppm", ... , "image.14.ppm". .TP fiascotopnm --fast --magnify=-1 --double video.wfa >stream.ppm Decompress the FIASCO file "video.wfa". The decompression speed is as fast as possible: the image is decompressed (in 4:2:0 format) at a quarter of its original size; then the image is enlarged again by pixel doubling. .RE .SH FILES .PD 0 .TP .B /etc/system.fiascorc The systemwide initialization file. .TP .RB $HOME /.fiascorc The personal initialization file. .PD .SH ENVIRONMENT .PD 0 .TP .B FIASCO_IMAGES Save path for image files. Default is "./". .TP .B FIASCO_DATA Search path for FIASCO files. Default is "./". .PD .SH "SEE ALSO" .BR pnmtofiasco (1), .BR pnm (5) Ullrich Hafner, Juergen Albert, Stefan Frank, and Michael Unger. \fBWeighted Finite Automata for Video Compression\fP, IEEE Journal on Selected Areas In Communications, January 1998 .br Ullrich Hafner. \fBLow Bit-Rate Image and Video Coding with Weighted Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR Ullrich Hafner netpbm-free-10.0-1/pnm/fiasco/getopt.c0100644004714500471450000007012307716230207020032 0ustar aba-guestaba-guest/* Getopt for GNU. NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu before changing it! Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This tells Alpha OSF/1 not to define a getopt prototype in . Ditto for AIX 3.2 and . */ #ifndef _NO_PROTO #define _NO_PROTO #endif #ifdef HAVE_CONFIG_H #include #endif #if !defined (__STDC__) || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 #include #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE #endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ #include #include #endif /* GNU C library. */ #ifdef VMS #include #if HAVE_STRING_H - 0 #include #endif #endif #if defined (WIN32) && !defined (__CYGWIN32__) /* It's not Unix, really. See? Capital letters. */ #include #define getpid() GetCurrentProcessId() #endif #ifndef _ /* This is for other GNU distributions with internationalized messages. When compiling libc, the _ macro is predefined. */ #ifdef HAVE_LIBINTL_H # include # define _(msgid) gettext (msgid) #else # define _(msgid) (msgid) #endif #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg = NULL; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* 1003.2 says this must be 1 before any call. */ int optind = 1; /* Formerly, initialization of getopt depended on optind==0, which causes problems with re-calling getopt as programs generally don't know that. */ int __getopt_initialized = 0; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ int optopt = '?'; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return -1 with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Value of POSIXLY_CORRECT environment variable. */ static char *posixly_correct; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ #include #define my_index strchr #else /* Avoid depending on library functions or files whose names are inconsistent. */ char *getenv (); static char * my_index (str, chr) const char *str; int chr; { while (*str) { if (*str == chr) return (char *) str; str++; } return 0; } /* If using GCC, we can safely declare strlen this way. If not using GCC, it is ok not to declare it. */ #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ #if !defined (__STDC__) || !__STDC__ /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen (const char *); #endif /* not __STDC__ */ #endif /* __GNUC__ */ #endif /* not __GNU_LIBRARY__ */ /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; #ifdef _LIBC /* Bash 2.0 gives us an environment variable containing flags indicating ARGV elements that should not be considered arguments. */ static const char *nonoption_flags; static int nonoption_flags_len; static int original_argc; static char *const *original_argv; /* Make sure the environment variable bash 2.0 puts in the environment is valid for the getopt call we must make sure that the ARGV passed to getopt is that one passed to the process. */ static void store_args (int argc, char *const *argv) __attribute__ ((unused)); static void store_args (int argc, char *const *argv) { /* XXX This is no good solution. We should rather copy the args so that we can compare them later. But we must not use malloc(3). */ original_argc = argc; original_argv = argv; } text_set_element (__libc_subinit, store_args); #endif /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ #if defined (__STDC__) && __STDC__ static void exchange (char **); #endif static void exchange (argv) char **argv; { int bottom = first_nonopt; int middle = last_nonopt; int top = optind; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } /* Initialize the internal data when the first call is made. */ #if defined (__STDC__) && __STDC__ static const char *_getopt_initialize (int, char *const *, const char *); #endif static const char * _getopt_initialize (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ first_nonopt = last_nonopt = optind = 1; nextchar = NULL; posixly_correct = getenv ("POSIXLY_CORRECT"); /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; #ifdef _LIBC if (posixly_correct == NULL && argc == original_argc && argv == original_argv) { /* Bash 2.0 puts a special variable in the environment for each command it runs, specifying which ARGV elements are the results of file name wildcard expansion and therefore should not be considered as options. */ char var[100]; sprintf (var, "_%d_GNU_nonoption_argv_flags_", getpid ()); nonoption_flags = getenv (var); if (nonoption_flags == NULL) nonoption_flags_len = 0; else nonoption_flags_len = strlen (nonoption_flags); } else nonoption_flags_len = 0; #endif return optstring; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns -1. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { optarg = NULL; if (!__getopt_initialized || optind == 0) { optstring = _getopt_initialize (argc, argv, optstring); optind = 1; /* Don't scan ARGV[0], the program name. */ __getopt_initialized = 1; } /* Test whether ARGV[optind] points to a non-option argument. Either it does not have option syntax, or there is an environment flag from the shell indicating it is not an option. The later information is only used when the used in the GNU libc. */ #ifdef _LIBC #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ || (optind < nonoption_flags_len \ && nonoption_flags[optind] == '1')) #else #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif if (nextchar == NULL || *nextchar == '\0') { /* Advance to the next ARGV-element. */ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been moved back by the user (who may also have changed the arguments). */ if (last_nonopt > optind) last_nonopt = optind; if (first_nonopt > optind) first_nonopt = optind; if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && NONOPTION_P) optind++; last_nonopt = optind; } /* The special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp (argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return -1; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if (NONOPTION_P) { if (ordering == REQUIRE_ORDER) return -1; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Skip the initial punctuation. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } /* Decode the current option-ARGV-element. */ /* Check whether the ARGV-element is a long option. If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = -1; int option_index; for (nameend = nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == (unsigned int) strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; optopt = 0; return '?'; } if (pfound != NULL) { option_index = indfound; optind++; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (opterr) { if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, _("%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); else /* +option or -option */ fprintf (stderr, _("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); } nextchar += strlen (nextchar); optopt = pfound->val; return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' || my_index (optstring, *nextchar) == NULL) { if (opterr) { if (argv[optind][1] == '-') /* --option */ fprintf (stderr, _("%s: unrecognized option `--%s'\n"), argv[0], nextchar); else /* +option or -option */ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; optind++; optopt = 0; return '?'; } } /* Look at and handle the next short option-character. */ { char c = *nextchar++; char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (opterr) { if (posixly_correct) /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); else fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); } optopt = c; return '?'; } /* Convenience. Treat POSIX -W foo same as long option --foo */ if (temp[0] == 'W' && temp[1] == ';') { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = 0; int option_index; /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; return c; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; /* optarg is now the argument, see if it's in the table of longopts. */ for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; return '?'; } if (pfound != NULL) { option_index = indfound; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (opterr) fprintf (stderr, _("\ %s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name); nextchar += strlen (nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } nextchar = NULL; return 'W'; /* Let the application handle it. */ } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = NULL; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } int getopt (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } #endif /* Not ELIDE_CODE. */ #ifdef TEST /* Compile with -DTEST to make an executable for use in testing the above definition of `getopt'. */ int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; c = getopt (argc, argv, "abc:d:0123456789"); if (c == -1) break; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ netpbm-free-10.0-1/pnm/fiasco/getopt.h0100644004714500471450000001112307716230207020032 0ustar aba-guestaba-guest/* Declarations for getopt. Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _GETOPT_H #define _GETOPT_H 1 #ifdef __cplusplus extern "C" { #endif /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { #if defined (__STDC__) && __STDC__ const char *name; #else char *name; #endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ #define no_argument 0 #define required_argument 1 #define optional_argument 2 #if defined (__STDC__) && __STDC__ #ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int argc, char *const *argv, const char *shortopts); #else /* not __GNU_LIBRARY__ */ extern int getopt (); #endif /* __GNU_LIBRARY__ */ extern int getopt_long (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); extern int getopt_long_only (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind, int long_only); #else /* not __STDC__ */ extern int getopt (); extern int getopt_long (); extern int getopt_long_only (); extern int _getopt_internal (); #endif /* __STDC__ */ #ifdef __cplusplus } #endif #endif /* _GETOPT_H */ netpbm-free-10.0-1/pnm/fiasco/getopt1.c0100644004714500471450000001105307716230207020110 0ustar aba-guestaba-guest/* getopt_long and getopt_long_only entry points for GNU getopt. Copyright (C) 1987,88,89,90,91,92,93,94,96,97 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include #endif #include "getopt.h" #if !defined (__STDC__) || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 #include #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE #endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ #include #endif #ifndef NULL #define NULL 0 #endif int getopt_long (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. If an option that starts with '-' (not '--') doesn't match a long option, but does match a short option, it is parsed as a short option instead. */ int getopt_long_only (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 1); } #endif /* Not ELIDE_CODE. */ #ifdef TEST #include int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; int option_index = 0; static struct option long_options[] = { {"add", 1, 0, 0}, {"append", 0, 0, 0}, {"delete", 1, 0, 0}, {"verbose", 0, 0, 0}, {"create", 0, 0, 0}, {"file", 1, 0, 0}, {0, 0, 0, 0} }; c = getopt_long (argc, argv, "abc:d:0123456789", long_options, &option_index); if (c == -1) break; switch (c) { case 0: printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case 'd': printf ("option d with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ netpbm-free-10.0-1/pnm/fiasco/params.c0100644004714500471450000004615607716230207020024 0ustar aba-guestaba-guest/* * params.c: Parameter file and command line parsing * * Written by: Stefan Frank * Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #include #include #include /* strtod() on SUN sparc */ #if STDC_HEADERS # include # include #else /* not STDC_HEADERS */ # if HAVE_STRING_H # include # else /* not HAVE_STRING_H */ # include # endif /* not HAVE_STRING_H */ #endif /* not STDC_HEADERS */ #include /* system or ../lib */ #include "types.h" #include "macros.h" #include "bit-io.h" #include "misc.h" #include "fiasco.h" #include "binerror.h" #include "params.h" /***************************************************************************** prototypes *****************************************************************************/ static void read_parameter_file (param_t *params, FILE *file); static int get_parameter_index (const param_t *params, const char *search_string); static void set_parameter (param_t *parameter, const char *value); static void usage (const param_t *params, const char *progname, const char *synopsis, const char *comment, const char *non_opt_string, bool_t show_all_options, const char *sys_file_name, const char *usr_file_name); /***************************************************************************** public code *****************************************************************************/ int parseargs (param_t *usr_params, int argc, char **argv, const char *synopsis, const char *comment, const char *non_opt_string, const char *path, const char *sys_file_name, const char *usr_file_name) /* * Perform the command line parsing. * List of allowed parameters is given by 'usr_params'. * Command line and number of parameters are given by 'argv' and 'argc'. * 'synopsis' contains a brief description of the program and * 'comment' may contain some additional advice. * Initialization order of parameters: * 1.) Default values given by the param_t struct * 2.) System parameter-file ('path'/'sys_file_name') * 3.) User parameter-file ($HOME/'usr_file_name') * 4.) Command line parameters * 5.) Parameter-file forced by option -f (--config-file) * * Return value: * index in ARGV of the first ARGV-element that is not an option. * * Side effects: * the elements of ARGV are permuted * usr_params [].value is modified */ { extern int optind; /* index in ARGV of the 1st element that is not an option */ bool_t detailed_help = NO; /* NO if all parameters can be modified with short options too */ unsigned n1; /* number of user parameters */ unsigned n2; /* number of system parameters */ bool_t read_config_file = NO; /* will override command line */ param_t *params; /* array of user and system params */ param_t *sys_params; /* array of system parameters */ param_t detailed_sys_params [] = /* detailed system parameters */ { {"version", NULL, 'v', PFLAG, {0}, NULL, "Print program version number, then exit."}, {"verbose", "NUM", 'V', PINT, {0}, "1", "Set level of verbosity to `%s'."}, {"config", "FILE", 'f', PSTR, {0}, NULL, "Load `%s' to initialize parameters."}, {"info", NULL, 'h', PFLAG, {0}, NULL, "Print brief help, then exit."}, {"help", NULL, 'H', PFLAG, {0}, NULL, "Print detailed help, then exit."}, {NULL, NULL, 0, PSTR, {0}, NULL, NULL } }; param_t short_sys_params [] = /* short system parameters */ { {"version", NULL, 'v', PFLAG, {0}, NULL, "Print program version number, then exit."}, {"verbose", "NUM", 'V', PINT, {0}, "1", "Set level of verbosity to `%s'."}, {"config", "FILE", 'f', PSTR, {0}, NULL, "Load `%s' to initialize parameters."}, {"help", NULL, 'h', PFLAG, {0}, NULL, "Print this help, then exit."}, {NULL, NULL, 0, PSTR, {0}, NULL, NULL } }; char *sys_path; /* path to system config file */ sys_path = calloc (strlen (path) + strlen (sys_file_name) + 2, sizeof (char)); if (!sys_path) error ("Out of memory."); sprintf (sys_path, "%s/%s", path, sys_file_name); /* * Set parameters defaults */ { param_t *p; for (p = usr_params; p->name != NULL; p++) { set_parameter (p, p->default_value); if (p->optchar == '\0') detailed_help = YES; } sys_params = detailed_help ? detailed_sys_params : short_sys_params; for (p = sys_params; p->name != NULL; p++) set_parameter (p, p->default_value); } /* * Append system command line option to user parameters */ for (n1 = 0; usr_params [n1].name != NULL; n1++) ; for (n2 = 0; sys_params [n2].name != NULL; n2++) ; params = calloc (n1 + n2 + 1, sizeof (param_t)); if (!params) error ("Out of memory."); memcpy (params, usr_params, n1 * sizeof (param_t)); memcpy (params + n1, sys_params, (n2 + 1) * sizeof (param_t)); /* * Try to open the system resource file 'path'/'sys_file_name' */ { FILE *parameter_file = open_file (sys_path, NULL, READ_ACCESS); if (parameter_file == NULL) /* warning ("No system resource file found."); */ {} else { read_parameter_file (params, parameter_file); fclose (parameter_file); } } /* * Try to read user resource file $HOME/'usr_file_name' */ { FILE *parameter_file = open_file (usr_file_name, "HOME", READ_ACCESS); if (parameter_file != NULL) { read_parameter_file (params, parameter_file); fclose (parameter_file); } } /* * Parse command line options */ { extern char *optarg; /* argument of current option */ struct option *long_options; /* array of long options */ int option_index = 0; char optstr [MAXSTRLEN]; /* string containing the legitimate option characters */ int optchar; /* found option character */ /* * Build short option string for getopt_long (). */ { param_t *p; /* counter */ char *ptr_optstr; /* pointer to position in string */ ptr_optstr = optstr; for (p = params; p->name != NULL; p++) if (p->optchar != '\0') { *ptr_optstr++ = p->optchar; if (p->type == POSTR) { *ptr_optstr++ = ':'; *ptr_optstr++ = ':'; } else if (p->type != PFLAG) *ptr_optstr++ = ':'; } *ptr_optstr = '\0'; } /* * Build long option string for getopt_long (). */ { int i; long_options = calloc (n1 + n2 + 1, sizeof (struct option)); if (!long_options) error ("Out of memory."); for (i = 0; params [i].name != NULL; i++) { long_options [i].name = params [i].name; switch (params [i].type) { case PFLAG: long_options [i].has_arg = 0; break; case POSTR: long_options [i].has_arg = 2; break; case PINT: case PSTR: case PFLOAT: default: long_options [i].has_arg = 1; break; } long_options [i].has_arg = params [i].type != PFLAG; long_options [i].flag = NULL; long_options [i].val = 0; } } /* * Parse comand line */ while ((optchar = getopt_long (argc, argv, optstr, long_options, &option_index)) != EOF) { int param_index = -1; switch (optchar) { case 0: param_index = option_index; break; case ':': if (detailed_help) fprintf (stderr, "Try `%s -h' or `%s --help' for " "more information.\n", argv [0], argv [0]); else fprintf (stderr, "Try `%s --help' for more information.\n", argv [0]); exit (2); break; case '?': if (detailed_help) fprintf (stderr, "Try `%s -h' or `%s --help' " "for more information.\n", argv [0], argv [0]); else fprintf (stderr, "Try `%s --help' for more information.\n", argv [0]); exit (2); break; default: { int i; for (i = 0; params [i].name != NULL; i++) if (params [i].optchar == optchar) { param_index = i; break; } } } /* * Check for system options */ if (param_index >= 0) { set_parameter (params + param_index, optarg ? optarg : ""); if (streq (params [param_index].name, "help")) usage (params, argv [0], synopsis, comment, non_opt_string, YES, sys_path, usr_file_name); else if (streq (params [param_index].name, "info")) usage (params, argv [0], synopsis, comment, non_opt_string, NO, sys_path, usr_file_name); else if (streq (params [param_index].name, "version")) { fprintf (stderr, "%s " VERSION "\n", argv [0]); exit (2); } else if (streq (params [param_index].name, "verbose")) fiasco_set_verbosity ( * (fiasco_verbosity_e *) parameter_value (params, "verbose")); else if (streq (params [param_index].name, "config")) read_config_file = YES; param_index = -1; /* clear index flag */ } } free (long_options); } /* * Read config-file if specified by option -f */ if (read_config_file) { char *filename; if ((filename = (char *) parameter_value (params, "config")) != NULL) { FILE *parameter_file; /* input file */ warning ("Options set in file `%s' will override" " command line options.", filename); parameter_file = open_file (filename, NULL, READ_ACCESS); if (parameter_file != NULL) { read_parameter_file (params, parameter_file); fclose (parameter_file); } else file_error (filename); } else error ("Invalid config filename."); } memcpy (usr_params, params, n1 * sizeof (param_t)); /* fill user struct */ free (sys_path); return optind; } void * parameter_value (const param_t *params, const char *name) /* * Extract value of parameter 'name.' of the given parameters 'params'. * * Return value: * value of given parameter */ { int pind = get_parameter_index (params, name); if (pind < 0) error ("Invalid parameter `%s'.", name); if (params [pind].type == PSTR || params [pind].type == POSTR) return (void *) params [pind].value.s; return (void *) &(params [pind].value); } void ask_and_set (param_t *params, const char *name, const char *msg) /* * Ask user (print given message 'msg') for missing mandatory * parameter 'name' of the given parameters 'params'. * * No return value. * * Side effects: * 'params ['name'].value' is changed */ { char answer [MAXSTRLEN]; int index = get_parameter_index (params, name); if (index < 0) error ("Invalid parameter %s.", name); if (msg) fprintf (stderr, "%s\n", msg); switch (params [index].type) { case PFLAG: /* Unusual, at least. */ warning ("Flags should be initialized and set on demand, " "not request"); case PINT: case PSTR: case POSTR: case PFLOAT: scanf (MAXSTRLEN_SCANF, answer); set_parameter (¶ms [index], answer); break; default: error ("Invalid parameter type for %s", name); } } void write_parameters (const param_t *params, FILE *output) /* * Write all parameter settings to 'output'. * * No return value. */ { int pind; if (!params || !output) error ("Parameters must be not NULL."); for (pind = 0; params [pind].name != NULL; pind++) { fprintf (output, "# %s = ", params [pind].name); switch (params [pind].type) { case PFLAG: fprintf (output, "%s\n", params [pind].value.b ? "TRUE" : "FALSE"); break; case PINT: fprintf (output, "%d\n", params [pind].value.i); break; case PFLOAT: fprintf (output, "%.4f\n", (double) params [pind].value.f); break; case PSTR: case POSTR: fprintf (output, "%s\n", params [pind].value.s); break; default: error ("Invalid type %d for parameter %s", params [pind].type, params [pind].name); } } fputc ('\n', output); } /***************************************************************************** private code *****************************************************************************/ static void set_parameter (param_t *parameter, const char *value) /* * Set value of 'parameter' to 'value'. * * No return value. * * Side effects: * 'parameter.value' is changed accordingly */ { assert (parameter); switch (parameter->type) { case PFLAG: if (value != NULL && *value != '\0') { if (strcaseeq (value, "TRUE")) parameter->value.b = YES; else if (strcaseeq (value, "FALSE")) parameter->value.b = NO; else if (strcaseeq (value, "YES")) parameter->value.b = YES; else if (strcaseeq (value, "NO")) parameter->value.b = NO; else { long int data; char *endptr; data = strtol (value, &endptr, 0); if (*endptr != '\0' || endptr == value) warning ("Invalid value `%s' converted to %d", value, (int) data); parameter->value.b = data ? YES : NO; } } else parameter->value.b = !parameter->value.b; break; case PINT: { long int data; char *endptr; data = strtol (value, &endptr, 0); if (*endptr != '\0' || endptr == value) warning ("Invalid value `%s' converted to %d", value, (int) data); parameter->value.i = data; } break; case PFLOAT: { double data; char *endptr; data = strtod (value, &endptr); if (*endptr != '\0' || endptr == value) warning ("Invalid value `%s' converted to %f", value, (double) data); parameter->value.f = data; } break; case PSTR: case POSTR: parameter->value.s = value ? strdup (value) : NULL; break; default: error ("Invalid parameter type for %s", parameter->name); } } static int get_parameter_index (const param_t *params, const char *search_string) /* * Search for parameter with name 'search_string' in parameter struct. * * Return value: * index of parameter or -1 if no matching parameter has been found */ { int n; int index = -1; assert (params && search_string); for (n = 0; params [n].name != NULL; n++) if (strcaseeq (params [n].name, search_string)) { index = n; break; } return index; } static void read_parameter_file (param_t *params, FILE *file) /* * Read parameter settings from 'file'. * * No return value. * * Side effects: * 'params [].value' are changed if specified in 'file' */ { char buffer [MAXSTRLEN]; int n = 0; assert (params && file); while (fgets (buffer, MAXSTRLEN, file) != NULL) { char *b; /* temporary variable */ char *name; /* parameter name */ char *value; /* parameter value */ int pind; /* current argument number */ b = strchr (buffer, '#'); if (b != NULL) /* Strip comments. */ *b = '\0'; b = strchr (buffer, '='); if (b == NULL) /* Strip lines that contain no '=' */ continue; *b = '\0'; /* Replace '=' by string terminator */ /* * Extract value of parameter */ for (value = b + 1; isspace (*value); value++) ; /* Delete leading spaces */ for (b = value + strlen (value) - 1; b >= value && isspace (*b); b--) *b = '\0'; /* Delete trailing spaces. */ /* * Extract parameter name */ for (name = buffer; isspace (*name); name++) ; /* Delete leading spaces */ for (b = name + strlen (name) - 1; b >= name && isspace (*b); b--) *b = '\0'; /* Delete trailing spaces. */ pind = get_parameter_index (params, name); if (pind >= 0) set_parameter (¶ms [pind], value); n++; } } static void usage (const param_t *params, const char *progname, const char *synopsis, const char *comment, const char *non_opt_string, bool_t show_all_options, const char *sys_file_name, const char *usr_file_name) /* * Generates and prints command line description from param_t struct 'params'. * 'progname' is the name of the excecutable, 'synopsis' a short program * description, and 'comment' some more advice. * If flag 'show_all_options' is set then print also options that are not * associated with a short option character. * 'sys_file_name' and 'usr_file_name' are filenames to parameter files. * * No return value. */ { int i; size_t width = 0; fprintf (stderr, "Usage: %s [OPTION]...%s\n", progname, non_opt_string ? non_opt_string : " "); if (synopsis != NULL) fprintf (stderr, synopsis); fprintf (stderr, "\n\n"); fprintf (stderr, "Mandatory or optional arguments to long options " "are mandatory or optional\nfor short options too. " "Default values are surrounded by {}.\n"); for (i = 0; params [i].name != NULL; i++) if (params [i].optchar != '\0' || show_all_options) { if (params [i].type == POSTR) width = max (width, (strlen (params [i].name) + strlen (params [i].argument_name) + 2)); else if (params [i].type != PFLAG) width = max (width, (strlen (params [i].name) + strlen (params [i].argument_name))); else width = max (width, (strlen (params [i].name)) - 1); } for (i = 0; params [i].name != NULL; i++) if (params [i].optchar != '\0' || show_all_options) { if (params [i].optchar != '\0') fprintf (stderr, " -%c, --", params [i].optchar); else fprintf (stderr, " --"); if (params [i].type == POSTR) fprintf (stderr, "%s=[%s]%-*s ", params [i].name, params [i].argument_name, max (0, (width - 2 - strlen (params [i].name) - strlen (params [i].argument_name))), ""); else if (params [i].type != PFLAG) fprintf (stderr, "%s=%-*s ", params [i].name, width - strlen (params [i].name), params [i].argument_name); else fprintf (stderr, "%-*s ", width + 1, params [i].name); fprintf (stderr, params [i].use, params [i].argument_name); switch (params [i].type) { case PFLAG: break; case PINT: fprintf (stderr, "{%d}", params [i].value.i); break; case PFLOAT: fprintf (stderr, "{%.2f}", (double) params [i].value.f); break; case PSTR: case POSTR: if (params [i].value.s) fprintf (stderr, "{%s}", params [i].value.s); break; default: error ("type %d for %s invalid", params [i].type, params [i].name); } fprintf (stderr, "\n"); } fprintf (stderr, "\n"); fprintf (stderr, "Parameter initialization order:\n"); fprintf (stderr, "1.) %s\n2.) $HOME/%s\t 3.) command line\t 4.) --config=file", sys_file_name, usr_file_name); fprintf (stderr, "\n\n"); if (comment != NULL) fprintf (stderr, "%s\n", comment); exit (1); } netpbm-free-10.0-1/pnm/fiasco/params.h0100644004714500471450000000265707716230207020027 0ustar aba-guestaba-guest/* * params.h * * Written by: Stefan Frank * Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef PARAMS_H #define PARAMS_H #include typedef union pdata_t /* Allow for different */ { /* parameter types. */ int b; int i; float f; char *s; } pdata_t; typedef enum {PFLAG = 1, PINT, PFLOAT, PSTR, POSTR} param_e; typedef struct param_t { char *name; /* Parameter name */ char *argument_name; /* Argument name */ char optchar; /* Corresponding command line switch */ param_e type; /* Parameter type */ pdata_t value; /* Parameter value */ char *default_value; /* Parameters default value */ char *use; /* One line usage. Must contain %s, which will be replaced by 'name'. */ } param_t; int parseargs (param_t *usr_params, int argc, char **argv, const char *synopsis, const char *comment, const char *non_opt_string, const char *path, const char *sys_file_name, const char *usr_file_name); void write_parameters (const param_t *params, FILE *output); void ask_and_set (param_t *params, const char *name, const char *msg); void * parameter_value (const param_t *params, const char *name); #endif /* not PARAMS_H */ netpbm-free-10.0-1/pnm/fiasco/pnmtofiasco.10100644004714500471450000002212407721162447020774 0ustar aba-guestaba-guest.TH pnmmtofiasco 1 "July 12, 2000" .SH NAME pnmtofiasco - Convert a portable anymap to FIASCO compressed file .SH SYNOPSIS .B pnmtofiasco .RI [ option ]... .RI [ filename ]... .SH DESCRIPTION .B pnmtofiasco compresses the named pbm, pgm, or ppm image files, or Standard Input if no file is named, and produces a FIASCO file on Standard Output. .SH OPTIONS All option names may be abbreviated; for example, --optimize may be written --optim or --opt. For most options a one letter short option is provided. Mandatory or optional arguments to long options are mandatory or optional for short options, too. Both short and long options are case sensitive. The basic options are: .TP \fB\-i\fP \fIname\fP, \fB\-\-input-name=\fIname\fP Compress the named images, not Standard Input. If .I name is .BR - , read Standard Input. .I name has to be either an image filename or a template of the form: .ce prefix[start-end{+,-}step]suffix Templates are useful when compressing video streams: e.g., if you specify the template .BR "img0[12-01-2].pgm" , then .B pnmtofiasco compresses the images img012.pgm, img010.pgm, ..., img002.pgm. If .I name is a relative path, .B pnmtofiasco searches for the image files in the current directory and in the (colon-separated) list of directories given by the environment variable .BR FIASCO_IMAGES . .TP \fB\-o\fP \fIoutput-file\fP, \fB\-\-output-name=\fIname\fP Write FIASCO output to the named file, not to Standard Output. If .I name is a relative path and the environment variable .B FIASCO_DATA is a (colon-separated) list of directories, then .B pnmtofiasco writes the output file to the first (writable) directory of this list. Otherwise, .B pnmtofiasco write it to the current directory. .TP \fB\-q\fP \fIN\fP, \fB\-\-quality=\fIN\fP Set quality of compression to .IR N . Quality is 1 (worst) to 100 (best); default is 20. .TP \fB\-v\fP, \fB\-\-version Print .B pnmtofiasco version number, then exit. .TP \fB\-V\fP \fIN\fP, \fB\-\-verbose \fIN\fP Set level of verbosity to .IR N . Level is 0 (no output at all), 1 (show progress meter), or 2 (show detailed compression statistics); default is 1. .TP \fB\-B\fP \fIN\fP, \fB\-\-progress-meter \fIN\fP Set type of progress-meter to .IR N . The following types are available; default is 1: .BR 0 : no progress meter .BR 1 : RPM style progress bar using 50 hash marks .BR 2 : percentage meter .TP \fB\-f\fP \fIname\fP, \fB\-\-config=\fIname\fP Load parameter file .I name to initialize the options of .BR pnmtofiasco . See file .B system.fiascorc for an example of the syntax. Options of .B pnmtofiasco are set by any of the following methods (in the specified order): 1) Global ressource file .B /etc/system.fiascorc 2) $HOME/.fiascorc 3) command line 4) --config=\fIname\fP .TP \fB\-h\fP, \fB\-\-info Print brief help, then exit. .TP \fB\-H\fP, \fB\-\-help Print detailed help, then exit. .TP The options for advanced users are: .TP \fB\-b\fP \fIname\fP, \fB\-\-basis-name=\fIname\fP Preload compression basis \fIname\fP into FIASCO. The basis \fIname\fP provides the initial compression dictionary. Either use one of the files "small.fco", "medium.fco", or "large.fco" that come with .B pnmtofiasco or create a new ASCII basis file. .TP \fB\-z\fP \fIN\fP, \fB\-\-optimize=\fIN\fP Set optimization level to \fIN\fP. Level is 0 (fastes) to 3 (slowest); default is 1. Be warned, the encoding time dramatically increased when \fIN\fP=\fB2\fP or \fIN\fP=\fB3\fP while the compression performance only slightly improves. .TP \fB\-P\fP, \fB\-\-prediction Use additional predictive coding. If this optimization is enabled then the image is compressed in two steps. In the first step, a coarse approximation of the image is computed using large unichrome blocks. Finally, the delta image is computed and the prediction error is approximated using the standard FIASCO algorithm. .TP \fB\-D\fP \fIN\fP, \fB\-\-dictionary-size=\fIN\fP Set size of dictionary that is used when coding the luminance band to \fIN\fP; default is 10000, i.e., the dictionary is not restricted. .TP \fB\-C\fP \fIN\fP, \fB\-\-chroma-dictionary=\fIN\fP Set size of dictionary that is used when coding chroma bands to \fIN\fP; default is 40. .TP \fB\-Q\fP \fIN\fP, \fB\-\-chroma-qfactor=\fIN\fP Reduce the quality of chroma band compression \fIN\fP-times with respect to the user defined quality \fIq\fP of the luminance band compression (\fB\-\-quality\fP=\fIq\fP); default is 2. .TP \fB\-t\fP \fIN\fP, \fB\-\-tiling-exponent=\fIN\fP Subdivide the image into 2^\fIN\fP tiles prior coding; default is 4, i.e. the image is subdivided into 16 tiles. The processing order of the individual tiles is defined by the option \fB\-\-tiling-method=\fIname\fP. .TP \fB\-T\fP \fIname\fP, \fB\-\-tiling-method=\fIname\fP Order the individual image tiles (the image is subdivided into; see option \fB\-\-tiling-exponent=\fP\fIN\fP) by method \fIname\fP; default is "desc-variance". \fBdesc-variance\fP: Tiles with small variances are processed first. \fBasc-variance\fP: Tiles with large variances are processed first. \fBdesc-spiral\fP: Tiles are process in spiral order starting in the middle. \fBasc-spiral\fP: Tiles are process in spiral order starting at the border. .TP \fB\-\-rpf-mantissa=\fIN\fP Use \fIN\fP mantissa bits for quantized coefficients. .TP \fB\-\-dc-rpf-mantissa=\fIN\fP Use \fIN\fP mantissa bits for quantized DC coefficients. .TP \fB\-\-rpf-range=\fIN\fP Coefficients outside the quantization interval [-\fIN\fP,+\fIN\fP] are set to zero. .TP \fB\-\-dc-rpf-range=\fIN\fP DC coefficients outside the quantization interval [-\fIN\fP,+\fIN\fP] are set to zero. .TP Additional options for video compression are: .TP \fB\-s\fP \fIN\fP, \fB\-\-smooth=\fIN\fP Smooth decompressed reference frames along the partitioning borders by the given amount \fIN\fP. \fIN\fP is 0 (no smoothing) to 100; default is 70. This factor is stored in the FIASCO file. .TP \fB\-m\fP \fIN\fP, \fB\-\-min-level=\fIN\fP Start prediction (motion compensated prediction or additional prediction) on block level \fIN\fP; default is level 6. I.e., motion compensation is applied to all image blocks of at least 8x8 pixels (binary tree level \fIN\fP=6), 16x8 (\fIN\fP=7), 16x16 (\fIN\fP=8), etc. .TP \fB\-M\fP \fIN\fP, \fB\-\-max-level=\fIN\fP Stop prediction (motion compensated prediction or additional prediction) on block level \fIN\fP; default is level 10. I.e., motion compensation is applied to all image blocks of at most 16x16 pixels (\fIN\fP=8), 32x16 (\fIN\fP=9), 32x32 (\fIN\fP=10), etc. .TP \fB\-2\fP, \fB\-\-half-pixel Use half pixel precise motion compensation. .TP \fB\-F\fP \fIN\fP, \fB\-\-fps=\fIN\fP Set number of frames per second to \fIN\fP. This value is stored in the FIASCO output file and is used in the decoder dfiasco(1) to control the framerate. .TP \fB\-p\fP \fItype\fP, \fB\-\-pattern=\fItype\fP Defines the type of inter frame compression which should be applied to individual frames of a video stream. \fItype\fP is a sequence of characters; default is "IPPPPPPPPP". Element \fBN\fP defines the type of predicting which should be used for frame \fBN\fP; the frame type pattern is periodically extended. Valid characters are: \fBI\fP: intra frame, i.e., no motion compensated prediction is used at all. \fBP\fP: predicted frame, i.e., a previously encoded frame is used for prediction (forward prediction). \fBB\fP: bidirectional predicted frame, i.e., not only a previously shown frame but also a frame of the future is used for prediction (forward, backward or interpolated prediction). .TP \fB\-\-cross-B-search Instead of using exhaustive search the "Cross-B-Search" algorithm is used to find the best interpolated prediction of B-frames. .TP \fB\-\-B-as-past-ref Also use previously encoded B-frames when prediction the current frame. If this option is not set, only I- and P-frames are used to predict the current frame. .SH EXAMPLES .TP pnmtofiasco < foo.ppm >foo.wfa Compress the still image "foo.ppm" to the FIASCO file "foo.wfa" using the default options. .TP pnmtofiasco -2 -p "IBBPBBPBB" -fps 15 -o video.wfa foo0*.ppm Compress the video frames "foo0*.ppm" to the FIASCO file "video.wfa" using half pixel precise motion compensation at a frame rate of 15 frames per second. Intra frame 1 is used to predict P-frame 4, frames 1 and 4 are used to predict B-frames 2 and 3, and so on. Frame 10 is again an intra-frame. .RE .SH FILES .PD 0 .TP .B /etc/system.fiascorc The systemwide initialization file. .TP .RB $HOME /.fiascorc The personal initialization file. .PD .SH ENVIRONMENT .PD 0 .TP .B FIASCO_IMAGES Search path for image files. Default is "./". .TP .B FIASCO_DATA Search and save path for FIASCO files. Default is "./". .PD .SH "SEE ALSO" .br .BR fiascotopnm (1), .BR ppmtojpeg (1), .BR pnmtojbig (1), .BR ppmtogif (1), .BR pnm (5) .br Ullrich Hafner, Juergen Albert, Stefan Frank, and Michael Unger. \fBWeighted Finite Automata for Video Compression\fP, IEEE Journal on Selected Areas In Communications, January 1998 .br Ullrich Hafner. \fBLow Bit-Rate Image and Video Coding with Weighted Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR Ullrich Hafner netpbm-free-10.0-1/pnm/fiasco/system.fiascorc0100644004714500471450000000772607716230207021434 0ustar aba-guestaba-guest# # system.wfarc: Resource file WFA coder # # Written by: Ullrich Hafner # # This file is part of FIASCO (Fractal Image And Sequence COdec) # Copyright (C) 1994-2000 Ullrich Hafner # # $Date: 2003/08/12 18:23:03 $ # $Author: aba-guest $ # $Revision: 1.1.1.1 $ # $State: Exp $ # # Options for FIASCO coder `cfiasco': # # Initial basis to start with # small.fco: domains 1, x, y # medium.fco: domains 1, x, y and 129 additional images # large.fco: domains 1, x, y and 226 additional images basis-name = small.fco # Limit the number of elements in the dictionary by `dictionary-size' # The smaller the value is the faster the coder runs and the worse # the image quality will be. dictionary-size = 10000 # Optimization level # 0: standard approximation method, process blocks of level [6, 10], # use up to 3 dictionary vectors # 1: standard approximation method, process blocks of level [4, 12], # use up to 5 dictionary vectors # 2: significantly increases the approximation quality, # running time is twice as high as with the standard method # 3: hardly increases the approximation quality of method 2, # running time is twice as high as with method 21 # (this method just remains for completeness) optimize = 0 # Approximation quality (typical range = [1-100]) quality = 20.0 # For compression of chroma bands the dictionary can be reduced to # the best #`chroma-dictionary' elements. # Furthermore, the quality of the approximation is decreased # 'chroma-qfactor' times. chroma-dictionary = 40 chroma-qfactor = 2 # Verbosity level # 0 no debug output # 1 some verbosity and statistics of the output size # 2 lots of debug information and log-files are written verbose = 1 # Set exponent and method of image tiling # 0 image is processed in normal bintree order # >0 image is subdivided into 2^`tiling-exponent' tiles. # Set type of image tiling # asc-variance Tiles with large variances are processed first # desc-variance Tiles with small variances are processed first # asc-spiral Tiles are process in spiral order starting in the middle # desc-spiral Tiles are process in spiral order starting at the border tiling-exponent = 4 tiling-method = desc-variance # Quantization parameters define the accuracy of coefficients quantization. # DC coefficients (of the constant dictionary vector f(x,y) = 1) are quantized # to values of the interval [-`dc-rpf-range', `dc-rpf-range'] using # #`dc-rpf-mantissa' bits. All other quantized coefficients are quantized in # an analogous way using the parameters `rpf-range' and `rpf-mantissa'. rpf-mantissa = 3 rpf-range = 1.5 dc-rpf-mantissa = 5 dc-rpf-range = 1 # Search for prediction (coarse approximation or motion compensation) # on all levels between minlevel and maxlevel min-level = 6 max-level = 10 # Set various parameters used for video compensation. # 'fps' defines the frame rate which should be # used when the video is decoded. This value has no effect during coding, # it is just passed to the FIASCO output file. # If 'half-pixel' is set then half pixel precise # motion compensated prediction is used. # If 'cross-B-search' is set then the fast Cross-B-Search algorithm is # used to determine the motion vectors of interpolated prediction. Otherwise # exhaustive search (in the given search range) is used. # If 'B-as-past-ref' is set then B frames are allowed to be used # for B frame predicion. fps = 25 half-pixel = NO cross-B-search = NO B-as-past-ref = NO # Set `pattern' of input frames. # `pattern' has to be a sequence of the following # characters (case insensitive): # 'i' intra frame # 'p' predicted frame # 'b' bidirectional predicted frame # E.g. pattern = 'IBBPBBPBB' # # When coding video frames the prediction type of input frame N is determined # by reading `pattern' [N] (`pattern' is periodically extended). pattern = ippppppppp # # Options for FIASCO decoder `dfiasco': # double = NO reduced = NO panel = NO enlarge = 0 netpbm-free-10.0-1/pnm/fiasco/doc/0040755004714500471450000000000007776237753017154 5ustar aba-guestaba-guestnetpbm-free-10.0-1/pnm/fiasco/doc/Makefile.am0100644004714500471450000000366207716230207021171 0ustar aba-guestaba-guest## Process this file with automake to produce Makefile.in ## ## Makefile.am: Documentation files ## ## This file is part of FIASCO (Fractal Image And Sequence COdec) ## Copyright (C) 1994-2000 Ullrich Hafner ## ## $Date: 2003/08/12 18:23:03 $ ## $Author: aba-guest $ ## $Revision: 1.1.1.1 $ ## man_MANS = fiasco_coder.3 \ fiasco_decoder.3 \ fiasco_decoder_new.3 \ fiasco_decoder_delete.3 \ fiasco_decoder_write_frame.3 \ fiasco_decoder_get_frame.3 \ fiasco_decoder_get_width.3 \ fiasco_decoder_get_height.3 \ fiasco_decoder_get_comment.3 \ fiasco_decoder_get_title.3 \ fiasco_decoder_is_color.3 \ fiasco_decoder_get_framerate.3 \ fiasco_decoder_get_length.3 \ fiasco_c_options.3 \ fiasco_c_options_new.3 \ fiasco_c_options_delete.3 \ fiasco_c_options_set_basisfile.3 \ fiasco_c_options_set_chroma_quality.3 \ fiasco_c_options_set_comment.3 \ fiasco_c_options_set_frame_pattern.3 \ fiasco_c_options_set_optimizations.3 \ fiasco_c_options_set_prediction.3 \ fiasco_c_options_set_progress_meter.3 \ fiasco_c_options_set_quantization.3 \ fiasco_c_options_set_smoothing.3 \ fiasco_c_options_set_tiling.3 \ fiasco_c_options_set_title.3 \ fiasco_c_options_set_video_param.3 \ fiasco_d_options.3 \ fiasco_d_options_new.3 \ fiasco_d_options_delete.3 \ fiasco_d_options_set_4_2_0_format.3 \ fiasco_d_options_set_magnification.3 \ fiasco_d_options_set_smoothing.3 \ fiasco_renderer.3 \ fiasco_renderer_new.3 \ fiasco_renderer_delete.3 \ fiasco_renderer_render.3 \ fiasco_image.3 \ fiasco_image_new.3 \ fiasco_image_delete.3 \ fiasco_image_get_width.3 \ fiasco_image_get_height.3 \ fiasco_image_is_color.3 \ fiasco_renderer_delete.3 \ fiasco_renderer_render.3 \ fiasco_get_error_message.3 \ fiasco_set_verbosity.3 \ fiasco_get_verbosity.3 \ afiasco.1 bfiasco.1 cfiasco.1 dfiasco.1 efiasco.1 pnmpsnr.1 EXTRA_DIST = README.LIB $(man_MANS) netpbm-free-10.0-1/pnm/fiasco/doc/Makefile.in0100644004714500471450000002060707716230207021200 0ustar aba-guestaba-guest# Makefile.in generated automatically by automake 1.4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : host_alias = @host_alias@ host_triplet = @host@ AFIASCO = @AFIASCO@ AS = @AS@ CC = @CC@ DFIASCO_EXTRA_LIBS = @DFIASCO_EXTRA_LIBS@ DFIASCO_EXTRA_SOURCES = @DFIASCO_EXTRA_SOURCES@ DLLTOOL = @DLLTOOL@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_CONFIG = @GTK_CONFIG@ GTK_LIBS = @GTK_LIBS@ INCLUDES = @INCLUDES@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIB_X11 = @LIB_X11@ LN_S = @LN_S@ MAKEINFO = @MAKEINFO@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ VERSION = @VERSION@ XEXT_LIB = @XEXT_LIB@ xfig = @xfig@ xmag = @xmag@ man_MANS = fiasco_coder.3 fiasco_decoder.3 fiasco_decoder_new.3 fiasco_decoder_delete.3 fiasco_decoder_write_frame.3 fiasco_decoder_get_frame.3 fiasco_decoder_get_width.3 fiasco_decoder_get_height.3 fiasco_decoder_get_comment.3 fiasco_decoder_get_title.3 fiasco_decoder_is_color.3 fiasco_decoder_get_framerate.3 fiasco_decoder_get_length.3 fiasco_c_options.3 fiasco_c_options_new.3 fiasco_c_options_delete.3 fiasco_c_options_set_basisfile.3 fiasco_c_options_set_chroma_quality.3 fiasco_c_options_set_comment.3 fiasco_c_options_set_frame_pattern.3 fiasco_c_options_set_optimizations.3 fiasco_c_options_set_prediction.3 fiasco_c_options_set_progress_meter.3 fiasco_c_options_set_quantization.3 fiasco_c_options_set_smoothing.3 fiasco_c_options_set_tiling.3 fiasco_c_options_set_title.3 fiasco_c_options_set_video_param.3 fiasco_d_options.3 fiasco_d_options_new.3 fiasco_d_options_delete.3 fiasco_d_options_set_4_2_0_format.3 fiasco_d_options_set_magnification.3 fiasco_d_options_set_smoothing.3 fiasco_renderer.3 fiasco_renderer_new.3 fiasco_renderer_delete.3 fiasco_renderer_render.3 fiasco_image.3 fiasco_image_new.3 fiasco_image_delete.3 fiasco_image_get_width.3 fiasco_image_get_height.3 fiasco_image_is_color.3 fiasco_renderer_delete.3 fiasco_renderer_render.3 fiasco_get_error_message.3 fiasco_set_verbosity.3 fiasco_get_verbosity.3 afiasco.1 bfiasco.1 cfiasco.1 dfiasco.1 efiasco.1 pnmpsnr.1 EXTRA_DIST = README.LIB $(man_MANS) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = man1dir = $(mandir)/man1 man3dir = $(mandir)/man3 MANS = $(man_MANS) NROFF = nroff DIST_COMMON = Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best all: all-redirect .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps doc/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status install-man1: $(mkinstalldirs) $(DESTDIR)$(man1dir) @list='$(man1_MANS)'; \ l2='$(man_MANS)'; for i in $$l2; do \ case "$$i" in \ *.1*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ else file=$$i; fi; \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \ $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \ done uninstall-man1: @list='$(man1_MANS)'; \ l2='$(man_MANS)'; for i in $$l2; do \ case "$$i" in \ *.1*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \ rm -f $(DESTDIR)$(man1dir)/$$inst; \ done install-man3: $(mkinstalldirs) $(DESTDIR)$(man3dir) @list='$(man3_MANS)'; \ l2='$(man_MANS)'; for i in $$l2; do \ case "$$i" in \ *.3*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ else file=$$i; fi; \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man3dir)/$$inst"; \ $(INSTALL_DATA) $$file $(DESTDIR)$(man3dir)/$$inst; \ done uninstall-man3: @list='$(man3_MANS)'; \ l2='$(man_MANS)'; for i in $$l2; do \ case "$$i" in \ *.3*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " rm -f $(DESTDIR)$(man3dir)/$$inst"; \ rm -f $(DESTDIR)$(man3dir)/$$inst; \ done install-man: $(MANS) @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-man1 install-man3 uninstall-man: @$(NORMAL_UNINSTALL) $(MAKE) $(AM_MAKEFLAGS) uninstall-man1 uninstall-man3 tags: TAGS TAGS: distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) subdir = doc distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done info-am: info: info-am dvi-am: dvi: dvi-am check-am: all-am check: check-am installcheck-am: installcheck: installcheck-am install-exec-am: install-exec: install-exec-am install-data-am: install-man install-data: install-data-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am uninstall-am: uninstall-man uninstall: uninstall-am all-am: Makefile $(MANS) all-redirect: all-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: $(mkinstalldirs) $(DESTDIR)$(mandir)/man1 $(DESTDIR)$(mandir)/man3 mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: mostlyclean-am: mostlyclean-generic mostlyclean: mostlyclean-am clean-am: clean-generic mostlyclean-am clean: clean-am distclean-am: distclean-generic clean-am -rm -f libtool distclean: distclean-am maintainer-clean-am: maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-am .PHONY: install-man1 uninstall-man1 install-man3 uninstall-man3 \ install-man uninstall-man tags distdir info-am info dvi-am dvi check \ check-am installcheck-am installcheck install-exec-am install-exec \ install-data-am install-data install-am install uninstall-am uninstall \ all-redirect all-am all installdirs mostlyclean-generic \ distclean-generic clean-generic maintainer-clean-generic clean \ mostlyclean distclean maintainer-clean # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: netpbm-free-10.0-1/pnm/fiasco/doc/README.LIB0100644004714500471450000000420507716230207020414 0ustar aba-guestaba-guest--------------------------------------------------------------------------- FIASCO (Fractal Image And Sequence COdec) Copyright (C) 1994-2000 Ullrich Hafner , http://ulli.linuxave.net Version 1.0 --------------------------------------------------------------------------- FIASCO is an image and video compression system based on fractal coding which outperforms the well known JPEG and MPEG standards. FIASCO has been developed during my Ph.D. thesis "Low Bit-Rate Image and Video Coding with Weighted Finite Automata", Mensch & Buch Verlag, ISBN 3-89820-002-7. Some information about the FIASCO compression library: The library consists of the five "classes" - fiasco_coder: used to encode a still image or a sequence of frames to a FIASCO stream, see fiasco_coder(3) or the file bin/cwfa.c for details. - fiasco_decoder: used to decode the individual frames step by step, see fiasco_decoder(3) or the file bin/dwfa.c for details. - fiasco_image: internal representation of an decoded FIASCO image, see fiasco_image(3) or the file bin/dwfa.c for details. - fiasco_renderer: used to render the generated image object to one of the supported X11 output formats, see fiasco_render(3) or the files bin/dwfa.c or bin/pnmpsnr.c for details. - fiasco_options: used to control various decoder and encoder options, see fiasco_options(3) or the files bin/cwfa.c, bin/dwfa.c or bin/pnmpsnr.c for details. Since the coder doesn't store any internal information, the only method of this class is the function fiasco_coder (). For all other classes, a new object is created with the fiasco_[object]_new () function, e.g., fiasco_decoder_new () creates a new fiasco_decoder_t object. Each object has to be deleted manually by calling the destructor fiasco_[object]_delete () (or by calling the method object->delete (object)). If you prefer C++ calls: every function of the type fiasco_[object]_[method] can be called via [object]->[method] ([object], args), too. Note: PLEASE use only functions, which are noted in the fiasco.h file (i.e., all functions and types with the prefix fiasco_)! netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options.30100644004714500471450000000004007716230207022525 0ustar aba-guestaba-guest.so man3/fiasco_c_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options_delete.30100644004714500471450000000004007716230207024047 0ustar aba-guestaba-guest.so man3/fiasco_c_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options_new.30100644004714500471450000003122407716230207023406 0ustar aba-guestaba-guest.\" $Id: fiasco_c_options_new.3,v 1.1.1.1 2003/08/12 18:23:03 aba-guest Exp $ .TH fiasco 3 "April, 2000" "FIASCO" "Fractal Image And Sequence COdec" .SH NAME .B fiasco_c_options_new, fiasco_c_options_delete, .B fiasco_c_options_set_progress_meter, fiasco_c_options_set_basisfile, .B fiasco_c_options_set_smoothing, fiasco_c_options_set_tiling, .B fiasco_c_options_set_chroma_quality, fiasco_c_options_set_optimizations, .B fiasco_c_options_set_prediction, fiasco_c_options_set_video_param, .B fiasco_c_options_set_quantization, fiasco_c_options_set_frame_pattern .B fiasco_c_options_set_title, fiasco_c_options_set_comment \- define additional options of FIASCO coder and decoder .SH SYNOPSIS .B #include .sp .BI "fiasco_c_options_t *" .fi .BI "fiasco_c_options_new" .fi .BI " (void);" .sp .BI "void" .fi .BI "fiasco_c_options_delete" .fi .BI " (fiasco_c_options_t * "options ); .sp .BI "int" .fi .BI "fiasco_c_options_set_basisfile" .fi .BI " (fiasco_c_options_t * "options , .fi .BI " const char * "filename ); .sp .BI "int" .fi .BI "fiasco_c_options_set_chroma_quality" .fi .BI " (fiasco_c_options_t * "options , .fi .BI " float "quality_factor , .fi .BI " unsigned "dictionary_size ); .sp .BI "int" .fi .BI "fiasco_c_options_set_comment" .fi .BI " (fiasco_c_options_t * "options , .fi .BI " const char * "comment ); .sp .BI "int" .fi .BI "fiasco_c_options_set_frame_pattern" .fi .BI " (fiasco_c_options_t * "options , .fi .BI " const char * "pattern ); .sp .BI "int" .fi .BI "fiasco_c_options_set_optimizations" .fi .BI " (fiasco_c_options_t * "options , .fi .BI " unsigned "min_block_level , .fi .BI " unsigned "max_block_level , .fi .BI " unsigned "max_elements , .fi .BI " unsigned "dictionary_size , .fi .BI " unsigned "optimization_level ); .sp .BI "int" .fi .BI "fiasco_c_options_set_quantization" .fi .BI " (fiasco_c_options_t * "options , .fi .BI " unsigned "mantissa , .fi .BI " fiasco_rpf_range_e "range , .fi .BI " unsigned "dc_mantissa , .fi .BI " fiasco_rpf_range_e "dc_range ); .sp .BI "int" .fi .BI "fiasco_c_options_set_prediction" .fi .BI " (fiasco_c_options_t * "options , .fi .BI " int "intra_prediction , .fi .BI " unsigned "min_block_level , .fi .BI " unsigned "max_block_level ); .sp .BI "int" .fi .BI "fiasco_c_options_set_progress_meter" .fi .BI " (fiasco_c_options_t * "options , .fi .BI " fiasco_progress_e "type ); .sp .BI "int" .fi .BI "fiasco_c_options_set_smoothing" .fi .BI " (fiasco_c_options_t * "options , .fi .BI " unsigned "smoothing ); .sp .BI "int" .fi .BI "fiasco_c_options_set_tiling" .fi .BI " (fiasco_c_options_t * "options , .fi .BI " fiasco_tiling_e "method , .fi .BI " unsigned "exponent ); .sp .BI "int" .fi .BI "fiasco_c_options_set_title" .fi .BI " (fiasco_c_options_t * "options , .fi .BI " const char * "title ); .sp .BI "int" .fi .BI "fiasco_c_options_set_video_param" .fi .BI " (fiasco_c_options_t * "options , .fi .BI " unsigned "frames_per_second , .fi .BI " int "half_pixel_prediction , .fi .BI " int "cross_B_search , .fi .BI " int "B_as_past_ref ); .fi .SH DESCRIPTION The \fBfiasco_c_options_new()\fP function allocates and initializes a FIASCO options object which is used to control additional compression parameters. Conversely, the function \fBfiasco_c_options_delete()\fP discards the given FIASCO coder options object. Several member functions are available to modify the default behavior of the FIASCO coder. \fBfiasco_c_options_set_smoothing()\fP sets the \fIsmoothing\fP-percentage along partitioning borders when the image is regenerated; default is 70. This value is stored in the FIASCO file and is used as default smoothing percentage in the decoder. \fBfiasco_c_options_set_frame_pattern()\fP sets the type of inter frame compression which should be applied to individual frames of a video stream; default is "IPPPPPPPPP". \fBfiasco_c_options_set_tiling()\fP sets \fImethod\fP and \fIexponent\fP of the image tiling algorithm which runs as initial step of the encoder; by default the image is subdivided into 16 tiles which are sorted by decreasing variance. \fBfiasco_c_options_set_basisfile()\fP sets the \fIfilename\fP of the FIASCO initial basis (codebook of dictionary vectors); default is "small.fco". \fBfiasco_c_options_set_chroma_quality()\fP sets the quality used when coding the chroma channels of a color image to the term "\fIquality\fP of luminance / \fIquality_factor\fP"; default is 2. Moreover, the size of the codebook is limited by \fIdictionary_size\fP; default is 40 elements. \fBfiasco_c_options_set_comment()\fP sets a \fIcomment\fP string to be stored in the FIASCO file; default is the empty string. \fBfiasco_c_options_set_title()\fP sets a \fItitle\fP string to be stored in the FIASCO file; default is the empty string. \fBfiasco_c_options_set_optimizations()\fP toggles various coding optimizations. E.g., the size of the dictionary (default is 10000), the subset of dictionary elements to use for an individual approximation (default is 5), the size of the image blocks to consider (4x4, ..., 64x64), and some additional low level optimizations (default level is 1). \fBfiasco_c_options_set_prediction()\fP enables an additional intra block prediction by using a DC component approximation. By giving levels \fImin_block_level\fP and \fImax_block_level\fP the prediction can be limited to a small range of blocks only. By default, this method is disabled. \fBfiasco_c_options_set_video_param()\fP defines the framerate (default is 25) and toggles whether to use half pixel precise motion compensated prediction (disabled by default), whether to determine motion vectors of interpolated prediction with the Cross-B-Search algorithm (disabled by default), and whether to allow B frames to be used for B frame predicion (disabled by default). \fBfiasco_c_options_set_quantization()\fP defines the quantization parameters of the approximation coefficients. By default the range of DC coefficients is [-1,+1] using a mantissa of 5 bits (and one sign bit). By default, all other coefficients are quantized with 3 mantissa bits in the interval [-1.5,+1.5]. \fBfiasco_c_options_set_progress_meter()\fP sets the type of progress meter to be used during coding. By default, an RPM style progress bar using 50 hash marks (####) is used. .SH ARGUMENTS .TP options This object encapsulates various coding parameters. .TP smoothing This percentage (range is 0 - i.e., no smoothing - to 100) defines how much the regenerated image is smoothed along the partitioning borders. .TP method Defines the algorithm which should be used to sort the image tiles which are generated in the initial coding step. If \fImethod\fP is \fBFIASCO_VARIANCE_ASC\fP then the tiles are sorted by variance - the first tile has the lowest variance. Conversely, when using \fBFIASCO_VARIANCE_DSC\fP the first tile has the largest variance. If \fImethod\fP is \fBFIASCO_SPIRAL_ASC\fP then the tiles are sorted like a spiral starting in the middle of the image. Conversely, when using \fBFIASCO_SPIRAL_DSC\fP the tiles are sorted like a spiral starting in the upper left corner. .TP exponent This value sets the number of image tiles - which are generated in the initial step of the encoder - to 2^\fIexponent\fP. .TP title This value is the title string of the FIASCO file. It is displayed, e.g., in the window title of the decoder. .TP comment This value defines an optional comment to be stored in the FIASCO file. .TP pattern This string defines the sequence of frame types. Character \fIn\fP of the string defines the type of frame \fIn\fP (\fIpattern\fP is periodically extended). Three different frame types are available (case insensitive): choose 'i' for intra-frames (no inter frame prediction is used), 'p' for predicted frames (a frame of the past is used for prediction), or 'b' for bi-directional predicted frames (both a frame of the past and the future is used for prediction). .TP filename The initial basis (codebook) of the coder is loaded from this (ASCII) file. Files that already come with FIASCO are "small.fco" (3 elements), "medium.fco" (132 elements), and "large.fco" (219 elements). .TP quality_factor When coding chroma channels (Cb and Cr band) the approximation quality is determined by the term `quality of Y component' / \fIquality_factor\fP. .TP dictionary_size FIASCO uses a dictionary (codebook) of variable size to approximate individual image blocks. The size of the codebook can be limited by \fIdictionary_size\fP to reduce the coding time, however, at the cost of decreasing quality. .TP min_block_level During coding only those image blocks are considered for approximation (or prediction) which binary tree level is larger than \fImin_block_level\fP (minimum value is 3). (Since FIASCO internally works with binary trees, the size of an image block is determined by the \fIlevel\fP of the corresponding binary tree). Refer to following table to convert these values: .ce level | width | height .fi ------+-------+-------- .fi 0 | 1 | 1 .fi 1 | 1 | 2 .fi 2 | 2 | 2 .fi 3 | 2 | 4 .fi 4 | 4 | 4 .fi 5 | 4 | 8 .fi 6 | 8 | 8 .fi 7 | 8 | 16 .fi ------+-------+-------- .fi The larger this value is the faster the coder runs but the worse the image quality will be. .TP max_block_level During coding only those image blocks are considered for approximation (or prediction) which binary tree level is smaller than \fImax_block_level\fP. The smaller this value is the faster the coder runs but the worse the image quality will be. .TP max_elements This value defines how many dictionary elements can be used to approximate an individual image block. The smaller this positive value (range is 1 to 5) is the faster the coder runs but the worse the image quality will be. .TP optimization_level Additional low level optimizations are available by setting \fIoptimization_level\fP to one of the following values: .fi 0 standard approximation method .fi 1 slightly increases the approximation quality, running time is twice as high as with the standard method .fi 2 hardly increases the approximation quality of method 1, running time is twice as high as with method 1 (this method just remains for completeness) .fi .TP intra_prediction If \fIintra_prediction\fP is set to a non-zero value then an additional block prediction of intra-frames is enabled. For some images, the image quality is slightly improved, however, at the cost of a significantly increased running time of the coder. .TP frames_per_second This value defines the frame rate, i.e., how many frames per second should be displayed. This value has no effect during coding, it is just passed to the FIASCO output file where it is read and used by the decoder. .TP half_pixel_prediction A non-zero value enables half pixel precise motion compensated prediction. .TP cross_B_search A non-zero value enables the fast Cross-B-Search algorithm to determine the motion vectors of an interpolated prediction. Otherwise, exhaustive search (in the given search range) is used. .TP B_as_past_ref A non-zero value allows not only I- and P-frames but also B-frames to be used for a forward or bi-directional predicion. .TP mantissa, range Approximation coefficients are quantized to a small number of values (in fixed point format) in the interval [-\fIrange\fP, +\fIrange\fP]. The number of \fImantissa\fP bits defines the accuracy of quantization. .TP dc_mantissa, dc_range Approximation coefficients of the DC component are quantized in a different way: the number of mantissa bits is given by \fIdc_mantissa\fP whereas the quantization interval is given by [-\fIdc_range\fP, +\fBdc_range\fP]. .TP type This value sets the \fItype\fP of progress meter which should be used during coding. The following types are available: .fi \fBFIASCO_PROGRESS_NONE\fP: no output at all .fi \fBFIASCO_PROGRESS_BAR\fP: print hash marks (###) \fBFIASCO_PROGRESS_PERCENT\fP: percentage meter (50%) .SH RETURN VALUES The function \fBfiasco_c_options_new()\fP returns a pointer to the newly allocated coder option object. If an error has been catched, a NULL pointer is returned. All set functions return 1 on success and 0 if an error has been catched. In case of an error, use the function fiasco_get_error_message(3) to get a string with the last error message of FIASCO. .SH "SEE ALSO" .br .BR fiasco_decoder "(3), " fiasco_coder (3) Ullrich Hafner, Juergen Albert, Stefan Frank, and Michael Unger. \fBWeighted Finite Automata for Video Compression\fP, IEEE Journal on Selected Areas In Communications, January 1998 .br Ullrich Hafner. \fBLow Bit-Rate Image and Video Coding with Weighted Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR Ullrich Hafner netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options_set_basisfile.30100644004714500471450000000004007716230207025421 0ustar aba-guestaba-guest.so man3/fiasco_c_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options_set_chroma_quality.30100644004714500471450000000004007716230207026501 0ustar aba-guestaba-guest.so man3/fiasco_c_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options_set_comment.30100644004714500471450000000004007716230207025122 0ustar aba-guestaba-guest.so man3/fiasco_c_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options_set_frame_pattern.30100644004714500471450000000004007716230207026307 0ustar aba-guestaba-guest.so man3/fiasco_c_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options_set_optimizations.30100644004714500471450000000004007716230207026371 0ustar aba-guestaba-guest.so man3/fiasco_c_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options_set_prediction.30100644004714500471450000000004007716230207025620 0ustar aba-guestaba-guest.so man3/fiasco_c_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options_set_progress_meter.30100644004714500471450000000004007716230207026520 0ustar aba-guestaba-guest.so man3/fiasco_c_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options_set_quantization.30100644004714500471450000000004007716230207026206 0ustar aba-guestaba-guest.so man3/fiasco_c_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options_set_smoothing.30100644004714500471450000000004007716230207025467 0ustar aba-guestaba-guest.so man3/fiasco_c_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options_set_tiling.30100644004714500471450000000004007716230207024746 0ustar aba-guestaba-guest.so man3/fiasco_c_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options_set_title.30100644004714500471450000000004007716230207024601 0ustar aba-guestaba-guest.so man3/fiasco_c_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_c_options_set_video_param.30100644004714500471450000000004007716230207025746 0ustar aba-guestaba-guest.so man3/fiasco_c_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_coder.30100644004714500471450000000650507716230207021640 0ustar aba-guestaba-guest.\" $Id: fiasco_coder.3,v 1.1.1.1 2003/08/12 18:23:03 aba-guest Exp $ .TH fiasco 3 "April, 2000" "FIASCO" "Fractal Image And Sequence COdec" .SH NAME .B fiasco_coder \- compress image files to a FIASCO file .SH SYNOPSIS .B #include .sp .BI "int " .fi .BI "fiasco_coder (char const * const * "image_names , .fi .BI " const char * "fiasco_name , .fi .BI " float "quality , .fi .BI " const fiasco_c_options_t * "options ); .fi .SH DESCRIPTION The \fBfiasco-coder()\fP function compresses the image file(s) given by the list of \fIimage_names\fP and creates the new FIASCO output file \fIfiasco_name\fP. Besides the approximation \fIquality\fP, several compression parameters can be adjusted by the class \fBoptions\fP (see fiasco_c_options_new(3)). .SH ARGUMENTS .TP image_names NULL terminated array of image filenames to process. If the first array element is "-" or a NULL pointer then FIASCO reads the image from standard input. Each array element either has to be an image filename or a template of the form: .ce prefix[start-end{+,-}step]suffix Templates are useful when compressing video streams: e.g., if the template "img0[12-01-2].pgm" is given as array element, then FIASCO compresses the images img012.pgm, img010.pgm, ..., img002.pgm (in this order). If a filename is a relative path then the images are searched for in the current directory and in the (colon-separated) list of directories given by the environment variable \fBFIASCO_IMAGES\fP. .TP fiasco_name Name of the FIASCO output file. If the name is "-" or NULL then the file is produced on standard output. If \fIfiasco_name\fP is a relative path and the environment variable \fBFIASCO_DATA\fP is a (colon-separated) list of directories, then the output file is written to the first (writable) directory of this list. Otherwise, the current directory is used to store the output file. .TP quality Defines the quality of compression. Quality has to be a positive value, its typical range is 1.0 (worst) to 100.0 (best). Larger values are also allowed - at the cost of exploding encoding times. .TP options This "class" encapsulates the various coding and decoding parameters. Use the functions fiasco_c_options_new(3) and fiasco_c_options_delete(3) to create and delete an object of this class. Several member functions (see fiasco_c_options(3)) are available to change the default values. .SH RETURN VALUE The function \fBfiasco_coder()\fP returns 1 if the FIASCO file has been successfully written. If an error has been catched during compression, 0 is returned - use the function fiasco_get_error_message(3) to get the last error message of FIASCO. .SH ENVIRONMENT .PD 0 .TP .B FIASCO_IMAGES Search path for image files. Default is "./". .TP .B FIASCO_DATA Search and save path for FIASCO files. Default is "./". .PD .SH "SEE ALSO" .br .BR fiasco_c_options_new "(3), " fiasco_c_options_delete (3), .br .BR fiasco_c_options "(3), " fiasco_get_error_message (3) .br Ullrich Hafner, Juergen Albert, Stefan Frank, and Michael Unger. \fBWeighted Finite Automata for Video Compression\fP, IEEE Journal on Selected Areas In Communications, January 1998 .br Ullrich Hafner. \fBLow Bit-Rate Image and Video Coding with Weighted Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR Ullrich Hafner netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_d_options.30100644004714500471450000000004007716230207022526 0ustar aba-guestaba-guest.so man3/fiasco_d_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_d_options_delete.30100644004714500471450000000004007716230207024050 0ustar aba-guestaba-guest.so man3/fiasco_d_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_d_options_new.30100644004714500471450000000663007716230207023412 0ustar aba-guestaba-guest.\" $Id: fiasco_d_options_new.3,v 1.1.1.1 2003/08/12 18:23:03 aba-guest Exp $ .TH fiasco 3 "April, 2000" "FIASCO" "Fractal Image And Sequence COdec" .SH NAME .B fiasco_d_options_new, fiasco_d_options_set_magnification, .B fiasco_d_options_delete, fiasco_d_options_set_smoothing .B fiasco_d_options_set_4_2_0_format \- define additional options of FIASCO decoder .SH SYNOPSIS .B #include .sp .BI "fiasco_d_options_t *" .fi .BI "fiasco_d_options_new" .fi .BI " (void);" .sp .BI "void" .fi .BI "fiasco_d_options_delete" .fi .BI " (fiasco_d_options_t * "options ); .sp .BI "int" .fi .BI "fiasco_d_options_set_4_2_0_format" .fi .BI " (fiasco_d_options_t * "options , .fi .BI " int "format ); .sp .BI "int" .fi .BI "fiasco_d_options_set_magnification" .fi .BI " (fiasco_d_options_t * "options , .fi .BI " int "level ); .sp .BI "int" .fi .BI "fiasco_d_options_set_smoothing" .fi .BI " (fiasco_d_options_t * "options , .fi .BI " unsigned "smoothing ); .fi .SH DESCRIPTION The \fBfiasco_d_options_new()\fP function allocates and initializes a FIASCO options object which is used to control additional decompression parameters. Conversely, the function \fBfiasco_d_options_delete()\fP discards the given FIASCO decoder options object. Several member functions are available to modify the default behavior of the FIASCO decoder. \fBfiasco_d_options_set_smoothing()\fP sets the \fIsmoothing\fP-percentage along partitioning borders when the images are regenerated; default is 70. \fBfiasco_d_options_set_magnification()\fP sets the \fImagnification\fP of the regenerated image; default is 0, i.e., the image geometry is not changed. \fBfiasco_d_options_set_4_2_0_format()\fP defines whether the decoder should use the default 4:4:4 format or the 4:2:0 format. The latter one significantly reduces the decoding time at the cost of some additional blocking artefacts. .SH ARGUMENTS .TP options This object encapsulates various decoding parameters. .TP smoothing This percentage (range is 0 - i.e., no smoothing - to 100) defines how much the regenerated image is smoothed along the partitioning borders. .TP level This value gives the magnification of the decoded image with respect to the original size. Positive values increase and negative values decrease the width and height of the image by a factor of 2^abs(\fIlevel\fP). .TP format If \fIformat\fP is 0 then the 4:4:4 color image format is used, i.e., the chroma channel are of the same size as the luminance. Otherwise, the 4:2:0 format is used. Then, width and height of each chroma channel is only one half of the width and height of the luminance. .SH RETURN VALUES The function \fBfiasco_d_options_new()\fP returns a pointer to the newly allocated decoder option object. If an error has been catched, a NULL pointer is returned. All set functions return 1 on success and 0 if an error has been catched. In case of an error, use the function fiasco_get_error_message(3) to get a string with the last error message of FIASCO. .SH "SEE ALSO" .br .BR fiasco_decoder "(3), " fiasco_coder (3) Ullrich Hafner, Juergen Albert, Stefan Frank, and Michael Unger. \fBWeighted Finite Automata for Video Compression\fP, IEEE Journal on Selected Areas In Communications, January 1998 .br Ullrich Hafner. \fBLow Bit-Rate Image and Video Coding with Weighted Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR Ullrich Hafner netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_d_options_set_4_2_0_format.30100644004714500471450000000004007716230207025634 0ustar aba-guestaba-guest.so man3/fiasco_d_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_d_options_set_magnification.30100644004714500471450000000004007716230207026271 0ustar aba-guestaba-guest.so man3/fiasco_d_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_d_options_set_smoothing.30100644004714500471450000000004007716230207025470 0ustar aba-guestaba-guest.so man3/fiasco_d_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_decoder.30100644004714500471450000000003607716230207022142 0ustar aba-guestaba-guest.so man3/fiasco_decoder_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_decoder_delete.30100644004714500471450000000003607716230207023464 0ustar aba-guestaba-guest.so man3/fiasco_decoder_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_decoder_get_comment.30100644004714500471450000000003607716230207024523 0ustar aba-guestaba-guest.so man3/fiasco_decoder_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_decoder_get_frame.30100644004714500471450000000003607716230207024153 0ustar aba-guestaba-guest.so man3/fiasco_decoder_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_decoder_get_framerate.30100644004714500471450000000003607716230207025027 0ustar aba-guestaba-guest.so man3/fiasco_decoder_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_decoder_get_height.30100644004714500471450000000003607716230207024331 0ustar aba-guestaba-guest.so man3/fiasco_decoder_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_decoder_get_length.30100644004714500471450000000003607716230207024342 0ustar aba-guestaba-guest.so man3/fiasco_decoder_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_decoder_get_title.30100644004714500471450000000003607716230207024202 0ustar aba-guestaba-guest.so man3/fiasco_decoder_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_decoder_get_width.30100644004714500471450000000003607716230207024200 0ustar aba-guestaba-guest.so man3/fiasco_decoder_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_decoder_is_color.30100644004714500471450000000003607716230207024033 0ustar aba-guestaba-guest.so man3/fiasco_decoder_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_decoder_new.30100644004714500471450000001456207716230207023024 0ustar aba-guestaba-guest.\" $Id: fiasco_decoder_new.3,v 1.1.1.1 2003/08/12 18:23:03 aba-guest Exp $ .TH fiasco 3 "April, 2000" "FIASCO" "Fractal Image And Sequence COdec" .SH NAME .B fiasco_decoder_new, fiasco_decoder_delete, .B fiasco_decoder_write_frame, fiasco_decoder_get_frame, .B fiasco_decoder_get_length, fiasco_decoder_get_rate, .B fiasco_decoder_get_width, fiasco_decoder_get_height .B fiasco_decoder_get_title, fiasco_decoder_get_comment .B fiasco_decoder_is_color \- decompress a FIASCO file .SH SYNOPSIS .B #include .sp .BI "fiasco_decoder_t *" .fi .BI "fiasco_decoder_new (const char * "fiasco_name , .fi .BI " const fiasco_d_options_t * "options ); .sp .BI "void" .fi .BI "fiasco_decoder_delete (fiasco_decoder_t * "decoder ); .sp .BI "int" .fi .BI "fiasco_decoder_write_frame (fiasco_decoder_t * "decoder , .fi .BI " const char * "image_name ); .sp .BI "fiasco_image_t *" .fi .BI "fiasco_decoder_get_frame (fiasco_decoder_t * "decoder ); .sp .BI "unsigned" .fi .BI "fiasco_decoder_get_length (fiasco_decoder_t * "decoder ); .sp .BI "unsigned" .fi .BI "fiasco_decoder_get_rate (fiasco_decoder_t * "decoder ); .sp .BI "unsigned" .fi .BI "fiasco_decoder_get_width (fiasco_decoder_t * "decoder ); .sp .BI "unsigned" .fi .BI "fiasco_decoder_get_height (fiasco_decoder_t * "decoder ); .sp .BI "const char *" .fi .BI "fiasco_decoder_get_title (fiasco_decoder_t * "decoder ); .sp .BI "const char *" .fi .BI "fiasco_decoder_get_comment (fiasco_decoder_t * "decoder ); .sp .BI "int" .fi .BI "fiasco_decoder_is_color (fiasco_decoder_t * "decoder ); .fi .SH DESCRIPTION The \fBfiasco_decoder_new()\fP function initializes the decompression of FIASCO file \fIfiasco_name\fP. Several decompression parameters can be adjusted by the class \fIoptions\fP (see fiasco_d_options_new(3)). The individual frames of a FIASCO video can be decompressed by calling successively either function \fBfiasco_decoder_write_frame()\fP or \fBfiasco_decoder_get_frame()\fP. The function \fBfiasco_decoder_write_frame()\fP decompresses the current frame and writes it in raw pgm(5) or ppm(5) format to the file \fIimage_name\fP. If \fIimage_name\fP=- or a NULL pointer then the image file is produced on the standard output. If \fIimage_name\fP is a relative path and the environment variable \fBFIASCO_IMAGES\fP is a (colon-separated) list of directories, then the output file is written to the first (writable) directory of this list. Otherwise, the current directory is used to store the file. The function \fBfiasco_decoder_get_frame()\fP decompresses the current frame and returns the computed image object. Use the function fiasco_renderer_new(3) to create a renderer object that converts the FIASCO image to the desired format. After all frames have been decompressed, the function \fBfiasco_decoder_delete()\fP should be called to close the input file and to free temporarily allocated memory. Number of available frames, frame rate and frames geometry, type of the FIASCO file are accessible through member functions \fBfiasco_decoder_get_length()\fP, \fBfiasco_decoder_get_rate()\fP, \fBfiasco_decoder_get_width()\fP, \fBfiasco_decoder_get_height()\fP, and \fBfiasco_decoder_is_color()\fP. Use \fBfiasco_decoder_get_title()\fP, \fBfiasco_decoder_get_comment()\fP to read title and comment strings of the FIASCO file. .SH ARGUMENTS .TP fiasco_name Filename of the FIASCO input file. If \fIfiasco_name\fP is a NULL pointer or "-" then the decoder reads from standard input. If the file is not found in the current directory and the environment variable \fBFIASCO_DATA\fP is a (colon-separated) list of directories, then the input file is searched for in these directories, too. .TP options This "class" encapsulates the various coding and decoding parameters. Use the functions fiasco_d_options_new(3) and fiasco_d_options_delete(3) to create and delete an object of this class. Several member functions (see fiasco_d_options(3)) are available to change the default values. .TP decoder The decoder "class" encapsulates the FIASCO decoder. It is used to store the internal state of the decoder. .SH RETURN VALUES The function \fBfiasco_decoder_new()\fP returns a pointer to the newly allocated decoder object. If an error has been catched, a NULL pointer is returned. The function \fBfiasco_decoder_write_frame()\fP returns 1 if the file has been successfully written. Otherwise, the function returns 0. The function \fBfiasco_decoder_get_frame()\fP returns a pointer to the newly allocated FIASCO image object. If an error has been catched, a NULL pointer is returned. The function \fBfiasco_decoder_get_length()\fP returns the number of frames of the FIASCO file. If an error has been catched, 0 is returned. The function \fBfiasco_decoder_get_rate()\fP returns the framerate (number of frames per second) of the FIASCO file. If an error has been catched, 0 is returned. The function \fBfiasco_decoder_get_width()\fP returns the width of the decoded frames of the FIASCO file. If an error has been catched, 0 is returned. The function \fBfiasco_decoder_get_height()\fP returns the height of the decoded frames of the FIASCO file. If an error has been catched, 0 is returned. The function \fBfiasco_decoder_get_title()\fP returns an optional title of the FIASCO file. If an error has been catched, 0 is returned. The function \fBfiasco_decoder_get_comment()\fP returns an optional comment of the FIASCO file. If an error has been catched, 0 is returned. The function \fBfiasco_decoder_is_color()\fP returns 0 if the decoded frames are grayscale images, otherwise a non-zero value is returned. In case of an error in one of the above functions, use the function fiasco_get_error_message(3) to get a string describing the last error message of FIASCO. .SH ENVIRONMENT .PD 0 .TP .B FIASCO_IMAGES Search path for image files. Default is "./". .TP .B FIASCO_DATA Search and save path for FIASCO files. Default is "./". .PD .SH "SEE ALSO" .br .BR fiasco_d_options_new "(3), " fiasco_d_options_delete (3), .br .BR fiasco_d_options "(3), " fiasco_get_error_message (3) .br Ullrich Hafner, Juergen Albert, Stefan Frank, and Michael Unger. \fBWeighted Finite Automata for Video Compression\fP, IEEE Journal on Selected Areas In Communications, January 1998 .br Ullrich Hafner. \fBLow Bit-Rate Image and Video Coding with Weighted Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR Ullrich Hafner netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_decoder_write_frame.30100644004714500471450000000003607716230207024526 0ustar aba-guestaba-guest.so man3/fiasco_decoder_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_get_error_message.30100644004714500471450000000225207716230207024233 0ustar aba-guestaba-guest.\" $Id: fiasco_get_error_message.3,v 1.1.1.1 2003/08/12 18:23:03 aba-guest Exp $ .TH fiasco 3 "April, 2000" "FIASCO" "Fractal Image And Sequence COdec" .SH NAME .B fiasco_get_error_message \- return string describing last error catched in FIASCO library .SH SYNOPSIS .B #include .sp .BI "const char * " .fi .BI "fiasco_get_error_message (void);" .fi .SH DESCRIPTION The \fBfiasco_get_error_message()\fP function returns a string describing the last error that has been catched in the FIASCO library. .SH RETURN VALUE The function \fBfiasco_get_error_message()\fP returns the appropriate description string, or an empty string if no error has been catched so far. .SH "SEE ALSO" .br .BR fiasco_options "(3), " fiasco_coder (3), .br .BR fiasco_decoder "(3), " fiasco_renderer (3) .br Ullrich Hafner, Juergen Albert, Stefan Frank, and Michael Unger. \fBWeighted Finite Automata for Video Compression\fP, IEEE Journal on Selected Areas In Communications, January 1998 .br Ullrich Hafner. \fBLow Bit-Rate Image and Video Coding with Weighted Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR Ullrich Hafner netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_get_verbosity.30100644004714500471450000000004007716230207023415 0ustar aba-guestaba-guest.so man3/fiasco_set_verbosity.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_image.30100644004714500471450000000003407716230207021615 0ustar aba-guestaba-guest.so man3/fiasco_image_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_image_delete.30100644004714500471450000000003407716230207023137 0ustar aba-guestaba-guest.so man3/fiasco_image_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_image_get_height.30100644004714500471450000000003407716230207024004 0ustar aba-guestaba-guest.so man3/fiasco_image_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_image_get_width.30100644004714500471450000000003407716230207023653 0ustar aba-guestaba-guest.so man3/fiasco_image_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_image_is_color.30100644004714500471450000000003407716230207023506 0ustar aba-guestaba-guest.so man3/fiasco_image_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_image_new.30100644004714500471450000000561707716230207022502 0ustar aba-guestaba-guest.\" $Id: fiasco_image_new.3,v 1.1.1.1 2003/08/12 18:23:03 aba-guest Exp $ .TH fiasco 3 "April, 2000" "FIASCO" "Fractal Image And Sequence COdec" .SH NAME .B fiasco_image_new, fiasco_image_delete, fiasco_image_get_width, .B fiasco_image_get_height, fiasco_image_is_color \- handle FIASCO image objects .SH SYNOPSIS .B #include .sp .BI "fiasco_image_t *" .fi .BI "fiasco_image_new (const char * "filename ); .sp .BI "void" .fi .BI "fiasco_image_delete (fiasco_image_t * "image ); .sp .BI "unsigned" .fi .BI "fiasco_image_get_width (const fiasco_image_t * "image ); .sp .BI "unsigned" .fi .BI "fiasco_image_get_height (const fiasco_image_t * "image ); .sp .BI "int" .fi .BI "fiasco_image_is_color (const fiasco_image_t * "image ); .fi .SH DESCRIPTION The \fBfiasco_image_new()\fP function reads the given image file and allocates and initializes a FIASCO image object. Use the function fiasco_renderer_new(3) to create a renderer object that converts the FIASCO image to the desired image format. The function \fBfiasco_image_delete()\fP deletes the image object and frees the image buffer. Image geometry and type are accessible through member functions \fBfiasco_image_get_width()\fP, \fBfiasco_image_get_height()\fP, and \fBfiasco_image_is_color()\fP. .SH ARGUMENTS .TP image The image "class" encapsulates the FIASCO image object. It is used to store the pixel values of the decoded or read image. .TP filename Image filename to process. If \fIfilename\fP is "-" or a NULL pointer then the image is read from standard input. If a filename is a relative path then the images are searched for in the current directory and in the (colon-separated) list of directories given by the environment variable \fBFIASCO_IMAGES\fP. .SH RETURN VALUE The function \fBfiasco_image_new()\fP returns a pointer to the newly allocated image object. If an error has been catched, a NULL pointer is returned. The function \fBfiasco_image_get_width()\fP returns the width of the image. If an error has been catched, 0 is returned. The function \fBfiasco_image_get_height()\fP returns the height of the image. If an error has been catched, 0 is returned. The function \fBfiasco_image_is_color()\fP returns 0 if the image object is a grayscale image, otherwise a non-zero value is returned. In case of an error in one of the above functions, use the function fiasco_get_error_message(3) to get a string with the last error message of FIASCO. .SH "SEE ALSO" .br .BR fiasco_decoder_get_frame "(3), " fiasco_get_error_message (3) .BR fiasco_renderer_new (3) .br Ullrich Hafner, Juergen Albert, Stefan Frank, and Michael Unger. \fBWeighted Finite Automata for Video Compression\fP, IEEE Journal on Selected Areas In Communications, January 1998 .br Ullrich Hafner. \fBLow Bit-Rate Image and Video Coding with Weighted Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR Ullrich Hafner netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options.30100644004714500471450000000003607716230207022230 0ustar aba-guestaba-guest.so man3/fiasco_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options_delete.30100644004714500471450000000003607716230207023552 0ustar aba-guestaba-guest.so man3/fiasco_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options_new.30100644004714500471450000003221407716230207023104 0ustar aba-guestaba-guest.\" $Id: fiasco_options_new.3,v 1.1.1.1 2003/08/12 18:23:03 aba-guest Exp $ .TH fiasco 3 "April, 2000" "FIASCO" "Fractal Image And Sequence COdec" .SH NAME .B fiasco_options_new, fiasco_options_set_magnification, .B fiasco_options_delete, fiasco_options_set_progress_meter, .B fiasco_options_set_smoothing, fiasco_options_set_tiling, .B fiasco_options_set_4_2_0_format, fiasco_options_set_basisfile, .B fiasco_options_set_chroma_quality, fiasco_options_set_optimizations, .B fiasco_options_set_prediction, fiasco_options_set_video_param, .B fiasco_options_set_quantization, fiasco_options_set_frame_pattern \- define additional options of FIASCO coder and decoder .SH SYNOPSIS .B #include .sp .BI "fiasco_options_t *" .fi .BI "fiasco_options_new" .fi .BI " (void);" .sp .BI "void" .fi .BI "fiasco_options_delete" .fi .BI " (fiasco_options_t * "options ); .sp .BI "int" .fi .BI "fiasco_options_set_4_2_0_format" .fi .BI " (fiasco_options_t * "options , .fi .BI " int "format ); .sp .BI "int" .fi .BI "fiasco_options_set_basisfile" .fi .BI " (fiasco_options_t * "options , .fi .BI " const char * "filename ); .sp .BI "int" .fi .BI "fiasco_options_set_chroma_quality" .fi .BI " (fiasco_options_t * "options , .fi .BI " float "quality_factor , .fi .BI " unsigned "dictionary_size ); .sp .BI "int" .fi .BI "fiasco_options_set_frame_pattern" .fi .BI " (fiasco_options_t * "options , .fi .BI " const char * "pattern ); .sp .BI "int" .fi .BI "fiasco_options_set_magnification" .fi .BI " (fiasco_options_t * "options , .fi .BI " int "level ); .sp .BI "int" .fi .BI "fiasco_options_set_optimizations" .fi .BI " (fiasco_options_t * "options , .fi .BI " unsigned "min_block_level , .fi .BI " unsigned "max_block_level , .fi .BI " unsigned "max_elements , .fi .BI " unsigned "dictionary_size , .fi .BI " unsigned "optimization_level ); .sp .BI "int" .fi .BI "fiasco_options_set_quantization" .fi .BI " (fiasco_options_t * "options , .fi .BI " unsigned "mantissa , .fi .BI " fiasco_rpf_range_e "range , .fi .BI " unsigned "dc_mantissa , .fi .BI " fiasco_rpf_range_e "dc_range ); .sp .BI "int" .fi .BI "fiasco_options_set_prediction" .fi .BI " (fiasco_options_t * "options , .fi .BI " int "intra_prediction , .fi .BI " unsigned "min_block_level , .fi .BI " unsigned "max_block_level ); .sp .BI "int" .fi .BI "fiasco_options_set_progress_meter" .fi .BI " (fiasco_options_t * "options , .fi .BI " fiasco_progress_e "type ); .sp .BI "int" .fi .BI "fiasco_options_set_smoothing" .fi .BI " (fiasco_options_t * "options , .fi .BI " unsigned "smoothing ); .sp .BI "int" .fi .BI "fiasco_options_set_tiling" .fi .BI " (fiasco_options_t * "options , .fi .BI " fiasco_tiling_e "method , .fi .BI " unsigned "exponent ); .sp .BI "int" .fi .BI "fiasco_options_set_video_param" .fi .BI " (fiasco_options_t * "options , .fi .BI " unsigned "frames_per_second , .fi .BI " int "half_pixel_prediction , .fi .BI " int "cross_B_search , .fi .BI " int "B_as_past_ref ); .fi .SH DESCRIPTION The \fBfiasco_options_new()\fP function allocates and initializes a FIASCO options object which is used to control additional compression and decompression parameters. Conversely, the function \fBfiasco_options_delete()\fP discards the given FIASCO options object. Several member functions are available to modify the default behavior of the FIASCO coder and decoder. \fBfiasco_options_set_smoothing()\fP sets the \fIsmoothing\fP-percentage along partitioning borders when the image is regenerated; default is 70. This option is used both by the decoder and encoder. You should use the \fIsmoothing\fP value specified in the FIASCO file when you are decoding video frames. \fBfiasco_options_set_magnification()\fP sets the \fImagnification\fP of the regenerated image; default is 0, i.e., the image geometry is not changed. This option is used by the decoder only. \fBfiasco_options_set_4_2_0_format()\fP defines whether the decoder should use the default 4:4:4 format or the 4:2:0 format. The latter one significantly reduces the decoding time at the cost of some additional blocking artefacts. This option is used by the decoder only. \fBfiasco_options_set_frame_pattern()\fP sets the type of inter frame compression which should be applied to individual frames of a video stream; default is "IPPPPPPPPP". \fBfiasco_options_set_tiling()\fP sets \fImethod\fP and \fIexponent\fP of the image tiling algorithm which runs as initial step of the encoder; by default the image is subdivided into 16 tiles which are sorted by decreasing variance. \fBfiasco_options_set_basisfile()\fP sets the \fIfilename\fP of the FIASCO initial basis (codebook of dictionary vectors); default is "small.fco". \fBfiasco_options_set_chroma_quality()\fP sets the quality used when coding the chroma channels of a color image to the term "\fIquality\fP of luminance / \fIquality_factor\fP"; default is 2. Moreover, the size of the codebook is limited by \fIdictionary_size\fP; default is 40 elements. \fBfiasco_options_set_optimizations()\fP toggles various coding optimizations. E.g., the size of the dictionary (default is 10000), the subset of dictionary elements to use for an individual approximation (default is 5), the size of the image blocks to consider (4x4, ..., 64x64), and some additional low level optimizations (default level is 1). \fBfiasco_options_set_prediction()\fP enables an additional intra block prediction by using a DC component approximation. By giving levels \fImin_block_level\fP and \fImax_block_level\fP the prediction can be limited to a small range of blocks only. By default, this method is disabled. \fBfiasco_options_set_video_param()\fP defines the framerate (default is 25) and toggles whether to use half pixel precise motion compensated prediction (disabled by default), whether to determine motion vectors of interpolated prediction with the Cross-B-Search algorithm (disabled by default), and whether to allow B frames to be used for B frame predicion (disabled by default). \fBfiasco_options_set_quantization()\fP defines the quantization parameters of the approximation coefficients. By default the range of DC coefficients is [-1,+1] using a mantissa of 5 bits (and one sign bit). By default, all other coefficients are quantized with 3 mantissa bits in the interval [-1.5,+1.5]. \fBfiasco_options_set_progress_meter()\fP sets the type of progress meter to be used during coding. By default, an RPM style progress bar using 50 hash marks (####) is used. .SH ARGUMENTS .TP options This object encapsulates the various coding and decoding parameters. .TP smoothing This percentage (range is 0 - i.e., no smoothing - to 100) defines how much the regenerated image is smoothed along the partitioning borders. .TP level This value gives the magnification of the decoded image with respect to the original size. Positive values increase and negative values decrease the width and height of the image by a factor of 2^abs(\fIlevel\fP). .TP format If \fIformat\fP is 0 then the 4:4:4 color image format is used, i.e., the chroma channel are of the same size as the luminance. Otherwise, the 4:2:0 format is used. Then, width and height of each chroma channel is only one half of the width and height of the luminance. .TP method Defines the algorithm which should be used to sort the image tiles which are generated in the initial coding step. If \fImethod\fP is \fBFIASCO_VARIANCE_ASC\fP then the tiles are sorted by variance - the first tile has the lowest variance. Conversely, when using \fBFIASCO_VARIANCE_DSC\fP the first tile has the largest variance. If \fImethod\fP is \fBFIASCO_SPIRAL_ASC\fP then the tiles are sorted like a spiral starting in the middle of the image. Conversely, when using \fBFIASCO_SPIRAL_DSC\fP the tiles are sorted like a spiral starting in the upper left corner. .TP exponent This value sets the number of image tiles - which are generated in the initial step of the encoder - to 2^\fIexponent\fP. .TP pattern This string defines the sequence of frame types. Character \fIn\fP of the string defines the type of frame \fIn\fP (\fIpattern\fP is periodically extended). Three different frame types are available (case insensitive): choose 'i' for intra-frames (no inter frame prediction is used), 'p' for predicted frames (a frame of the past is used for prediction), or 'b' for bi-directional predicted frames (both a frame of the past and the future is used for prediction). .TP filename The initial basis (codebook) of the coder is loaded from this (ASCII) file. Files that already come with FIASCO are "small.fco" (3 elements), "medium.fco" (132 elements), and "large.fco" (219 elements). .TP quality_factor When coding chroma channels (Cb and Cr band) the approximation quality is determined by the term `quality of Y component' / \fIquality_factor\fP. .TP dictionary_size FIASCO uses a dictionary (codebook) of variable size to approximate individual image blocks. The size of the codebook can be limited by \fIdictionary_size\fP to reduce the coding time, however, at the cost of decreasing quality. .TP min_block_level During coding only those image blocks are considered for approximation (or prediction) which binary tree level is larger than \fImin_block_level\fP (minimum value is 3). (Since FIASCO internally works with binary trees, the size of an image block is determined by the \fIlevel\fP of the corresponding binary tree). Refer to following table to convert these values: .ce level | width | height .fi ------+-------+-------- .fi 0 | 1 | 1 .fi 1 | 1 | 2 .fi 2 | 2 | 2 .fi 3 | 2 | 4 .fi 4 | 4 | 4 .fi 5 | 4 | 8 .fi 6 | 8 | 8 .fi 7 | 8 | 16 .fi ------+-------+-------- .fi The larger this value is the faster the coder runs but the worse the image quality will be. .TP max_block_level During coding only those image blocks are considered for approximation (or prediction) which binary tree level is smaller than \fImax_block_level\fP. The smaller this value is the faster the coder runs but the worse the image quality will be. .TP max_elements This value defines how many dictionary elements can be used to approximate an individual image block. The smaller this positive value (range is 1 to 5) is the faster the coder runs but the worse the image quality will be. .TP optimization_level Additional low level optimizations are available by setting \fIoptimization_level\fP to one of the following values: .fi 0 standard approximation method .fi 1 slightly increases the approximation quality, running time is twice as high as with the standard method .fi 2 hardly increases the approximation quality of method 1, running time is twice as high as with method 1 (this method just remains for completeness) .fi .TP intra_prediction If \fIintra_prediction\fP is set to a non-zero value then an additional block prediction of intra-frames is enabled. For some images, the image quality is slightly improved, however, at the cost of a significantly increased running time of the coder. .TP frames_per_second This value defines the frame rate, i.e., how many frames per second should be displayed. This value has no effect during coding, it is just passed to the FIASCO output file where it is read and used by the decoder. .TP half_pixel_prediction A non-zero value enables half pixel precise motion compensated prediction. .TP cross_B_search A non-zero value enables the fast Cross-B-Search algorithm to determine the motion vectors of an interpolated prediction. Otherwise, exhaustive search (in the given search range) is used. .TP B_as_past_ref A non-zero value allows not only I- and P-frames but also B-frames to be used for a forward or bi-directional predicion. .TP mantissa, range Approximation coefficients are quantized to a small number of values (in fixed point format) in the interval [-\fIrange\fP, +\fIrange\fP]. The number of \fImantissa\fP bits defines the accuracy of quantization. .TP dc_mantissa, dc_range Approximation coefficients of the DC component are quantized in a different way: the number of mantissa bits is given by \fIdc_mantissa\fP whereas the quantization interval is given by [-\fIdc_range\fP, +\fBdc_range\fP]. .TP type This value sets the \fItype\fP of progress meter which should be used during coding. The following types are available: .fi \fBFIASCO_PROGRESS_NONE\fP: no output at all .fi \fBFIASCO_PROGRESS_BAR\fP: print hash marks (###) \fBFIASCO_PROGRESS_PERCENT\fP: percentage meter (50%) .SH RETURN VALUES The function \fBfiasco_decoder_new()\fP returns a pointer to the newly allocated option object. If an error has been catched, a NULL pointer is returned. All set functions return 1 on success and 0 if an error has been catched. In case of an error, use the function fiasco_get_error_message(3) to get a string with the last error message of FIASCO. .SH "SEE ALSO" .br .BR fiasco_decoder "(3), " fiasco_coder (3) Ullrich Hafner, Juergen Albert, Stefan Frank, and Michael Unger. \fBWeighted Finite Automata for Video Compression\fP, IEEE Journal on Selected Areas In Communications, January 1998 .br Ullrich Hafner. \fBLow Bit-Rate Image and Video Coding with Weighted Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR Ullrich Hafner netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options_set_4_2_0_format.30100644004714500471450000000003607716230207025336 0ustar aba-guestaba-guest.so man3/fiasco_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options_set_basisfile.30100644004714500471450000000003607716230207025124 0ustar aba-guestaba-guest.so man3/fiasco_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options_set_chroma_quality.30100644004714500471450000000003607716230207026204 0ustar aba-guestaba-guest.so man3/fiasco_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options_set_frame_pattern.30100644004714500471450000000003607716230207026012 0ustar aba-guestaba-guest.so man3/fiasco_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options_set_magnification.30100644004714500471450000000003607716230207025773 0ustar aba-guestaba-guest.so man3/fiasco_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options_set_optimizations.30100644004714500471450000000003607716230207026074 0ustar aba-guestaba-guest.so man3/fiasco_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options_set_prediction.30100644004714500471450000000003607716230207025323 0ustar aba-guestaba-guest.so man3/fiasco_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options_set_progress_meter.30100644004714500471450000000003607716230207026223 0ustar aba-guestaba-guest.so man3/fiasco_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options_set_quantization.30100644004714500471450000000003607716230207025711 0ustar aba-guestaba-guest.so man3/fiasco_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options_set_smoothing.30100644004714500471450000000003607716230207025172 0ustar aba-guestaba-guest.so man3/fiasco_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options_set_tiling.30100644004714500471450000000003607716230207024451 0ustar aba-guestaba-guest.so man3/fiasco_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_options_set_video_param.30100644004714500471450000000003607716230207025451 0ustar aba-guestaba-guest.so man3/fiasco_options_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_renderer.30100644004714500471450000000003707716230207022344 0ustar aba-guestaba-guest.so man3/fiasco_renderer_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_renderer_delete.30100644004714500471450000000003707716230207023666 0ustar aba-guestaba-guest.so man3/fiasco_renderer_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_renderer_new.30100644004714500471450000001001407716230207023211 0ustar aba-guestaba-guest.\" $Id: fiasco_renderer_new.3,v 1.1.1.1 2003/08/12 18:23:03 aba-guest Exp $ .TH fiasco 3 "April, 2000" "FIASCO" "Fractal Image And Sequence COdec" .SH NAME .B fiasco_renderer_new, fiasco_renderer_delete \- convert a FIASCO image object to an X11 XImage .SH SYNOPSIS .B #include .sp .BI "fiasco_renderer_t *" .fi .BI "fiasco_renderer_new (unsigned long "red_mask , .fi .BI " unsigned long "green_mask , .fi .BI " unsigned long "blue_mask , .fi .BI " unsigned "bpp , .fi .BI " int "double_resolution ); .sp .BI "void" .fi .BI "fiasco_renderer_delete (fiasco_renderer_t * "renderer ); .sp .BI "int" .fi .BI "fiasco_renderer_render (const fiasco_renderer_t * "renderer , .fi .BI " unsigned char * "data ); .fi .BI " const fiasco_image_t * "fiasco_image ); .fi .SH DESCRIPTION The \fBfiasco_renderer_new()\fP function allocates and initializes a renderer object which has to be used to convert an internal FIASCO image object to one of the supported X11 formats. Currently, the FIASCO image can be rendered to an X11 XImage of either 16, 24, or 32 bits per pixel. Additional formats will be supported upon request. Function \fBfiasco_renderer_render()\fP is used to convert the given FIASCO image object to the specified format. After all frames are rendered, the function \fBfiasco_renderer_delete()\fP should be called to free temporarily allocated memory and to discard the renderer object. Note that the FIASCO renderer class is not restricted to X11 images: a FIASCO image object can be converted to an image data array of the form RGBRGB... by setting \fIred_mask\fP=0xff0000, \fIgreen_mask\fP=0xff00, \fIblue_mask\fP=0xff, and \fIbpp\fP=24. .SH ARGUMENTS .TP bpp Determines the number of bits of a single pixel of the X11 XImage structure (see XCreateImage(3)). If the XImage is already allocated then the value XImage->bits_per_pixel should be used. Currently, 16, 24, and 32 bits per pixel are supported. .TP red_mask Determines which bits of a pixel should be used for the red component. If the XImage is already allocated then the value XImage->red_mask should be used. E.g., if \fIbpp=16\fP and \fIred_mask=0xf800\fP then each pixel is stored with two bytes. The red component uses bits 11-15, the remaining green and blue components use bits 0-10. .TP green_mask Determines which bits of a pixel should be used for the green component. If the XImage is already allocated then the value XImage->green_mask should be used. .TP blue_mask Determines which bits of a pixel should be used for the blue component. If the XImage is already allocated then the value XImage->blue_mask should be used. .TP data A pointer to the image data. If the XImage is already allocated then the value XImage->data should be used. This array has to be large enough to hold the decoded image at the given size (geometry and bits per pixel). .TP fiasco_image This object represents the decoded image which has been created by the FIASCO functions fiasco_decoder_get_frame(3) or fiasco_image_new(3). .SH RETURN VALUE The function \fBfiasco_renderer_new()\fP returns a pointer to the newly allocated renderer object. If an error has been catched, a NULL pointer is returned. The function \fBfiasco_renderer_render()\fP returns 1 if the image has been successfully converted. Otherwise, the function returns 0. In case of an error in one of the above functions, use the function fiasco_get_error_message(3) to get a string with the last error message of FIASCO. .SH "SEE ALSO" .br .BR fiasco_decoder_get_frame "(3), " fiasco_get_error_message (3) .BR fiasco_image_new (3) .br Ullrich Hafner, Juergen Albert, Stefan Frank, and Michael Unger. \fBWeighted Finite Automata for Video Compression\fP, IEEE Journal on Selected Areas In Communications, January 1998 .br Ullrich Hafner. \fBLow Bit-Rate Image and Video Coding with Weighted Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR Ullrich Hafner netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_renderer_render.30100644004714500471450000000003707716230207023703 0ustar aba-guestaba-guest.so man3/fiasco_renderer_new.3 netpbm-free-10.0-1/pnm/fiasco/doc/fiasco_set_verbosity.30100644004714500471450000000256607716230207023450 0ustar aba-guestaba-guest.\" $Id: fiasco_set_verbosity.3,v 1.1.1.1 2003/08/12 18:23:03 aba-guest Exp $ .TH fiasco 3 "April, 2000" "FIASCO" "Fractal Image And Sequence COdec" .SH NAME .B fiasco_get_verbosity, fiasco_set_verbosity \- get or set verbosity of FIASCO library .SH SYNOPSIS .B #include .sp .BI "fiasco_verbosity_e" .fi .BI "fiasco_get_verbosity (void);" .sp .BI "void" .fi .BI "fiasco_set_verbosity (fiasco_verbosity_e "level ); .fi .SH DESCRIPTION The \fBfiasco_get_verbosity()\fP function returns the current verbosity level of the FIASCO library. Conversely, the function \fBfiasco_set_verbosity()\fP sets the verbosity of the FIASCO library to the given \fIlevel\fP. .SH RETURN VALUE The function \fBfiasco_get_verbosity()\fP returns the current verbosity level. Level either is \fBFIASCO_NO_VERBOSITY\fP (no output at all), \fBFIASCO_SOME_VERBOSITY\fP (show progress meter) or \fBFIASCO_ULTIMATE_VERBOSITY\fP (show debugging output). .SH "SEE ALSO" .br .BR fiasco_coder (3), fiasco_decoder (3) .br Ullrich Hafner, Juergen Albert, Stefan Frank, and Michael Unger. \fBWeighted Finite Automata for Video Compression\fP, IEEE Journal on Selected Areas In Communications, January 1998 .br Ullrich Hafner. \fBLow Bit-Rate Image and Video Coding with Weighted Finite Automata\fP, Ph.D. thesis, Mensch & Buch Verlag, ISBN 3-89820-002-7, October 1999. .SH AUTHOR Ullrich Hafner netpbm-free-10.0-1/pnm/fiasco/input/0040755004714500471450000000000007776237753017546 5ustar aba-guestaba-guestnetpbm-free-10.0-1/pnm/fiasco/input/Makefile0100644004714500471450000000052407716230207021161 0ustar aba-guestaba-guestSRCDIR = ../../.. BUILDDIR = $(SRCDIR) include $(BUILDDIR)/Makefile.config OBJECTS = basis.o matrices.o mc.o nd.o read.o tree.o weights.o INCLUDE = -I.. -I../lib -I../codec all: libfiasco_input.a libfiasco_input.a: $(OBJECTS) $(AR) -rc $@ $(OBJECTS) $(RANLIB) $@ .PHONY: clean clean: clean.common include $(SRCDIR)/Makefile.common netpbm-free-10.0-1/pnm/fiasco/input/Makefile.depend0100644004714500471450000000000007716230207022404 0ustar aba-guestaba-guestnetpbm-free-10.0-1/pnm/fiasco/input/basis.c0100644004714500471450000000737707725102161021000 0ustar aba-guestaba-guest/* * basis.c: WFA initial basis files * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/09/02 11:52:17 $ * $Author: aba-guest $ * $Revision: 1.2 $ * $State: Exp $ */ #include #include "config.h" #include "types.h" #include "macros.h" #include "error.h" #include "wfa.h" #include "wfalib.h" #include "basis.h" typedef struct basis_values { unsigned states; real_t *final; bool_t *use_domain; real_t (*transitions)[4]; } basis_values_t; typedef struct { char *filename; void (*function)(basis_values_t *bv); } basis_file_t; /***************************************************************************** prototypes *****************************************************************************/ static void small_init (basis_values_t *bv); static const basis_file_t basis_files[] = { {"small.fco", small_init}, {"small.wfa", small_init}, {NULL, NULL} }; /***************************************************************************** public code *****************************************************************************/ bool_t get_linked_basis (const char *basis_name, wfa_t *wfa) /* * Check wether given WFA initial basis 'basis_name' is already linked * with the excecutable. If the basis is available then fill the 'wfa' struct * according to the stored data, otherwise print a warning message. * * Return value: * true on success, false if basis is not available yet. * * Side effects: * 'wfa' struct is filled on success. */ { bool_t success = NO; /* indicates if basis is found */ unsigned n; /* counter */ basis_values_t bv; /* basis values */ for (n = 0; basis_files [n].filename != NULL; n++) if (streq (basis_files [n].filename, basis_name)) /* basis is stored */ { unsigned state, edge; (*basis_files [n].function) (&bv); /* initialize local variables */ /* * Generate WFA */ wfa->basis_states = wfa->states = bv.states + 1; wfa->domain_type[0] = USE_DOMAIN_MASK; wfa->final_distribution[0] = 128; append_edge (0, 0, 1.0, 0, wfa); append_edge (0, 0, 1.0, 1, wfa); for (state = 1; state < wfa->basis_states; state++) { wfa->final_distribution [state] = bv.final [state - 1]; wfa->domain_type [state] = bv.use_domain [state - 1] ? USE_DOMAIN_MASK : AUXILIARY_MASK; } for (edge = 0; isedge (bv.transitions [edge][0]); edge++) append_edge (bv.transitions [edge][0], bv.transitions [edge][1], bv.transitions [edge][2], bv.transitions [edge][3], wfa); success = YES; break; } if (!success) warning ("WFA initial basis '%s' isn't linked with the excecutable yet." "\nLoading basis from disk instead.", basis_name); return success; } /***************************************************************************** private code *****************************************************************************/ /***************************************************************************** basis "small.wfa" *****************************************************************************/ static unsigned states_small = 2; static bool_t use_domain_small[] = {YES, YES}; static real_t final_small[] = {64, 64}; static real_t transitions_small[][4] = {{1, 2, 0.5, 0}, {1, 2, 0.5, 1}, {1, 0, 0.5, 1}, {2, 1, 1.0, 0}, {2, 1, 1.0, 1}, {-1, 0, 0, 0}}; static void small_init (basis_values_t *bv) { bv->states = states_small; bv->final = final_small; bv->use_domain = use_domain_small; bv->transitions = transitions_small; } netpbm-free-10.0-1/pnm/fiasco/input/basis.h0100644004714500471450000000070407716230207020773 0ustar aba-guestaba-guest/* * basis.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _BASIS_H #define _BASIS_H #include "wfa.h" bool_t get_linked_basis (const char *basis_name, wfa_t *wfa); #endif /* not _BASIS_H */ netpbm-free-10.0-1/pnm/fiasco/input/matrices.c0100644004714500471450000004113207716230207021474 0ustar aba-guestaba-guest/* * matrices.c: Input of transition matrices * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #include "types.h" #include "macros.h" #include "error.h" #include "bit-io.h" #include "arith.h" #include "misc.h" #include "wfalib.h" #include "matrices.h" #if STDC_HEADERS # include #endif /* not STDC_HEADERS */ /***************************************************************************** prototypes *****************************************************************************/ static unsigned delta_decoding (wfa_t *wfa, unsigned last_domain, bitfile_t *input); static unsigned column_0_decoding (wfa_t *wfa, unsigned last_row, bitfile_t *input); static unsigned chroma_decoding (wfa_t *wfa, bitfile_t *input); static void compute_y_state (int state, int y_state, wfa_t *wfa); /***************************************************************************** public code *****************************************************************************/ unsigned read_matrices (wfa_t *wfa, bitfile_t *input) /* * Read transitions of WFA given from the stream 'input'. * * Return value: * number of edges * * Side effects: * 'wfa->into' is filled with decoded values */ { unsigned total; /* total number of edges in the WFA */ unsigned root_state = wfa->wfainfo->color ? wfa->tree [wfa->tree [wfa->root_state][0]][0] : wfa->root_state; total = column_0_decoding (wfa, root_state, input); total += delta_decoding (wfa, root_state, input); if (wfa->wfainfo->color) total += chroma_decoding (wfa, input); return total; } /***************************************************************************** private code *****************************************************************************/ static unsigned delta_decoding (wfa_t *wfa, unsigned last_domain, bitfile_t *input) /* * Read transition matrices which are encoded with delta coding * from stream 'input'. * 'last_domain' is the maximum state number used as domain image. * * Return value: * number of non-zero matrix elements (WFA edges) * * Side effects: * 'wfa->into' is filled with decoded values */ { range_sort_t rs; /* ranges are sorted as in the coder */ unsigned max_domain; /* dummy used for recursion */ unsigned range; unsigned count [MAXEDGES + 1]; unsigned state, label; unsigned *n_edges; /* number of elements per row */ unsigned total = 0; /* total number of decoded edges */ /* * Generate a list of range blocks. * The order is the same as in the coder. */ rs.range_state = Calloc ((last_domain + 1) * MAXLABELS, sizeof (u_word_t)); rs.range_label = Calloc ((last_domain + 1) * MAXLABELS, sizeof (byte_t)); rs.range_max_domain = Calloc ((last_domain + 1) * MAXLABELS, sizeof (u_word_t)); rs.range_subdivided = Calloc ((last_domain + 1) * MAXLABELS, sizeof (bool_t)); rs.range_no = 0; max_domain = wfa->basis_states - 1; sort_ranges (last_domain, &max_domain, &rs, wfa); /* * Get row statistics */ { arith_t *decoder; model_t *elements; unsigned max_edges = read_rice_code (3, input); /* * Get the probability array of the number of edges distribution * and allocate the corresponding model. */ { unsigned edge; for (edge = 0; edge <= max_edges; edge++) count [edge] = read_rice_code ((int) log2 (last_domain) - 2, input); elements = alloc_model (max_edges + 1, 0, 0, count); } /* * Get number of elements per matrix row */ { unsigned row; n_edges = Calloc (wfa->states, sizeof (unsigned)); decoder = alloc_decoder (input); for (row = range = 0; range < rs.range_no; range++) if (!rs.range_subdivided [range]) { state = rs.range_state [range]; label = rs.range_label [range]; n_edges [row++] = decode_symbol (decoder, elements) - (isedge (wfa->into [state][label][0]) ? 1 : 0); } free_decoder (decoder); free_model (elements); } } /* * Get matrix elements */ { unsigned row; u_word_t *mapping1 = Calloc (wfa->states, sizeof (word_t)); u_word_t *mapping_coder1 = Calloc (wfa->states, sizeof (word_t)); u_word_t *mapping2 = Calloc (wfa->states, sizeof (word_t)); u_word_t *mapping_coder2 = Calloc (wfa->states, sizeof (word_t)); bool_t use_normal_domains = get_bit (input); bool_t use_delta_domains = get_bit (input); /* * Generate array of states which are admitted domains. * When coding intra frames 'mapping1' == 'mapping2' otherwise * 'mapping1' is a list of 'normal' domains which are admitted for * coding intra blocks * 'mapping2' is a list of 'delta' domains which are admitted for * coding the motion compensated prediction error */ { unsigned n1, n2, state; for (n1 = n2 = state = 0; state < wfa->states; state++) { mapping1 [n1] = state; mapping_coder1 [state] = n1; if (usedomain (state, wfa) && (state < wfa->basis_states || use_delta_domains || !wfa->delta_state [state])) n1++; mapping2 [n2] = state; mapping_coder2 [state] = n2; if (usedomain (state, wfa) && (state < wfa->basis_states || use_normal_domains || wfa->delta_state [state])) n2++; } } for (row = 0, range = 0; range < rs.range_no; range++) if (!rs.range_subdivided [range]) { u_word_t *mapping; u_word_t *mapping_coder; unsigned max_value; unsigned edge; unsigned state = rs.range_state [range]; unsigned label = rs.range_label [range]; unsigned last = 1; if (wfa->delta_state [state] || wfa->mv_tree [state][label].type != NONE) { mapping = mapping2; mapping_coder = mapping_coder2; } else { mapping = mapping1; mapping_coder = mapping_coder1; } max_value = mapping_coder [rs.range_max_domain [range]]; for (edge = n_edges [row]; edge; edge--) { unsigned domain; if (max_value - last) domain = read_bin_code (max_value - last, input) + last; else domain = max_value; append_edge (state, mapping [domain], -1, label, wfa); last = domain + 1; total++; } row++; } Free (mapping1); Free (mapping_coder1); Free (mapping2); Free (mapping_coder2); } Free (n_edges); Free (rs.range_state); Free (rs.range_label); Free (rs.range_max_domain); Free (rs.range_subdivided); return total; } static unsigned column_0_decoding (wfa_t *wfa, unsigned last_row, bitfile_t *input) /* * Read column 0 of the transition matrices of the 'wfa' which are coded * with quasi arithmetic coding from stream 'input'. * All rows from 'wfa->basis_states' up to 'last_row' are decoded. * * Return value: * number of non-zero matrix elements (WFA edges) * * Side effects: * 'wfa->into' is filled with decoded values */ { unsigned row; /* current matrix row */ unsigned total = 0; /* total number of edges in col 0 */ unsigned *prob_ptr; /* pointer to current probability */ unsigned *last; /* pointer to minimum probability */ unsigned *first; /* pointer to maximum probability */ unsigned *new_prob_ptr; /* ptr to probability of last domain */ unsigned *prob; /* probability array */ u_word_t high; /* Start of the current code range */ u_word_t low; /* End of the current code range */ u_word_t code; /* The present input code value */ word_t *is_leaf; /* pointer to the tree structure */ /* * Compute the asymmetric probability array * prob[] = { 1/2, 1/2, 1/4, 1/4, 1/4, 1/4, * 1/8, ... , 1/16, ..., 1/(MAXPROB+1)} */ { unsigned n; unsigned index; /* probability index */ unsigned exp; /* current exponent */ prob = Calloc (1 << (MAX_PROB + 1), sizeof (unsigned)); for (index = 0, n = MIN_PROB; n <= MAX_PROB; n++) for (exp = 0; exp < 1U << n; exp++, index++) prob [index] = n; } first = prob_ptr = new_prob_ptr = prob; last = first + 1020; is_leaf = wfa->tree [wfa->basis_states]; /* use pointer arithmetics ... */ high = HIGH; /* 1.0 */ low = LOW; /* 0.0 */ code = get_bits (input, 16); /* * Decode column 0 with a quasi arithmetic coder (QAC). * Advantage of this QAC with respect to a binary AC: * Instead of using time consuming multiplications and divisions * to compute the probability of the most probable symbol (MPS) and * the range of the interval, a table look up procedure linked * with a shift operation is used for both computations. * * Loops and array accesses have been removed * to make real time decoding possible. */ for (row = wfa->basis_states; row <= last_row; row++) { unsigned count; /* value in the current interval */ /* * Read label 0 element */ if (isrange (*is_leaf++)) /* valid matrix index */ { count = high - ((high - low) >> *prob_ptr); if (code < count) { if (prob_ptr < last) /* model update */ prob_ptr++; /* * Decode the MPS '0' */ high = count - 1; RESCALE_INPUT_INTERVAL; } else { prob_ptr = ((prob_ptr - first) >> 1) + first; /* model update */ /* * Decode the LPS '1' */ low = count; RESCALE_INPUT_INTERVAL; /* * Restore the transition (weight = -1) */ append_edge (row, 0, -1, 0, wfa); total++; } } /* * Read label 1 element */ if (isrange (*is_leaf++)) /* valid matrix index */ { count = high - ((high - low) >> *prob_ptr); if (code < count) { if (prob_ptr < last) prob_ptr++; /* model update */ /* * Decode the MPS '0' */ high = count - 1; RESCALE_INPUT_INTERVAL; } else { prob_ptr = ((prob_ptr - first) >> 1) + first; /* model update */ /* * Decode the LPS '1' */ low = count; RESCALE_INPUT_INTERVAL; /* * Restore the transition (weight = -1) */ append_edge (row, 0, -1, 1, wfa); total++; } } } INPUT_BYTE_ALIGN (input); Free (prob); return total; } static unsigned chroma_decoding (wfa_t *wfa, bitfile_t *input) /* * Read transition matrices of 'wfa' states which are part of the * chroma channels Cb and Cr from stream 'input'. * * Return value: * number of non-zero matrix elements (WFA edges) * * Side effects: * 'wfa->into' is filled with decoded values */ { unsigned domain; /* current domain, counter */ unsigned total = 0; /* total number of chroma edges */ unsigned *prob_ptr; /* pointer to current probability */ unsigned *last; /* pointer to minimum probability */ unsigned *first; /* pointer to maximum probability */ unsigned *new_prob_ptr; /* ptr to probability of last domain */ unsigned *prob; /* probability array */ u_word_t high; /* Start of the current code range */ u_word_t low; /* End of the current code range */ u_word_t code; /* The present input code value */ word_t *y_domains; /* domain images corresponding to Y */ int save_index; /* YES: store current probabilty */ /* * Compute the asymmetric probability array * prob[] = { 1/2, 1/2, 1/4, 1/4, 1/4, 1/4, * 1/8, ... , 1/16, ..., 1/(MAXPROB+1)} */ { unsigned n; unsigned index; /* probability index */ unsigned exp; /* current exponent */ prob = Calloc (1 << (MAX_PROB + 1), sizeof (unsigned)); for (index = 0, n = MIN_PROB; n <= MAX_PROB; n++) for (exp = 0; exp < 1U << n; exp++, index++) prob [index] = n; } high = HIGH; /* 1.0 */ low = LOW; /* 0.0 */ code = get_bits (input, 16); /* * Compute list of admitted domains */ y_domains = compute_hits (wfa->basis_states, wfa->tree [wfa->tree [wfa->root_state][0]][0], wfa->wfainfo->chroma_max_states, wfa); first = prob_ptr = new_prob_ptr = prob; last = first + 1020; /* * First of all, read all matrix columns given in the list 'y_domains' * which note all admitted domains. * These matrix elements are stored with QAC (see column_0_decoding ()). */ for (domain = 0; y_domains [domain] != -1; domain++) { unsigned row = wfa->tree [wfa->tree [wfa->root_state][0]][0] + 1; word_t *is_leaf = wfa->tree [row]; prob_ptr = new_prob_ptr; save_index = YES; for (; row < wfa->states; row++) { unsigned count; /* value in the current interval */ /* * Read label 0 element */ if (isrange (*is_leaf++)) /* valid matrix index */ { count = high - ((high - low) >> *prob_ptr); if (code < count) { if (prob_ptr < last) prob_ptr++; /* * Decode the MPS '0' */ high = count - 1; RESCALE_INPUT_INTERVAL; } else { prob_ptr = ((prob_ptr - first) >> 1) + first; /* * Decode the LPS '1' */ low = count; RESCALE_INPUT_INTERVAL; /* * Restore the transition (weight = -1) */ append_edge (row, y_domains [domain], -1, 0, wfa); total++; } } /* * Read label 1 element */ if (isrange (*is_leaf++)) /* valid matrix index */ { count = high - ((high - low) >> *prob_ptr); if (code < count) { if (prob_ptr < last) prob_ptr++; /* * Decode the MPS '0' */ high = count - 1; RESCALE_INPUT_INTERVAL; } else { prob_ptr = ((prob_ptr - first) >> 1) + first; /* * Decode the LPS '1' */ low = count; RESCALE_INPUT_INTERVAL; /* * Restore the transition (weight = -1) */ append_edge (row, y_domains [domain], -1, 1, wfa); total++; } } if (save_index) { save_index = NO; new_prob_ptr = prob_ptr; } } } Free (y_domains); compute_y_state (wfa->tree [wfa->tree [wfa->root_state][0]][1], wfa->tree [wfa->tree [wfa->root_state][0]][0], wfa); compute_y_state (wfa->tree [wfa->tree [wfa->root_state][1]][0], wfa->tree [wfa->tree [wfa->root_state][0]][0], wfa); first = prob_ptr = new_prob_ptr = prob; /* * Decode the additional column which indicates whether there * are transitions to a state with same spatial coordinates * in the Y component. * * Again, quasi arithmetic decoding is used for this task. */ { unsigned row; for (row = wfa->tree [wfa->tree [wfa->root_state][0]][0] + 1; row < wfa->states; row++) { int label; /* current label */ for (label = 0; label < MAXLABELS; label++) { u_word_t count = high - ((high - low) >> *prob_ptr); if (code < count) { if (prob_ptr < last) prob_ptr++; /* * Decode the MPS '0' */ high = count - 1; RESCALE_INPUT_INTERVAL; } else { prob_ptr = ((prob_ptr - first) >> 1) + first; /* * Decode the LPS '1' */ low = count; RESCALE_INPUT_INTERVAL; /* * Restore the transition (weight = -1) */ append_edge (row, wfa->y_state [row][label], -1, label, wfa); total++; } } } } INPUT_BYTE_ALIGN (input); Free (prob); return total; } static void compute_y_state (int state, int y_state, wfa_t *wfa) /* * Compute the 'wfa->y_state' array which denotes those states of * the Y band that have the same spatial coordinates as the corresponding * states of the Cb and Cr bands. * The current root of the Y tree is given by 'y_state'. * The current root of the tree of the chroma channel is given by 'state'. * * No return value. * * Side effects: * 'wfa->y_state' is filled with the generated tree structure. */ { unsigned label; for (label = 0; label < MAXLABELS; label++) if (isrange (y_state)) wfa->y_state [state][label] = RANGE; else { wfa->y_state [state][label] = wfa->tree [y_state][label]; if (!isrange (wfa->tree [state][label])) compute_y_state (wfa->tree [state][label], wfa->y_state [state][label], wfa); } } netpbm-free-10.0-1/pnm/fiasco/input/matrices.h0100644004714500471450000000073507716230207021505 0ustar aba-guestaba-guest/* * matrices.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _MATRICES_H #define _MATRICES_H #include "wfa.h" #include "bit-io.h" unsigned read_matrices (wfa_t *wfa, bitfile_t *input); #endif /* not _MATRICES_H */ netpbm-free-10.0-1/pnm/fiasco/input/mc.c0100644004714500471450000002331707725102161020266 0ustar aba-guestaba-guest/* * mc.c: Input of motion compensation * * written by: Michael Unger * Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/09/02 11:52:17 $ * $Author: aba-guest $ * $Revision: 1.2 $ * $State: Exp $ */ #include #include "config.h" #include "types.h" #include "macros.h" #include "error.h" #include "wfa.h" #include "bit-io.h" #include "misc.h" #include "mc.h" static int mv_code_table [33][2] = /* * MPEG's huffman code for vector components. Format: code_value, length */ { {0x19, 11}, {0x1b, 11}, {0x1d, 11}, {0x1f, 11}, {0x21, 11}, {0x23, 11}, {0x13, 10}, {0x15, 10}, {0x17, 10}, {0x7, 8}, {0x9, 8}, {0xb, 8}, {0x7, 7}, {0x3, 5}, {0x3, 4}, {0x3, 3}, {0x1, 1}, {0x2, 3}, {0x2, 4}, {0x2, 5}, {0x6, 7}, {0xa, 8}, {0x8, 8}, {0x6, 8}, {0x16, 10}, {0x14, 10}, {0x12, 10}, {0x22, 11}, {0x20, 11}, {0x1e, 11}, {0x1c, 11}, {0x1a, 11}, {0x18, 11} }; /***************************************************************************** local variables *****************************************************************************/ typedef struct huff_node { int code_index; /* leaf if index >= 0 */ struct huff_node *left; /* follow if '0' bit read */ struct huff_node *right; /* follow if '1' bit read */ int index_set [34]; } huff_node_t; /***************************************************************************** prototypes *****************************************************************************/ static void decode_mc_tree (frame_type_e frame_type, unsigned max_state, wfa_t *wfa, bitfile_t *input); static void decode_mc_coords (unsigned max_state, wfa_t *wfa, bitfile_t *input); static int get_mv (int f_code, huff_node_t *hn, bitfile_t *input); static huff_node_t * create_huff_tree (void); static void create_huff_node (huff_node_t *hn, int bits_processed); /***************************************************************************** public code *****************************************************************************/ void read_mc (frame_type_e frame_type, wfa_t *wfa, bitfile_t *input) /* * Read motion compensation information of the 'input' stream. * Depending on 'frame_type' different decoding methods are used. * * No return value. * * Side effects: * 'wfa->mv_tree' is filled with the decoded values. */ { unsigned max_state = wfa->wfainfo->color ? wfa->tree [wfa->tree [wfa->root_state][0]][0] : wfa->states; decode_mc_tree (frame_type, max_state, wfa, input); decode_mc_coords (max_state, wfa, input); } /***************************************************************************** private code *****************************************************************************/ static void decode_mc_tree (frame_type_e frame_type, unsigned max_state, wfa_t *wfa, bitfile_t *input) /* * Read tree of motion compensation decisions of the 'input' stream. * Depending on 'frame_type' different decoding methods are used. * 'max_state' is the last state with motion compensation infos. * * No return value. * * Side effects: * 'wfa->mv_tree' is filled with decoded values. */ { unsigned state; /* current state */ unsigned *queue; /* states in breadth first order */ unsigned last; /* last node (update for each new node) */ /* * Traverse tree in breadth first order (starting at level * 'wfa->wfainfo->p_max_level'). Use a queue to store the childs * of each node ('last' is the next free queue element). */ queue = Calloc (MAXSTATES, sizeof (unsigned)); for (last = 0, state = wfa->basis_states; state < max_state; state++) if (wfa->level_of_state [state] - 1 == (int) wfa->wfainfo->p_max_level) queue [last++] = state; /* init level 'p_max_level' */ if (frame_type == P_FRAME) { unsigned label; /* current label */ unsigned current; /* current node to process */ for (current = 0; current < last; current++) for (label = 0; label < MAXLABELS; label++) { state = queue[current]; if (wfa->x [state][label] /* process visible states only */ + width_of_level (wfa->level_of_state [state] - 1) <= wfa->wfainfo->width && wfa->y [state][label] + height_of_level (wfa->level_of_state [state] - 1) <= wfa->wfainfo->height) { wfa->mv_tree [state][label].type = get_bit (input) ? NONE : FORWARD; } else wfa->mv_tree [state][label].type = NONE; if (wfa->mv_tree [state][label].type == NONE && !isrange (wfa->tree [state][label]) && wfa->level_of_state [state] - 1 >= (int) wfa->wfainfo->p_min_level) queue [last++] = wfa->tree [state][label]; /* append child */ } } else { unsigned label; /* current label */ unsigned current; /* current node to process */ for (current = 0; current < last; current++) for (label = 0; label < MAXLABELS; label++) { state = queue[current]; if (wfa->x [state][label] /* process visible states only */ + width_of_level (wfa->level_of_state [state] - 1) > wfa->wfainfo->width || wfa->y [state][label] + height_of_level (wfa->level_of_state [state] - 1) > wfa->wfainfo->height) wfa->mv_tree[state][label].type = NONE; else if (get_bit (input)) /* 1 */ wfa->mv_tree[state][label].type = NONE; else if (get_bit (input)) /* 01 */ wfa->mv_tree[state][label].type = INTERPOLATED; else if (get_bit (input)) /* 001 */ wfa->mv_tree[state][label].type = BACKWARD; else /* 000 */ wfa->mv_tree[state][label].type = FORWARD; if (wfa->mv_tree[state][label].type == NONE && !isrange (wfa->tree[state][label]) && wfa->level_of_state[state] - 1 >= (int) wfa->wfainfo->p_min_level) queue[last++] = wfa->tree[state][label]; /* append child */ } } INPUT_BYTE_ALIGN (input); Free (queue); } static void decode_mc_coords (unsigned max_state, wfa_t *wfa, bitfile_t *input) /* * Read motion vector coordinates of the 'input' stream. They are stored * with the static Huffman code of the MPEG and H.263 standards. * 'max_state' is the last state with motion compensation infos. * * No return value. * * Side effects: * 'wfa->mv_tree' is filled with decoded values. */ { unsigned label; /* current label */ unsigned state; /* current state */ mv_t *mv; /* current motion vector */ static huff_node_t *huff_mv_root = NULL; /* root of huffman tree */ if (huff_mv_root == NULL) huff_mv_root = create_huff_tree (); for (state = wfa->basis_states; state < max_state; state++) for (label = 0; label < MAXLABELS; label++) { mv = &wfa->mv_tree[state][label]; switch (mv->type) { case NONE: break; case FORWARD: mv->fx = get_mv (1, huff_mv_root, input); mv->fy = get_mv (1, huff_mv_root, input); break; case BACKWARD: mv->bx = get_mv (1, huff_mv_root, input); mv->by = get_mv (1, huff_mv_root, input); break; case INTERPOLATED: mv->fx = get_mv (1, huff_mv_root, input); mv->fy = get_mv (1, huff_mv_root, input); mv->bx = get_mv (1, huff_mv_root, input); mv->by = get_mv (1, huff_mv_root, input); break; } } INPUT_BYTE_ALIGN (input); } static int get_mv (int f_code, huff_node_t *hn, bitfile_t *input) /* * Decode next motion vector component in bitstream * by traversing the huffman tree. */ { int vlc_code, vlc_code_magnitude, residual, diffvec; while (hn->code_index < 0) { if (hn->code_index == -2) error ("wrong huffman code !"); if (get_bit (input)) hn = hn->right; else hn = hn->left; } vlc_code = hn->code_index - 16; if (vlc_code == 0 || f_code == 1) return vlc_code; vlc_code_magnitude = abs (vlc_code) - 1; if (f_code <= 1) residual = 0; else residual = get_bits (input, f_code - 1); diffvec = (vlc_code_magnitude << (f_code - 1)) + residual + 1; return vlc_code > 0 ? diffvec : - diffvec; } static huff_node_t * create_huff_tree (void) /* * Construct huffman tree from code table */ { unsigned i; huff_node_t *huff_root = Calloc (1, sizeof (huff_node_t)); /* * The nodes' index set contains indices of all codewords that are * still decodable by traversing further down from the node. * (The root node has the full index set.) */ for (i = 0; i < 33; i++) huff_root->index_set [i] = i; huff_root->index_set [i] = -1; /* end marker */ create_huff_node (huff_root, 0); return huff_root; } static void create_huff_node (huff_node_t *hn, int bits_processed) /* * Create one node in the huffman tree */ { int lind = 0; /* next index of left huff_node */ int rind = 0; /* next index of right huff_node */ int code_len, i, ind; hn->code_index = -1; if (hn->index_set [0] < 0) /* empty index set ? */ { hn->code_index = -2; /* error */ return; } hn->left = Calloc (1, sizeof (huff_node_t)); hn->right = Calloc (1, sizeof (huff_node_t)); for (i = 0; (ind = hn->index_set[i]) >= 0; i++) { code_len = mv_code_table[ind][1]; if (code_len == bits_processed) /* generate leaf */ { hn->code_index = ind; Free (hn->left); Free (hn->right); return; } if (mv_code_table[ind][0] & (1 << (code_len - 1 - bits_processed))) hn->right->index_set[rind++] = ind; else hn->left->index_set[lind++] = ind; } hn->right->index_set[rind] = -1; /* set end markers */ hn->left->index_set[lind] = -1; create_huff_node (hn->left, bits_processed + 1); create_huff_node (hn->right, bits_processed + 1); } netpbm-free-10.0-1/pnm/fiasco/input/mc.h0100644004714500471450000000074207716230207020273 0ustar aba-guestaba-guest/* * mc.h * * written by: Michael Unger * Ullrich Hafner * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _MC_H #define _MC_H #include "wfa.h" #include "bit-io.h" void read_mc (frame_type_e frame_type, wfa_t *wfa, bitfile_t *input); #endif /* not _MC_H */ netpbm-free-10.0-1/pnm/fiasco/input/nd.c0100644004714500471450000001361307716230207020271 0ustar aba-guestaba-guest/* * nd.c: Input of prediction tree * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #include "types.h" #include "macros.h" #include "error.h" #include "bit-io.h" #include "arith.h" #include "misc.h" #include "list.h" #include "wfalib.h" #include "nd.h" /***************************************************************************** prototypes *****************************************************************************/ static void decode_nd_coefficients (unsigned total, wfa_t *wfa, bitfile_t *input); static unsigned decode_nd_tree (wfa_t *wfa, bitfile_t *input); /***************************************************************************** public code *****************************************************************************/ void read_nd (wfa_t *wfa, bitfile_t *input) /* * Read transitions of the nondetermistic 'wfa' part from 'input' stream. * ND is used only at levels {'wfa->p_min_level', ... , 'wfa->p_max_level'}. * * Side effects: * 'wfa->into' and 'wfa->weights' are filled with the decoded values */ { unsigned total = decode_nd_tree (wfa, input); if (total > 0) decode_nd_coefficients (total, wfa, input); } /***************************************************************************** private code *****************************************************************************/ static unsigned decode_nd_tree (wfa_t *wfa, bitfile_t *input) /* * Read 'wfa' prediction tree of given 'input' stream. * * No return value. * * Side effects: * 'wfa->into' is filled with the decoded values */ { lqueue_t *queue; /* queue of states */ int next, state; /* state and its current child */ unsigned total = 0; /* total number of predicted states */ u_word_t sum0, sum1; /* Probability model */ u_word_t code; /* The present input code value */ u_word_t low; /* Start of the current code range */ u_word_t high; /* End of the current code range */ /* * Initialize arithmetic decoder */ code = get_bits (input, 16); low = 0; high = 0xffff; sum0 = 1; sum1 = 11; queue = alloc_queue (sizeof (int)); state = wfa->root_state; queue_append (queue, &state); /* * Traverse the WFA tree in breadth first order (using a queue). */ while (queue_remove (queue, &next)) { unsigned label; if (wfa->level_of_state [next] > wfa->wfainfo->p_max_level + 1) { /* * Nondetermismn is not allowed at levels larger than * 'wfa->wfainfo->p_max_level'. */ for (label = 0; label < MAXLABELS; label++) if (ischild (state = wfa->tree [next][label])) queue_append (queue, &state); /* continue with childs */ } else if (wfa->level_of_state [next] > wfa->wfainfo->p_min_level) { for (label = 0; label < MAXLABELS; label++) if (ischild (state = wfa->tree [next][label])) { unsigned count; /* Current interval count */ unsigned range; /* Current interval range */ count = (((code - low) + 1) * sum1 - 1) / ((high - low) + 1); if (count < sum0) { /* * Decode a '0' symbol * First, the range is expanded to account for the * symbol removal. */ range = (high - low) + 1; high = low + (u_word_t) ((range * sum0) / sum1 - 1 ); RESCALE_INPUT_INTERVAL; /* * Update the frequency counts */ sum0++; sum1++; if (sum1 > 50) /* scale the symbol frequencies */ { sum0 >>= 1; sum1 >>= 1; if (!sum0) sum0 = 1; if (sum0 >= sum1) sum1 = sum0 + 1; } if (wfa->level_of_state [state] > wfa->wfainfo->p_min_level) queue_append (queue, &state); } else { /* * Decode a '1' symbol * First, the range is expanded to account for the * symbol removal. */ range = (high - low) + 1; high = low + (u_word_t) ((range * sum1) / sum1 - 1); low = low + (u_word_t) ((range * sum0) / sum1); RESCALE_INPUT_INTERVAL; /* * Update the frequency counts */ sum1++; if (sum1 > 50) /* scale the symbol frequencies */ { sum0 >>= 1; sum1 >>= 1; if (!sum0) sum0 = 1; if (sum0 >= sum1) sum1 = sum0 + 1; } append_edge (next, 0, -1, label, wfa); total++; } } } } free_queue (queue); INPUT_BYTE_ALIGN (input); return total; } static void decode_nd_coefficients (unsigned total, wfa_t *wfa, bitfile_t *input) /* * Read #'total' weights of nondeterministic part of 'wfa' * of given 'input' stream. * 'frame' gives the current frame number. * * No return value. * * Side effects: * 'wfa->weights' is filled with the decoded values. */ { unsigned *coefficients; /* array of factors to encode */ unsigned *ptr; /* pointer to current factor */ /* * Decode array of coefficients stored with arithmetic coding */ { const int scaling = 50; /* scaling factor of prob. model */ unsigned c_symbols = 1 << (wfa->wfainfo->dc_rpf->mantissa_bits + 1); ptr = coefficients = decode_array (input, NULL, &c_symbols, 1, total, scaling); } /* * Fill 'wfa->weights' with decoded coefficients */ { unsigned state, label; for (state = wfa->basis_states; state < wfa->states; state++) for (label = 0; label < MAXLABELS; label++) if (ischild (wfa->tree [state][label]) && isedge (wfa->into [state][label][0])) { wfa->weight [state][label][0] = btor (*ptr++, wfa->wfainfo->dc_rpf); wfa->int_weight [state][label][0] = wfa->weight [state][label][0] * 512 + 0.5; } } Free (coefficients); } netpbm-free-10.0-1/pnm/fiasco/input/nd.h0100644004714500471450000000071407716230207020274 0ustar aba-guestaba-guest/* * nd.h * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #ifndef _ND_H #define _ND_H #include "wfa.h" #include "rpf.h" #include "bit-io.h" void read_nd (wfa_t *wfa, bitfile_t *input); #endif /* not _ND_H */ netpbm-free-10.0-1/pnm/fiasco/input/read.c0100644004714500471450000003235407716230207020606 0ustar aba-guestaba-guest/* * read.c: Input of WFA files * * Written by: Ullrich Hafner * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ /* * $Date: 2003/08/12 18:23:03 $ * $Author: aba-guest $ * $Revision: 1.1.1.1 $ * $State: Exp $ */ #include "config.h" #include #if STDC_HEADERS # include #else /* not STDC_HEADERS */ # if HAVE_STRING_H # include # else /* not HAVE_STRING_H */ # include # endif /* not HAVE_STRING_H */ #endif /* not STDC_HEADERS */ #include "types.h" #include "macros.h" #include "error.h" #include "wfa.h" #include "misc.h" #include "rpf.h" #include "bit-io.h" #include "wfalib.h" #include "tree.h" #include "matrices.h" #include "weights.h" #include "nd.h" #include "mc.h" #include "basis.h" #include "read.h" /***************************************************************************** prototypes *****************************************************************************/ static void read_tiling (tiling_t *tiling, unsigned image_width, unsigned image_height, unsigned image_level, bitfile_t *input); /***************************************************************************** public code *****************************************************************************/ bitfile_t * open_wfa (const char *filename, wfa_info_t *wi) /* * Open WFA file 'filename' and read header information. * * Return value: * Pointer to input stream (fileposition: first WFA frame) * * Side effects: * The values of the header of 'filename' are copied to 'wfainfo'. * */ { bitfile_t *input; /* pointer to WFA bitfile */ assert (filename && wi); wi->wfa_name = strdup (filename); /* * Check whether 'filename' is a regular WFA file */ { unsigned n; char *str; if (!(input = open_bitfile (filename, "FIASCO_DATA", READ_ACCESS))) file_error (filename); for (str = FIASCO_MAGIC, n = strlen (FIASCO_MAGIC); n; n--) if (get_bits (input, 8) != (unsigned) *str++) error ("Input file %s is not a valid FIASCO file!", filename); get_bits (input, 8); /* fetch newline */ } /* * Read WFA header information */ { char basis_name [MAXSTRLEN]; /* temp. buffer */ const unsigned rice_k = 8; /* parameter of Rice Code */ char *str = basis_name; while ((*str++ = get_bits (input, 8)) != 0 && str < basis_name + MAXSTRLEN) ; if (str == basis_name + MAXSTRLEN) error ("Input file %s is not a valid FIASCO file!", filename); { wi->release = read_rice_code (rice_k, input); if (wi->release > FIASCO_BINFILE_RELEASE) error ("Can't decode FIASCO files of file format release `%d'." "\nCurrent file format release is `%d'.", wi->release, FIASCO_BINFILE_RELEASE); } if (wi->release > 1) { header_type_e type; while ((type = read_rice_code (rice_k, input)) != HEADER_END) { char buffer [MAXSTRLEN]; unsigned n = 0; switch (type) { case HEADER_TITLE: while ((buffer [n++] = get_bits (input, 8))) ; wi->title = strdup (buffer); break; case HEADER_COMMENT: while ((buffer [n++] = get_bits (input, 8))) ; wi->comment = strdup (buffer); break; default: /* should not happen */ break; } } } wi->basis_name = strdup (basis_name); wi->max_states = read_rice_code (rice_k, input); wi->color = get_bit (input) ? YES : NO; wi->width = read_rice_code (rice_k, input); wi->height = read_rice_code (rice_k, input); /* * Compute bintree level */ { unsigned lx = log2 (wi->width - 1) + 1; unsigned ly = log2 (wi->height - 1) + 1; wi->level = max (lx, ly) * 2 - ((ly == lx + 1) ? 1 : 0); } wi->chroma_max_states = wi->color ? read_rice_code (rice_k, input) : -1; wi->p_min_level = read_rice_code (rice_k, input); wi->p_max_level = read_rice_code (rice_k, input); wi->frames = read_rice_code (rice_k, input); wi->smoothing = read_rice_code (rice_k, input); /* * Read RPF models from disk */ { unsigned mantissa; fiasco_rpf_range_e range; mantissa = get_bits (input, 3) + 2; range = get_bits (input, 2); wi->rpf = alloc_rpf (mantissa, range); if (get_bit (input)) /* different DC model */ { mantissa = get_bits (input, 3) + 2; range = get_bits (input, 2); wi->dc_rpf = alloc_rpf (mantissa, range); } else /* use same model for DC coefficents */ wi->dc_rpf = alloc_rpf (wi->rpf->mantissa_bits, wi->rpf->range_e); if (get_bit (input)) /* different delta model */ { mantissa = get_bits (input, 3) + 2; range = get_bits (input, 2); wi->d_rpf = alloc_rpf (mantissa, range); } else wi->d_rpf = alloc_rpf (wi->rpf->mantissa_bits, wi->rpf->range_e); if (get_bit (input)) /* different DC delta model */ { mantissa = get_bits (input, 3) + 2; range = get_bits (input, 2); wi->d_dc_rpf = alloc_rpf (mantissa, range); } else wi->d_dc_rpf = alloc_rpf (wi->dc_rpf->mantissa_bits, wi->dc_rpf->range_e); } if (wi->frames > 1) /* motion compensation stuff */ { wi->fps = read_rice_code (rice_k, input); wi->search_range = read_rice_code (rice_k, input); wi->half_pixel = get_bit (input) ? YES : NO; wi->B_as_past_ref = get_bit (input) ? YES : NO; } } INPUT_BYTE_ALIGN (input); return input; } void read_basis (const char *filename, wfa_t *wfa) /* * Read WFA initial basis 'filename' and fill 'wfa' struct. * * No return value. * * Side effects: * wfa->into, wfa->weights, wfa->final_distribution, wfa->basis_states * wfa->domain_type wfa->wfainfo->basis_name, are filled with the * values of the WFA basis. */ { FILE *input; /* ASCII WFA initial basis file */ assert (filename && wfa); if (!wfa->wfainfo->basis_name || !streq (wfa->wfainfo->basis_name, filename)) { if (wfa->wfainfo->basis_name) Free (wfa->wfainfo->basis_name); wfa->wfainfo->basis_name = strdup (filename); } if (get_linked_basis (filename, wfa)) return; /* basis is linked with excecutable */ /* * Check whether 'wfa_name' is a regular ASCII WFA initial basis file */ { char magic [MAXSTRLEN]; /* WFA magic number */ if (!(input = open_file (filename, "FIASCO_DATA", READ_ACCESS))) file_error(filename); if (fscanf (input, MAXSTRLEN_SCANF, magic) != 1) error ("Format error: ASCII FIASCO initial basis file %s", filename); else if (strneq (FIASCO_BASIS_MAGIC, magic)) error ("Input file %s is not an ASCII FIASCO initial basis!", filename); } /* * WFA ASCII format: * * Note: State 0 is assumed to be the constant function f(x, y) = 128. * Don't define any transitions of state 0 in an initial basis. * * Header: * type |description * ----------------+----------- * string |MAGIC Number "Wfa" * int |Number of basis states 'N' * bool_t-array[N] |use vector in linear combinations, * |0: don't use vector (auxilliary state) * |1: use vector in linear combinations * float-array[N] |final distribution of every state * * Transitions: * * current state *