home *** CD-ROM | disk | FTP | other *** search
view JSON data
|
view as text
|
open on a Mac
|
open on a PC
This file was processed as: SHell self-extracting ARchive
(archive/shar).
You can browse this item here: part08
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| SHell self-extracting ARchive (archive/shar)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| ASCII text
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/329 Shell Archive Format
| default
| |
100%
| detectItEasy
| Format: plain text[LF]
| default (weak)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 4e 65 77 73 67 72 6f 75 | 70 73 3a 20 63 6f 6d 70 |Newsgrou|ps: comp|
|00000010| 2e 73 6f 75 72 63 65 73 | 2e 6d 69 73 63 0a 46 72 |.sources|.misc.Fr|
|00000020| 6f 6d 3a 20 6a 70 65 67 | 2d 69 6e 66 6f 40 75 75 |om: jpeg|-info@uu|
|00000030| 6e 65 74 2e 75 75 2e 6e | 65 74 20 28 49 6e 64 65 |net.uu.n|et (Inde|
|00000040| 70 65 6e 64 65 6e 74 20 | 4a 50 45 47 20 47 72 6f |pendent |JPEG Gro|
|00000050| 75 70 29 0a 53 75 62 6a | 65 63 74 3a 20 20 76 33 |up).Subj|ect: v3|
|00000060| 34 69 30 36 32 3a 20 20 | 6a 70 65 67 20 2d 20 4a |4i062: |jpeg - J|
|00000070| 50 45 47 20 69 6d 61 67 | 65 20 63 6f 6d 70 72 65 |PEG imag|e compre|
|00000080| 73 73 69 6f 6e 2c 20 50 | 61 72 74 30 38 2f 31 38 |ssion, P|art08/18|
|00000090| 0a 4d 65 73 73 61 67 65 | 2d 49 44 3a 20 3c 31 39 |.Message|-ID: <19|
|000000a0| 39 32 44 65 63 31 37 2e | 30 34 31 38 32 34 2e 32 |92Dec17.|041824.2|
|000000b0| 33 36 32 33 40 73 70 61 | 72 6b 79 2e 69 6d 64 2e |3623@spa|rky.imd.|
|000000c0| 73 74 65 72 6c 69 6e 67 | 2e 63 6f 6d 3e 0a 58 2d |sterling|.com>.X-|
|000000d0| 4d 64 34 2d 53 69 67 6e | 61 74 75 72 65 3a 20 30 |Md4-Sign|ature: 0|
|000000e0| 35 38 39 64 31 34 30 36 | 37 37 33 32 66 34 39 35 |589d1406|7732f495|
|000000f0| 61 61 61 35 31 39 37 64 | 34 61 66 61 35 66 36 0a |aaa5197d|4afa5f6.|
|00000100| 44 61 74 65 3a 20 54 68 | 75 2c 20 31 37 20 44 65 |Date: Th|u, 17 De|
|00000110| 63 20 31 39 39 32 20 30 | 34 3a 31 38 3a 32 34 20 |c 1992 0|4:18:24 |
|00000120| 47 4d 54 0a 41 70 70 72 | 6f 76 65 64 3a 20 6b 65 |GMT.Appr|oved: ke|
|00000130| 6e 74 40 73 70 61 72 6b | 79 2e 69 6d 64 2e 73 74 |nt@spark|y.imd.st|
|00000140| 65 72 6c 69 6e 67 2e 63 | 6f 6d 0a 0a 53 75 62 6d |erling.c|om..Subm|
|00000150| 69 74 74 65 64 2d 62 79 | 3a 20 6a 70 65 67 2d 69 |itted-by|: jpeg-i|
|00000160| 6e 66 6f 40 75 75 6e 65 | 74 2e 75 75 2e 6e 65 74 |nfo@uune|t.uu.net|
|00000170| 20 28 49 6e 64 65 70 65 | 6e 64 65 6e 74 20 4a 50 | (Indepe|ndent JP|
|00000180| 45 47 20 47 72 6f 75 70 | 29 0a 50 6f 73 74 69 6e |EG Group|).Postin|
|00000190| 67 2d 6e 75 6d 62 65 72 | 3a 20 56 6f 6c 75 6d 65 |g-number|: Volume|
|000001a0| 20 33 34 2c 20 49 73 73 | 75 65 20 36 32 0a 41 72 | 34, Iss|ue 62.Ar|
|000001b0| 63 68 69 76 65 2d 6e 61 | 6d 65 3a 20 6a 70 65 67 |chive-na|me: jpeg|
|000001c0| 2f 70 61 72 74 30 38 0a | 45 6e 76 69 72 6f 6e 6d |/part08.|Environm|
|000001d0| 65 6e 74 3a 20 55 4e 49 | 58 2c 20 56 4d 53 2c 20 |ent: UNI|X, VMS, |
|000001e0| 4d 53 2d 44 4f 53 2c 20 | 4d 61 63 2c 20 41 6d 69 |MS-DOS, |Mac, Ami|
|000001f0| 67 61 2c 20 41 74 61 72 | 69 2c 20 43 72 61 79 0a |ga, Atar|i, Cray.|
|00000200| 53 75 70 65 72 73 65 64 | 65 73 3a 20 6a 70 65 67 |Supersed|es: jpeg|
|00000210| 3a 20 56 6f 6c 75 6d 65 | 20 32 39 2c 20 49 73 73 |: Volume| 29, Iss|
|00000220| 75 65 20 31 2d 31 38 0a | 0a 23 21 20 2f 62 69 6e |ue 1-18.|.#! /bin|
|00000230| 2f 73 68 0a 23 20 54 68 | 69 73 20 69 73 20 61 20 |/sh.# Th|is is a |
|00000240| 73 68 65 6c 6c 20 61 72 | 63 68 69 76 65 2e 20 20 |shell ar|chive. |
|00000250| 52 65 6d 6f 76 65 20 61 | 6e 79 74 68 69 6e 67 20 |Remove a|nything |
|00000260| 62 65 66 6f 72 65 20 74 | 68 69 73 20 6c 69 6e 65 |before t|his line|
|00000270| 2c 20 74 68 65 6e 20 66 | 65 65 64 20 69 74 0a 23 |, then f|eed it.#|
|00000280| 20 69 6e 74 6f 20 61 20 | 73 68 65 6c 6c 20 76 69 | into a |shell vi|
|00000290| 61 20 22 73 68 20 66 69 | 6c 65 22 20 6f 72 20 73 |a "sh fi|le" or s|
|000002a0| 69 6d 69 6c 61 72 2e 20 | 20 54 6f 20 6f 76 65 72 |imilar. | To over|
|000002b0| 77 72 69 74 65 20 65 78 | 69 73 74 69 6e 67 20 66 |write ex|isting f|
|000002c0| 69 6c 65 73 2c 0a 23 20 | 74 79 70 65 20 22 73 68 |iles,.# |type "sh|
|000002d0| 20 66 69 6c 65 20 2d 63 | 22 2e 0a 23 20 43 6f 6e | file -c|"..# Con|
|000002e0| 74 65 6e 74 73 3a 20 20 | 65 78 61 6d 70 6c 65 2e |tents: |example.|
|000002f0| 63 20 6a 63 61 72 69 74 | 68 2e 63 20 6a 63 70 69 |c jcarit|h.c jcpi|
|00000300| 70 65 2e 63 0a 23 20 57 | 72 61 70 70 65 64 20 62 |pe.c.# W|rapped b|
|00000310| 79 20 6b 65 6e 74 40 73 | 70 61 72 6b 79 20 6f 6e |y kent@s|parky on|
|00000320| 20 57 65 64 20 44 65 63 | 20 31 36 20 32 30 3a 35 | Wed Dec| 16 20:5|
|00000330| 32 3a 32 37 20 31 39 39 | 32 0a 50 41 54 48 3d 2f |2:27 199|2.PATH=/|
|00000340| 62 69 6e 3a 2f 75 73 72 | 2f 62 69 6e 3a 2f 75 73 |bin:/usr|/bin:/us|
|00000350| 72 2f 75 63 62 3a 2f 75 | 73 72 2f 6c 6f 63 61 6c |r/ucb:/u|sr/local|
|00000360| 2f 62 69 6e 3a 2f 75 73 | 72 2f 6c 62 69 6e 20 3b |/bin:/us|r/lbin ;|
|00000370| 20 65 78 70 6f 72 74 20 | 50 41 54 48 0a 65 63 68 | export |PATH.ech|
|00000380| 6f 20 49 66 20 74 68 69 | 73 20 61 72 63 68 69 76 |o If thi|s archiv|
|00000390| 65 20 69 73 20 63 6f 6d | 70 6c 65 74 65 2c 20 79 |e is com|plete, y|
|000003a0| 6f 75 20 77 69 6c 6c 20 | 73 65 65 20 74 68 65 20 |ou will |see the |
|000003b0| 66 6f 6c 6c 6f 77 69 6e | 67 20 6d 65 73 73 61 67 |followin|g messag|
|000003c0| 65 3a 0a 65 63 68 6f 20 | 27 20 20 20 20 20 20 20 |e:.echo |' |
|000003d0| 20 20 20 22 73 68 61 72 | 3a 20 45 6e 64 20 6f 66 | "shar|: End of|
|000003e0| 20 61 72 63 68 69 76 65 | 20 38 20 28 6f 66 20 31 | archive| 8 (of 1|
|000003f0| 38 29 2e 22 27 0a 69 66 | 20 74 65 73 74 20 2d 66 |8)."'.if| test -f|
|00000400| 20 27 65 78 61 6d 70 6c | 65 2e 63 27 20 2d 61 20 | 'exampl|e.c' -a |
|00000410| 22 24 7b 31 7d 22 20 21 | 3d 20 22 2d 63 22 20 3b |"${1}" !|= "-c" ;|
|00000420| 20 74 68 65 6e 20 0a 20 | 20 65 63 68 6f 20 73 68 | then . | echo sh|
|00000430| 61 72 3a 20 57 69 6c 6c | 20 6e 6f 74 20 63 6c 6f |ar: Will| not clo|
|00000440| 62 62 65 72 20 65 78 69 | 73 74 69 6e 67 20 66 69 |bber exi|sting fi|
|00000450| 6c 65 20 5c 22 27 65 78 | 61 6d 70 6c 65 2e 63 27 |le \"'ex|ample.c'|
|00000460| 5c 22 0a 65 6c 73 65 0a | 20 20 65 63 68 6f 20 73 |\".else.| echo s|
|00000470| 68 61 72 3a 20 45 78 74 | 72 61 63 74 69 6e 67 20 |har: Ext|racting |
|00000480| 5c 22 27 65 78 61 6d 70 | 6c 65 2e 63 27 5c 22 20 |\"'examp|le.c'\" |
|00000490| 5c 28 32 36 38 37 39 20 | 63 68 61 72 61 63 74 65 |\(26879 |characte|
|000004a0| 72 73 5c 29 0a 20 20 73 | 65 64 20 22 73 2f 5e 58 |rs\). s|ed "s/^X|
|000004b0| 2f 2f 22 20 3e 27 65 78 | 61 6d 70 6c 65 2e 63 27 |//" >'ex|ample.c'|
|000004c0| 20 3c 3c 27 45 4e 44 5f | 4f 46 5f 46 49 4c 45 27 | <<'END_|OF_FILE'|
|000004d0| 0a 58 2f 2a 0a 58 20 2a | 20 65 78 61 6d 70 6c 65 |.X/*.X *| example|
|000004e0| 2e 63 0a 58 20 2a 0a 58 | 20 2a 20 54 68 69 73 20 |.c.X *.X| * This |
|000004f0| 66 69 6c 65 20 69 73 20 | 6e 6f 74 20 61 63 74 75 |file is |not actu|
|00000500| 61 6c 6c 79 20 70 61 72 | 74 20 6f 66 20 74 68 65 |ally par|t of the|
|00000510| 20 4a 50 45 47 20 73 6f | 66 74 77 61 72 65 2e 20 | JPEG so|ftware. |
|00000520| 20 52 61 74 68 65 72 2c | 20 69 74 20 70 72 6f 76 | Rather,| it prov|
|00000530| 69 64 65 73 0a 58 20 2a | 20 61 20 73 6b 65 6c 65 |ides.X *| a skele|
|00000540| 74 6f 6e 20 74 68 61 74 | 20 6d 61 79 20 62 65 20 |ton that| may be |
|00000550| 75 73 65 66 75 6c 20 66 | 6f 72 20 63 6f 6e 73 74 |useful f|or const|
|00000560| 72 75 63 74 69 6e 67 20 | 61 70 70 6c 69 63 61 74 |ructing |applicat|
|00000570| 69 6f 6e 73 20 74 68 61 | 74 20 75 73 65 20 74 68 |ions tha|t use th|
|00000580| 65 0a 58 20 2a 20 4a 50 | 45 47 20 73 6f 66 74 77 |e.X * JP|EG softw|
|00000590| 61 72 65 20 61 73 20 73 | 75 62 72 6f 75 74 69 6e |are as s|ubroutin|
|000005a0| 65 73 2e 20 20 54 68 69 | 73 20 63 6f 64 65 20 77 |es. Thi|s code w|
|000005b0| 69 6c 6c 20 4e 4f 54 20 | 64 6f 20 61 6e 79 74 68 |ill NOT |do anyth|
|000005c0| 69 6e 67 20 75 73 65 66 | 75 6c 20 61 73 20 69 73 |ing usef|ul as is|
|000005d0| 2e 0a 58 20 2a 0a 58 20 | 2a 20 54 68 69 73 20 66 |..X *.X |* This f|
|000005e0| 69 6c 65 20 69 6c 6c 75 | 73 74 72 61 74 65 73 20 |ile illu|strates |
|000005f0| 68 6f 77 20 74 6f 20 75 | 73 65 20 74 68 65 20 4a |how to u|se the J|
|00000600| 50 45 47 20 63 6f 64 65 | 20 61 73 20 61 20 73 75 |PEG code| as a su|
|00000610| 62 72 6f 75 74 69 6e 65 | 20 6c 69 62 72 61 72 79 |broutine| library|
|00000620| 0a 58 20 2a 20 74 6f 20 | 72 65 61 64 20 6f 72 20 |.X * to |read or |
|00000630| 77 72 69 74 65 20 4a 50 | 45 47 20 69 6d 61 67 65 |write JP|EG image|
|00000640| 20 66 69 6c 65 73 2e 20 | 20 57 65 20 61 73 73 75 | files. | We assu|
|00000650| 6d 65 20 68 65 72 65 20 | 74 68 61 74 20 79 6f 75 |me here |that you|
|00000660| 20 61 72 65 20 6e 6f 74 | 0a 58 20 2a 20 6d 65 72 | are not|.X * mer|
|00000670| 65 6c 79 20 69 6e 74 65 | 72 65 73 74 65 64 20 69 |ely inte|rested i|
|00000680| 6e 20 63 6f 6e 76 65 72 | 74 69 6e 67 20 74 68 65 |n conver|ting the|
|00000690| 20 69 6d 61 67 65 20 74 | 6f 20 79 65 74 20 61 6e | image t|o yet an|
|000006a0| 6f 74 68 65 72 20 69 6d | 61 67 65 20 66 69 6c 65 |other im|age file|
|000006b0| 20 66 6f 72 6d 61 74 0a | 58 20 2a 20 28 69 66 20 | format.|X * (if |
|000006c0| 79 6f 75 20 61 72 65 2c | 20 79 6f 75 20 73 68 6f |you are,| you sho|
|000006d0| 75 6c 64 20 62 65 20 61 | 64 64 69 6e 67 20 61 6e |uld be a|dding an|
|000006e0| 6f 74 68 65 72 20 49 2f | 4f 20 6d 6f 64 75 6c 65 |other I/|O module|
|000006f0| 20 74 6f 20 63 6a 70 65 | 67 2f 64 6a 70 65 67 2c | to cjpe|g/djpeg,|
|00000700| 20 6e 6f 74 0a 58 20 2a | 20 63 6f 6e 73 74 72 75 | not.X *| constru|
|00000710| 63 74 69 6e 67 20 61 20 | 6e 65 77 20 61 70 70 6c |cting a |new appl|
|00000720| 69 63 61 74 69 6f 6e 29 | 2e 20 20 49 6e 73 74 65 |ication)|. Inste|
|00000730| 61 64 2c 20 77 65 20 73 | 68 6f 77 20 68 6f 77 20 |ad, we s|how how |
|00000740| 74 6f 20 70 61 73 73 20 | 74 68 65 0a 58 20 2a 20 |to pass |the.X * |
|00000750| 64 65 63 6f 6d 70 72 65 | 73 73 65 64 20 69 6d 61 |decompre|ssed ima|
|00000760| 67 65 20 64 61 74 61 20 | 69 6e 74 6f 20 6f 72 20 |ge data |into or |
|00000770| 6f 75 74 20 6f 66 20 72 | 6f 75 74 69 6e 65 73 20 |out of r|outines |
|00000780| 74 68 61 74 20 79 6f 75 | 20 70 72 6f 76 69 64 65 |that you| provide|
|00000790| 2e 20 20 46 6f 72 0a 58 | 20 2a 20 65 78 61 6d 70 |. For.X| * examp|
|000007a0| 6c 65 2c 20 61 20 76 69 | 65 77 65 72 20 70 72 6f |le, a vi|ewer pro|
|000007b0| 67 72 61 6d 20 6d 69 67 | 68 74 20 75 73 65 20 74 |gram mig|ht use t|
|000007c0| 68 65 20 4a 50 45 47 20 | 64 65 63 6f 6d 70 72 65 |he JPEG |decompre|
|000007d0| 73 73 6f 72 20 74 6f 67 | 65 74 68 65 72 20 77 69 |ssor tog|ether wi|
|000007e0| 74 68 0a 58 20 2a 20 72 | 6f 75 74 69 6e 65 73 20 |th.X * r|outines |
|000007f0| 74 68 61 74 20 77 72 69 | 74 65 20 74 68 65 20 64 |that wri|te the d|
|00000800| 65 63 6f 6d 70 72 65 73 | 73 65 64 20 69 6d 61 67 |ecompres|sed imag|
|00000810| 65 20 64 69 72 65 63 74 | 6c 79 20 74 6f 20 61 20 |e direct|ly to a |
|00000820| 64 69 73 70 6c 61 79 2e | 0a 58 20 2a 0a 58 20 2a |display.|.X *.X *|
|00000830| 20 57 65 20 70 72 65 73 | 65 6e 74 20 74 68 65 73 | We pres|ent thes|
|00000840| 65 20 72 6f 75 74 69 6e | 65 73 20 69 6e 20 74 68 |e routin|es in th|
|00000850| 65 20 73 61 6d 65 20 63 | 6f 64 69 6e 67 20 73 74 |e same c|oding st|
|00000860| 79 6c 65 20 75 73 65 64 | 20 69 6e 20 74 68 65 20 |yle used| in the |
|00000870| 4a 50 45 47 20 63 6f 64 | 65 0a 58 20 2a 20 28 41 |JPEG cod|e.X * (A|
|00000880| 4e 53 49 20 66 75 6e 63 | 74 69 6f 6e 20 64 65 66 |NSI func|tion def|
|00000890| 69 6e 69 74 69 6f 6e 73 | 2c 20 65 74 63 29 3b 20 |initions|, etc); |
|000008a0| 62 75 74 20 79 6f 75 20 | 61 72 65 20 6f 66 20 63 |but you |are of c|
|000008b0| 6f 75 72 73 65 20 66 72 | 65 65 20 74 6f 20 63 6f |ourse fr|ee to co|
|000008c0| 64 65 20 79 6f 75 72 0a | 58 20 2a 20 72 6f 75 74 |de your.|X * rout|
|000008d0| 69 6e 65 73 20 69 6e 20 | 61 20 64 69 66 66 65 72 |ines in |a differ|
|000008e0| 65 6e 74 20 73 74 79 6c | 65 20 69 66 20 79 6f 75 |ent styl|e if you|
|000008f0| 20 70 72 65 66 65 72 2e | 0a 58 20 2a 2f 0a 58 0a | prefer.|.X */.X.|
|00000900| 58 2f 2a 0a 58 20 2a 20 | 49 6e 63 6c 75 64 65 20 |X/*.X * |Include |
|00000910| 66 69 6c 65 20 66 6f 72 | 20 64 65 63 6c 61 72 69 |file for| declari|
|00000920| 6e 67 20 4a 50 45 47 20 | 64 61 74 61 20 73 74 72 |ng JPEG |data str|
|00000930| 75 63 74 75 72 65 73 2e | 0a 58 20 2a 20 54 68 69 |uctures.|.X * Thi|
|00000940| 73 20 66 69 6c 65 20 61 | 6c 73 6f 20 69 6e 63 6c |s file a|lso incl|
|00000950| 75 64 65 73 20 73 6f 6d | 65 20 73 79 73 74 65 6d |udes som|e system|
|00000960| 20 68 65 61 64 65 72 73 | 20 6c 69 6b 65 20 3c 73 | headers| like <s|
|00000970| 74 64 69 6f 2e 68 3e 3b | 0a 58 20 2a 20 69 66 20 |tdio.h>;|.X * if |
|00000980| 79 6f 75 20 70 72 65 66 | 65 72 2c 20 79 6f 75 20 |you pref|er, you |
|00000990| 63 61 6e 20 69 6e 63 6c | 75 64 65 20 22 6a 63 6f |can incl|ude "jco|
|000009a0| 6e 66 69 67 2e 68 22 20 | 61 6e 64 20 22 6a 70 65 |nfig.h" |and "jpe|
|000009b0| 67 64 61 74 61 2e 68 22 | 20 69 6e 73 74 65 61 64 |gdata.h"| instead|
|000009c0| 2e 0a 58 20 2a 2f 0a 58 | 0a 58 23 69 6e 63 6c 75 |..X */.X|.X#inclu|
|000009d0| 64 65 20 22 6a 69 6e 63 | 6c 75 64 65 2e 68 22 0a |de "jinc|lude.h".|
|000009e0| 58 0a 58 2f 2a 0a 58 20 | 2a 20 3c 73 65 74 6a 6d |X.X/*.X |* <setjm|
|000009f0| 70 2e 68 3e 20 69 73 20 | 75 73 65 64 20 66 6f 72 |p.h> is |used for|
|00000a00| 20 74 68 65 20 6f 70 74 | 69 6f 6e 61 6c 20 65 72 | the opt|ional er|
|00000a10| 72 6f 72 20 72 65 63 6f | 76 65 72 79 20 6d 65 63 |ror reco|very mec|
|00000a20| 68 61 6e 69 73 6d 20 73 | 68 6f 77 6e 20 69 6e 0a |hanism s|hown in.|
|00000a30| 58 20 2a 20 74 68 65 20 | 73 65 63 6f 6e 64 20 70 |X * the |second p|
|00000a40| 61 72 74 20 6f 66 20 74 | 68 65 20 65 78 61 6d 70 |art of t|he examp|
|00000a50| 6c 65 2e 0a 58 20 2a 2f | 0a 58 0a 58 23 69 6e 63 |le..X */|.X.X#inc|
|00000a60| 6c 75 64 65 20 3c 73 65 | 74 6a 6d 70 2e 68 3e 0a |lude <se|tjmp.h>.|
|00000a70| 58 0a 58 0a 58 0a 58 2f | 2a 2a 2a 2a 2a 2a 2a 2a |X.X.X.X/|********|
|00000a80| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 20 4a 50 45 |********|**** JPE|
|00000a90| 47 20 43 4f 4d 50 52 45 | 53 53 49 4f 4e 20 53 41 |G COMPRE|SSION SA|
|00000aa0| 4d 50 4c 45 20 49 4e 54 | 45 52 46 41 43 45 20 2a |MPLE INT|ERFACE *|
|00000ab0| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000ac0| 2a 2a 2f 0a 58 0a 58 2f | 2a 20 54 68 69 73 20 68 |**/.X.X/|* This h|
|00000ad0| 61 6c 66 20 6f 66 20 74 | 68 65 20 65 78 61 6d 70 |alf of t|he examp|
|00000ae0| 6c 65 20 73 68 6f 77 73 | 20 68 6f 77 20 74 6f 20 |le shows| how to |
|00000af0| 66 65 65 64 20 64 61 74 | 61 20 69 6e 74 6f 20 74 |feed dat|a into t|
|00000b00| 68 65 20 4a 50 45 47 20 | 63 6f 6d 70 72 65 73 73 |he JPEG |compress|
|00000b10| 6f 72 2e 0a 58 20 2a 20 | 57 65 20 70 72 65 73 65 |or..X * |We prese|
|00000b20| 6e 74 20 61 20 6d 69 6e | 69 6d 61 6c 20 76 65 72 |nt a min|imal ver|
|00000b30| 73 69 6f 6e 20 74 68 61 | 74 20 64 6f 65 73 20 6e |sion tha|t does n|
|00000b40| 6f 74 20 77 6f 72 72 79 | 20 61 62 6f 75 74 20 72 |ot worry| about r|
|00000b50| 65 66 69 6e 65 6d 65 6e | 74 73 20 73 75 63 68 0a |efinemen|ts such.|
|00000b60| 58 20 2a 20 61 73 20 65 | 72 72 6f 72 20 72 65 63 |X * as e|rror rec|
|00000b70| 6f 76 65 72 79 20 28 74 | 68 65 20 4a 50 45 47 20 |overy (t|he JPEG |
|00000b80| 63 6f 64 65 20 77 69 6c | 6c 20 6a 75 73 74 20 65 |code wil|l just e|
|00000b90| 78 69 74 28 29 20 69 66 | 20 69 74 20 67 65 74 73 |xit() if| it gets|
|00000ba0| 20 61 6e 20 65 72 72 6f | 72 29 2e 0a 58 20 2a 2f | an erro|r)..X */|
|00000bb0| 0a 58 0a 58 0a 58 2f 2a | 0a 58 20 2a 20 54 6f 20 |.X.X.X/*|.X * To |
|00000bc0| 73 75 70 70 6c 79 20 74 | 68 65 20 69 6d 61 67 65 |supply t|he image|
|00000bd0| 20 64 61 74 61 20 66 6f | 72 20 63 6f 6d 70 72 65 | data fo|r compre|
|00000be0| 73 73 69 6f 6e 2c 20 79 | 6f 75 20 6d 75 73 74 20 |ssion, y|ou must |
|00000bf0| 64 65 66 69 6e 65 20 74 | 68 72 65 65 20 72 6f 75 |define t|hree rou|
|00000c00| 74 69 6e 65 73 0a 58 20 | 2a 20 69 6e 70 75 74 5f |tines.X |* input_|
|00000c10| 69 6e 69 74 2c 20 67 65 | 74 5f 69 6e 70 75 74 5f |init, ge|t_input_|
|00000c20| 72 6f 77 2c 20 61 6e 64 | 20 69 6e 70 75 74 5f 74 |row, and| input_t|
|00000c30| 65 72 6d 2e 20 20 54 68 | 65 73 65 20 72 6f 75 74 |erm. Th|ese rout|
|00000c40| 69 6e 65 73 20 77 69 6c | 6c 20 62 65 20 63 61 6c |ines wil|l be cal|
|00000c50| 6c 65 64 0a 58 20 2a 20 | 66 72 6f 6d 20 74 68 65 |led.X * |from the|
|00000c60| 20 4a 50 45 47 20 63 6f | 6d 70 72 65 73 73 6f 72 | JPEG co|mpressor|
|00000c70| 20 76 69 61 20 66 75 6e | 63 74 69 6f 6e 20 70 6f | via fun|ction po|
|00000c80| 69 6e 74 65 72 20 76 61 | 6c 75 65 73 20 74 68 61 |inter va|lues tha|
|00000c90| 74 20 79 6f 75 20 73 74 | 6f 72 65 20 69 6e 20 74 |t you st|ore in t|
|00000ca0| 68 65 0a 58 20 2a 20 63 | 69 6e 66 6f 20 64 61 74 |he.X * c|info dat|
|00000cb0| 61 20 73 74 72 75 63 74 | 75 72 65 3b 20 68 65 6e |a struct|ure; hen|
|00000cc0| 63 65 20 74 68 65 79 20 | 6e 65 65 64 20 6e 6f 74 |ce they |need not|
|00000cd0| 20 62 65 20 67 6c 6f 62 | 61 6c 6c 79 20 76 69 73 | be glob|ally vis|
|00000ce0| 69 62 6c 65 20 61 6e 64 | 20 74 68 65 20 65 78 61 |ible and| the exa|
|00000cf0| 63 74 0a 58 20 2a 20 6e | 61 6d 65 73 20 64 6f 6e |ct.X * n|ames don|
|00000d00| 27 74 20 6d 61 74 74 65 | 72 2e 20 20 28 49 6e 20 |'t matte|r. (In |
|00000d10| 66 61 63 74 2c 20 74 68 | 65 20 22 4d 45 54 48 4f |fact, th|e "METHO|
|00000d20| 44 44 45 46 22 20 6d 61 | 63 72 6f 20 65 78 70 61 |DDEF" ma|cro expa|
|00000d30| 6e 64 73 20 74 6f 20 22 | 73 74 61 74 69 63 22 20 |nds to "|static" |
|00000d40| 69 66 0a 58 20 2a 20 79 | 6f 75 20 75 73 65 20 74 |if.X * y|ou use t|
|00000d50| 68 65 20 75 6e 6d 6f 64 | 69 66 69 65 64 20 4a 50 |he unmod|ified JP|
|00000d60| 45 47 20 69 6e 63 6c 75 | 64 65 20 66 69 6c 65 73 |EG inclu|de files|
|00000d70| 2e 29 0a 58 20 2a 0a 58 | 20 2a 20 54 68 65 20 69 |.).X *.X| * The i|
|00000d80| 6e 70 75 74 20 66 69 6c | 65 20 72 65 61 64 69 6e |nput fil|e readin|
|00000d90| 67 20 6d 6f 64 75 6c 65 | 73 20 28 6a 72 64 70 70 |g module|s (jrdpp|
|00000da0| 6d 2e 63 2c 20 6a 72 64 | 67 69 66 2e 63 2c 20 6a |m.c, jrd|gif.c, j|
|00000db0| 72 64 74 61 72 67 61 2e | 63 2c 20 65 74 63 29 20 |rdtarga.|c, etc) |
|00000dc0| 6d 61 79 20 62 65 0a 58 | 20 2a 20 75 73 65 66 75 |may be.X| * usefu|
|00000dd0| 6c 20 65 78 61 6d 70 6c | 65 73 20 6f 66 20 77 68 |l exampl|es of wh|
|00000de0| 61 74 20 74 68 65 73 65 | 20 72 6f 75 74 69 6e 65 |at these| routine|
|00000df0| 73 20 73 68 6f 75 6c 64 | 20 61 63 74 75 61 6c 6c |s should| actuall|
|00000e00| 79 20 64 6f 2c 20 61 6c | 74 68 6f 75 67 68 20 65 |y do, al|though e|
|00000e10| 61 63 68 20 6f 66 0a 58 | 20 2a 20 74 68 65 6d 20 |ach of.X| * them |
|00000e20| 69 73 20 65 6e 63 72 75 | 73 74 65 64 20 77 69 74 |is encru|sted wit|
|00000e30| 68 20 61 20 6c 6f 74 20 | 6f 66 20 73 70 65 63 69 |h a lot |of speci|
|00000e40| 61 6c 69 7a 65 64 20 63 | 6f 64 65 20 66 6f 72 20 |alized c|ode for |
|00000e50| 69 74 73 20 6f 77 6e 20 | 66 69 6c 65 20 66 6f 72 |its own |file for|
|00000e60| 6d 61 74 2e 0a 58 20 2a | 2f 0a 58 0a 58 0a 58 4d |mat..X *|/.X.X.XM|
|00000e70| 45 54 48 4f 44 44 45 46 | 20 76 6f 69 64 0a 58 69 |ETHODDEF| void.Xi|
|00000e80| 6e 70 75 74 5f 69 6e 69 | 74 20 28 63 6f 6d 70 72 |nput_ini|t (compr|
|00000e90| 65 73 73 5f 69 6e 66 6f | 5f 70 74 72 20 63 69 6e |ess_info|_ptr cin|
|00000ea0| 66 6f 29 0a 58 2f 2a 20 | 49 6e 69 74 69 61 6c 69 |fo).X/* |Initiali|
|00000eb0| 7a 65 20 66 6f 72 20 69 | 6e 70 75 74 3b 20 72 65 |ze for i|nput; re|
|00000ec0| 74 75 72 6e 20 69 6d 61 | 67 65 20 73 69 7a 65 20 |turn ima|ge size |
|00000ed0| 61 6e 64 20 63 6f 6d 70 | 6f 6e 65 6e 74 20 64 61 |and comp|onent da|
|00000ee0| 74 61 2e 20 2a 2f 0a 58 | 7b 0a 58 20 20 2f 2a 20 |ta. */.X|{.X /* |
|00000ef0| 54 68 69 73 20 72 6f 75 | 74 69 6e 65 20 6d 75 73 |This rou|tine mus|
|00000f00| 74 20 72 65 74 75 72 6e | 20 66 69 76 65 20 70 69 |t return| five pi|
|00000f10| 65 63 65 73 20 6f 66 20 | 69 6e 66 6f 72 6d 61 74 |eces of |informat|
|00000f20| 69 6f 6e 20 61 62 6f 75 | 74 20 74 68 65 20 69 6e |ion abou|t the in|
|00000f30| 63 6f 6d 69 6e 67 0a 58 | 20 20 20 2a 20 69 6d 61 |coming.X| * ima|
|00000f40| 67 65 2c 20 61 6e 64 20 | 6d 75 73 74 20 64 6f 20 |ge, and |must do |
|00000f50| 61 6e 79 20 73 65 74 75 | 70 20 6e 65 65 64 65 64 |any setu|p needed|
|00000f60| 20 66 6f 72 20 74 68 65 | 20 67 65 74 5f 69 6e 70 | for the| get_inp|
|00000f70| 75 74 5f 72 6f 77 20 72 | 6f 75 74 69 6e 65 2e 0a |ut_row r|outine..|
|00000f80| 58 20 20 20 2a 20 54 68 | 65 20 69 6d 61 67 65 20 |X * Th|e image |
|00000f90| 69 6e 66 6f 72 6d 61 74 | 69 6f 6e 20 69 73 20 72 |informat|ion is r|
|00000fa0| 65 74 75 72 6e 65 64 20 | 69 6e 20 66 69 65 6c 64 |eturned |in field|
|00000fb0| 73 20 6f 66 20 74 68 65 | 20 63 69 6e 66 6f 20 73 |s of the| cinfo s|
|00000fc0| 74 72 75 63 74 2e 0a 58 | 20 20 20 2a 20 28 49 66 |truct..X| * (If|
|00000fd0| 20 79 6f 75 20 64 6f 6e | 27 74 20 63 61 72 65 20 | you don|'t care |
|00000fe0| 61 62 6f 75 74 20 6d 6f | 64 75 6c 61 72 69 74 79 |about mo|dularity|
|00000ff0| 2c 20 79 6f 75 20 63 6f | 75 6c 64 20 69 6e 69 74 |, you co|uld init|
|00001000| 69 61 6c 69 7a 65 20 74 | 68 65 73 65 20 66 69 65 |ialize t|hese fie|
|00001010| 6c 64 73 0a 58 20 20 20 | 2a 20 69 6e 20 74 68 65 |lds.X |* in the|
|00001020| 20 6d 61 69 6e 20 4a 50 | 45 47 20 63 61 6c 6c 69 | main JP|EG calli|
|00001030| 6e 67 20 72 6f 75 74 69 | 6e 65 2c 20 61 6e 64 20 |ng routi|ne, and |
|00001040| 6d 61 6b 65 20 74 68 69 | 73 20 72 6f 75 74 69 6e |make thi|s routin|
|00001050| 65 20 62 65 20 61 20 6e | 6f 2d 6f 70 2e 29 0a 58 |e be a n|o-op.).X|
|00001060| 20 20 20 2a 20 57 65 20 | 73 68 6f 77 20 73 6f 6d | * We |show som|
|00001070| 65 20 65 78 61 6d 70 6c | 65 20 76 61 6c 75 65 73 |e exampl|e values|
|00001080| 20 68 65 72 65 2e 0a 58 | 20 20 20 2a 2f 0a 58 20 | here..X| */.X |
|00001090| 20 63 69 6e 66 6f 2d 3e | 69 6d 61 67 65 5f 77 69 | cinfo->|image_wi|
|000010a0| 64 74 68 20 3d 20 36 34 | 30 3b 09 09 2f 2a 20 77 |dth = 64|0;../* w|
|000010b0| 69 64 74 68 20 69 6e 20 | 70 69 78 65 6c 73 20 2a |idth in |pixels *|
|000010c0| 2f 0a 58 20 20 63 69 6e | 66 6f 2d 3e 69 6d 61 67 |/.X cin|fo->imag|
|000010d0| 65 5f 68 65 69 67 68 74 | 20 3d 20 34 38 30 3b 09 |e_height| = 480;.|
|000010e0| 09 2f 2a 20 68 65 69 67 | 68 74 20 69 6e 20 70 69 |./* heig|ht in pi|
|000010f0| 78 65 6c 73 20 2a 2f 0a | 58 20 20 2f 2a 20 4a 50 |xels */.|X /* JP|
|00001100| 45 47 20 76 69 65 77 73 | 20 61 6e 20 69 6d 61 67 |EG views| an imag|
|00001110| 65 20 61 73 20 62 65 69 | 6e 67 20 61 20 72 65 63 |e as bei|ng a rec|
|00001120| 74 61 6e 67 75 6c 61 72 | 20 61 72 72 61 79 20 6f |tangular| array o|
|00001130| 66 20 70 69 78 65 6c 73 | 2c 20 77 69 74 68 20 65 |f pixels|, with e|
|00001140| 61 63 68 0a 58 20 20 20 | 2a 20 70 69 78 65 6c 20 |ach.X |* pixel |
|00001150| 68 61 76 69 6e 67 20 74 | 68 65 20 73 61 6d 65 20 |having t|he same |
|00001160| 6e 75 6d 62 65 72 20 6f | 66 20 22 63 6f 6d 70 6f |number o|f "compo|
|00001170| 6e 65 6e 74 22 20 76 61 | 6c 75 65 73 20 28 63 6f |nent" va|lues (co|
|00001180| 6c 6f 72 20 63 68 61 6e | 6e 65 6c 73 29 2e 0a 58 |lor chan|nels)..X|
|00001190| 20 20 20 2a 20 59 6f 75 | 20 6d 75 73 74 20 73 70 | * You| must sp|
|000011a0| 65 63 69 66 79 20 68 6f | 77 20 6d 61 6e 79 20 63 |ecify ho|w many c|
|000011b0| 6f 6d 70 6f 6e 65 6e 74 | 73 20 74 68 65 72 65 20 |omponent|s there |
|000011c0| 61 72 65 20 61 6e 64 20 | 74 68 65 20 63 6f 6c 6f |are and |the colo|
|000011d0| 72 73 70 61 63 65 0a 58 | 20 20 20 2a 20 69 6e 74 |rspace.X| * int|
|000011e0| 65 72 70 72 65 74 61 74 | 69 6f 6e 20 6f 66 20 74 |erpretat|ion of t|
|000011f0| 68 65 20 63 6f 6d 70 6f | 6e 65 6e 74 73 2e 20 20 |he compo|nents. |
|00001200| 4d 6f 73 74 20 61 70 70 | 6c 69 63 61 74 69 6f 6e |Most app|lication|
|00001210| 73 20 77 69 6c 6c 20 75 | 73 65 20 52 47 42 20 64 |s will u|se RGB d|
|00001220| 61 74 61 20 6f 72 0a 58 | 20 20 20 2a 20 67 72 61 |ata or.X| * gra|
|00001230| 79 73 63 61 6c 65 20 64 | 61 74 61 2e 20 20 49 66 |yscale d|ata. If|
|00001240| 20 79 6f 75 20 77 61 6e | 74 20 74 6f 20 75 73 65 | you wan|t to use|
|00001250| 20 73 6f 6d 65 74 68 69 | 6e 67 20 65 6c 73 65 2c | somethi|ng else,|
|00001260| 20 79 6f 75 27 6c 6c 20 | 6e 65 65 64 20 74 6f 20 | you'll |need to |
|00001270| 73 74 75 64 79 0a 58 20 | 20 20 2a 20 61 6e 64 20 |study.X | * and |
|00001280| 70 65 72 68 61 70 73 20 | 6d 6f 64 69 66 79 20 6a |perhaps |modify j|
|00001290| 63 64 65 66 6c 74 73 2e | 63 2c 20 6a 63 63 6f 6c |cdeflts.|c, jccol|
|000012a0| 6f 72 2e 63 2c 20 61 6e | 64 20 6a 64 63 6f 6c 6f |or.c, an|d jdcolo|
|000012b0| 72 2e 63 2e 0a 58 20 20 | 20 2a 2f 0a 58 20 20 63 |r.c..X | */.X c|
|000012c0| 69 6e 66 6f 2d 3e 69 6e | 70 75 74 5f 63 6f 6d 70 |info->in|put_comp|
|000012d0| 6f 6e 65 6e 74 73 20 3d | 20 33 3b 09 09 2f 2a 20 |onents =| 3;../* |
|000012e0| 6f 72 20 31 20 66 6f 72 | 20 67 72 61 79 73 63 61 |or 1 for| graysca|
|000012f0| 6c 65 20 2a 2f 0a 58 20 | 20 63 69 6e 66 6f 2d 3e |le */.X | cinfo->|
|00001300| 69 6e 5f 63 6f 6c 6f 72 | 5f 73 70 61 63 65 20 3d |in_color|_space =|
|00001310| 20 43 53 5f 52 47 42 3b | 09 2f 2a 20 6f 72 20 43 | CS_RGB;|./* or C|
|00001320| 53 5f 47 52 41 59 53 43 | 41 4c 45 20 66 6f 72 20 |S_GRAYSC|ALE for |
|00001330| 67 72 61 79 73 63 61 6c | 65 20 2a 2f 0a 58 20 20 |grayscal|e */.X |
|00001340| 63 69 6e 66 6f 2d 3e 64 | 61 74 61 5f 70 72 65 63 |cinfo->d|ata_prec|
|00001350| 69 73 69 6f 6e 20 3d 20 | 38 3b 09 09 2f 2a 20 62 |ision = |8;../* b|
|00001360| 69 74 73 20 70 65 72 20 | 70 69 78 65 6c 20 63 6f |its per |pixel co|
|00001370| 6d 70 6f 6e 65 6e 74 20 | 76 61 6c 75 65 20 2a 2f |mponent |value */|
|00001380| 0a 58 20 20 2f 2a 20 49 | 6e 20 74 68 65 20 63 75 |.X /* I|n the cu|
|00001390| 72 72 65 6e 74 20 4a 50 | 45 47 20 73 6f 66 74 77 |rrent JP|EG softw|
|000013a0| 61 72 65 2c 20 64 61 74 | 61 5f 70 72 65 63 69 73 |are, dat|a_precis|
|000013b0| 69 6f 6e 20 6d 75 73 74 | 20 62 65 20 73 65 74 20 |ion must| be set |
|000013c0| 65 71 75 61 6c 20 74 6f | 0a 58 20 20 20 2a 20 42 |equal to|.X * B|
|000013d0| 49 54 53 5f 49 4e 5f 4a | 53 41 4d 50 4c 45 2c 20 |ITS_IN_J|SAMPLE, |
|000013e0| 77 68 69 63 68 20 69 73 | 20 38 20 75 6e 6c 65 73 |which is| 8 unles|
|000013f0| 73 20 79 6f 75 20 74 77 | 69 64 64 6c 65 20 6a 63 |s you tw|iddle jc|
|00001400| 6f 6e 66 69 67 2e 68 2e | 20 20 46 75 74 75 72 65 |onfig.h.| Future|
|00001410| 0a 58 20 20 20 2a 20 76 | 65 72 73 69 6f 6e 73 20 |.X * v|ersions |
|00001420| 6d 69 67 68 74 20 61 6c | 6c 6f 77 20 79 6f 75 20 |might al|low you |
|00001430| 74 6f 20 73 61 79 20 65 | 69 74 68 65 72 20 38 20 |to say e|ither 8 |
|00001440| 6f 72 20 31 32 20 69 66 | 20 63 6f 6d 70 69 6c 65 |or 12 if| compile|
|00001450| 64 20 77 69 74 68 0a 58 | 20 20 20 2a 20 31 32 2d |d with.X| * 12-|
|00001460| 62 69 74 20 4a 53 41 4d | 50 4c 45 73 2c 20 6f 72 |bit JSAM|PLEs, or|
|00001470| 20 75 70 20 74 6f 20 31 | 36 20 69 6e 20 6c 6f 73 | up to 1|6 in los|
|00001480| 73 6c 65 73 73 20 6d 6f | 64 65 2e 20 20 49 6e 20 |sless mo|de. In |
|00001490| 61 6e 79 20 63 61 73 65 | 2c 0a 58 20 20 20 2a 20 |any case|,.X * |
|000014a0| 69 74 20 69 73 20 75 70 | 20 74 6f 20 79 6f 75 20 |it is up| to you |
|000014b0| 74 6f 20 73 63 61 6c 65 | 20 69 6e 63 6f 6d 69 6e |to scale| incomin|
|000014c0| 67 20 70 69 78 65 6c 20 | 76 61 6c 75 65 73 20 74 |g pixel |values t|
|000014d0| 6f 20 74 68 65 20 72 61 | 6e 67 65 0a 58 20 20 20 |o the ra|nge.X |
|000014e0| 2a 20 20 20 30 20 2e 2e | 20 28 31 3c 3c 64 61 74 |* 0 ..| (1<<dat|
|000014f0| 61 5f 70 72 65 63 69 73 | 69 6f 6e 29 2d 31 2e 0a |a_precis|ion)-1..|
|00001500| 58 20 20 20 2a 20 49 66 | 20 79 6f 75 72 20 69 6d |X * If| your im|
|00001510| 61 67 65 20 64 61 74 61 | 20 66 6f 72 6d 61 74 20 |age data| format |
|00001520| 69 73 20 66 69 78 65 64 | 20 61 74 20 61 20 62 79 |is fixed| at a by|
|00001530| 74 65 20 70 65 72 20 63 | 6f 6d 70 6f 6e 65 6e 74 |te per c|omponent|
|00001540| 2c 0a 58 20 20 20 2a 20 | 74 68 65 6e 20 73 61 79 |,.X * |then say|
|00001550| 69 6e 67 20 22 38 22 20 | 69 73 20 70 72 6f 62 61 |ing "8" |is proba|
|00001560| 62 6c 79 20 74 68 65 20 | 62 65 73 74 20 6c 6f 6e |bly the |best lon|
|00001570| 67 2d 74 65 72 6d 20 73 | 6f 6c 75 74 69 6f 6e 2e |g-term s|olution.|
|00001580| 0a 58 20 20 20 2a 2f 0a | 58 7d 0a 58 0a 58 0a 58 |.X */.|X}.X.X.X|
|00001590| 2f 2a 0a 58 20 2a 20 54 | 68 69 73 20 66 75 6e 63 |/*.X * T|his func|
|000015a0| 74 69 6f 6e 20 69 73 20 | 63 61 6c 6c 65 64 20 72 |tion is |called r|
|000015b0| 65 70 65 61 74 65 64 6c | 79 20 61 6e 64 20 6d 75 |epeatedl|y and mu|
|000015c0| 73 74 20 73 75 70 70 6c | 79 20 74 68 65 20 6e 65 |st suppl|y the ne|
|000015d0| 78 74 20 72 6f 77 20 6f | 66 20 70 69 78 65 6c 73 |xt row o|f pixels|
|000015e0| 0a 58 20 2a 20 6f 6e 20 | 65 61 63 68 20 63 61 6c |.X * on |each cal|
|000015f0| 6c 2e 20 20 54 68 65 20 | 72 6f 77 73 20 4d 55 53 |l. The |rows MUS|
|00001600| 54 20 62 65 20 72 65 74 | 75 72 6e 65 64 20 69 6e |T be ret|urned in|
|00001610| 20 74 6f 70 2d 74 6f 2d | 62 6f 74 74 6f 6d 20 6f | top-to-|bottom o|
|00001620| 72 64 65 72 20 69 66 20 | 79 6f 75 20 77 61 6e 74 |rder if |you want|
|00001630| 0a 58 20 2a 20 79 6f 75 | 72 20 4a 50 45 47 20 66 |.X * you|r JPEG f|
|00001640| 69 6c 65 73 20 74 6f 20 | 62 65 20 63 6f 6d 70 61 |iles to |be compa|
|00001650| 74 69 62 6c 65 20 77 69 | 74 68 20 65 76 65 72 79 |tible wi|th every|
|00001660| 6f 6e 65 20 65 6c 73 65 | 27 73 2e 20 20 28 49 66 |one else|'s. (If|
|00001670| 20 79 6f 75 20 63 61 6e | 6e 6f 74 0a 58 20 2a 20 | you can|not.X * |
|00001680| 72 65 61 64 69 6c 79 20 | 72 65 61 64 20 79 6f 75 |readily |read you|
|00001690| 72 20 64 61 74 61 20 69 | 6e 20 74 68 61 74 20 6f |r data i|n that o|
|000016a0| 72 64 65 72 2c 20 79 6f | 75 27 6c 6c 20 6e 65 65 |rder, yo|u'll nee|
|000016b0| 64 20 61 6e 20 69 6e 74 | 65 72 6d 65 64 69 61 74 |d an int|ermediat|
|000016c0| 65 20 61 72 72 61 79 20 | 74 6f 0a 58 20 2a 20 68 |e array |to.X * h|
|000016d0| 6f 6c 64 20 74 68 65 20 | 69 6d 61 67 65 2e 20 20 |old the |image. |
|000016e0| 53 65 65 20 6a 72 64 74 | 61 72 67 61 2e 63 20 6f |See jrdt|arga.c o|
|000016f0| 72 20 6a 72 64 72 6c 65 | 2e 63 20 66 6f 72 20 65 |r jrdrle|.c for e|
|00001700| 78 61 6d 70 6c 65 73 20 | 6f 66 20 68 61 6e 64 6c |xamples |of handl|
|00001710| 69 6e 67 0a 58 20 2a 20 | 62 6f 74 74 6f 6d 2d 74 |ing.X * |bottom-t|
|00001720| 6f 2d 74 6f 70 20 73 6f | 75 72 63 65 20 64 61 74 |o-top so|urce dat|
|00001730| 61 20 75 73 69 6e 67 20 | 74 68 65 20 4a 50 45 47 |a using |the JPEG|
|00001740| 20 63 6f 64 65 27 73 20 | 70 6f 72 74 61 62 6c 65 | code's |portable|
|00001750| 20 6d 65 63 68 61 6e 69 | 73 6d 73 2e 29 0a 58 20 | mechani|sms.).X |
|00001760| 2a 20 54 68 65 20 64 61 | 74 61 20 69 73 20 74 6f |* The da|ta is to|
|00001770| 20 62 65 20 72 65 74 75 | 72 6e 65 64 20 69 6e 74 | be retu|rned int|
|00001780| 6f 20 61 20 32 2d 44 20 | 61 72 72 61 79 20 6f 66 |o a 2-D |array of|
|00001790| 20 4a 53 41 4d 50 4c 45 | 73 2c 20 69 6e 64 65 78 | JSAMPLE|s, index|
|000017a0| 65 64 20 61 73 0a 58 20 | 2a 09 09 4a 53 41 4d 50 |ed as.X |*..JSAMP|
|000017b0| 4c 45 20 70 69 78 65 6c | 5f 72 6f 77 5b 63 6f 6d |LE pixel|_row[com|
|000017c0| 70 6f 6e 65 6e 74 5d 5b | 63 6f 6c 75 6d 6e 5d 0a |ponent][|column].|
|000017d0| 58 20 2a 20 77 68 65 72 | 65 20 63 6f 6d 70 6f 6e |X * wher|e compon|
|000017e0| 65 6e 74 20 72 75 6e 73 | 20 66 72 6f 6d 20 30 20 |ent runs| from 0 |
|000017f0| 74 6f 20 63 69 6e 66 6f | 2d 3e 69 6e 70 75 74 5f |to cinfo|->input_|
|00001800| 63 6f 6d 70 6f 6e 65 6e | 74 73 2d 31 2c 20 61 6e |componen|ts-1, an|
|00001810| 64 20 63 6f 6c 75 6d 6e | 20 72 75 6e 73 0a 58 20 |d column| runs.X |
|00001820| 2a 20 66 72 6f 6d 20 30 | 20 74 6f 20 63 69 6e 66 |* from 0| to cinf|
|00001830| 6f 2d 3e 69 6d 61 67 65 | 5f 77 69 64 74 68 2d 31 |o->image|_width-1|
|00001840| 20 28 63 6f 6c 75 6d 6e | 20 30 20 69 73 20 6c 65 | (column| 0 is le|
|00001850| 66 74 20 65 64 67 65 20 | 6f 66 20 69 6d 61 67 65 |ft edge |of image|
|00001860| 29 2e 20 20 4e 6f 74 65 | 20 74 68 61 74 0a 58 20 |). Note| that.X |
|00001870| 2a 20 74 68 69 73 20 69 | 73 20 61 63 74 75 61 6c |* this i|s actual|
|00001880| 6c 79 20 61 6e 20 61 72 | 72 61 79 20 6f 66 20 70 |ly an ar|ray of p|
|00001890| 6f 69 6e 74 65 72 73 20 | 74 6f 20 61 72 72 61 79 |ointers |to array|
|000018a0| 73 20 72 61 74 68 65 72 | 20 74 68 61 6e 20 61 20 |s rather| than a |
|000018b0| 74 72 75 65 20 32 44 20 | 61 72 72 61 79 2c 0a 58 |true 2D |array,.X|
|000018c0| 20 2a 20 73 69 6e 63 65 | 20 43 20 64 6f 65 73 20 | * since| C does |
|000018d0| 6e 6f 74 20 73 75 70 70 | 6f 72 74 20 76 61 72 69 |not supp|ort vari|
|000018e0| 61 62 6c 65 2d 73 69 7a | 65 20 6d 75 6c 74 69 64 |able-siz|e multid|
|000018f0| 69 6d 65 6e 73 69 6f 6e | 61 6c 20 61 72 72 61 79 |imension|al array|
|00001900| 73 2e 0a 58 20 2a 20 4a | 53 41 4d 50 4c 45 20 69 |s..X * J|SAMPLE i|
|00001910| 73 20 74 79 70 69 63 61 | 6c 6c 79 20 74 79 70 65 |s typica|lly type|
|00001920| 64 65 66 27 64 20 61 73 | 20 22 75 6e 73 69 67 6e |def'd as| "unsign|
|00001930| 65 64 20 63 68 61 72 22 | 2e 0a 58 20 2a 2f 0a 58 |ed char"|..X */.X|
|00001940| 0a 58 0a 58 4d 45 54 48 | 4f 44 44 45 46 20 76 6f |.X.XMETH|ODDEF vo|
|00001950| 69 64 0a 58 67 65 74 5f | 69 6e 70 75 74 5f 72 6f |id.Xget_|input_ro|
|00001960| 77 20 28 63 6f 6d 70 72 | 65 73 73 5f 69 6e 66 6f |w (compr|ess_info|
|00001970| 5f 70 74 72 20 63 69 6e | 66 6f 2c 20 4a 53 41 4d |_ptr cin|fo, JSAM|
|00001980| 50 41 52 52 41 59 20 70 | 69 78 65 6c 5f 72 6f 77 |PARRAY p|ixel_row|
|00001990| 29 0a 58 2f 2a 20 52 65 | 61 64 20 6e 65 78 74 20 |).X/* Re|ad next |
|000019a0| 72 6f 77 20 6f 66 20 70 | 69 78 65 6c 73 20 69 6e |row of p|ixels in|
|000019b0| 74 6f 20 70 69 78 65 6c | 5f 72 6f 77 5b 5d 5b 5d |to pixel|_row[][]|
|000019c0| 20 2a 2f 0a 58 7b 0a 58 | 20 20 2f 2a 20 54 68 69 | */.X{.X| /* Thi|
|000019d0| 73 20 65 78 61 6d 70 6c | 65 20 73 68 6f 77 73 20 |s exampl|e shows |
|000019e0| 68 6f 77 20 79 6f 75 20 | 6d 69 67 68 74 20 72 65 |how you |might re|
|000019f0| 61 64 20 52 47 42 20 64 | 61 74 61 20 28 33 20 63 |ad RGB d|ata (3 c|
|00001a00| 6f 6d 70 6f 6e 65 6e 74 | 73 29 0a 58 20 20 20 2a |omponent|s).X *|
|00001a10| 20 66 72 6f 6d 20 61 6e | 20 69 6e 70 75 74 20 66 | from an| input f|
|00001a20| 69 6c 65 20 69 6e 20 77 | 68 69 63 68 20 74 68 65 |ile in w|hich the|
|00001a30| 20 64 61 74 61 20 69 73 | 20 73 74 6f 72 65 64 20 | data is| stored |
|00001a40| 33 20 62 79 74 65 73 20 | 70 65 72 20 70 69 78 65 |3 bytes |per pixe|
|00001a50| 6c 0a 58 20 20 20 2a 20 | 69 6e 20 6c 65 66 74 2d |l.X * |in left-|
|00001a60| 74 6f 2d 72 69 67 68 74 | 2c 20 74 6f 70 2d 74 6f |to-right|, top-to|
|00001a70| 2d 62 6f 74 74 6f 6d 20 | 6f 72 64 65 72 2e 0a 58 |-bottom |order..X|
|00001a80| 20 20 20 2a 2f 0a 58 20 | 20 72 65 67 69 73 74 65 | */.X | registe|
|00001a90| 72 20 46 49 4c 45 20 2a | 20 69 6e 66 69 6c 65 20 |r FILE *| infile |
|00001aa0| 3d 20 63 69 6e 66 6f 2d | 3e 69 6e 70 75 74 5f 66 |= cinfo-|>input_f|
|00001ab0| 69 6c 65 3b 0a 58 20 20 | 72 65 67 69 73 74 65 72 |ile;.X |register|
|00001ac0| 20 4a 53 41 4d 50 52 4f | 57 20 70 74 72 30 2c 20 | JSAMPRO|W ptr0, |
|00001ad0| 70 74 72 31 2c 20 70 74 | 72 32 3b 0a 58 20 20 72 |ptr1, pt|r2;.X r|
|00001ae0| 65 67 69 73 74 65 72 20 | 6c 6f 6e 67 20 63 6f 6c |egister |long col|
|00001af0| 3b 0a 58 20 20 0a 58 20 | 20 70 74 72 30 20 3d 20 |;.X .X | ptr0 = |
|00001b00| 70 69 78 65 6c 5f 72 6f | 77 5b 30 5d 3b 0a 58 20 |pixel_ro|w[0];.X |
|00001b10| 20 70 74 72 31 20 3d 20 | 70 69 78 65 6c 5f 72 6f | ptr1 = |pixel_ro|
|00001b20| 77 5b 31 5d 3b 0a 58 20 | 20 70 74 72 32 20 3d 20 |w[1];.X | ptr2 = |
|00001b30| 70 69 78 65 6c 5f 72 6f | 77 5b 32 5d 3b 0a 58 20 |pixel_ro|w[2];.X |
|00001b40| 20 66 6f 72 20 28 63 6f | 6c 20 3d 20 30 3b 20 63 | for (co|l = 0; c|
|00001b50| 6f 6c 20 3c 20 63 69 6e | 66 6f 2d 3e 69 6d 61 67 |ol < cin|fo->imag|
|00001b60| 65 5f 77 69 64 74 68 3b | 20 63 6f 6c 2b 2b 29 20 |e_width;| col++) |
|00001b70| 7b 0a 58 20 20 20 20 2a | 70 74 72 30 2b 2b 20 3d |{.X *|ptr0++ =|
|00001b80| 20 28 4a 53 41 4d 50 4c | 45 29 20 67 65 74 63 28 | (JSAMPL|E) getc(|
|00001b90| 69 6e 66 69 6c 65 29 3b | 20 2f 2a 20 72 65 64 20 |infile);| /* red |
|00001ba0| 2a 2f 0a 58 20 20 20 20 | 2a 70 74 72 31 2b 2b 20 |*/.X |*ptr1++ |
|00001bb0| 3d 20 28 4a 53 41 4d 50 | 4c 45 29 20 67 65 74 63 |= (JSAMP|LE) getc|
|00001bc0| 28 69 6e 66 69 6c 65 29 | 3b 20 2f 2a 20 67 72 65 |(infile)|; /* gre|
|00001bd0| 65 6e 20 2a 2f 0a 58 20 | 20 20 20 2a 70 74 72 32 |en */.X | *ptr2|
|00001be0| 2b 2b 20 3d 20 28 4a 53 | 41 4d 50 4c 45 29 20 67 |++ = (JS|AMPLE) g|
|00001bf0| 65 74 63 28 69 6e 66 69 | 6c 65 29 3b 20 2f 2a 20 |etc(infi|le); /* |
|00001c00| 62 6c 75 65 20 2a 2f 0a | 58 20 20 7d 0a 58 7d 0a |blue */.|X }.X}.|
|00001c10| 58 0a 58 0a 58 4d 45 54 | 48 4f 44 44 45 46 20 76 |X.X.XMET|HODDEF v|
|00001c20| 6f 69 64 0a 58 69 6e 70 | 75 74 5f 74 65 72 6d 20 |oid.Xinp|ut_term |
|00001c30| 28 63 6f 6d 70 72 65 73 | 73 5f 69 6e 66 6f 5f 70 |(compres|s_info_p|
|00001c40| 74 72 20 63 69 6e 66 6f | 29 0a 58 2f 2a 20 46 69 |tr cinfo|).X/* Fi|
|00001c50| 6e 69 73 68 20 75 70 20 | 61 74 20 74 68 65 20 65 |nish up |at the e|
|00001c60| 6e 64 20 6f 66 20 74 68 | 65 20 69 6e 70 75 74 20 |nd of th|e input |
|00001c70| 2a 2f 0a 58 7b 0a 58 20 | 20 2f 2a 20 54 68 69 73 |*/.X{.X | /* This|
|00001c80| 20 74 65 72 6d 69 6e 61 | 74 69 6f 6e 20 72 6f 75 | termina|tion rou|
|00001c90| 74 69 6e 65 20 77 69 6c | 6c 20 76 65 72 79 20 6f |tine wil|l very o|
|00001ca0| 66 74 65 6e 20 68 61 76 | 65 20 6e 6f 20 77 6f 72 |ften hav|e no wor|
|00001cb0| 6b 20 74 6f 20 64 6f 2c | 20 2a 2f 0a 58 20 20 2f |k to do,| */.X /|
|00001cc0| 2a 20 62 75 74 20 79 6f | 75 20 6d 75 73 74 20 70 |* but yo|u must p|
|00001cd0| 72 6f 76 69 64 65 20 69 | 74 20 61 6e 79 77 61 79 |rovide i|t anyway|
|00001ce0| 2e 20 2a 2f 0a 58 20 20 | 2f 2a 20 4e 6f 74 65 20 |. */.X |/* Note |
|00001cf0| 74 68 61 74 20 74 68 65 | 20 4a 50 45 47 20 63 6f |that the| JPEG co|
|00001d00| 64 65 20 77 69 6c 6c 20 | 6f 6e 6c 79 20 63 61 6c |de will |only cal|
|00001d10| 6c 20 69 74 20 64 75 72 | 69 6e 67 20 73 75 63 63 |l it dur|ing succ|
|00001d20| 65 73 73 66 75 6c 20 65 | 78 69 74 3b 20 2a 2f 0a |essful e|xit; */.|
|00001d30| 58 20 20 2f 2a 20 69 66 | 20 79 6f 75 20 77 61 6e |X /* if| you wan|
|00001d40| 74 20 69 74 20 63 61 6c | 6c 65 64 20 64 75 72 69 |t it cal|led duri|
|00001d50| 6e 67 20 65 72 72 6f 72 | 20 65 78 69 74 2c 20 79 |ng error| exit, y|
|00001d60| 6f 75 20 67 6f 74 74 61 | 20 64 6f 20 74 68 61 74 |ou gotta| do that|
|00001d70| 20 79 6f 75 72 73 65 6c | 66 2e 20 2a 2f 0a 58 7d | yoursel|f. */.X}|
|00001d80| 0a 58 0a 58 0a 58 2f 2a | 0a 58 20 2a 20 54 68 61 |.X.X.X/*|.X * Tha|
|00001d90| 74 27 73 20 69 74 20 66 | 6f 72 20 74 68 65 20 72 |t's it f|or the r|
|00001da0| 6f 75 74 69 6e 65 73 20 | 74 68 61 74 20 64 65 61 |outines |that dea|
|00001db0| 6c 20 77 69 74 68 20 72 | 65 61 64 69 6e 67 20 74 |l with r|eading t|
|00001dc0| 68 65 20 69 6e 70 75 74 | 20 69 6d 61 67 65 20 64 |he input| image d|
|00001dd0| 61 74 61 2e 0a 58 20 2a | 20 4e 6f 77 20 77 65 20 |ata..X *| Now we |
|00001de0| 68 61 76 65 20 6f 76 65 | 72 61 6c 6c 20 63 6f 6e |have ove|rall con|
|00001df0| 74 72 6f 6c 20 61 6e 64 | 20 70 61 72 61 6d 65 74 |trol and| paramet|
|00001e00| 65 72 20 73 65 6c 65 63 | 74 69 6f 6e 20 72 6f 75 |er selec|tion rou|
|00001e10| 74 69 6e 65 73 2e 0a 58 | 20 2a 2f 0a 58 0a 58 0a |tines..X| */.X.X.|
|00001e20| 58 2f 2a 0a 58 20 2a 20 | 54 68 69 73 20 72 6f 75 |X/*.X * |This rou|
|00001e30| 74 69 6e 65 20 6d 75 73 | 74 20 64 65 74 65 72 6d |tine mus|t determ|
|00001e40| 69 6e 65 20 77 68 61 74 | 20 6f 75 74 70 75 74 20 |ine what| output |
|00001e50| 4a 50 45 47 20 66 69 6c | 65 20 66 6f 72 6d 61 74 |JPEG fil|e format|
|00001e60| 20 69 73 20 74 6f 20 62 | 65 20 77 72 69 74 74 65 | is to b|e writte|
|00001e70| 6e 2c 0a 58 20 2a 20 61 | 6e 64 20 6d 61 6b 65 20 |n,.X * a|nd make |
|00001e80| 61 6e 79 20 6f 74 68 65 | 72 20 63 6f 6d 70 72 65 |any othe|r compre|
|00001e90| 73 73 69 6f 6e 20 70 61 | 72 61 6d 65 74 65 72 20 |ssion pa|rameter |
|00001ea0| 63 68 61 6e 67 65 73 20 | 74 68 61 74 20 61 72 65 |changes |that are|
|00001eb0| 20 64 65 73 69 72 61 62 | 6c 65 2e 0a 58 20 2a 20 | desirab|le..X * |
|00001ec0| 54 68 69 73 20 72 6f 75 | 74 69 6e 65 20 67 65 74 |This rou|tine get|
|00001ed0| 73 20 63 6f 6e 74 72 6f | 6c 20 61 66 74 65 72 20 |s contro|l after |
|00001ee0| 74 68 65 20 69 6e 70 75 | 74 20 66 69 6c 65 20 68 |the inpu|t file h|
|00001ef0| 65 61 64 65 72 20 68 61 | 73 20 62 65 65 6e 20 72 |eader ha|s been r|
|00001f00| 65 61 64 0a 58 20 2a 20 | 28 69 2e 65 2e 2c 20 72 |ead.X * |(i.e., r|
|00001f10| 69 67 68 74 20 61 66 74 | 65 72 20 69 6e 70 75 74 |ight aft|er input|
|00001f20| 5f 69 6e 69 74 20 68 61 | 73 20 62 65 65 6e 20 63 |_init ha|s been c|
|00001f30| 61 6c 6c 65 64 29 2e 20 | 20 59 6f 75 20 63 6f 75 |alled). | You cou|
|00001f40| 6c 64 20 63 6f 6d 62 69 | 6e 65 20 69 74 73 0a 58 |ld combi|ne its.X|
|00001f50| 20 2a 20 66 75 6e 63 74 | 69 6f 6e 73 20 69 6e 74 | * funct|ions int|
|00001f60| 6f 20 69 6e 70 75 74 5f | 69 6e 69 74 2c 20 6f 72 |o input_|init, or|
|00001f70| 20 65 76 65 6e 20 69 6e | 74 6f 20 74 68 65 20 6d | even in|to the m|
|00001f80| 61 69 6e 20 63 6f 6e 74 | 72 6f 6c 20 72 6f 75 74 |ain cont|rol rout|
|00001f90| 69 6e 65 2c 20 62 75 74 | 0a 58 20 2a 20 69 66 20 |ine, but|.X * if |
|00001fa0| 79 6f 75 20 68 61 76 65 | 20 73 65 76 65 72 61 6c |you have| several|
|00001fb0| 20 64 69 66 66 65 72 65 | 6e 74 20 69 6e 70 75 74 | differe|nt input|
|00001fc0| 5f 69 6e 69 74 20 72 6f | 75 74 69 6e 65 73 2c 20 |_init ro|utines, |
|00001fd0| 69 74 27 73 20 61 20 64 | 65 66 69 6e 69 74 65 20 |it's a d|efinite |
|00001fe0| 77 69 6e 0a 58 20 2a 20 | 74 6f 20 6b 65 65 70 20 |win.X * |to keep |
|00001ff0| 74 68 69 73 20 73 65 70 | 61 72 61 74 65 2e 20 20 |this sep|arate. |
|00002000| 59 6f 75 20 4d 55 53 54 | 20 73 75 70 70 6c 79 20 |You MUST| supply |
|00002010| 74 68 69 73 20 72 6f 75 | 74 69 6e 65 20 65 76 65 |this rou|tine eve|
|00002020| 6e 20 69 66 20 69 74 27 | 73 20 61 20 6e 6f 2d 6f |n if it'|s a no-o|
|00002030| 70 2e 0a 58 20 2a 2f 0a | 58 0a 58 4d 45 54 48 4f |p..X */.|X.XMETHO|
|00002040| 44 44 45 46 20 76 6f 69 | 64 0a 58 63 5f 75 69 5f |DDEF voi|d.Xc_ui_|
|00002050| 6d 65 74 68 6f 64 5f 73 | 65 6c 65 63 74 69 6f 6e |method_s|election|
|00002060| 20 28 63 6f 6d 70 72 65 | 73 73 5f 69 6e 66 6f 5f | (compre|ss_info_|
|00002070| 70 74 72 20 63 69 6e 66 | 6f 29 0a 58 7b 0a 58 20 |ptr cinf|o).X{.X |
|00002080| 20 2f 2a 20 49 66 20 74 | 68 65 20 69 6e 70 75 74 | /* If t|he input|
|00002090| 20 69 73 20 67 72 61 79 | 20 73 63 61 6c 65 2c 20 | is gray| scale, |
|000020a0| 67 65 6e 65 72 61 74 65 | 20 61 20 6d 6f 6e 6f 63 |generate| a monoc|
|000020b0| 68 72 6f 6d 65 20 4a 50 | 45 47 20 66 69 6c 65 2e |hrome JP|EG file.|
|000020c0| 20 2a 2f 0a 58 20 20 69 | 66 20 28 63 69 6e 66 6f | */.X i|f (cinfo|
|000020d0| 2d 3e 69 6e 5f 63 6f 6c | 6f 72 5f 73 70 61 63 65 |->in_col|or_space|
|000020e0| 20 3d 3d 20 43 53 5f 47 | 52 41 59 53 43 41 4c 45 | == CS_G|RAYSCALE|
|000020f0| 29 0a 58 20 20 20 20 6a | 5f 6d 6f 6e 6f 63 68 72 |).X j|_monochr|
|00002100| 6f 6d 65 5f 64 65 66 61 | 75 6c 74 28 63 69 6e 66 |ome_defa|ult(cinf|
|00002110| 6f 29 3b 0a 58 20 20 2f | 2a 20 46 6f 72 20 6e 6f |o);.X /|* For no|
|00002120| 77 2c 20 61 6c 77 61 79 | 73 20 73 65 6c 65 63 74 |w, alway|s select|
|00002130| 20 4a 46 49 46 20 6f 75 | 74 70 75 74 20 66 6f 72 | JFIF ou|tput for|
|00002140| 6d 61 74 2e 20 2a 2f 0a | 58 20 20 6a 73 65 6c 77 |mat. */.|X jselw|
|00002150| 6a 66 69 66 28 63 69 6e | 66 6f 29 3b 0a 58 7d 0a |jfif(cin|fo);.X}.|
|00002160| 58 0a 58 0a 58 2f 2a 0a | 58 20 2a 20 4f 4b 2c 20 |X.X.X/*.|X * OK, |
|00002170| 68 65 72 65 20 69 73 20 | 74 68 65 20 6d 61 69 6e |here is |the main|
|00002180| 20 66 75 6e 63 74 69 6f | 6e 20 74 68 61 74 20 61 | functio|n that a|
|00002190| 63 74 75 61 6c 6c 79 20 | 63 61 75 73 65 73 20 65 |ctually |causes e|
|000021a0| 76 65 72 79 74 68 69 6e | 67 20 74 6f 20 68 61 70 |verythin|g to hap|
|000021b0| 70 65 6e 2e 0a 58 20 2a | 20 57 65 20 61 73 73 75 |pen..X *| We assu|
|000021c0| 6d 65 20 68 65 72 65 20 | 74 68 61 74 20 74 68 65 |me here |that the|
|000021d0| 20 74 61 72 67 65 74 20 | 66 69 6c 65 6e 61 6d 65 | target |filename|
|000021e0| 20 69 73 20 73 75 70 70 | 6c 69 65 64 20 62 79 20 | is supp|lied by |
|000021f0| 74 68 65 20 63 61 6c 6c | 65 72 20 6f 66 20 74 68 |the call|er of th|
|00002200| 69 73 0a 58 20 2a 20 72 | 6f 75 74 69 6e 65 2c 20 |is.X * r|outine, |
|00002210| 61 6e 64 20 74 68 61 74 | 20 61 6c 6c 20 4a 50 45 |and that| all JPE|
|00002220| 47 20 63 6f 6d 70 72 65 | 73 73 69 6f 6e 20 70 61 |G compre|ssion pa|
|00002230| 72 61 6d 65 74 65 72 73 | 20 63 61 6e 20 62 65 20 |rameters| can be |
|00002240| 64 65 66 61 75 6c 74 20 | 76 61 6c 75 65 73 2e 0a |default |values..|
|00002250| 58 20 2a 2f 0a 58 0a 58 | 47 4c 4f 42 41 4c 20 76 |X */.X.X|GLOBAL v|
|00002260| 6f 69 64 0a 58 77 72 69 | 74 65 5f 4a 50 45 47 5f |oid.Xwri|te_JPEG_|
|00002270| 66 69 6c 65 20 28 63 68 | 61 72 20 2a 20 66 69 6c |file (ch|ar * fil|
|00002280| 65 6e 61 6d 65 29 0a 58 | 7b 0a 58 20 20 2f 2a 20 |ename).X|{.X /* |
|00002290| 54 68 65 73 65 20 74 68 | 72 65 65 20 73 74 72 75 |These th|ree stru|
|000022a0| 63 74 73 20 63 6f 6e 74 | 61 69 6e 20 4a 50 45 47 |cts cont|ain JPEG|
|000022b0| 20 70 61 72 61 6d 65 74 | 65 72 73 20 61 6e 64 20 | paramet|ers and |
|000022c0| 77 6f 72 6b 69 6e 67 20 | 64 61 74 61 2e 0a 58 20 |working |data..X |
|000022d0| 20 20 2a 20 54 68 65 79 | 20 6d 75 73 74 20 73 75 | * They| must su|
|000022e0| 72 76 69 76 65 20 66 6f | 72 20 74 68 65 20 64 75 |rvive fo|r the du|
|000022f0| 72 61 74 69 6f 6e 20 6f | 66 20 70 61 72 61 6d 65 |ration o|f parame|
|00002300| 74 65 72 20 73 65 74 75 | 70 20 61 6e 64 20 6f 6e |ter setu|p and on|
|00002310| 65 0a 58 20 20 20 2a 20 | 63 61 6c 6c 20 74 6f 20 |e.X * |call to |
|00002320| 6a 70 65 67 5f 63 6f 6d | 70 72 65 73 73 3b 20 74 |jpeg_com|press; t|
|00002330| 79 70 69 63 61 6c 6c 79 | 2c 20 6d 61 6b 69 6e 67 |ypically|, making|
|00002340| 20 74 68 65 6d 20 6c 6f | 63 61 6c 20 64 61 74 61 | them lo|cal data|
|00002350| 20 69 6e 20 74 68 65 0a | 58 20 20 20 2a 20 63 61 | in the.|X * ca|
|00002360| 6c 6c 69 6e 67 20 72 6f | 75 74 69 6e 65 20 69 73 |lling ro|utine is|
|00002370| 20 74 68 65 20 62 65 73 | 74 20 73 74 72 61 74 65 | the bes|t strate|
|00002380| 67 79 2e 0a 58 20 20 20 | 2a 2f 0a 58 20 20 73 74 |gy..X |*/.X st|
|00002390| 72 75 63 74 20 43 6f 6d | 70 72 65 73 73 5f 69 6e |ruct Com|press_in|
|000023a0| 66 6f 5f 73 74 72 75 63 | 74 20 63 69 6e 66 6f 3b |fo_struc|t cinfo;|
|000023b0| 0a 58 20 20 73 74 72 75 | 63 74 20 43 6f 6d 70 72 |.X stru|ct Compr|
|000023c0| 65 73 73 5f 6d 65 74 68 | 6f 64 73 5f 73 74 72 75 |ess_meth|ods_stru|
|000023d0| 63 74 20 63 5f 6d 65 74 | 68 6f 64 73 3b 0a 58 20 |ct c_met|hods;.X |
|000023e0| 20 73 74 72 75 63 74 20 | 45 78 74 65 72 6e 61 6c | struct |External|
|000023f0| 5f 6d 65 74 68 6f 64 73 | 5f 73 74 72 75 63 74 20 |_methods|_struct |
|00002400| 65 5f 6d 65 74 68 6f 64 | 73 3b 0a 58 0a 58 20 20 |e_method|s;.X.X |
|00002410| 2f 2a 20 49 6e 69 74 69 | 61 6c 69 7a 65 20 74 68 |/* Initi|alize th|
|00002420| 65 20 73 79 73 74 65 6d | 2d 64 65 70 65 6e 64 65 |e system|-depende|
|00002430| 6e 74 20 6d 65 74 68 6f | 64 20 70 6f 69 6e 74 65 |nt metho|d pointe|
|00002440| 72 73 2e 20 2a 2f 0a 58 | 20 20 63 69 6e 66 6f 2e |rs. */.X| cinfo.|
|00002450| 6d 65 74 68 6f 64 73 20 | 3d 20 26 63 5f 6d 65 74 |methods |= &c_met|
|00002460| 68 6f 64 73 3b 09 2f 2a | 20 6c 69 6e 6b 73 20 74 |hods;./*| links t|
|00002470| 6f 20 6d 65 74 68 6f 64 | 20 73 74 72 75 63 74 73 |o method| structs|
|00002480| 20 2a 2f 0a 58 20 20 63 | 69 6e 66 6f 2e 65 6d 65 | */.X c|info.eme|
|00002490| 74 68 6f 64 73 20 3d 20 | 26 65 5f 6d 65 74 68 6f |thods = |&e_metho|
|000024a0| 64 73 3b 0a 58 20 20 2f | 2a 20 48 65 72 65 20 77 |ds;.X /|* Here w|
|000024b0| 65 20 75 73 65 20 74 68 | 65 20 64 65 66 61 75 6c |e use th|e defaul|
|000024c0| 74 20 4a 50 45 47 20 65 | 72 72 6f 72 20 68 61 6e |t JPEG e|rror han|
|000024d0| 64 6c 65 72 2c 20 77 68 | 69 63 68 20 77 69 6c 6c |dler, wh|ich will|
|000024e0| 20 6a 75 73 74 20 70 72 | 69 6e 74 0a 58 20 20 20 | just pr|int.X |
|000024f0| 2a 20 61 6e 20 65 72 72 | 6f 72 20 6d 65 73 73 61 |* an err|or messa|
|00002500| 67 65 20 6f 6e 20 73 74 | 64 65 72 72 20 61 6e 64 |ge on st|derr and|
|00002510| 20 63 61 6c 6c 20 65 78 | 69 74 28 29 2e 20 20 53 | call ex|it(). S|
|00002520| 65 65 20 74 68 65 20 73 | 65 63 6f 6e 64 20 68 61 |ee the s|econd ha|
|00002530| 6c 66 20 6f 66 0a 58 20 | 20 20 2a 20 74 68 69 73 |lf of.X | * this|
|00002540| 20 66 69 6c 65 20 66 6f | 72 20 61 6e 20 65 78 61 | file fo|r an exa|
|00002550| 6d 70 6c 65 20 6f 66 20 | 6d 6f 72 65 20 67 72 61 |mple of |more gra|
|00002560| 63 65 66 75 6c 20 65 72 | 72 6f 72 20 72 65 63 6f |ceful er|ror reco|
|00002570| 76 65 72 79 2e 0a 58 20 | 20 20 2a 2f 0a 58 20 20 |very..X | */.X |
|00002580| 6a 73 65 6c 65 72 72 6f | 72 28 26 65 5f 6d 65 74 |jselerro|r(&e_met|
|00002590| 68 6f 64 73 29 3b 09 2f | 2a 20 73 65 6c 65 63 74 |hods);./|* select|
|000025a0| 20 73 74 64 20 65 72 72 | 6f 72 2f 74 72 61 63 65 | std err|or/trace|
|000025b0| 20 6d 65 73 73 61 67 65 | 20 72 6f 75 74 69 6e 65 | message| routine|
|000025c0| 73 20 2a 2f 0a 58 20 20 | 2f 2a 20 48 65 72 65 20 |s */.X |/* Here |
|000025d0| 77 65 20 75 73 65 20 74 | 68 65 20 73 74 61 6e 64 |we use t|he stand|
|000025e0| 61 72 64 20 6d 65 6d 6f | 72 79 20 6d 61 6e 61 67 |ard memo|ry manag|
|000025f0| 65 72 20 70 72 6f 76 69 | 64 65 64 20 77 69 74 68 |er provi|ded with|
|00002600| 20 74 68 65 20 4a 50 45 | 47 20 63 6f 64 65 2e 0a | the JPE|G code..|
|00002610| 58 20 20 20 2a 20 49 6e | 20 73 6f 6d 65 20 63 61 |X * In| some ca|
|00002620| 73 65 73 20 79 6f 75 20 | 6d 69 67 68 74 20 77 61 |ses you |might wa|
|00002630| 6e 74 20 74 6f 20 72 65 | 70 6c 61 63 65 20 74 68 |nt to re|place th|
|00002640| 65 20 6d 65 6d 6f 72 79 | 20 6d 61 6e 61 67 65 72 |e memory| manager|
|00002650| 2c 20 6f 72 20 61 74 0a | 58 20 20 20 2a 20 6c 65 |, or at.|X * le|
|00002660| 61 73 74 20 74 68 65 20 | 73 79 73 74 65 6d 2d 64 |ast the |system-d|
|00002670| 65 70 65 6e 64 65 6e 74 | 20 70 61 72 74 20 6f 66 |ependent| part of|
|00002680| 20 69 74 2c 20 77 69 74 | 68 20 79 6f 75 72 20 6f | it, wit|h your o|
|00002690| 77 6e 20 63 6f 64 65 2e | 0a 58 20 20 20 2a 2f 0a |wn code.|.X */.|
|000026a0| 58 20 20 6a 73 65 6c 6d | 65 6d 6d 67 72 28 26 65 |X jselm|emmgr(&e|
|000026b0| 5f 6d 65 74 68 6f 64 73 | 29 3b 09 2f 2a 20 73 65 |_methods|);./* se|
|000026c0| 6c 65 63 74 20 73 74 64 | 20 6d 65 6d 6f 72 79 20 |lect std| memory |
|000026d0| 61 6c 6c 6f 63 61 74 69 | 6f 6e 20 72 6f 75 74 69 |allocati|on routi|
|000026e0| 6e 65 73 20 2a 2f 0a 58 | 20 20 2f 2a 20 49 66 20 |nes */.X| /* If |
|000026f0| 74 68 65 20 63 6f 6d 70 | 72 65 73 73 6f 72 20 72 |the comp|ressor r|
|00002700| 65 71 75 69 72 65 73 20 | 66 75 6c 6c 2d 69 6d 61 |equires |full-ima|
|00002710| 67 65 20 62 75 66 66 65 | 72 73 20 28 66 6f 72 20 |ge buffe|rs (for |
|00002720| 65 6e 74 72 6f 70 79 2d | 63 6f 64 69 6e 67 0a 58 |entropy-|coding.X|
|00002730| 20 20 20 2a 20 6f 70 74 | 69 6d 69 7a 61 74 69 6f | * opt|imizatio|
|00002740| 6e 20 6f 72 20 61 20 6e | 6f 6e 69 6e 74 65 72 6c |n or a n|oninterl|
|00002750| 65 61 76 65 64 20 4a 50 | 45 47 20 66 69 6c 65 29 |eaved JP|EG file)|
|00002760| 2c 20 69 74 20 77 69 6c | 6c 20 63 72 65 61 74 65 |, it wil|l create|
|00002770| 20 74 65 6d 70 6f 72 61 | 72 79 0a 58 20 20 20 2a | tempora|ry.X *|
|00002780| 20 66 69 6c 65 73 20 66 | 6f 72 20 61 6e 79 74 68 | files f|or anyth|
|00002790| 69 6e 67 20 74 68 61 74 | 20 64 6f 65 73 6e 27 74 |ing that| doesn't|
|000027a0| 20 66 69 74 20 77 69 74 | 68 69 6e 20 74 68 65 20 | fit wit|hin the |
|000027b0| 6d 61 78 69 6d 75 6d 2d | 6d 65 6d 6f 72 79 20 73 |maximum-|memory s|
|000027c0| 65 74 74 69 6e 67 2e 0a | 58 20 20 20 2a 20 28 4e |etting..|X * (N|
|000027d0| 6f 74 65 20 74 68 61 74 | 20 74 65 6d 70 20 66 69 |ote that| temp fi|
|000027e0| 6c 65 73 20 61 72 65 20 | 4e 4f 54 20 6e 65 65 64 |les are |NOT need|
|000027f0| 65 64 20 69 66 20 79 6f | 75 20 75 73 65 20 74 68 |ed if yo|u use th|
|00002800| 65 20 64 65 66 61 75 6c | 74 20 70 61 72 61 6d 65 |e defaul|t parame|
|00002810| 74 65 72 73 2e 29 0a 58 | 20 20 20 2a 20 59 6f 75 |ters.).X| * You|
|00002820| 20 63 61 6e 20 63 68 61 | 6e 67 65 20 74 68 65 20 | can cha|nge the |
|00002830| 64 65 66 61 75 6c 74 20 | 6d 61 78 69 6d 75 6d 2d |default |maximum-|
|00002840| 6d 65 6d 6f 72 79 20 73 | 65 74 74 69 6e 67 20 62 |memory s|etting b|
|00002850| 79 20 63 68 61 6e 67 69 | 6e 67 0a 58 20 20 20 2a |y changi|ng.X *|
|00002860| 20 65 5f 6d 65 74 68 6f | 64 73 2e 6d 61 78 5f 6d | e_metho|ds.max_m|
|00002870| 65 6d 6f 72 79 5f 74 6f | 5f 75 73 65 20 61 66 74 |emory_to|_use aft|
|00002880| 65 72 20 6a 73 65 6c 6d | 65 6d 6d 67 72 20 72 65 |er jselm|emmgr re|
|00002890| 74 75 72 6e 73 2e 0a 58 | 20 20 20 2a 20 4f 6e 20 |turns..X| * On |
|000028a0| 73 6f 6d 65 20 73 79 73 | 74 65 6d 73 20 79 6f 75 |some sys|tems you|
|000028b0| 20 6d 61 79 20 61 6c 73 | 6f 20 6e 65 65 64 20 74 | may als|o need t|
|000028c0| 6f 20 73 65 74 20 75 70 | 20 61 20 73 69 67 6e 61 |o set up| a signa|
|000028d0| 6c 20 68 61 6e 64 6c 65 | 72 20 74 6f 0a 58 20 20 |l handle|r to.X |
|000028e0| 20 2a 20 65 6e 73 75 72 | 65 20 74 68 61 74 20 74 | * ensur|e that t|
|000028f0| 65 6d 70 6f 72 61 72 79 | 20 66 69 6c 65 73 20 61 |emporary| files a|
|00002900| 72 65 20 64 65 6c 65 74 | 65 64 20 69 66 20 74 68 |re delet|ed if th|
|00002910| 65 20 70 72 6f 67 72 61 | 6d 20 69 73 20 69 6e 74 |e progra|m is int|
|00002920| 65 72 72 75 70 74 65 64 | 2e 0a 58 20 20 20 2a 20 |errupted|..X * |
|00002930| 28 54 68 69 73 20 69 73 | 20 6d 6f 73 74 20 69 6d |(This is| most im|
|00002940| 70 6f 72 74 61 6e 74 20 | 69 66 20 79 6f 75 20 61 |portant |if you a|
|00002950| 72 65 20 6f 6e 20 4d 53 | 2d 44 4f 53 20 61 6e 64 |re on MS|-DOS and|
|00002960| 20 75 73 65 20 74 68 65 | 20 6a 6d 65 6d 64 6f 73 | use the| jmemdos|
|00002970| 2e 63 0a 58 20 20 20 2a | 20 6d 65 6d 6f 72 79 20 |.c.X *| memory |
|00002980| 6d 61 6e 61 67 65 72 20 | 62 61 63 6b 20 65 6e 64 |manager |back end|
|00002990| 3b 20 69 74 20 77 69 6c | 6c 20 74 72 79 20 74 6f |; it wil|l try to|
|000029a0| 20 67 72 61 62 20 65 78 | 74 65 6e 64 65 64 20 6d | grab ex|tended m|
|000029b0| 65 6d 6f 72 79 20 66 6f | 72 0a 58 20 20 20 2a 20 |emory fo|r.X * |
|000029c0| 74 65 6d 70 20 66 69 6c | 65 73 2c 20 61 6e 64 20 |temp fil|es, and |
|000029d0| 74 68 61 74 20 73 70 61 | 63 65 20 77 69 6c 6c 20 |that spa|ce will |
|000029e0| 4e 4f 54 20 62 65 20 66 | 72 65 65 64 20 61 75 74 |NOT be f|reed aut|
|000029f0| 6f 6d 61 74 69 63 61 6c | 6c 79 2e 29 0a 58 20 20 |omatical|ly.).X |
|00002a00| 20 2a 20 53 65 65 20 6a | 63 6d 61 69 6e 2e 63 20 | * See j|cmain.c |
|00002a10| 6f 72 20 6a 64 6d 61 69 | 6e 2e 63 20 66 6f 72 20 |or jdmai|n.c for |
|00002a20| 61 6e 20 65 78 61 6d 70 | 6c 65 20 73 69 67 6e 61 |an examp|le signa|
|00002a30| 6c 20 68 61 6e 64 6c 65 | 72 2e 0a 58 20 20 20 2a |l handle|r..X *|
|00002a40| 2f 0a 58 0a 58 20 20 2f | 2a 20 48 65 72 65 2c 20 |/.X.X /|* Here, |
|00002a50| 73 65 74 20 75 70 20 70 | 6f 69 6e 74 65 72 73 20 |set up p|ointers |
|00002a60| 74 6f 20 79 6f 75 72 20 | 6f 77 6e 20 72 6f 75 74 |to your |own rout|
|00002a70| 69 6e 65 73 20 66 6f 72 | 20 69 6e 70 75 74 20 64 |ines for| input d|
|00002a80| 61 74 61 20 68 61 6e 64 | 6c 69 6e 67 0a 58 20 20 |ata hand|ling.X |
|00002a90| 20 2a 20 61 6e 64 20 70 | 6f 73 74 2d 69 6e 69 74 | * and p|ost-init|
|00002aa0| 20 70 61 72 61 6d 65 74 | 65 72 20 73 65 6c 65 63 | paramet|er selec|
|00002ab0| 74 69 6f 6e 2e 0a 58 20 | 20 20 2a 2f 0a 58 20 20 |tion..X | */.X |
|00002ac0| 63 5f 6d 65 74 68 6f 64 | 73 2e 69 6e 70 75 74 5f |c_method|s.input_|
|00002ad0| 69 6e 69 74 20 3d 20 69 | 6e 70 75 74 5f 69 6e 69 |init = i|nput_ini|
|00002ae0| 74 3b 0a 58 20 20 63 5f | 6d 65 74 68 6f 64 73 2e |t;.X c_|methods.|
|00002af0| 67 65 74 5f 69 6e 70 75 | 74 5f 72 6f 77 20 3d 20 |get_inpu|t_row = |
|00002b00| 67 65 74 5f 69 6e 70 75 | 74 5f 72 6f 77 3b 0a 58 |get_inpu|t_row;.X|
|00002b10| 20 20 63 5f 6d 65 74 68 | 6f 64 73 2e 69 6e 70 75 | c_meth|ods.inpu|
|00002b20| 74 5f 74 65 72 6d 20 3d | 20 69 6e 70 75 74 5f 74 |t_term =| input_t|
|00002b30| 65 72 6d 3b 0a 58 20 20 | 63 5f 6d 65 74 68 6f 64 |erm;.X |c_method|
|00002b40| 73 2e 63 5f 75 69 5f 6d | 65 74 68 6f 64 5f 73 65 |s.c_ui_m|ethod_se|
|00002b50| 6c 65 63 74 69 6f 6e 20 | 3d 20 63 5f 75 69 5f 6d |lection |= c_ui_m|
|00002b60| 65 74 68 6f 64 5f 73 65 | 6c 65 63 74 69 6f 6e 3b |ethod_se|lection;|
|00002b70| 0a 58 0a 58 20 20 2f 2a | 20 53 65 74 20 75 70 20 |.X.X /*| Set up |
|00002b80| 64 65 66 61 75 6c 74 20 | 4a 50 45 47 20 70 61 72 |default |JPEG par|
|00002b90| 61 6d 65 74 65 72 73 20 | 69 6e 20 74 68 65 20 63 |ameters |in the c|
|00002ba0| 69 6e 66 6f 20 64 61 74 | 61 20 73 74 72 75 63 74 |info dat|a struct|
|00002bb0| 75 72 65 2e 20 2a 2f 0a | 58 20 20 6a 5f 63 5f 64 |ure. */.|X j_c_d|
|00002bc0| 65 66 61 75 6c 74 73 28 | 26 63 69 6e 66 6f 2c 20 |efaults(|&cinfo, |
|00002bd0| 37 35 2c 20 46 41 4c 53 | 45 29 3b 0a 58 20 20 2f |75, FALS|E);.X /|
|00002be0| 2a 20 4e 6f 74 65 3a 20 | 37 35 20 69 73 20 74 68 |* Note: |75 is th|
|00002bf0| 65 20 72 65 63 6f 6d 6d | 65 6e 64 65 64 20 64 65 |e recomm|ended de|
|00002c00| 66 61 75 6c 74 20 71 75 | 61 6c 69 74 79 20 6c 65 |fault qu|ality le|
|00002c10| 76 65 6c 3b 20 79 6f 75 | 20 6d 61 79 20 69 6e 73 |vel; you| may ins|
|00002c20| 74 65 61 64 20 70 61 73 | 73 0a 58 20 20 20 2a 20 |tead pas|s.X * |
|00002c30| 61 20 75 73 65 72 2d 73 | 70 65 63 69 66 69 65 64 |a user-s|pecified|
|00002c40| 20 71 75 61 6c 69 74 79 | 20 6c 65 76 65 6c 2e 20 | quality| level. |
|00002c50| 20 42 65 20 61 77 61 72 | 65 20 74 68 61 74 20 76 | Be awar|e that v|
|00002c60| 61 6c 75 65 73 20 62 65 | 6c 6f 77 20 32 35 20 77 |alues be|low 25 w|
|00002c70| 69 6c 6c 20 63 61 75 73 | 65 0a 58 20 20 20 2a 20 |ill caus|e.X * |
|00002c80| 6e 6f 6e 2d 62 61 73 65 | 6c 69 6e 65 20 4a 50 45 |non-base|line JPE|
|00002c90| 47 20 66 69 6c 65 73 20 | 74 6f 20 62 65 20 63 72 |G files |to be cr|
|00002ca0| 65 61 74 65 64 20 28 61 | 6e 64 20 61 20 77 61 72 |eated (a|nd a war|
|00002cb0| 6e 69 6e 67 20 6d 65 73 | 73 61 67 65 20 74 6f 20 |ning mes|sage to |
|00002cc0| 74 68 61 74 0a 58 20 20 | 20 2a 20 65 66 66 65 63 |that.X | * effec|
|00002cd0| 74 20 74 6f 20 62 65 20 | 65 6d 69 74 74 65 64 20 |t to be |emitted |
|00002ce0| 6f 6e 20 73 74 64 65 72 | 72 29 2e 20 20 54 68 69 |on stder|r). Thi|
|00002cf0| 73 20 77 6f 6e 27 74 20 | 62 6f 74 68 65 72 20 6f |s won't |bother o|
|00002d00| 75 72 20 64 65 63 6f 64 | 65 72 2c 20 62 75 74 20 |ur decod|er, but |
|00002d10| 73 6f 6d 65 0a 58 20 20 | 20 2a 20 63 6f 6d 6d 65 |some.X | * comme|
|00002d20| 72 63 69 61 6c 20 4a 50 | 45 47 20 69 6d 70 6c 65 |rcial JP|EG imple|
|00002d30| 6d 65 6e 74 61 74 69 6f | 6e 73 20 6d 61 79 20 63 |mentatio|ns may c|
|00002d40| 68 6f 6b 65 20 6f 6e 20 | 6e 6f 6e 2d 62 61 73 65 |hoke on |non-base|
|00002d50| 6c 69 6e 65 20 4a 50 45 | 47 20 66 69 6c 65 73 2e |line JPE|G files.|
|00002d60| 0a 58 20 20 20 2a 20 49 | 66 20 79 6f 75 20 77 61 |.X * I|f you wa|
|00002d70| 6e 74 20 74 6f 20 66 6f | 72 63 65 20 62 61 73 65 |nt to fo|rce base|
|00002d80| 6c 69 6e 65 20 63 6f 6d | 70 61 74 69 62 69 6c 69 |line com|patibili|
|00002d90| 74 79 2c 20 70 61 73 73 | 20 54 52 55 45 20 69 6e |ty, pass| TRUE in|
|00002da0| 73 74 65 61 64 20 6f 66 | 20 46 41 4c 53 45 2e 0a |stead of| FALSE..|
|00002db0| 58 20 20 20 2a 20 28 49 | 66 20 6e 6f 6e 2d 62 61 |X * (I|f non-ba|
|00002dc0| 73 65 6c 69 6e 65 20 66 | 69 6c 65 73 20 61 72 65 |seline f|iles are|
|00002dd0| 20 66 69 6e 65 2c 20 62 | 75 74 20 79 6f 75 20 63 | fine, b|ut you c|
|00002de0| 6f 75 6c 64 20 64 6f 20 | 77 69 74 68 6f 75 74 20 |ould do |without |
|00002df0| 74 68 61 74 20 77 61 72 | 6e 69 6e 67 0a 58 20 20 |that war|ning.X |
|00002e00| 20 2a 20 6d 65 73 73 61 | 67 65 2c 20 73 65 74 20 | * messa|ge, set |
|00002e10| 65 5f 6d 65 74 68 6f 64 | 73 2e 74 72 61 63 65 5f |e_method|s.trace_|
|00002e20| 6c 65 76 65 6c 20 74 6f | 20 2d 31 2e 29 0a 58 20 |level to| -1.).X |
|00002e30| 20 20 2a 2f 0a 58 0a 58 | 20 20 2f 2a 20 41 74 20 | */.X.X| /* At |
|00002e40| 74 68 69 73 20 70 6f 69 | 6e 74 20 79 6f 75 20 63 |this poi|nt you c|
|00002e50| 61 6e 20 6d 6f 64 69 66 | 79 20 74 68 65 20 64 65 |an modif|y the de|
|00002e60| 66 61 75 6c 74 20 70 61 | 72 61 6d 65 74 65 72 73 |fault pa|rameters|
|00002e70| 20 73 65 74 20 62 79 20 | 6a 5f 63 5f 64 65 66 61 | set by |j_c_defa|
|00002e80| 75 6c 74 73 0a 58 20 20 | 20 2a 20 61 73 20 6e 65 |ults.X | * as ne|
|00002e90| 65 64 65 64 2e 20 20 46 | 6f 72 20 61 20 6d 69 6e |eded. F|or a min|
|00002ea0| 69 6d 61 6c 20 69 6d 70 | 6c 65 6d 65 6e 74 61 74 |imal imp|lementat|
|00002eb0| 69 6f 6e 2c 20 79 6f 75 | 20 73 68 6f 75 6c 64 6e |ion, you| shouldn|
|00002ec0| 27 74 20 6e 65 65 64 20 | 74 6f 20 63 68 61 6e 67 |'t need |to chang|
|00002ed0| 65 0a 58 20 20 20 2a 20 | 61 6e 79 74 68 69 6e 67 |e.X * |anything|
|00002ee0| 2e 20 20 53 65 65 20 6a | 63 6d 61 69 6e 2e 63 20 |. See j|cmain.c |
|00002ef0| 66 6f 72 20 73 6f 6d 65 | 20 65 78 61 6d 70 6c 65 |for some| example|
|00002f00| 73 20 6f 66 20 77 68 61 | 74 20 79 6f 75 20 6d 69 |s of wha|t you mi|
|00002f10| 67 68 74 20 63 68 61 6e | 67 65 2e 0a 58 20 20 20 |ght chan|ge..X |
|00002f20| 2a 2f 0a 58 0a 58 20 20 | 2f 2a 20 53 65 6c 65 63 |*/.X.X |/* Selec|
|00002f30| 74 20 74 68 65 20 69 6e | 70 75 74 20 61 6e 64 20 |t the in|put and |
|00002f40| 6f 75 74 70 75 74 20 66 | 69 6c 65 73 2e 0a 58 20 |output f|iles..X |
|00002f50| 20 20 2a 20 4e 6f 74 65 | 20 74 68 61 74 20 63 69 | * Note| that ci|
|00002f60| 6e 66 6f 2e 69 6e 70 75 | 74 5f 66 69 6c 65 20 69 |nfo.inpu|t_file i|
|00002f70| 73 20 6f 6e 6c 79 20 75 | 73 65 64 20 69 66 20 79 |s only u|sed if y|
|00002f80| 6f 75 72 20 69 6e 70 75 | 74 20 72 65 61 64 69 6e |our inpu|t readin|
|00002f90| 67 20 72 6f 75 74 69 6e | 65 73 0a 58 20 20 20 2a |g routin|es.X *|
|00002fa0| 20 75 73 65 20 69 74 3b | 20 6f 74 68 65 72 77 69 | use it;| otherwi|
|00002fb0| 73 65 2c 20 79 6f 75 20 | 63 61 6e 20 6a 75 73 74 |se, you |can just|
|00002fc0| 20 6d 61 6b 65 20 69 74 | 20 4e 55 4c 4c 2e 0a 58 | make it| NULL..X|
|00002fd0| 20 20 20 2a 20 56 45 52 | 59 20 49 4d 50 4f 52 54 | * VER|Y IMPORT|
|00002fe0| 41 4e 54 3a 20 75 73 65 | 20 22 62 22 20 6f 70 74 |ANT: use| "b" opt|
|00002ff0| 69 6f 6e 20 74 6f 20 66 | 6f 70 65 6e 28 29 20 69 |ion to f|open() i|
|00003000| 66 20 79 6f 75 20 61 72 | 65 20 6f 6e 20 61 20 6d |f you ar|e on a m|
|00003010| 61 63 68 69 6e 65 20 74 | 68 61 74 0a 58 20 20 20 |achine t|hat.X |
|00003020| 2a 20 72 65 71 75 69 72 | 65 73 20 69 74 20 69 6e |* requir|es it in|
|00003030| 20 6f 72 64 65 72 20 74 | 6f 20 77 72 69 74 65 20 | order t|o write |
|00003040| 62 69 6e 61 72 79 20 66 | 69 6c 65 73 2e 0a 58 20 |binary f|iles..X |
|00003050| 20 20 2a 2f 0a 58 0a 58 | 20 20 63 69 6e 66 6f 2e | */.X.X| cinfo.|
|00003060| 69 6e 70 75 74 5f 66 69 | 6c 65 20 3d 20 4e 55 4c |input_fi|le = NUL|
|00003070| 4c 3b 09 2f 2a 20 69 66 | 20 6e 6f 20 61 63 74 75 |L;./* if| no actu|
|00003080| 61 6c 20 69 6e 70 75 74 | 20 66 69 6c 65 20 69 6e |al input| file in|
|00003090| 76 6f 6c 76 65 64 20 2a | 2f 0a 58 0a 58 20 20 69 |volved *|/.X.X i|
|000030a0| 66 20 28 28 63 69 6e 66 | 6f 2e 6f 75 74 70 75 74 |f ((cinf|o.output|
|000030b0| 5f 66 69 6c 65 20 3d 20 | 66 6f 70 65 6e 28 66 69 |_file = |fopen(fi|
|000030c0| 6c 65 6e 61 6d 65 2c 20 | 22 77 62 22 29 29 20 3d |lename, |"wb")) =|
|000030d0| 3d 20 4e 55 4c 4c 29 20 | 7b 0a 58 20 20 20 20 66 |= NULL) |{.X f|
|000030e0| 70 72 69 6e 74 66 28 73 | 74 64 65 72 72 2c 20 22 |printf(s|tderr, "|
|000030f0| 63 61 6e 27 74 20 6f 70 | 65 6e 20 25 73 5c 6e 22 |can't op|en %s\n"|
|00003100| 2c 20 66 69 6c 65 6e 61 | 6d 65 29 3b 0a 58 20 20 |, filena|me);.X |
|00003110| 20 20 65 78 69 74 28 31 | 29 3b 0a 58 20 20 7d 0a | exit(1|);.X }.|
|00003120| 58 0a 58 20 20 2f 2a 20 | 48 65 72 65 20 77 65 20 |X.X /* |Here we |
|00003130| 67 6f 21 20 2a 2f 0a 58 | 20 20 6a 70 65 67 5f 63 |go! */.X| jpeg_c|
|00003140| 6f 6d 70 72 65 73 73 28 | 26 63 69 6e 66 6f 29 3b |ompress(|&cinfo);|
|00003150| 0a 58 0a 58 20 20 2f 2a | 20 54 68 61 74 27 73 20 |.X.X /*| That's |
|00003160| 69 74 2c 20 73 6f 6e 2e | 20 20 4e 6f 74 68 69 6e |it, son.| Nothin|
|00003170| 27 20 65 6c 73 65 20 74 | 6f 20 64 6f 2c 20 65 78 |' else t|o do, ex|
|00003180| 63 65 70 74 20 63 6c 6f | 73 65 20 66 69 6c 65 73 |cept clo|se files|
|00003190| 2e 20 2a 2f 0a 58 20 20 | 2f 2a 20 48 65 72 65 20 |. */.X |/* Here |
|000031a0| 77 65 20 61 73 73 75 6d | 65 20 6f 6e 6c 79 20 74 |we assum|e only t|
|000031b0| 68 65 20 6f 75 74 70 75 | 74 20 66 69 6c 65 20 6e |he outpu|t file n|
|000031c0| 65 65 64 20 62 65 20 63 | 6c 6f 73 65 64 2e 20 2a |eed be c|losed. *|
|000031d0| 2f 0a 58 20 20 66 63 6c | 6f 73 65 28 63 69 6e 66 |/.X fcl|ose(cinf|
|000031e0| 6f 2e 6f 75 74 70 75 74 | 5f 66 69 6c 65 29 3b 0a |o.output|_file);.|
|000031f0| 58 0a 58 20 20 2f 2a 20 | 4e 6f 74 65 3a 20 69 66 |X.X /* |Note: if|
|00003200| 20 79 6f 75 20 77 61 6e | 74 20 74 6f 20 63 6f 6d | you wan|t to com|
|00003210| 70 72 65 73 73 20 6d 6f | 72 65 20 74 68 61 6e 20 |press mo|re than |
|00003220| 6f 6e 65 20 69 6d 61 67 | 65 2c 20 77 65 20 72 65 |one imag|e, we re|
|00003230| 63 6f 6d 6d 65 6e 64 20 | 79 6f 75 0a 58 20 20 20 |commend |you.X |
|00003240| 2a 20 72 65 70 65 61 74 | 20 74 68 69 73 20 77 68 |* repeat| this wh|
|00003250| 6f 6c 65 20 72 6f 75 74 | 69 6e 65 2e 20 20 59 6f |ole rout|ine. Yo|
|00003260| 75 20 4d 55 53 54 20 72 | 65 70 65 61 74 20 74 68 |u MUST r|epeat th|
|00003270| 65 20 6a 5f 63 5f 64 65 | 66 61 75 6c 74 73 28 29 |e j_c_de|faults()|
|00003280| 2f 61 6c 74 65 72 0a 58 | 20 20 20 2a 20 70 61 72 |/alter.X| * par|
|00003290| 61 6d 65 74 65 72 73 2f | 6a 70 65 67 5f 63 6f 6d |ameters/|jpeg_com|
|000032a0| 70 72 65 73 73 28 29 20 | 73 65 71 75 65 6e 63 65 |press() |sequence|
|000032b0| 2c 20 61 73 20 73 6f 6d | 65 20 64 61 74 61 20 73 |, as som|e data s|
|000032c0| 74 72 75 63 74 75 72 65 | 73 20 61 6c 6c 6f 63 61 |tructure|s alloca|
|000032d0| 74 65 64 0a 58 20 20 20 | 2a 20 69 6e 20 6a 5f 63 |ted.X |* in j_c|
|000032e0| 5f 64 65 66 61 75 6c 74 | 73 20 61 72 65 20 66 72 |_default|s are fr|
|000032f0| 65 65 64 20 75 70 6f 6e | 20 65 78 69 74 20 66 72 |eed upon| exit fr|
|00003300| 6f 6d 20 6a 70 65 67 5f | 63 6f 6d 70 72 65 73 73 |om jpeg_|compress|
|00003310| 2e 0a 58 20 20 20 2a 2f | 0a 58 7d 0a 58 0a 58 0a |..X */|.X}.X.X.|
|00003320| 58 0a 58 2f 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |X.X/****|********|
|00003330| 2a 2a 2a 2a 2a 2a 2a 2a | 20 4a 50 45 47 20 44 45 |********| JPEG DE|
|00003340| 43 4f 4d 50 52 45 53 53 | 49 4f 4e 20 53 41 4d 50 |COMPRESS|ION SAMP|
|00003350| 4c 45 20 49 4e 54 45 52 | 46 41 43 45 20 2a 2a 2a |LE INTER|FACE ***|
|00003360| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00003370| 2f 0a 58 0a 58 2f 2a 20 | 54 68 69 73 20 68 61 6c |/.X.X/* |This hal|
|00003380| 66 20 6f 66 20 74 68 65 | 20 65 78 61 6d 70 6c 65 |f of the| example|
|00003390| 20 73 68 6f 77 73 20 68 | 6f 77 20 74 6f 20 72 65 | shows h|ow to re|
|000033a0| 61 64 20 64 61 74 61 20 | 66 72 6f 6d 20 74 68 65 |ad data |from the|
|000033b0| 20 4a 50 45 47 20 64 65 | 63 6f 6d 70 72 65 73 73 | JPEG de|compress|
|000033c0| 6f 72 2e 0a 58 20 2a 20 | 49 74 27 73 20 61 20 6c |or..X * |It's a l|
|000033d0| 69 74 74 6c 65 20 6d 6f | 72 65 20 72 65 66 69 6e |ittle mo|re refin|
|000033e0| 65 64 20 74 68 61 6e 20 | 74 68 65 20 61 62 6f 76 |ed than |the abov|
|000033f0| 65 20 69 6e 20 74 68 61 | 74 20 77 65 20 73 68 6f |e in tha|t we sho|
|00003400| 77 20 68 6f 77 20 74 6f | 20 64 6f 20 79 6f 75 72 |w how to| do your|
|00003410| 0a 58 20 2a 20 6f 77 6e | 20 65 72 72 6f 72 20 72 |.X * own| error r|
|00003420| 65 63 6f 76 65 72 79 2e | 20 20 49 66 20 79 6f 75 |ecovery.| If you|
|00003430| 20 64 6f 6e 27 74 20 63 | 61 72 65 20 61 62 6f 75 | don't c|are abou|
|00003440| 74 20 74 68 61 74 2c 20 | 79 6f 75 20 64 6f 6e 27 |t that, |you don'|
|00003450| 74 20 6e 65 65 64 20 74 | 68 65 73 65 0a 58 20 2a |t need t|hese.X *|
|00003460| 20 6e 65 78 74 20 74 77 | 6f 20 72 6f 75 74 69 6e | next tw|o routin|
|00003470| 65 73 2e 0a 58 20 2a 2f | 0a 58 0a 58 0a 58 2f 2a |es..X */|.X.X.X/*|
|00003480| 0a 58 20 2a 20 54 68 65 | 73 65 20 72 6f 75 74 69 |.X * The|se routi|
|00003490| 6e 65 73 20 72 65 70 6c | 61 63 65 20 74 68 65 20 |nes repl|ace the |
|000034a0| 64 65 66 61 75 6c 74 20 | 74 72 61 63 65 2f 65 72 |default |trace/er|
|000034b0| 72 6f 72 20 72 6f 75 74 | 69 6e 65 73 20 69 6e 63 |ror rout|ines inc|
|000034c0| 6c 75 64 65 64 20 77 69 | 74 68 20 74 68 65 0a 58 |luded wi|th the.X|
|000034d0| 20 2a 20 4a 50 45 47 20 | 63 6f 64 65 2e 20 20 54 | * JPEG |code. T|
|000034e0| 68 65 20 65 78 61 6d 70 | 6c 65 20 74 72 61 63 65 |he examp|le trace|
|000034f0| 5f 6d 65 73 73 61 67 65 | 20 72 6f 75 74 69 6e 65 |_message| routine|
|00003500| 20 73 68 6f 77 6e 20 68 | 65 72 65 20 69 73 20 61 | shown h|ere is a|
|00003510| 63 74 75 61 6c 6c 79 20 | 74 68 65 0a 58 20 2a 20 |ctually |the.X * |
|00003520| 73 61 6d 65 20 61 73 20 | 74 68 65 20 73 74 61 6e |same as |the stan|
|00003530| 64 61 72 64 20 6f 6e 65 | 2c 20 62 75 74 20 79 6f |dard one|, but yo|
|00003540| 75 20 63 6f 75 6c 64 20 | 6d 6f 64 69 66 79 20 69 |u could |modify i|
|00003550| 74 20 69 66 20 79 6f 75 | 20 64 6f 6e 27 74 20 77 |t if you| don't w|
|00003560| 61 6e 74 20 6d 65 73 73 | 61 67 65 73 0a 58 20 2a |ant mess|ages.X *|
|00003570| 20 73 65 6e 74 20 74 6f | 20 73 74 64 65 72 72 2e | sent to| stderr.|
|00003580| 20 20 54 68 65 20 65 78 | 61 6d 70 6c 65 20 65 72 | The ex|ample er|
|00003590| 72 6f 72 5f 65 78 69 74 | 20 72 6f 75 74 69 6e 65 |ror_exit| routine|
|000035a0| 20 69 73 20 73 65 74 20 | 75 70 20 74 6f 20 72 65 | is set |up to re|
|000035b0| 74 75 72 6e 0a 58 20 2a | 20 63 6f 6e 74 72 6f 6c |turn.X *| control|
|000035c0| 20 74 6f 20 72 65 61 64 | 5f 4a 50 45 47 5f 66 69 | to read|_JPEG_fi|
|000035d0| 6c 65 28 29 20 72 61 74 | 68 65 72 20 74 68 61 6e |le() rat|her than|
|000035e0| 20 63 61 6c 6c 69 6e 67 | 20 65 78 69 74 28 29 2e | calling| exit().|
|000035f0| 20 20 59 6f 75 20 63 61 | 6e 20 75 73 65 20 74 68 | You ca|n use th|
|00003600| 65 0a 58 20 2a 20 73 61 | 6d 65 20 72 6f 75 74 69 |e.X * sa|me routi|
|00003610| 6e 65 73 20 66 6f 72 20 | 62 6f 74 68 20 63 6f 6d |nes for |both com|
|00003620| 70 72 65 73 73 69 6f 6e | 20 61 6e 64 20 64 65 63 |pression| and dec|
|00003630| 6f 6d 70 72 65 73 73 69 | 6f 6e 20 65 72 72 6f 72 |ompressi|on error|
|00003640| 20 72 65 63 6f 76 65 72 | 79 2e 0a 58 20 2a 2f 0a | recover|y..X */.|
|00003650| 58 0a 58 2f 2a 20 54 68 | 65 73 65 20 73 74 61 74 |X.X/* Th|ese stat|
|00003660| 69 63 20 76 61 72 69 61 | 62 6c 65 73 20 61 72 65 |ic varia|bles are|
|00003670| 20 6e 65 65 64 65 64 20 | 62 79 20 74 68 65 20 65 | needed |by the e|
|00003680| 72 72 6f 72 20 72 6f 75 | 74 69 6e 65 73 2e 20 2a |rror rou|tines. *|
|00003690| 2f 0a 58 73 74 61 74 69 | 63 20 6a 6d 70 5f 62 75 |/.Xstati|c jmp_bu|
|000036a0| 66 20 73 65 74 6a 6d 70 | 5f 62 75 66 66 65 72 3b |f setjmp|_buffer;|
|000036b0| 09 2f 2a 20 66 6f 72 20 | 72 65 74 75 72 6e 20 74 |./* for |return t|
|000036c0| 6f 20 63 61 6c 6c 65 72 | 20 2a 2f 0a 58 73 74 61 |o caller| */.Xsta|
|000036d0| 74 69 63 20 65 78 74 65 | 72 6e 61 6c 5f 6d 65 74 |tic exte|rnal_met|
|000036e0| 68 6f 64 73 5f 70 74 72 | 20 65 6d 65 74 68 6f 64 |hods_ptr| emethod|
|000036f0| 73 3b 20 2f 2a 20 6e 65 | 65 64 65 64 20 66 6f 72 |s; /* ne|eded for|
|00003700| 20 61 63 63 65 73 73 20 | 74 6f 20 6d 65 73 73 61 | access |to messa|
|00003710| 67 65 5f 70 61 72 6d 20 | 2a 2f 0a 58 0a 58 0a 58 |ge_parm |*/.X.X.X|
|00003720| 2f 2a 20 54 68 69 73 20 | 72 6f 75 74 69 6e 65 20 |/* This |routine |
|00003730| 69 73 20 75 73 65 64 20 | 66 6f 72 20 61 6e 79 20 |is used |for any |
|00003740| 61 6e 64 20 61 6c 6c 20 | 74 72 61 63 65 2c 20 64 |and all |trace, d|
|00003750| 65 62 75 67 2c 20 6f 72 | 20 65 72 72 6f 72 20 70 |ebug, or| error p|
|00003760| 72 69 6e 74 6f 75 74 73 | 0a 58 20 2a 20 66 72 6f |rintouts|.X * fro|
|00003770| 6d 20 74 68 65 20 4a 50 | 45 47 20 63 6f 64 65 2e |m the JP|EG code.|
|00003780| 20 20 54 68 65 20 70 61 | 72 61 6d 65 74 65 72 20 | The pa|rameter |
|00003790| 69 73 20 61 20 70 72 69 | 6e 74 66 20 66 6f 72 6d |is a pri|ntf form|
|000037a0| 61 74 20 73 74 72 69 6e | 67 3b 20 75 70 20 74 6f |at strin|g; up to|
|000037b0| 20 38 0a 58 20 2a 20 69 | 6e 74 65 67 65 72 20 64 | 8.X * i|nteger d|
|000037c0| 61 74 61 20 76 61 6c 75 | 65 73 20 66 6f 72 20 74 |ata valu|es for t|
|000037d0| 68 65 20 66 6f 72 6d 61 | 74 20 73 74 72 69 6e 67 |he forma|t string|
|000037e0| 20 68 61 76 65 20 62 65 | 65 6e 20 73 74 6f 72 65 | have be|en store|
|000037f0| 64 20 69 6e 20 74 68 65 | 0a 58 20 2a 20 6d 65 73 |d in the|.X * mes|
|00003800| 73 61 67 65 5f 70 61 72 | 6d 5b 5d 20 66 69 65 6c |sage_par|m[] fiel|
|00003810| 64 20 6f 66 20 74 68 65 | 20 65 78 74 65 72 6e 61 |d of the| externa|
|00003820| 6c 5f 6d 65 74 68 6f 64 | 73 20 73 74 72 75 63 74 |l_method|s struct|
|00003830| 2e 0a 58 20 2a 2f 0a 58 | 0a 58 4d 45 54 48 4f 44 |..X */.X|.XMETHOD|
|00003840| 44 45 46 20 76 6f 69 64 | 0a 58 74 72 61 63 65 5f |DEF void|.Xtrace_|
|00003850| 6d 65 73 73 61 67 65 20 | 28 63 6f 6e 73 74 20 63 |message |(const c|
|00003860| 68 61 72 20 2a 6d 73 67 | 74 65 78 74 29 0a 58 7b |har *msg|text).X{|
|00003870| 0a 58 20 20 66 70 72 69 | 6e 74 66 28 73 74 64 65 |.X fpri|ntf(stde|
|00003880| 72 72 2c 20 6d 73 67 74 | 65 78 74 2c 0a 58 09 20 |rr, msgt|ext,.X. |
|00003890| 20 65 6d 65 74 68 6f 64 | 73 2d 3e 6d 65 73 73 61 | emethod|s->messa|
|000038a0| 67 65 5f 70 61 72 6d 5b | 30 5d 2c 20 65 6d 65 74 |ge_parm[|0], emet|
|000038b0| 68 6f 64 73 2d 3e 6d 65 | 73 73 61 67 65 5f 70 61 |hods->me|ssage_pa|
|000038c0| 72 6d 5b 31 5d 2c 0a 58 | 09 20 20 65 6d 65 74 68 |rm[1],.X|. emeth|
|000038d0| 6f 64 73 2d 3e 6d 65 73 | 73 61 67 65 5f 70 61 72 |ods->mes|sage_par|
|000038e0| 6d 5b 32 5d 2c 20 65 6d | 65 74 68 6f 64 73 2d 3e |m[2], em|ethods->|
|000038f0| 6d 65 73 73 61 67 65 5f | 70 61 72 6d 5b 33 5d 2c |message_|parm[3],|
|00003900| 0a 58 09 20 20 65 6d 65 | 74 68 6f 64 73 2d 3e 6d |.X. eme|thods->m|
|00003910| 65 73 73 61 67 65 5f 70 | 61 72 6d 5b 34 5d 2c 20 |essage_p|arm[4], |
|00003920| 65 6d 65 74 68 6f 64 73 | 2d 3e 6d 65 73 73 61 67 |emethods|->messag|
|00003930| 65 5f 70 61 72 6d 5b 35 | 5d 2c 0a 58 09 20 20 65 |e_parm[5|],.X. e|
|00003940| 6d 65 74 68 6f 64 73 2d | 3e 6d 65 73 73 61 67 65 |methods-|>message|
|00003950| 5f 70 61 72 6d 5b 36 5d | 2c 20 65 6d 65 74 68 6f |_parm[6]|, emetho|
|00003960| 64 73 2d 3e 6d 65 73 73 | 61 67 65 5f 70 61 72 6d |ds->mess|age_parm|
|00003970| 5b 37 5d 29 3b 0a 58 20 | 20 66 70 72 69 6e 74 66 |[7]);.X | fprintf|
|00003980| 28 73 74 64 65 72 72 2c | 20 22 5c 6e 22 29 3b 09 |(stderr,| "\n");.|
|00003990| 2f 2a 20 74 68 65 72 65 | 20 69 73 20 6e 6f 20 5c |/* there| is no \|
|000039a0| 6e 20 69 6e 20 74 68 65 | 20 66 6f 72 6d 61 74 20 |n in the| format |
|000039b0| 73 74 72 69 6e 67 21 20 | 2a 2f 0a 58 7d 0a 58 0a |string! |*/.X}.X.|
|000039c0| 58 2f 2a 0a 58 20 2a 20 | 54 68 65 20 65 72 72 6f |X/*.X * |The erro|
|000039d0| 72 5f 65 78 69 74 28 29 | 20 72 6f 75 74 69 6e 65 |r_exit()| routine|
|000039e0| 20 73 68 6f 75 6c 64 20 | 6e 6f 74 20 72 65 74 75 | should |not retu|
|000039f0| 72 6e 20 74 6f 20 69 74 | 73 20 63 61 6c 6c 65 72 |rn to it|s caller|
|00003a00| 2e 20 20 54 68 65 20 64 | 65 66 61 75 6c 74 0a 58 |. The d|efault.X|
|00003a10| 20 2a 20 72 6f 75 74 69 | 6e 65 20 63 61 6c 6c 73 | * routi|ne calls|
|00003a20| 20 65 78 69 74 28 29 2c | 20 62 75 74 20 68 65 72 | exit(),| but her|
|00003a30| 65 20 77 65 20 61 73 73 | 75 6d 65 20 74 68 61 74 |e we ass|ume that|
|00003a40| 20 77 65 20 77 61 6e 74 | 20 74 6f 20 72 65 74 75 | we want| to retu|
|00003a50| 72 6e 20 74 6f 0a 58 20 | 2a 20 72 65 61 64 5f 4a |rn to.X |* read_J|
|00003a60| 50 45 47 5f 66 69 6c 65 | 2c 20 77 68 69 63 68 20 |PEG_file|, which |
|00003a70| 68 61 73 20 73 65 74 20 | 75 70 20 61 20 73 65 74 |has set |up a set|
|00003a80| 6a 6d 70 20 63 6f 6e 74 | 65 78 74 20 66 6f 72 20 |jmp cont|ext for |
|00003a90| 74 68 65 20 70 75 72 70 | 6f 73 65 2e 0a 58 20 2a |the purp|ose..X *|
|00003aa0| 20 59 6f 75 20 73 68 6f | 75 6c 64 20 6d 61 6b 65 | You sho|uld make|
|00003ab0| 20 73 75 72 65 20 74 68 | 61 74 20 74 68 65 20 66 | sure th|at the f|
|00003ac0| 72 65 65 5f 61 6c 6c 20 | 6d 65 74 68 6f 64 20 69 |ree_all |method i|
|00003ad0| 73 20 63 61 6c 6c 65 64 | 2c 20 65 69 74 68 65 72 |s called|, either|
|00003ae0| 20 77 69 74 68 69 6e 0a | 58 20 2a 20 65 72 72 6f | within.|X * erro|
|00003af0| 72 5f 65 78 69 74 20 6f | 72 20 61 66 74 65 72 20 |r_exit o|r after |
|00003b00| 74 68 65 20 72 65 74 75 | 72 6e 20 74 6f 20 74 68 |the retu|rn to th|
|00003b10| 65 20 6f 75 74 65 72 2d | 6c 65 76 65 6c 20 72 6f |e outer-|level ro|
|00003b20| 75 74 69 6e 65 2e 0a 58 | 20 2a 2f 0a 58 0a 58 4d |utine..X| */.X.XM|
|00003b30| 45 54 48 4f 44 44 45 46 | 20 76 6f 69 64 0a 58 65 |ETHODDEF| void.Xe|
|00003b40| 72 72 6f 72 5f 65 78 69 | 74 20 28 63 6f 6e 73 74 |rror_exi|t (const|
|00003b50| 20 63 68 61 72 20 2a 6d | 73 67 74 65 78 74 29 0a | char *m|sgtext).|
|00003b60| 58 7b 0a 58 20 20 74 72 | 61 63 65 5f 6d 65 73 73 |X{.X tr|ace_mess|
|00003b70| 61 67 65 28 6d 73 67 74 | 65 78 74 29 3b 09 2f 2a |age(msgt|ext);./*|
|00003b80| 20 72 65 70 6f 72 74 20 | 74 68 65 20 65 72 72 6f | report |the erro|
|00003b90| 72 20 6d 65 73 73 61 67 | 65 20 2a 2f 0a 58 20 20 |r messag|e */.X |
|00003ba0| 28 2a 65 6d 65 74 68 6f | 64 73 2d 3e 66 72 65 65 |(*emetho|ds->free|
|00003bb0| 5f 61 6c 6c 29 20 28 29 | 3b 09 2f 2a 20 63 6c 65 |_all) ()|;./* cle|
|00003bc0| 61 6e 20 75 70 20 6d 65 | 6d 6f 72 79 20 61 6c 6c |an up me|mory all|
|00003bd0| 6f 63 61 74 69 6f 6e 20 | 26 20 74 65 6d 70 20 66 |ocation |& temp f|
|00003be0| 69 6c 65 73 20 2a 2f 0a | 58 20 20 6c 6f 6e 67 6a |iles */.|X longj|
|00003bf0| 6d 70 28 73 65 74 6a 6d | 70 5f 62 75 66 66 65 72 |mp(setjm|p_buffer|
|00003c00| 2c 20 31 29 3b 09 2f 2a | 20 72 65 74 75 72 6e 20 |, 1);./*| return |
|00003c10| 63 6f 6e 74 72 6f 6c 20 | 74 6f 20 6f 75 74 65 72 |control |to outer|
|00003c20| 20 72 6f 75 74 69 6e 65 | 20 2a 2f 0a 58 7d 0a 58 | routine| */.X}.X|
|00003c30| 0a 58 0a 58 0a 58 2f 2a | 0a 58 20 2a 20 54 6f 20 |.X.X.X/*|.X * To |
|00003c40| 61 63 63 65 70 74 20 74 | 68 65 20 69 6d 61 67 65 |accept t|he image|
|00003c50| 20 64 61 74 61 20 66 72 | 6f 6d 20 64 65 63 6f 6d | data fr|om decom|
|00003c60| 70 72 65 73 73 69 6f 6e | 2c 20 79 6f 75 20 6d 75 |pression|, you mu|
|00003c70| 73 74 20 64 65 66 69 6e | 65 20 66 6f 75 72 20 72 |st defin|e four r|
|00003c80| 6f 75 74 69 6e 65 73 0a | 58 20 2a 20 6f 75 74 70 |outines.|X * outp|
|00003c90| 75 74 5f 69 6e 69 74 2c | 20 70 75 74 5f 63 6f 6c |ut_init,| put_col|
|00003ca0| 6f 72 5f 6d 61 70 2c 20 | 70 75 74 5f 70 69 78 65 |or_map, |put_pixe|
|00003cb0| 6c 5f 72 6f 77 73 2c 20 | 61 6e 64 20 6f 75 74 70 |l_rows, |and outp|
|00003cc0| 75 74 5f 74 65 72 6d 2e | 0a 58 20 2a 0a 58 20 2a |ut_term.|.X *.X *|
|00003cd0| 20 59 6f 75 20 6d 75 73 | 74 20 75 6e 64 65 72 73 | You mus|t unders|
|00003ce0| 74 61 6e 64 20 74 68 65 | 20 64 69 73 74 69 6e 63 |tand the| distinc|
|00003cf0| 74 69 6f 6e 20 62 65 74 | 77 65 65 6e 20 66 75 6c |tion bet|ween ful|
|00003d00| 6c 20 63 6f 6c 6f 72 20 | 6f 75 74 70 75 74 20 6d |l color |output m|
|00003d10| 6f 64 65 0a 58 20 2a 20 | 28 4e 20 69 6e 64 65 70 |ode.X * |(N indep|
|00003d20| 65 6e 64 65 6e 74 20 63 | 6f 6c 6f 72 20 63 6f 6d |endent c|olor com|
|00003d30| 70 6f 6e 65 6e 74 73 29 | 20 61 6e 64 20 63 6f 6c |ponents)| and col|
|00003d40| 6f 72 6d 61 70 70 65 64 | 20 6f 75 74 70 75 74 20 |ormapped| output |
|00003d50| 6d 6f 64 65 20 28 61 20 | 73 69 6e 67 6c 65 0a 58 |mode (a |single.X|
|00003d60| 20 2a 20 6f 75 74 70 75 | 74 20 63 6f 6d 70 6f 6e | * outpu|t compon|
|00003d70| 65 6e 74 20 72 65 70 72 | 65 73 65 6e 74 69 6e 67 |ent repr|esenting|
|00003d80| 20 61 6e 20 69 6e 64 65 | 78 20 69 6e 74 6f 20 61 | an inde|x into a|
|00003d90| 20 63 6f 6c 6f 72 20 6d | 61 70 29 2e 20 20 59 6f | color m|ap). Yo|
|00003da0| 75 20 73 68 6f 75 6c 64 | 20 75 73 65 0a 58 20 2a |u should| use.X *|
|00003db0| 20 63 6f 6c 6f 72 6d 61 | 70 70 65 64 20 6d 6f 64 | colorma|pped mod|
|00003dc0| 65 20 74 6f 20 77 72 69 | 74 65 20 74 6f 20 61 20 |e to wri|te to a |
|00003dd0| 63 6f 6c 6f 72 6d 61 70 | 70 65 64 20 64 69 73 70 |colormap|ped disp|
|00003de0| 6c 61 79 20 73 63 72 65 | 65 6e 20 6f 72 20 6f 75 |lay scre|en or ou|
|00003df0| 74 70 75 74 20 66 69 6c | 65 2e 0a 58 20 2a 20 43 |tput fil|e..X * C|
|00003e00| 6f 6c 6f 72 6d 61 70 70 | 65 64 20 6d 6f 64 65 20 |olormapp|ed mode |
|00003e10| 69 73 20 61 6c 73 6f 20 | 75 73 65 66 75 6c 20 66 |is also |useful f|
|00003e20| 6f 72 20 72 65 64 75 63 | 69 6e 67 20 67 72 61 79 |or reduc|ing gray|
|00003e30| 73 63 61 6c 65 20 6f 75 | 74 70 75 74 20 74 6f 20 |scale ou|tput to |
|00003e40| 61 20 73 6d 61 6c 6c 0a | 58 20 2a 20 6e 75 6d 62 |a small.|X * numb|
|00003e50| 65 72 20 6f 66 20 67 72 | 61 79 20 6c 65 76 65 6c |er of gr|ay level|
|00003e60| 73 3a 20 77 68 65 6e 20 | 75 73 69 6e 67 20 74 68 |s: when |using th|
|00003e70| 65 20 31 2d 70 61 73 73 | 20 71 75 61 6e 74 69 7a |e 1-pass| quantiz|
|00003e80| 65 72 20 6f 6e 20 67 72 | 61 79 73 63 61 6c 65 20 |er on gr|ayscale |
|00003e90| 64 61 74 61 2c 0a 58 20 | 2a 20 74 68 65 20 63 6f |data,.X |* the co|
|00003ea0| 6c 6f 72 6d 61 70 20 65 | 6e 74 72 69 65 73 20 77 |lormap e|ntries w|
|00003eb0| 69 6c 6c 20 62 65 20 65 | 76 65 6e 6c 79 20 73 70 |ill be e|venly sp|
|00003ec0| 61 63 65 64 20 66 72 6f | 6d 20 30 20 74 6f 20 4d |aced fro|m 0 to M|
|00003ed0| 41 58 5f 4a 53 41 4d 50 | 4c 45 2c 20 73 6f 20 79 |AX_JSAMP|LE, so y|
|00003ee0| 6f 75 0a 58 20 2a 20 63 | 61 6e 20 72 65 67 61 72 |ou.X * c|an regar|
|00003ef0| 64 20 74 68 65 20 69 6e | 64 65 78 65 73 20 61 72 |d the in|dexes ar|
|00003f00| 65 20 64 69 72 65 63 74 | 6c 79 20 72 65 70 72 65 |e direct|ly repre|
|00003f10| 73 65 6e 74 69 6e 67 20 | 67 72 61 79 20 6c 65 76 |senting |gray lev|
|00003f20| 65 6c 73 20 61 74 20 72 | 65 64 75 63 65 64 0a 58 |els at r|educed.X|
|00003f30| 20 2a 20 70 72 65 63 69 | 73 69 6f 6e 2e 20 20 49 | * preci|sion. I|
|00003f40| 6e 20 61 6e 79 20 6f 74 | 68 65 72 20 63 61 73 65 |n any ot|her case|
|00003f50| 2c 20 79 6f 75 20 73 68 | 6f 75 6c 64 20 6e 6f 74 |, you sh|ould not|
|00003f60| 20 64 65 70 65 6e 64 20 | 6f 6e 20 74 68 65 20 63 | depend |on the c|
|00003f70| 6f 6c 6f 72 6d 61 70 0a | 58 20 2a 20 65 6e 74 72 |olormap.|X * entr|
|00003f80| 69 65 73 20 68 61 76 69 | 6e 67 20 61 6e 79 20 70 |ies havi|ng any p|
|00003f90| 61 72 74 69 63 75 6c 61 | 72 20 6f 72 64 65 72 2e |articula|r order.|
|00003fa0| 0a 58 20 2a 20 54 6f 20 | 67 65 74 20 63 6f 6c 6f |.X * To |get colo|
|00003fb0| 72 6d 61 70 70 65 64 20 | 6f 75 74 70 75 74 2c 20 |rmapped |output, |
|00003fc0| 73 65 74 20 63 69 6e 66 | 6f 2d 3e 71 75 61 6e 74 |set cinf|o->quant|
|00003fd0| 69 7a 65 5f 63 6f 6c 6f | 72 73 20 74 6f 20 54 52 |ize_colo|rs to TR|
|00003fe0| 55 45 20 61 6e 64 20 73 | 65 74 0a 58 20 2a 20 63 |UE and s|et.X * c|
|00003ff0| 69 6e 66 6f 2d 3e 64 65 | 73 69 72 65 64 5f 6e 75 |info->de|sired_nu|
|00004000| 6d 62 65 72 5f 6f 66 5f | 63 6f 6c 6f 72 73 20 74 |mber_of_|colors t|
|00004010| 6f 20 74 68 65 20 6d 61 | 78 69 6d 75 6d 20 6e 75 |o the ma|ximum nu|
|00004020| 6d 62 65 72 20 6f 66 20 | 65 6e 74 72 69 65 73 20 |mber of |entries |
|00004030| 69 6e 20 74 68 65 0a 58 | 20 2a 20 63 6f 6c 6f 72 |in the.X| * color|
|00004040| 6d 61 70 2e 20 20 54 68 | 69 73 20 63 61 6e 20 62 |map. Th|is can b|
|00004050| 65 20 64 6f 6e 65 20 65 | 69 74 68 65 72 20 69 6e |e done e|ither in|
|00004060| 20 79 6f 75 72 20 6d 61 | 69 6e 20 72 6f 75 74 69 | your ma|in routi|
|00004070| 6e 65 20 6f 72 20 69 6e | 0a 58 20 2a 20 64 5f 75 |ne or in|.X * d_u|
|00004080| 69 5f 6d 65 74 68 6f 64 | 5f 73 65 6c 65 63 74 69 |i_method|_selecti|
|00004090| 6f 6e 2e 20 20 46 6f 72 | 20 67 72 61 79 73 63 61 |on. For| graysca|
|000040a0| 6c 65 20 71 75 61 6e 74 | 69 7a 61 74 69 6f 6e 2c |le quant|ization,|
|000040b0| 20 61 6c 73 6f 20 73 65 | 74 0a 58 20 2a 20 63 69 | also se|t.X * ci|
|000040c0| 6e 66 6f 2d 3e 74 77 6f | 5f 70 61 73 73 5f 71 75 |nfo->two|_pass_qu|
|000040d0| 61 6e 74 69 7a 65 20 74 | 6f 20 46 41 4c 53 45 20 |antize t|o FALSE |
|000040e0| 74 6f 20 65 6e 73 75 72 | 65 20 74 68 65 20 31 2d |to ensur|e the 1-|
|000040f0| 70 61 73 73 20 71 75 61 | 6e 74 69 7a 65 72 20 69 |pass qua|ntizer i|
|00004100| 73 20 75 73 65 64 0a 58 | 20 2a 20 28 70 72 65 73 |s used.X| * (pres|
|00004110| 65 6e 74 6c 79 20 74 68 | 69 73 20 69 73 20 74 68 |ently th|is is th|
|00004120| 65 20 64 65 66 61 75 6c | 74 2c 20 62 75 74 20 69 |e defaul|t, but i|
|00004130| 74 20 6d 61 79 20 6e 6f | 74 20 62 65 20 73 6f 20 |t may no|t be so |
|00004140| 69 6e 20 74 68 65 20 66 | 75 74 75 72 65 29 2e 0a |in the f|uture)..|
|00004150| 58 20 2a 0a 58 20 2a 20 | 54 68 65 20 6f 75 74 70 |X *.X * |The outp|
|00004160| 75 74 20 66 69 6c 65 20 | 77 72 69 74 69 6e 67 20 |ut file |writing |
|00004170| 6d 6f 64 75 6c 65 73 20 | 28 6a 77 72 70 70 6d 2e |modules |(jwrppm.|
|00004180| 63 2c 20 6a 77 72 67 69 | 66 2e 63 2c 20 6a 77 72 |c, jwrgi|f.c, jwr|
|00004190| 74 61 72 67 61 2e 63 2c | 20 65 74 63 29 20 6d 61 |targa.c,| etc) ma|
|000041a0| 79 20 62 65 0a 58 20 2a | 20 75 73 65 66 75 6c 20 |y be.X *| useful |
|000041b0| 65 78 61 6d 70 6c 65 73 | 20 6f 66 20 77 68 61 74 |examples| of what|
|000041c0| 20 74 68 65 73 65 20 72 | 6f 75 74 69 6e 65 73 20 | these r|outines |
|000041d0| 73 68 6f 75 6c 64 20 61 | 63 74 75 61 6c 6c 79 20 |should a|ctually |
|000041e0| 64 6f 2c 20 61 6c 74 68 | 6f 75 67 68 20 65 61 63 |do, alth|ough eac|
|000041f0| 68 20 6f 66 0a 58 20 2a | 20 74 68 65 6d 20 69 73 |h of.X *| them is|
|00004200| 20 65 6e 63 72 75 73 74 | 65 64 20 77 69 74 68 20 | encrust|ed with |
|00004210| 61 20 6c 6f 74 20 6f 66 | 20 73 70 65 63 69 61 6c |a lot of| special|
|00004220| 69 7a 65 64 20 63 6f 64 | 65 20 66 6f 72 20 69 74 |ized cod|e for it|
|00004230| 73 20 6f 77 6e 20 66 69 | 6c 65 20 66 6f 72 6d 61 |s own fi|le forma|
|00004240| 74 2e 0a 58 20 2a 2f 0a | 58 0a 58 0a 58 4d 45 54 |t..X */.|X.X.XMET|
|00004250| 48 4f 44 44 45 46 20 76 | 6f 69 64 0a 58 6f 75 74 |HODDEF v|oid.Xout|
|00004260| 70 75 74 5f 69 6e 69 74 | 20 28 64 65 63 6f 6d 70 |put_init| (decomp|
|00004270| 72 65 73 73 5f 69 6e 66 | 6f 5f 70 74 72 20 63 69 |ress_inf|o_ptr ci|
|00004280| 6e 66 6f 29 0a 58 2f 2a | 20 54 68 69 73 20 72 6f |nfo).X/*| This ro|
|00004290| 75 74 69 6e 65 20 73 68 | 6f 75 6c 64 20 64 6f 20 |utine sh|ould do |
|000042a0| 61 6e 79 20 73 65 74 75 | 70 20 72 65 71 75 69 72 |any setu|p requir|
|000042b0| 65 64 20 2a 2f 0a 58 7b | 0a 58 20 20 2f 2a 20 54 |ed */.X{|.X /* T|
|000042c0| 68 69 73 20 72 6f 75 74 | 69 6e 65 20 63 61 6e 20 |his rout|ine can |
|000042d0| 69 6e 69 74 69 61 6c 69 | 7a 65 20 66 6f 72 20 6f |initiali|ze for o|
|000042e0| 75 74 70 75 74 20 62 61 | 73 65 64 20 6f 6e 20 74 |utput ba|sed on t|
|000042f0| 68 65 20 64 61 74 61 20 | 70 61 73 73 65 64 20 69 |he data |passed i|
|00004300| 6e 20 63 69 6e 66 6f 2e | 0a 58 20 20 20 2a 20 55 |n cinfo.|.X * U|
|00004310| 73 65 66 75 6c 20 66 69 | 65 6c 64 73 20 69 6e 63 |seful fi|elds inc|
|00004320| 6c 75 64 65 3a 0a 58 20 | 20 20 2a 09 69 6d 61 67 |lude:.X | *.imag|
|00004330| 65 5f 77 69 64 74 68 2c | 20 69 6d 61 67 65 5f 68 |e_width,| image_h|
|00004340| 65 69 67 68 74 09 50 72 | 65 74 74 79 20 6f 62 76 |eight.Pr|etty obv|
|00004350| 69 6f 75 73 2c 20 49 20 | 68 6f 70 65 2e 0a 58 20 |ious, I |hope..X |
|00004360| 20 20 2a 09 64 61 74 61 | 5f 70 72 65 63 69 73 69 | *.data|_precisi|
|00004370| 6f 6e 09 09 09 62 69 74 | 73 20 70 65 72 20 70 69 |on...bit|s per pi|
|00004380| 78 65 6c 20 76 61 6c 75 | 65 3b 20 74 79 70 69 63 |xel valu|e; typic|
|00004390| 61 6c 6c 79 20 38 2e 0a | 58 20 20 20 2a 09 6f 75 |ally 8..|X *.ou|
|000043a0| 74 5f 63 6f 6c 6f 72 5f | 73 70 61 63 65 09 09 09 |t_color_|space...|
|000043b0| 6f 75 74 70 75 74 20 63 | 6f 6c 6f 72 73 70 61 63 |output c|olorspac|
|000043c0| 65 20 70 72 65 76 69 6f | 75 73 6c 79 20 72 65 71 |e previo|usly req|
|000043d0| 75 65 73 74 65 64 0a 58 | 20 20 20 2a 09 63 6f 6c |uested.X| *.col|
|000043e0| 6f 72 5f 6f 75 74 5f 63 | 6f 6d 70 73 09 09 09 6e |or_out_c|omps...n|
|000043f0| 75 6d 62 65 72 20 6f 66 | 20 63 6f 6c 6f 72 20 63 |umber of| color c|
|00004400| 6f 6d 70 6f 6e 65 6e 74 | 73 20 69 6e 20 73 61 6d |omponent|s in sam|
|00004410| 65 0a 58 20 20 20 2a 09 | 66 69 6e 61 6c 5f 6f 75 |e.X *.|final_ou|
|00004420| 74 5f 63 6f 6d 70 73 09 | 09 09 6e 75 6d 62 65 72 |t_comps.|..number|
|00004430| 20 6f 66 20 63 6f 6d 70 | 6f 6e 65 6e 74 73 20 61 | of comp|onents a|
|00004440| 63 74 75 61 6c 6c 79 20 | 6f 75 74 70 75 74 0a 58 |ctually |output.X|
|00004450| 20 20 20 2a 20 66 69 6e | 61 6c 5f 6f 75 74 5f 63 | * fin|al_out_c|
|00004460| 6f 6d 70 73 20 69 73 20 | 31 20 69 66 20 71 75 61 |omps is |1 if qua|
|00004470| 6e 74 69 7a 65 5f 63 6f | 6c 6f 72 73 20 69 73 20 |ntize_co|lors is |
|00004480| 74 72 75 65 2c 20 65 6c | 73 65 20 69 74 20 69 73 |true, el|se it is|
|00004490| 20 65 71 75 61 6c 20 74 | 6f 0a 58 20 20 20 2a 20 | equal t|o.X * |
|000044a0| 63 6f 6c 6f 72 5f 6f 75 | 74 5f 63 6f 6d 70 73 2e |color_ou|t_comps.|
|000044b0| 0a 58 20 20 20 2a 0a 58 | 20 20 20 2a 20 49 66 20 |.X *.X| * If |
|000044c0| 79 6f 75 20 68 61 76 65 | 20 72 65 71 75 65 73 74 |you have| request|
|000044d0| 65 64 20 63 6f 6c 6f 72 | 20 71 75 61 6e 74 69 7a |ed color| quantiz|
|000044e0| 61 74 69 6f 6e 2c 20 74 | 68 65 20 63 6f 6c 6f 72 |ation, t|he color|
|000044f0| 6d 61 70 20 69 73 20 4e | 4f 54 20 79 65 74 20 73 |map is N|OT yet s|
|00004500| 65 74 2e 0a 58 20 20 20 | 2a 20 59 6f 75 20 6d 61 |et..X |* You ma|
|00004510| 79 20 77 69 73 68 20 74 | 6f 20 64 65 66 65 72 20 |y wish t|o defer |
|00004520| 6f 75 74 70 75 74 20 69 | 6e 69 74 69 61 6c 69 7a |output i|nitializ|
|00004530| 61 74 69 6f 6e 20 75 6e | 74 69 6c 20 70 75 74 5f |ation un|til put_|
|00004540| 63 6f 6c 6f 72 5f 6d 61 | 70 20 69 73 20 63 61 6c |color_ma|p is cal|
|00004550| 6c 65 64 2e 0a 58 20 20 | 20 2a 2f 0a 58 7d 0a 58 |led..X | */.X}.X|
|00004560| 0a 58 0a 58 2f 2a 0a 58 | 20 2a 20 54 68 69 73 20 |.X.X/*.X| * This |
|00004570| 72 6f 75 74 69 6e 65 20 | 69 73 20 63 61 6c 6c 65 |routine |is calle|
|00004580| 64 20 69 66 20 61 6e 64 | 20 6f 6e 6c 79 20 69 66 |d if and| only if|
|00004590| 20 79 6f 75 20 68 61 76 | 65 20 73 65 74 20 63 69 | you hav|e set ci|
|000045a0| 6e 66 6f 2d 3e 71 75 61 | 6e 74 69 7a 65 5f 63 6f |nfo->qua|ntize_co|
|000045b0| 6c 6f 72 73 0a 58 20 2a | 20 74 6f 20 54 52 55 45 |lors.X *| to TRUE|
|000045c0| 2e 20 20 49 74 20 69 73 | 20 67 69 76 65 6e 20 74 |. It is| given t|
|000045d0| 68 65 20 73 65 6c 65 63 | 74 65 64 20 63 6f 6c 6f |he selec|ted colo|
|000045e0| 72 6d 61 70 20 61 6e 64 | 20 63 61 6e 20 63 6f 6d |rmap and| can com|
|000045f0| 70 6c 65 74 65 20 61 6e | 79 20 72 65 71 75 69 72 |plete an|y requir|
|00004600| 65 64 0a 58 20 2a 20 69 | 6e 69 74 69 61 6c 69 7a |ed.X * i|nitializ|
|00004610| 61 74 69 6f 6e 2e 20 20 | 54 68 69 73 20 63 61 6c |ation. |This cal|
|00004620| 6c 20 77 69 6c 6c 20 6f | 63 63 75 72 20 61 66 74 |l will o|ccur aft|
|00004630| 65 72 20 6f 75 74 70 75 | 74 5f 69 6e 69 74 20 61 |er outpu|t_init a|
|00004640| 6e 64 20 62 65 66 6f 72 | 65 20 61 6e 79 0a 58 20 |nd befor|e any.X |
|00004650| 2a 20 63 61 6c 6c 73 20 | 74 6f 20 70 75 74 5f 70 |* calls |to put_p|
|00004660| 69 78 65 6c 5f 72 6f 77 | 73 2e 20 20 4e 6f 74 65 |ixel_row|s. Note|
|00004670| 20 74 68 61 74 20 74 68 | 65 20 63 6f 6c 6f 72 6d | that th|e colorm|
|00004680| 61 70 20 70 6f 69 6e 74 | 65 72 20 69 73 20 61 6c |ap point|er is al|
|00004690| 73 6f 20 70 6c 61 63 65 | 64 0a 58 20 2a 20 69 6e |so place|d.X * in|
|000046a0| 20 61 20 63 69 6e 66 6f | 20 66 69 65 6c 64 2c 20 | a cinfo| field, |
|000046b0| 77 68 65 6e 63 65 20 69 | 74 20 63 61 6e 20 62 65 |whence i|t can be|
|000046c0| 20 75 73 65 64 20 62 79 | 20 70 75 74 5f 70 69 78 | used by| put_pix|
|000046d0| 65 6c 5f 72 6f 77 73 20 | 6f 72 20 6f 75 74 70 75 |el_rows |or outpu|
|000046e0| 74 5f 74 65 72 6d 2e 0a | 58 20 2a 20 6e 75 6d 5f |t_term..|X * num_|
|000046f0| 63 6f 6c 6f 72 73 20 77 | 69 6c 6c 20 62 65 20 6c |colors w|ill be l|
|00004700| 65 73 73 20 74 68 61 6e | 20 6f 72 20 65 71 75 61 |ess than| or equa|
|00004710| 6c 20 74 6f 20 64 65 73 | 69 72 65 64 5f 6e 75 6d |l to des|ired_num|
|00004720| 62 65 72 5f 6f 66 5f 63 | 6f 6c 6f 72 73 2e 0a 58 |ber_of_c|olors..X|
|00004730| 20 2a 0a 58 20 2a 20 54 | 68 65 20 63 6f 6c 6f 72 | *.X * T|he color|
|00004740| 6d 61 70 20 64 61 74 61 | 20 69 73 20 73 75 70 70 |map data| is supp|
|00004750| 6c 69 65 64 20 61 73 20 | 61 20 32 2d 44 20 61 72 |lied as |a 2-D ar|
|00004760| 72 61 79 20 6f 66 20 4a | 53 41 4d 50 4c 45 73 2c |ray of J|SAMPLEs,|
|00004770| 20 69 6e 64 65 78 65 64 | 20 61 73 0a 58 20 2a 09 | indexed| as.X *.|
|00004780| 09 4a 53 41 4d 50 4c 45 | 20 63 6f 6c 6f 72 6d 61 |.JSAMPLE| colorma|
|00004790| 70 5b 63 6f 6d 70 6f 6e | 65 6e 74 5d 5b 69 6e 64 |p[compon|ent][ind|
|000047a0| 65 78 76 61 6c 75 65 5d | 0a 58 20 2a 20 77 68 65 |exvalue]|.X * whe|
|000047b0| 72 65 20 63 6f 6d 70 6f | 6e 65 6e 74 20 72 75 6e |re compo|nent run|
|000047c0| 73 20 66 72 6f 6d 20 30 | 20 74 6f 20 63 69 6e 66 |s from 0| to cinf|
|000047d0| 6f 2d 3e 63 6f 6c 6f 72 | 5f 6f 75 74 5f 63 6f 6d |o->color|_out_com|
|000047e0| 70 73 2d 31 2c 20 61 6e | 64 20 69 6e 64 65 78 76 |ps-1, an|d indexv|
|000047f0| 61 6c 75 65 0a 58 20 2a | 20 72 75 6e 73 20 66 72 |alue.X *| runs fr|
|00004800| 6f 6d 20 30 20 74 6f 20 | 6e 75 6d 5f 63 6f 6c 6f |om 0 to |num_colo|
|00004810| 72 73 2d 31 2e 20 20 4e | 6f 74 65 20 74 68 61 74 |rs-1. N|ote that|
|00004820| 20 74 68 69 73 20 69 73 | 20 61 63 74 75 61 6c 6c | this is| actuall|
|00004830| 79 20 61 6e 20 61 72 72 | 61 79 20 6f 66 0a 58 20 |y an arr|ay of.X |
|00004840| 2a 20 70 6f 69 6e 74 65 | 72 73 20 74 6f 20 61 72 |* pointe|rs to ar|
|00004850| 72 61 79 73 20 72 61 74 | 68 65 72 20 74 68 61 6e |rays rat|her than|
|00004860| 20 61 20 74 72 75 65 20 | 32 44 20 61 72 72 61 79 | a true |2D array|
|00004870| 2c 20 73 69 6e 63 65 20 | 43 20 64 6f 65 73 20 6e |, since |C does n|
|00004880| 6f 74 20 73 75 70 70 6f | 72 74 0a 58 20 2a 20 76 |ot suppo|rt.X * v|
|00004890| 61 72 69 61 62 6c 65 2d | 73 69 7a 65 20 6d 75 6c |ariable-|size mul|
|000048a0| 74 69 64 69 6d 65 6e 73 | 69 6f 6e 61 6c 20 61 72 |tidimens|ional ar|
|000048b0| 72 61 79 73 2e 0a 58 20 | 2a 20 4a 53 41 4d 50 4c |rays..X |* JSAMPL|
|000048c0| 45 20 69 73 20 74 79 70 | 69 63 61 6c 6c 79 20 74 |E is typ|ically t|
|000048d0| 79 70 65 64 65 66 27 64 | 20 61 73 20 22 75 6e 73 |ypedef'd| as "uns|
|000048e0| 69 67 6e 65 64 20 63 68 | 61 72 22 2e 20 20 49 66 |igned ch|ar". If|
|000048f0| 20 79 6f 75 20 77 61 6e | 74 20 79 6f 75 72 20 63 | you wan|t your c|
|00004900| 6f 64 65 0a 58 20 2a 20 | 74 6f 20 62 65 20 61 73 |ode.X * |to be as|
|00004910| 20 70 6f 72 74 61 62 6c | 65 20 61 73 20 74 68 65 | portabl|e as the|
|00004920| 20 4a 50 45 47 20 63 6f | 64 65 20 70 72 6f 70 65 | JPEG co|de prope|
|00004930| 72 2c 20 79 6f 75 20 73 | 68 6f 75 6c 64 20 61 6c |r, you s|hould al|
|00004940| 77 61 79 73 20 61 63 63 | 65 73 73 20 4a 53 41 4d |ways acc|ess JSAM|
|00004950| 50 4c 45 0a 58 20 2a 20 | 76 61 6c 75 65 73 20 77 |PLE.X * |values w|
|00004960| 69 74 68 20 74 68 65 20 | 47 45 54 4a 53 41 4d 50 |ith the |GETJSAMP|
|00004970| 4c 45 28 29 20 6d 61 63 | 72 6f 2c 20 77 68 69 63 |LE() mac|ro, whic|
|00004980| 68 20 77 69 6c 6c 20 64 | 6f 20 74 68 65 20 72 69 |h will d|o the ri|
|00004990| 67 68 74 20 74 68 69 6e | 67 20 69 66 20 74 68 65 |ght thin|g if the|
|000049a0| 0a 58 20 2a 20 6d 61 63 | 68 69 6e 65 20 68 61 73 |.X * mac|hine has|
|000049b0| 20 6f 6e 6c 79 20 73 69 | 67 6e 65 64 20 63 68 61 | only si|gned cha|
|000049c0| 72 73 2e 0a 58 20 2a 2f | 0a 58 0a 58 4d 45 54 48 |rs..X */|.X.XMETH|
|000049d0| 4f 44 44 45 46 20 76 6f | 69 64 0a 58 70 75 74 5f |ODDEF vo|id.Xput_|
|000049e0| 63 6f 6c 6f 72 5f 6d 61 | 70 20 28 64 65 63 6f 6d |color_ma|p (decom|
|000049f0| 70 72 65 73 73 5f 69 6e | 66 6f 5f 70 74 72 20 63 |press_in|fo_ptr c|
|00004a00| 69 6e 66 6f 2c 20 69 6e | 74 20 6e 75 6d 5f 63 6f |info, in|t num_co|
|00004a10| 6c 6f 72 73 2c 20 4a 53 | 41 4d 50 41 52 52 41 59 |lors, JS|AMPARRAY|
|00004a20| 20 63 6f 6c 6f 72 6d 61 | 70 29 0a 58 2f 2a 20 57 | colorma|p).X/* W|
|00004a30| 72 69 74 65 20 74 68 65 | 20 63 6f 6c 6f 72 20 6d |rite the| color m|
|00004a40| 61 70 20 2a 2f 0a 58 7b | 0a 58 20 20 2f 2a 20 59 |ap */.X{|.X /* Y|
|00004a50| 6f 75 20 6e 65 65 64 20 | 6e 6f 74 20 70 72 6f 76 |ou need |not prov|
|00004a60| 69 64 65 20 74 68 69 73 | 20 72 6f 75 74 69 6e 65 |ide this| routine|
|00004a70| 20 69 66 20 79 6f 75 20 | 61 6c 77 61 79 73 20 73 | if you |always s|
|00004a80| 65 74 20 63 69 6e 66 6f | 2d 3e 71 75 61 6e 74 69 |et cinfo|->quanti|
|00004a90| 7a 65 5f 63 6f 6c 6f 72 | 73 0a 58 20 20 20 2a 20 |ze_color|s.X * |
|00004aa0| 46 41 4c 53 45 3b 20 62 | 75 74 20 61 20 73 61 66 |FALSE; b|ut a saf|
|00004ab0| 65 72 20 70 72 61 63 74 | 69 63 65 20 69 73 20 74 |er pract|ice is t|
|00004ac0| 6f 20 70 72 6f 76 69 64 | 65 20 69 74 20 61 6e 64 |o provid|e it and|
|00004ad0| 20 68 61 76 65 20 69 74 | 20 6a 75 73 74 20 70 72 | have it| just pr|
|00004ae0| 69 6e 74 20 61 6e 0a 58 | 20 20 20 2a 20 65 72 72 |int an.X| * err|
|00004af0| 6f 72 20 6d 65 73 73 61 | 67 65 2c 20 6c 69 6b 65 |or messa|ge, like|
|00004b00| 20 74 68 69 73 3a 0a 58 | 20 20 20 2a 2f 0a 58 20 | this:.X| */.X |
|00004b10| 20 66 70 72 69 6e 74 66 | 28 73 74 64 65 72 72 2c | fprintf|(stderr,|
|00004b20| 20 22 70 75 74 5f 63 6f | 6c 6f 72 5f 6d 61 70 20 | "put_co|lor_map |
|00004b30| 63 61 6c 6c 65 64 3a 20 | 74 68 65 72 65 27 73 20 |called: |there's |
|00004b40| 61 20 62 75 67 20 68 65 | 72 65 20 73 6f 6d 65 77 |a bug he|re somew|
|00004b50| 68 65 72 65 21 5c 6e 22 | 29 3b 0a 58 7d 0a 58 0a |here!\n"|);.X}.X.|
|00004b60| 58 0a 58 2f 2a 0a 58 20 | 2a 20 54 68 69 73 20 66 |X.X/*.X |* This f|
|00004b70| 75 6e 63 74 69 6f 6e 20 | 69 73 20 63 61 6c 6c 65 |unction |is calle|
|00004b80| 64 20 72 65 70 65 61 74 | 65 64 6c 79 2c 20 77 69 |d repeat|edly, wi|
|00004b90| 74 68 20 61 20 66 65 77 | 20 6d 6f 72 65 20 72 6f |th a few| more ro|
|00004ba0| 77 73 20 6f 66 20 70 69 | 78 65 6c 73 20 73 75 70 |ws of pi|xels sup|
|00004bb0| 70 6c 69 65 64 0a 58 20 | 2a 20 6f 6e 20 65 61 63 |plied.X |* on eac|
|00004bc0| 68 20 63 61 6c 6c 2e 20 | 20 57 69 74 68 20 74 68 |h call. | With th|
|00004bd0| 65 20 63 75 72 72 65 6e | 74 20 4a 50 45 47 20 63 |e curren|t JPEG c|
|00004be0| 6f 64 65 2c 20 73 6f 6d | 65 20 6d 75 6c 74 69 70 |ode, som|e multip|
|00004bf0| 6c 65 20 6f 66 20 38 20 | 72 6f 77 73 20 77 69 6c |le of 8 |rows wil|
|00004c00| 6c 20 62 65 0a 58 20 2a | 20 70 61 73 73 65 64 20 |l be.X *| passed |
|00004c10| 6f 6e 20 65 61 63 68 20 | 63 61 6c 6c 20 65 78 63 |on each |call exc|
|00004c20| 65 70 74 20 74 68 65 20 | 6c 61 73 74 2c 20 62 75 |ept the |last, bu|
|00004c30| 74 20 69 74 20 69 73 20 | 65 78 74 72 65 6d 65 6c |t it is |extremel|
|00004c40| 79 20 62 61 64 20 66 6f | 72 6d 20 74 6f 20 64 65 |y bad fo|rm to de|
|00004c50| 70 65 6e 64 0a 58 20 2a | 20 6f 6e 20 74 68 69 73 |pend.X *| on this|
|00004c60| 2e 20 20 59 6f 75 20 43 | 41 4e 20 61 73 73 75 6d |. You C|AN assum|
|00004c70| 65 20 6e 75 6d 5f 72 6f | 77 73 20 3e 20 30 2e 0a |e num_ro|ws > 0..|
|00004c80| 58 20 2a 20 54 68 65 20 | 64 61 74 61 20 69 73 20 |X * The |data is |
|00004c90| 73 75 70 70 6c 69 65 64 | 20 69 6e 20 74 6f 70 2d |supplied| in top-|
|00004ca0| 74 6f 2d 62 6f 74 74 6f | 6d 20 72 6f 77 20 6f 72 |to-botto|m row or|
|00004cb0| 64 65 72 20 28 74 68 65 | 20 73 74 61 6e 64 61 72 |der (the| standar|
|00004cc0| 64 20 6f 72 64 65 72 20 | 77 69 74 68 69 6e 0a 58 |d order |within.X|
|00004cd0| 20 2a 20 61 20 4a 50 45 | 47 20 66 69 6c 65 29 2e | * a JPE|G file).|
|00004ce0| 20 20 49 66 20 79 6f 75 | 20 63 61 6e 6e 6f 74 20 | If you| cannot |
|00004cf0| 72 65 61 64 69 6c 79 20 | 75 73 65 20 74 68 65 20 |readily |use the |
|00004d00| 64 61 74 61 20 69 6e 20 | 74 68 61 74 20 6f 72 64 |data in |that ord|
|00004d10| 65 72 2c 20 79 6f 75 27 | 6c 6c 0a 58 20 2a 20 6e |er, you'|ll.X * n|
|00004d20| 65 65 64 20 61 6e 20 69 | 6e 74 65 72 6d 65 64 69 |eed an i|ntermedi|
|00004d30| 61 74 65 20 61 72 72 61 | 79 20 74 6f 20 68 6f 6c |ate arra|y to hol|
|00004d40| 64 20 74 68 65 20 69 6d | 61 67 65 2e 20 20 53 65 |d the im|age. Se|
|00004d50| 65 20 6a 77 72 72 6c 65 | 2e 63 20 66 6f 72 20 61 |e jwrrle|.c for a|
|00004d60| 6e 20 65 78 61 6d 70 6c | 65 0a 58 20 2a 20 6f 66 |n exampl|e.X * of|
|00004d70| 20 6f 75 74 70 75 74 74 | 69 6e 67 20 64 61 74 61 | outputt|ing data|
|00004d80| 20 69 6e 20 62 6f 74 74 | 6f 6d 2d 74 6f 2d 74 6f | in bott|om-to-to|
|00004d90| 70 20 6f 72 64 65 72 2e | 0a 58 20 2a 0a 58 20 2a |p order.|.X *.X *|
|00004da0| 20 54 68 65 20 64 61 74 | 61 20 69 73 20 73 75 70 | The dat|a is sup|
|00004db0| 70 6c 69 65 64 20 61 73 | 20 61 20 33 2d 44 20 61 |plied as| a 3-D a|
|00004dc0| 72 72 61 79 20 6f 66 20 | 4a 53 41 4d 50 4c 45 73 |rray of |JSAMPLEs|
|00004dd0| 2c 20 69 6e 64 65 78 65 | 64 20 61 73 0a 58 20 2a |, indexe|d as.X *|
|00004de0| 09 09 4a 53 41 4d 50 4c | 45 20 70 69 78 65 6c 5f |..JSAMPL|E pixel_|
|00004df0| 64 61 74 61 5b 63 6f 6d | 70 6f 6e 65 6e 74 5d 5b |data[com|ponent][|
|00004e00| 72 6f 77 5d 5b 63 6f 6c | 75 6d 6e 5d 0a 58 20 2a |row][col|umn].X *|
|00004e10| 20 77 68 65 72 65 20 63 | 6f 6d 70 6f 6e 65 6e 74 | where c|omponent|
|00004e20| 20 72 75 6e 73 20 66 72 | 6f 6d 20 30 20 74 6f 20 | runs fr|om 0 to |
|00004e30| 63 69 6e 66 6f 2d 3e 66 | 69 6e 61 6c 5f 6f 75 74 |cinfo->f|inal_out|
|00004e40| 5f 63 6f 6d 70 73 2d 31 | 2c 20 72 6f 77 20 72 75 |_comps-1|, row ru|
|00004e50| 6e 73 20 66 72 6f 6d 20 | 30 20 74 6f 0a 58 20 2a |ns from |0 to.X *|
|00004e60| 20 6e 75 6d 5f 72 6f 77 | 73 2d 31 2c 20 61 6e 64 | num_row|s-1, and|
|00004e70| 20 63 6f 6c 75 6d 6e 20 | 72 75 6e 73 20 66 72 6f | column |runs fro|
|00004e80| 6d 20 30 20 74 6f 20 63 | 69 6e 66 6f 2d 3e 69 6d |m 0 to c|info->im|
|00004e90| 61 67 65 5f 77 69 64 74 | 68 2d 31 20 28 63 6f 6c |age_widt|h-1 (col|
|00004ea0| 75 6d 6e 20 30 20 69 73 | 0a 58 20 2a 20 6c 65 66 |umn 0 is|.X * lef|
|00004eb0| 74 20 65 64 67 65 20 6f | 66 20 69 6d 61 67 65 29 |t edge o|f image)|
|00004ec0| 2e 20 20 4e 6f 74 65 20 | 74 68 61 74 20 74 68 69 |. Note |that thi|
|00004ed0| 73 20 69 73 20 61 63 74 | 75 61 6c 6c 79 20 61 6e |s is act|ually an|
|00004ee0| 20 61 72 72 61 79 20 6f | 66 20 70 6f 69 6e 74 65 | array o|f pointe|
|00004ef0| 72 73 20 74 6f 0a 58 20 | 2a 20 70 6f 69 6e 74 65 |rs to.X |* pointe|
|00004f00| 72 73 20 74 6f 20 61 72 | 72 61 79 73 20 72 61 74 |rs to ar|rays rat|
|00004f10| 68 65 72 20 74 68 61 6e | 20 61 20 74 72 75 65 20 |her than| a true |
|00004f20| 33 44 20 61 72 72 61 79 | 2c 20 73 69 6e 63 65 20 |3D array|, since |
|00004f30| 43 20 64 6f 65 73 20 6e | 6f 74 20 73 75 70 70 6f |C does n|ot suppo|
|00004f40| 72 74 0a 58 20 2a 20 76 | 61 72 69 61 62 6c 65 2d |rt.X * v|ariable-|
|00004f50| 73 69 7a 65 20 6d 75 6c | 74 69 64 69 6d 65 6e 73 |size mul|tidimens|
|00004f60| 69 6f 6e 61 6c 20 61 72 | 72 61 79 73 2e 0a 58 20 |ional ar|rays..X |
|00004f70| 2a 20 4a 53 41 4d 50 4c | 45 20 69 73 20 74 79 70 |* JSAMPL|E is typ|
|00004f80| 69 63 61 6c 6c 79 20 74 | 79 70 65 64 65 66 27 64 |ically t|ypedef'd|
|00004f90| 20 61 73 20 22 75 6e 73 | 69 67 6e 65 64 20 63 68 | as "uns|igned ch|
|00004fa0| 61 72 22 2e 20 20 49 66 | 20 79 6f 75 20 77 61 6e |ar". If| you wan|
|00004fb0| 74 20 79 6f 75 72 20 63 | 6f 64 65 0a 58 20 2a 20 |t your c|ode.X * |
|00004fc0| 74 6f 20 62 65 20 61 73 | 20 70 6f 72 74 61 62 6c |to be as| portabl|
|00004fd0| 65 20 61 73 20 74 68 65 | 20 4a 50 45 47 20 63 6f |e as the| JPEG co|
|00004fe0| 64 65 20 70 72 6f 70 65 | 72 2c 20 79 6f 75 20 73 |de prope|r, you s|
|00004ff0| 68 6f 75 6c 64 20 61 6c | 77 61 79 73 20 61 63 63 |hould al|ways acc|
|00005000| 65 73 73 20 4a 53 41 4d | 50 4c 45 0a 58 20 2a 20 |ess JSAM|PLE.X * |
|00005010| 76 61 6c 75 65 73 20 77 | 69 74 68 20 74 68 65 20 |values w|ith the |
|00005020| 47 45 54 4a 53 41 4d 50 | 4c 45 28 29 20 6d 61 63 |GETJSAMP|LE() mac|
|00005030| 72 6f 2c 20 77 68 69 63 | 68 20 77 69 6c 6c 20 64 |ro, whic|h will d|
|00005040| 6f 20 74 68 65 20 72 69 | 67 68 74 20 74 68 69 6e |o the ri|ght thin|
|00005050| 67 20 69 66 20 74 68 65 | 0a 58 20 2a 20 6d 61 63 |g if the|.X * mac|
|00005060| 68 69 6e 65 20 68 61 73 | 20 6f 6e 6c 79 20 73 69 |hine has| only si|
|00005070| 67 6e 65 64 20 63 68 61 | 72 73 2e 0a 58 20 2a 0a |gned cha|rs..X *.|
|00005080| 58 20 2a 20 49 66 20 71 | 75 61 6e 74 69 7a 65 5f |X * If q|uantize_|
|00005090| 63 6f 6c 6f 72 73 20 69 | 73 20 74 72 75 65 2c 20 |colors i|s true, |
|000050a0| 74 68 65 6e 20 74 68 65 | 72 65 20 69 73 20 6f 6e |then the|re is on|
|000050b0| 6c 79 20 6f 6e 65 20 63 | 6f 6d 70 6f 6e 65 6e 74 |ly one c|omponent|
|000050c0| 2c 20 61 6e 64 20 69 74 | 73 20 76 61 6c 75 65 73 |, and it|s values|
|000050d0| 0a 58 20 2a 20 61 72 65 | 20 69 6e 64 65 78 65 73 |.X * are| indexes|
|000050e0| 20 69 6e 74 6f 20 74 68 | 65 20 70 72 65 76 69 6f | into th|e previo|
|000050f0| 75 73 6c 79 20 73 75 70 | 70 6c 69 65 64 20 63 6f |usly sup|plied co|
|00005100| 6c 6f 72 6d 61 70 2e 20 | 20 4f 74 68 65 72 77 69 |lormap. | Otherwi|
|00005110| 73 65 20 74 68 65 20 76 | 61 6c 75 65 73 0a 58 20 |se the v|alues.X |
|00005120| 2a 20 61 72 65 20 61 63 | 74 75 61 6c 20 64 61 74 |* are ac|tual dat|
|00005130| 61 20 69 6e 20 79 6f 75 | 72 20 73 65 6c 65 63 74 |a in you|r select|
|00005140| 65 64 20 6f 75 74 70 75 | 74 20 63 6f 6c 6f 72 73 |ed outpu|t colors|
|00005150| 70 61 63 65 2e 0a 58 20 | 2a 2f 0a 58 0a 58 0a 58 |pace..X |*/.X.X.X|
|00005160| 4d 45 54 48 4f 44 44 45 | 46 20 76 6f 69 64 0a 58 |METHODDE|F void.X|
|00005170| 70 75 74 5f 70 69 78 65 | 6c 5f 72 6f 77 73 20 28 |put_pixe|l_rows (|
|00005180| 64 65 63 6f 6d 70 72 65 | 73 73 5f 69 6e 66 6f 5f |decompre|ss_info_|
|00005190| 70 74 72 20 63 69 6e 66 | 6f 2c 20 69 6e 74 20 6e |ptr cinf|o, int n|
|000051a0| 75 6d 5f 72 6f 77 73 2c | 20 4a 53 41 4d 50 49 4d |um_rows,| JSAMPIM|
|000051b0| 41 47 45 20 70 69 78 65 | 6c 5f 64 61 74 61 29 0a |AGE pixe|l_data).|
|000051c0| 58 2f 2a 20 57 72 69 74 | 65 20 73 6f 6d 65 20 72 |X/* Writ|e some r|
|000051d0| 6f 77 73 20 6f 66 20 6f | 75 74 70 75 74 20 64 61 |ows of o|utput da|
|000051e0| 74 61 20 2a 2f 0a 58 7b | 0a 58 20 20 2f 2a 20 54 |ta */.X{|.X /* T|
|000051f0| 68 69 73 20 65 78 61 6d | 70 6c 65 20 73 68 6f 77 |his exam|ple show|
|00005200| 73 20 68 6f 77 20 79 6f | 75 20 6d 69 67 68 74 20 |s how yo|u might |
|00005210| 77 72 69 74 65 20 66 75 | 6c 6c 2d 63 6f 6c 6f 72 |write fu|ll-color|
|00005220| 20 52 47 42 20 64 61 74 | 61 20 28 33 20 63 6f 6d | RGB dat|a (3 com|
|00005230| 70 6f 6e 65 6e 74 73 29 | 0a 58 20 20 20 2a 20 74 |ponents)|.X * t|
|00005240| 6f 20 61 6e 20 6f 75 74 | 70 75 74 20 66 69 6c 65 |o an out|put file|
|00005250| 20 69 6e 20 77 68 69 63 | 68 20 74 68 65 20 64 61 | in whic|h the da|
|00005260| 74 61 20 69 73 20 73 74 | 6f 72 65 64 20 33 20 62 |ta is st|ored 3 b|
|00005270| 79 74 65 73 20 70 65 72 | 20 70 69 78 65 6c 2e 0a |ytes per| pixel..|
|00005280| 58 20 20 20 2a 2f 0a 58 | 20 20 72 65 67 69 73 74 |X */.X| regist|
|00005290| 65 72 20 46 49 4c 45 20 | 2a 20 6f 75 74 66 69 6c |er FILE |* outfil|
|000052a0| 65 20 3d 20 63 69 6e 66 | 6f 2d 3e 6f 75 74 70 75 |e = cinf|o->outpu|
|000052b0| 74 5f 66 69 6c 65 3b 0a | 58 20 20 72 65 67 69 73 |t_file;.|X regis|
|000052c0| 74 65 72 20 4a 53 41 4d | 50 52 4f 57 20 70 74 72 |ter JSAM|PROW ptr|
|000052d0| 30 2c 20 70 74 72 31 2c | 20 70 74 72 32 3b 0a 58 |0, ptr1,| ptr2;.X|
|000052e0| 20 20 72 65 67 69 73 74 | 65 72 20 6c 6f 6e 67 20 | regist|er long |
|000052f0| 63 6f 6c 3b 0a 58 20 20 | 72 65 67 69 73 74 65 72 |col;.X |register|
|00005300| 20 69 6e 74 20 72 6f 77 | 3b 0a 58 20 20 0a 58 20 | int row|;.X .X |
|00005310| 20 66 6f 72 20 28 72 6f | 77 20 3d 20 30 3b 20 72 | for (ro|w = 0; r|
|00005320| 6f 77 20 3c 20 6e 75 6d | 5f 72 6f 77 73 3b 20 72 |ow < num|_rows; r|
|00005330| 6f 77 2b 2b 29 20 7b 0a | 58 20 20 20 20 70 74 72 |ow++) {.|X ptr|
|00005340| 30 20 3d 20 70 69 78 65 | 6c 5f 64 61 74 61 5b 30 |0 = pixe|l_data[0|
|00005350| 5d 5b 72 6f 77 5d 3b 0a | 58 20 20 20 20 70 74 72 |][row];.|X ptr|
|00005360| 31 20 3d 20 70 69 78 65 | 6c 5f 64 61 74 61 5b 31 |1 = pixe|l_data[1|
|00005370| 5d 5b 72 6f 77 5d 3b 0a | 58 20 20 20 20 70 74 72 |][row];.|X ptr|
|00005380| 32 20 3d 20 70 69 78 65 | 6c 5f 64 61 74 61 5b 32 |2 = pixe|l_data[2|
|00005390| 5d 5b 72 6f 77 5d 3b 0a | 58 20 20 20 20 66 6f 72 |][row];.|X for|
|000053a0| 20 28 63 6f 6c 20 3d 20 | 30 3b 20 63 6f 6c 20 3c | (col = |0; col <|
|000053b0| 20 63 69 6e 66 6f 2d 3e | 69 6d 61 67 65 5f 77 69 | cinfo->|image_wi|
|000053c0| 64 74 68 3b 20 63 6f 6c | 2b 2b 29 20 7b 0a 58 20 |dth; col|++) {.X |
|000053d0| 20 20 20 20 20 70 75 74 | 63 28 47 45 54 4a 53 41 | put|c(GETJSA|
|000053e0| 4d 50 4c 45 28 2a 70 74 | 72 30 29 2c 20 6f 75 74 |MPLE(*pt|r0), out|
|000053f0| 66 69 6c 65 29 3b 09 2f | 2a 20 72 65 64 20 2a 2f |file);./|* red */|
|00005400| 0a 58 20 20 20 20 20 20 | 70 74 72 30 2b 2b 3b 0a |.X |ptr0++;.|
|00005410| 58 20 20 20 20 20 20 70 | 75 74 63 28 47 45 54 4a |X p|utc(GETJ|
|00005420| 53 41 4d 50 4c 45 28 2a | 70 74 72 31 29 2c 20 6f |SAMPLE(*|ptr1), o|
|00005430| 75 74 66 69 6c 65 29 3b | 09 2f 2a 20 67 72 65 65 |utfile);|./* gree|
|00005440| 6e 20 2a 2f 0a 58 20 20 | 20 20 20 20 70 74 72 31 |n */.X | ptr1|
|00005450| 2b 2b 3b 0a 58 20 20 20 | 20 20 20 70 75 74 63 28 |++;.X | putc(|
|00005460| 47 45 54 4a 53 41 4d 50 | 4c 45 28 2a 70 74 72 32 |GETJSAMP|LE(*ptr2|
|00005470| 29 2c 20 6f 75 74 66 69 | 6c 65 29 3b 09 2f 2a 20 |), outfi|le);./* |
|00005480| 62 6c 75 65 20 2a 2f 0a | 58 20 20 20 20 20 20 70 |blue */.|X p|
|00005490| 74 72 32 2b 2b 3b 0a 58 | 20 20 20 20 7d 0a 58 20 |tr2++;.X| }.X |
|000054a0| 20 7d 0a 58 7d 0a 58 0a | 58 0a 58 4d 45 54 48 4f | }.X}.X.|X.XMETHO|
|000054b0| 44 44 45 46 20 76 6f 69 | 64 0a 58 6f 75 74 70 75 |DDEF voi|d.Xoutpu|
|000054c0| 74 5f 74 65 72 6d 20 28 | 64 65 63 6f 6d 70 72 65 |t_term (|decompre|
|000054d0| 73 73 5f 69 6e 66 6f 5f | 70 74 72 20 63 69 6e 66 |ss_info_|ptr cinf|
|000054e0| 6f 29 0a 58 2f 2a 20 46 | 69 6e 69 73 68 20 75 70 |o).X/* F|inish up|
|000054f0| 20 61 74 20 74 68 65 20 | 65 6e 64 20 6f 66 20 74 | at the |end of t|
|00005500| 68 65 20 6f 75 74 70 75 | 74 20 2a 2f 0a 58 7b 0a |he outpu|t */.X{.|
|00005510| 58 20 20 2f 2a 20 54 68 | 69 73 20 74 65 72 6d 69 |X /* Th|is termi|
|00005520| 6e 61 74 69 6f 6e 20 72 | 6f 75 74 69 6e 65 20 6d |nation r|outine m|
|00005530| 61 79 20 6e 6f 74 20 6e | 65 65 64 20 74 6f 20 64 |ay not n|eed to d|
|00005540| 6f 20 61 6e 79 74 68 69 | 6e 67 2e 20 2a 2f 0a 58 |o anythi|ng. */.X|
|00005550| 20 20 2f 2a 20 4e 6f 74 | 65 20 74 68 61 74 20 74 | /* Not|e that t|
|00005560| 68 65 20 4a 50 45 47 20 | 63 6f 64 65 20 77 69 6c |he JPEG |code wil|
|00005570| 6c 20 6f 6e 6c 79 20 63 | 61 6c 6c 20 69 74 20 64 |l only c|all it d|
|00005580| 75 72 69 6e 67 20 73 75 | 63 63 65 73 73 66 75 6c |uring su|ccessful|
|00005590| 20 65 78 69 74 3b 20 2a | 2f 0a 58 20 20 2f 2a 20 | exit; *|/.X /* |
|000055a0| 69 66 20 79 6f 75 20 77 | 61 6e 74 20 69 74 20 63 |if you w|ant it c|
|000055b0| 61 6c 6c 65 64 20 64 75 | 72 69 6e 67 20 65 72 72 |alled du|ring err|
|000055c0| 6f 72 20 65 78 69 74 2c | 20 79 6f 75 20 67 6f 74 |or exit,| you got|
|000055d0| 74 61 20 64 6f 20 74 68 | 61 74 20 79 6f 75 72 73 |ta do th|at yours|
|000055e0| 65 6c 66 2e 20 2a 2f 0a | 58 7d 0a 58 0a 58 0a 58 |elf. */.|X}.X.X.X|
|000055f0| 2f 2a 0a 58 20 2a 20 54 | 68 61 74 27 73 20 69 74 |/*.X * T|hat's it|
|00005600| 20 66 6f 72 20 74 68 65 | 20 72 6f 75 74 69 6e 65 | for the| routine|
|00005610| 73 20 74 68 61 74 20 64 | 65 61 6c 20 77 69 74 68 |s that d|eal with|
|00005620| 20 77 72 69 74 69 6e 67 | 20 74 68 65 20 6f 75 74 | writing| the out|
|00005630| 70 75 74 20 69 6d 61 67 | 65 2e 0a 58 20 2a 20 4e |put imag|e..X * N|
|00005640| 6f 77 20 77 65 20 68 61 | 76 65 20 6f 76 65 72 61 |ow we ha|ve overa|
|00005650| 6c 6c 20 63 6f 6e 74 72 | 6f 6c 20 61 6e 64 20 70 |ll contr|ol and p|
|00005660| 61 72 61 6d 65 74 65 72 | 20 73 65 6c 65 63 74 69 |arameter| selecti|
|00005670| 6f 6e 20 72 6f 75 74 69 | 6e 65 73 2e 0a 58 20 2a |on routi|nes..X *|
|00005680| 2f 0a 58 0a 58 0a 58 2f | 2a 0a 58 20 2a 20 54 68 |/.X.X.X/|*.X * Th|
|00005690| 69 73 20 72 6f 75 74 69 | 6e 65 20 67 65 74 73 20 |is routi|ne gets |
|000056a0| 63 6f 6e 74 72 6f 6c 20 | 61 66 74 65 72 20 74 68 |control |after th|
|000056b0| 65 20 4a 50 45 47 20 66 | 69 6c 65 20 68 65 61 64 |e JPEG f|ile head|
|000056c0| 65 72 20 68 61 73 20 62 | 65 65 6e 20 72 65 61 64 |er has b|een read|
|000056d0| 3b 0a 58 20 2a 20 61 74 | 20 74 68 69 73 20 70 6f |;.X * at| this po|
|000056e0| 69 6e 74 20 74 68 65 20 | 69 6d 61 67 65 20 73 69 |int the |image si|
|000056f0| 7a 65 20 61 6e 64 20 63 | 6f 6c 6f 72 73 70 61 63 |ze and c|olorspac|
|00005700| 65 20 61 72 65 20 6b 6e | 6f 77 6e 2e 0a 58 20 2a |e are kn|own..X *|
|00005710| 20 54 68 65 20 72 6f 75 | 74 69 6e 65 20 6d 75 73 | The rou|tine mus|
|00005720| 74 20 64 65 74 65 72 6d | 69 6e 65 20 77 68 61 74 |t determ|ine what|
|00005730| 20 6f 75 74 70 75 74 20 | 72 6f 75 74 69 6e 65 73 | output |routines|
|00005740| 20 61 72 65 20 74 6f 20 | 62 65 20 75 73 65 64 2c | are to |be used,|
|00005750| 20 61 6e 64 20 6d 61 6b | 65 0a 58 20 2a 20 61 6e | and mak|e.X * an|
|00005760| 79 20 64 65 63 6f 6d 70 | 72 65 73 73 69 6f 6e 20 |y decomp|ression |
|00005770| 70 61 72 61 6d 65 74 65 | 72 20 63 68 61 6e 67 65 |paramete|r change|
|00005780| 73 20 74 68 61 74 20 61 | 72 65 20 64 65 73 69 72 |s that a|re desir|
|00005790| 61 62 6c 65 2e 20 20 46 | 6f 72 20 65 78 61 6d 70 |able. F|or examp|
|000057a0| 6c 65 2c 0a 58 20 2a 20 | 69 66 20 69 74 20 69 73 |le,.X * |if it is|
|000057b0| 20 66 6f 75 6e 64 20 74 | 68 61 74 20 74 68 65 20 | found t|hat the |
|000057c0| 4a 50 45 47 20 66 69 6c | 65 20 69 73 20 67 72 61 |JPEG fil|e is gra|
|000057d0| 79 73 63 61 6c 65 2c 20 | 79 6f 75 20 6d 69 67 68 |yscale, |you migh|
|000057e0| 74 20 77 61 6e 74 20 74 | 6f 20 64 6f 0a 58 20 2a |t want t|o do.X *|
|000057f0| 20 74 68 69 6e 67 73 20 | 64 69 66 66 65 72 65 6e | things |differen|
|00005800| 74 6c 79 20 74 68 61 6e | 20 69 66 20 69 74 20 69 |tly than| if it i|
|00005810| 73 20 63 6f 6c 6f 72 2e | 20 20 59 6f 75 20 63 61 |s color.| You ca|
|00005820| 6e 20 61 6c 73 6f 20 64 | 65 6c 61 79 20 73 65 74 |n also d|elay set|
|00005830| 74 69 6e 67 0a 58 20 2a | 20 71 75 61 6e 74 69 7a |ting.X *| quantiz|
|00005840| 65 5f 63 6f 6c 6f 72 73 | 20 61 6e 64 20 61 73 73 |e_colors| and ass|
|00005850| 6f 63 69 61 74 65 64 20 | 6f 70 74 69 6f 6e 73 20 |ociated |options |
|00005860| 75 6e 74 69 6c 20 74 68 | 69 73 20 70 6f 69 6e 74 |until th|is point|
|00005870| 2e 20 0a 58 20 2a 0a 58 | 20 2a 20 6a 5f 64 5f 64 |. .X *.X| * j_d_d|
|00005880| 65 66 61 75 6c 74 73 20 | 69 6e 69 74 69 61 6c 69 |efaults |initiali|
|00005890| 7a 65 73 20 6f 75 74 5f | 63 6f 6c 6f 72 5f 73 70 |zes out_|color_sp|
|000058a0| 61 63 65 20 74 6f 20 43 | 53 5f 52 47 42 2e 20 20 |ace to C|S_RGB. |
|000058b0| 49 66 20 79 6f 75 20 77 | 61 6e 74 20 67 72 61 79 |If you w|ant gray|
|000058c0| 73 63 61 6c 65 0a 58 20 | 2a 20 6f 75 74 70 75 74 |scale.X |* output|
|000058d0| 20 79 6f 75 20 73 68 6f | 75 6c 64 20 73 65 74 20 | you sho|uld set |
|000058e0| 6f 75 74 5f 63 6f 6c 6f | 72 5f 73 70 61 63 65 20 |out_colo|r_space |
|000058f0| 74 6f 20 43 53 5f 47 52 | 41 59 53 43 41 4c 45 2e |to CS_GR|AYSCALE.|
|00005900| 20 20 4e 6f 74 65 20 74 | 68 61 74 20 79 6f 75 20 | Note t|hat you |
|00005910| 63 61 6e 0a 58 20 2a 20 | 66 6f 72 63 65 20 67 72 |can.X * |force gr|
|00005920| 61 79 73 63 61 6c 65 20 | 6f 75 74 70 75 74 20 66 |ayscale |output f|
|00005930| 72 6f 6d 20 61 20 63 6f | 6c 6f 72 20 4a 50 45 47 |rom a co|lor JPEG|
|00005940| 20 66 69 6c 65 20 28 74 | 68 6f 75 67 68 20 6e 6f | file (t|hough no|
|00005950| 74 20 76 69 63 65 20 76 | 65 72 73 61 29 2e 0a 58 |t vice v|ersa)..X|
|00005960| 20 2a 2f 0a 58 0a 58 4d | 45 54 48 4f 44 44 45 46 | */.X.XM|ETHODDEF|
|00005970| 20 76 6f 69 64 0a 58 64 | 5f 75 69 5f 6d 65 74 68 | void.Xd|_ui_meth|
|00005980| 6f 64 5f 73 65 6c 65 63 | 74 69 6f 6e 20 28 64 65 |od_selec|tion (de|
|00005990| 63 6f 6d 70 72 65 73 73 | 5f 69 6e 66 6f 5f 70 74 |compress|_info_pt|
|000059a0| 72 20 63 69 6e 66 6f 29 | 0a 58 7b 0a 58 20 20 2f |r cinfo)|.X{.X /|
|000059b0| 2a 20 69 66 20 67 72 61 | 79 73 63 61 6c 65 20 69 |* if gra|yscale i|
|000059c0| 6e 70 75 74 2c 20 66 6f | 72 63 65 20 67 72 61 79 |nput, fo|rce gray|
|000059d0| 73 63 61 6c 65 20 6f 75 | 74 70 75 74 3b 20 2a 2f |scale ou|tput; */|
|000059e0| 0a 58 20 20 2f 2a 20 65 | 6c 73 65 20 6c 65 61 76 |.X /* e|lse leav|
|000059f0| 65 20 74 68 65 20 6f 75 | 74 70 75 74 20 63 6f 6c |e the ou|tput col|
|00005a00| 6f 72 73 70 61 63 65 20 | 61 73 20 73 65 74 20 62 |orspace |as set b|
|00005a10| 79 20 6d 61 69 6e 20 72 | 6f 75 74 69 6e 65 2e 20 |y main r|outine. |
|00005a20| 2a 2f 0a 58 20 20 69 66 | 20 28 63 69 6e 66 6f 2d |*/.X if| (cinfo-|
|00005a30| 3e 6a 70 65 67 5f 63 6f | 6c 6f 72 5f 73 70 61 63 |>jpeg_co|lor_spac|
|00005a40| 65 20 3d 3d 20 43 53 5f | 47 52 41 59 53 43 41 4c |e == CS_|GRAYSCAL|
|00005a50| 45 29 0a 58 20 20 20 20 | 63 69 6e 66 6f 2d 3e 6f |E).X |cinfo->o|
|00005a60| 75 74 5f 63 6f 6c 6f 72 | 5f 73 70 61 63 65 20 3d |ut_color|_space =|
|00005a70| 20 43 53 5f 47 52 41 59 | 53 43 41 4c 45 3b 0a 58 | CS_GRAY|SCALE;.X|
|00005a80| 0a 58 20 20 2f 2a 20 73 | 65 6c 65 63 74 20 6f 75 |.X /* s|elect ou|
|00005a90| 74 70 75 74 20 72 6f 75 | 74 69 6e 65 73 20 2a 2f |tput rou|tines */|
|00005aa0| 0a 58 20 20 63 69 6e 66 | 6f 2d 3e 6d 65 74 68 6f |.X cinf|o->metho|
|00005ab0| 64 73 2d 3e 6f 75 74 70 | 75 74 5f 69 6e 69 74 20 |ds->outp|ut_init |
|00005ac0| 3d 20 6f 75 74 70 75 74 | 5f 69 6e 69 74 3b 0a 58 |= output|_init;.X|
|00005ad0| 20 20 63 69 6e 66 6f 2d | 3e 6d 65 74 68 6f 64 73 | cinfo-|>methods|
|00005ae0| 2d 3e 70 75 74 5f 63 6f | 6c 6f 72 5f 6d 61 70 20 |->put_co|lor_map |
|00005af0| 3d 20 70 75 74 5f 63 6f | 6c 6f 72 5f 6d 61 70 3b |= put_co|lor_map;|
|00005b00| 0a 58 20 20 63 69 6e 66 | 6f 2d 3e 6d 65 74 68 6f |.X cinf|o->metho|
|00005b10| 64 73 2d 3e 70 75 74 5f | 70 69 78 65 6c 5f 72 6f |ds->put_|pixel_ro|
|00005b20| 77 73 20 3d 20 70 75 74 | 5f 70 69 78 65 6c 5f 72 |ws = put|_pixel_r|
|00005b30| 6f 77 73 3b 0a 58 20 20 | 63 69 6e 66 6f 2d 3e 6d |ows;.X |cinfo->m|
|00005b40| 65 74 68 6f 64 73 2d 3e | 6f 75 74 70 75 74 5f 74 |ethods->|output_t|
|00005b50| 65 72 6d 20 3d 20 6f 75 | 74 70 75 74 5f 74 65 72 |erm = ou|tput_ter|
|00005b60| 6d 3b 0a 58 7d 0a 58 0a | 58 0a 58 2f 2a 0a 58 20 |m;.X}.X.|X.X/*.X |
|00005b70| 2a 20 4f 4b 2c 20 68 65 | 72 65 20 69 73 20 74 68 |* OK, he|re is th|
|00005b80| 65 20 6d 61 69 6e 20 66 | 75 6e 63 74 69 6f 6e 20 |e main f|unction |
|00005b90| 74 68 61 74 20 61 63 74 | 75 61 6c 6c 79 20 63 61 |that act|ually ca|
|00005ba0| 75 73 65 73 20 65 76 65 | 72 79 74 68 69 6e 67 20 |uses eve|rything |
|00005bb0| 74 6f 20 68 61 70 70 65 | 6e 2e 0a 58 20 2a 20 57 |to happe|n..X * W|
|00005bc0| 65 20 61 73 73 75 6d 65 | 20 68 65 72 65 20 74 68 |e assume| here th|
|00005bd0| 61 74 20 74 68 65 20 4a | 50 45 47 20 66 69 6c 65 |at the J|PEG file|
|00005be0| 6e 61 6d 65 20 69 73 20 | 73 75 70 70 6c 69 65 64 |name is |supplied|
|00005bf0| 20 62 79 20 74 68 65 20 | 63 61 6c 6c 65 72 20 6f | by the |caller o|
|00005c00| 66 20 74 68 69 73 0a 58 | 20 2a 20 72 6f 75 74 69 |f this.X| * routi|
|00005c10| 6e 65 2c 20 61 6e 64 20 | 74 68 61 74 20 61 6c 6c |ne, and |that all|
|00005c20| 20 64 65 63 6f 6d 70 72 | 65 73 73 69 6f 6e 20 70 | decompr|ession p|
|00005c30| 61 72 61 6d 65 74 65 72 | 73 20 63 61 6e 20 62 65 |arameter|s can be|
|00005c40| 20 64 65 66 61 75 6c 74 | 20 76 61 6c 75 65 73 2e | default| values.|
|00005c50| 0a 58 20 2a 20 54 68 65 | 20 72 6f 75 74 69 6e 65 |.X * The| routine|
|00005c60| 20 72 65 74 75 72 6e 73 | 20 31 20 69 66 20 73 75 | returns| 1 if su|
|00005c70| 63 63 65 73 73 66 75 6c | 2c 20 30 20 69 66 20 6e |ccessful|, 0 if n|
|00005c80| 6f 74 2e 0a 58 20 2a 2f | 0a 58 0a 58 47 4c 4f 42 |ot..X */|.X.XGLOB|
|00005c90| 41 4c 20 69 6e 74 0a 58 | 72 65 61 64 5f 4a 50 45 |AL int.X|read_JPE|
|00005ca0| 47 5f 66 69 6c 65 20 28 | 63 68 61 72 20 2a 20 66 |G_file (|char * f|
|00005cb0| 69 6c 65 6e 61 6d 65 29 | 0a 58 7b 0a 58 20 20 2f |ilename)|.X{.X /|
|00005cc0| 2a 20 54 68 65 73 65 20 | 74 68 72 65 65 20 73 74 |* These |three st|
|00005cd0| 72 75 63 74 73 20 63 6f | 6e 74 61 69 6e 20 4a 50 |ructs co|ntain JP|
|00005ce0| 45 47 20 70 61 72 61 6d | 65 74 65 72 73 20 61 6e |EG param|eters an|
|00005cf0| 64 20 77 6f 72 6b 69 6e | 67 20 64 61 74 61 2e 0a |d workin|g data..|
|00005d00| 58 20 20 20 2a 20 54 68 | 65 79 20 6d 75 73 74 20 |X * Th|ey must |
|00005d10| 73 75 72 76 69 76 65 20 | 66 6f 72 20 74 68 65 20 |survive |for the |
|00005d20| 64 75 72 61 74 69 6f 6e | 20 6f 66 20 70 61 72 61 |duration| of para|
|00005d30| 6d 65 74 65 72 20 73 65 | 74 75 70 20 61 6e 64 20 |meter se|tup and |
|00005d40| 6f 6e 65 0a 58 20 20 20 | 2a 20 63 61 6c 6c 20 74 |one.X |* call t|
|00005d50| 6f 20 6a 70 65 67 5f 64 | 65 63 6f 6d 70 72 65 73 |o jpeg_d|ecompres|
|00005d60| 73 3b 20 74 79 70 69 63 | 61 6c 6c 79 2c 20 6d 61 |s; typic|ally, ma|
|00005d70| 6b 69 6e 67 20 74 68 65 | 6d 20 6c 6f 63 61 6c 20 |king the|m local |
|00005d80| 64 61 74 61 20 69 6e 20 | 74 68 65 0a 58 20 20 20 |data in |the.X |
|00005d90| 2a 20 63 61 6c 6c 69 6e | 67 20 72 6f 75 74 69 6e |* callin|g routin|
|00005da0| 65 20 69 73 20 74 68 65 | 20 62 65 73 74 20 73 74 |e is the| best st|
|00005db0| 72 61 74 65 67 79 2e 0a | 58 20 20 20 2a 2f 0a 58 |rategy..|X */.X|
|00005dc0| 20 20 73 74 72 75 63 74 | 20 44 65 63 6f 6d 70 72 | struct| Decompr|
|00005dd0| 65 73 73 5f 69 6e 66 6f | 5f 73 74 72 75 63 74 20 |ess_info|_struct |
|00005de0| 63 69 6e 66 6f 3b 0a 58 | 20 20 73 74 72 75 63 74 |cinfo;.X| struct|
|00005df0| 20 44 65 63 6f 6d 70 72 | 65 73 73 5f 6d 65 74 68 | Decompr|ess_meth|
|00005e00| 6f 64 73 5f 73 74 72 75 | 63 74 20 64 63 5f 6d 65 |ods_stru|ct dc_me|
|00005e10| 74 68 6f 64 73 3b 0a 58 | 20 20 73 74 72 75 63 74 |thods;.X| struct|
|00005e20| 20 45 78 74 65 72 6e 61 | 6c 5f 6d 65 74 68 6f 64 | Externa|l_method|
|00005e30| 73 5f 73 74 72 75 63 74 | 20 65 5f 6d 65 74 68 6f |s_struct| e_metho|
|00005e40| 64 73 3b 0a 58 0a 58 20 | 20 2f 2a 20 53 65 6c 65 |ds;.X.X | /* Sele|
|00005e50| 63 74 20 74 68 65 20 69 | 6e 70 75 74 20 61 6e 64 |ct the i|nput and|
|00005e60| 20 6f 75 74 70 75 74 20 | 66 69 6c 65 73 2e 0a 58 | output |files..X|
|00005e70| 20 20 20 2a 20 49 6e 20 | 74 68 69 73 20 65 78 61 | * In |this exa|
|00005e80| 6d 70 6c 65 20 77 65 20 | 77 61 6e 74 20 74 6f 20 |mple we |want to |
|00005e90| 6f 70 65 6e 20 74 68 65 | 20 69 6e 70 75 74 20 66 |open the| input f|
|00005ea0| 69 6c 65 20 62 65 66 6f | 72 65 20 64 6f 69 6e 67 |ile befo|re doing|
|00005eb0| 20 61 6e 79 74 68 69 6e | 67 20 65 6c 73 65 2c 0a | anythin|g else,.|
|00005ec0| 58 20 20 20 2a 20 73 6f | 20 74 68 61 74 20 74 68 |X * so| that th|
|00005ed0| 65 20 73 65 74 6a 6d 70 | 28 29 20 65 72 72 6f 72 |e setjmp|() error|
|00005ee0| 20 72 65 63 6f 76 65 72 | 79 20 62 65 6c 6f 77 20 | recover|y below |
|00005ef0| 63 61 6e 20 61 73 73 75 | 6d 65 20 74 68 65 20 66 |can assu|me the f|
|00005f00| 69 6c 65 20 69 73 20 6f | 70 65 6e 2e 0a 58 20 20 |ile is o|pen..X |
|00005f10| 20 2a 20 4e 6f 74 65 20 | 74 68 61 74 20 63 69 6e | * Note |that cin|
|00005f20| 66 6f 2e 6f 75 74 70 75 | 74 5f 66 69 6c 65 20 69 |fo.outpu|t_file i|
|00005f30| 73 20 6f 6e 6c 79 20 75 | 73 65 64 20 69 66 20 79 |s only u|sed if y|
|00005f40| 6f 75 72 20 6f 75 74 70 | 75 74 20 68 61 6e 64 6c |our outp|ut handl|
|00005f50| 69 6e 67 20 72 6f 75 74 | 69 6e 65 73 0a 58 20 20 |ing rout|ines.X |
|00005f60| 20 2a 20 75 73 65 20 69 | 74 3b 20 6f 74 68 65 72 | * use i|t; other|
|00005f70| 77 69 73 65 2c 20 79 6f | 75 20 63 61 6e 20 6a 75 |wise, yo|u can ju|
|00005f80| 73 74 20 6d 61 6b 65 20 | 69 74 20 4e 55 4c 4c 2e |st make |it NULL.|
|00005f90| 0a 58 20 20 20 2a 20 56 | 45 52 59 20 49 4d 50 4f |.X * V|ERY IMPO|
|00005fa0| 52 54 41 4e 54 3a 20 75 | 73 65 20 22 62 22 20 6f |RTANT: u|se "b" o|
|00005fb0| 70 74 69 6f 6e 20 74 6f | 20 66 6f 70 65 6e 28 29 |ption to| fopen()|
|00005fc0| 20 69 66 20 79 6f 75 20 | 61 72 65 20 6f 6e 20 61 | if you |are on a|
|00005fd0| 20 6d 61 63 68 69 6e 65 | 20 74 68 61 74 0a 58 20 | machine| that.X |
|00005fe0| 20 20 2a 20 72 65 71 75 | 69 72 65 73 20 69 74 20 | * requ|ires it |
|00005ff0| 69 6e 20 6f 72 64 65 72 | 20 74 6f 20 72 65 61 64 |in order| to read|
|00006000| 20 62 69 6e 61 72 79 20 | 66 69 6c 65 73 2e 0a 58 | binary |files..X|
|00006010| 20 20 20 2a 2f 0a 58 0a | 58 20 20 69 66 20 28 28 | */.X.|X if ((|
|00006020| 63 69 6e 66 6f 2e 69 6e | 70 75 74 5f 66 69 6c 65 |cinfo.in|put_file|
|00006030| 20 3d 20 66 6f 70 65 6e | 28 66 69 6c 65 6e 61 6d | = fopen|(filenam|
|00006040| 65 2c 20 22 72 62 22 29 | 29 20 3d 3d 20 4e 55 4c |e, "rb")|) == NUL|
|00006050| 4c 29 20 7b 0a 58 20 20 | 20 20 66 70 72 69 6e 74 |L) {.X | fprint|
|00006060| 66 28 73 74 64 65 72 72 | 2c 20 22 63 61 6e 27 74 |f(stderr|, "can't|
|00006070| 20 6f 70 65 6e 20 25 73 | 5c 6e 22 2c 20 66 69 6c | open %s|\n", fil|
|00006080| 65 6e 61 6d 65 29 3b 0a | 58 20 20 20 20 72 65 74 |ename);.|X ret|
|00006090| 75 72 6e 20 30 3b 0a 58 | 20 20 7d 0a 58 0a 58 20 |urn 0;.X| }.X.X |
|000060a0| 20 63 69 6e 66 6f 2e 6f | 75 74 70 75 74 5f 66 69 | cinfo.o|utput_fi|
|000060b0| 6c 65 20 3d 20 4e 55 4c | 4c 3b 09 2f 2a 20 69 66 |le = NUL|L;./* if|
|000060c0| 20 6e 6f 20 61 63 74 75 | 61 6c 20 6f 75 74 70 75 | no actu|al outpu|
|000060d0| 74 20 66 69 6c 65 20 69 | 6e 76 6f 6c 76 65 64 20 |t file i|nvolved |
|000060e0| 2a 2f 0a 58 0a 58 20 20 | 2f 2a 20 49 6e 69 74 69 |*/.X.X |/* Initi|
|000060f0| 61 6c 69 7a 65 20 74 68 | 65 20 73 79 73 74 65 6d |alize th|e system|
|00006100| 2d 64 65 70 65 6e 64 65 | 6e 74 20 6d 65 74 68 6f |-depende|nt metho|
|00006110| 64 20 70 6f 69 6e 74 65 | 72 73 2e 20 2a 2f 0a 58 |d pointe|rs. */.X|
|00006120| 20 20 63 69 6e 66 6f 2e | 6d 65 74 68 6f 64 73 20 | cinfo.|methods |
|00006130| 3d 20 26 64 63 5f 6d 65 | 74 68 6f 64 73 3b 09 2f |= &dc_me|thods;./|
|00006140| 2a 20 6c 69 6e 6b 73 20 | 74 6f 20 6d 65 74 68 6f |* links |to metho|
|00006150| 64 20 73 74 72 75 63 74 | 73 20 2a 2f 0a 58 20 20 |d struct|s */.X |
|00006160| 63 69 6e 66 6f 2e 65 6d | 65 74 68 6f 64 73 20 3d |cinfo.em|ethods =|
|00006170| 20 26 65 5f 6d 65 74 68 | 6f 64 73 3b 0a 58 20 20 | &e_meth|ods;.X |
|00006180| 2f 2a 20 48 65 72 65 20 | 77 65 20 73 75 70 70 6c |/* Here |we suppl|
|00006190| 79 20 6f 75 72 20 6f 77 | 6e 20 65 72 72 6f 72 20 |y our ow|n error |
|000061a0| 68 61 6e 64 6c 65 72 3b | 20 63 6f 6d 70 61 72 65 |handler;| compare|
|000061b0| 20 74 6f 20 75 73 65 20 | 6f 66 20 73 74 61 6e 64 | to use |of stand|
|000061c0| 61 72 64 20 65 72 72 6f | 72 0a 58 20 20 20 2a 20 |ard erro|r.X * |
|000061d0| 68 61 6e 64 6c 65 72 20 | 69 6e 20 74 68 65 20 70 |handler |in the p|
|000061e0| 72 65 76 69 6f 75 73 20 | 77 72 69 74 65 5f 4a 50 |revious |write_JP|
|000061f0| 45 47 5f 66 69 6c 65 20 | 65 78 61 6d 70 6c 65 2e |EG_file |example.|
|00006200| 0a 58 20 20 20 2a 2f 0a | 58 20 20 65 6d 65 74 68 |.X */.|X emeth|
|00006210| 6f 64 73 20 3d 20 26 65 | 5f 6d 65 74 68 6f 64 73 |ods = &e|_methods|
|00006220| 3b 09 2f 2a 20 73 61 76 | 65 20 73 74 72 75 63 74 |;./* sav|e struct|
|00006230| 20 61 64 64 72 20 66 6f | 72 20 70 6f 73 73 69 62 | addr fo|r possib|
|00006240| 6c 65 20 61 63 63 65 73 | 73 20 2a 2f 0a 58 20 20 |le acces|s */.X |
|00006250| 65 5f 6d 65 74 68 6f 64 | 73 2e 65 72 72 6f 72 5f |e_method|s.error_|
|00006260| 65 78 69 74 20 3d 20 65 | 72 72 6f 72 5f 65 78 69 |exit = e|rror_exi|
|00006270| 74 3b 20 2f 2a 20 73 75 | 70 70 6c 79 20 65 72 72 |t; /* su|pply err|
|00006280| 6f 72 2d 65 78 69 74 20 | 72 6f 75 74 69 6e 65 20 |or-exit |routine |
|00006290| 2a 2f 0a 58 20 20 65 5f | 6d 65 74 68 6f 64 73 2e |*/.X e_|methods.|
|000062a0| 74 72 61 63 65 5f 6d 65 | 73 73 61 67 65 20 3d 20 |trace_me|ssage = |
|000062b0| 74 72 61 63 65 5f 6d 65 | 73 73 61 67 65 3b 20 2f |trace_me|ssage; /|
|000062c0| 2a 20 73 75 70 70 6c 79 | 20 74 72 61 63 65 2d 6d |* supply| trace-m|
|000062d0| 65 73 73 61 67 65 20 72 | 6f 75 74 69 6e 65 20 2a |essage r|outine *|
|000062e0| 2f 0a 58 20 20 65 5f 6d | 65 74 68 6f 64 73 2e 74 |/.X e_m|ethods.t|
|000062f0| 72 61 63 65 5f 6c 65 76 | 65 6c 20 3d 20 30 3b 09 |race_lev|el = 0;.|
|00006300| 2f 2a 20 64 65 66 61 75 | 6c 74 20 3d 20 6e 6f 20 |/* defau|lt = no |
|00006310| 74 72 61 63 69 6e 67 20 | 2a 2f 0a 58 20 20 65 5f |tracing |*/.X e_|
|00006320| 6d 65 74 68 6f 64 73 2e | 6e 75 6d 5f 77 61 72 6e |methods.|num_warn|
|00006330| 69 6e 67 73 20 3d 20 30 | 3b 09 2f 2a 20 6e 6f 20 |ings = 0|;./* no |
|00006340| 77 61 72 6e 69 6e 67 73 | 20 65 6d 69 74 74 65 64 |warnings| emitted|
|00006350| 20 79 65 74 20 2a 2f 0a | 58 20 20 65 5f 6d 65 74 | yet */.|X e_met|
|00006360| 68 6f 64 73 2e 66 69 72 | 73 74 5f 77 61 72 6e 69 |hods.fir|st_warni|
|00006370| 6e 67 5f 6c 65 76 65 6c | 20 3d 20 30 3b 20 2f 2a |ng_level| = 0; /*|
|00006380| 20 64 69 73 70 6c 61 79 | 20 66 69 72 73 74 20 63 | display| first c|
|00006390| 6f 72 72 75 70 74 2d 64 | 61 74 61 20 77 61 72 6e |orrupt-d|ata warn|
|000063a0| 69 6e 67 20 2a 2f 0a 58 | 20 20 65 5f 6d 65 74 68 |ing */.X| e_meth|
|000063b0| 6f 64 73 2e 6d 6f 72 65 | 5f 77 61 72 6e 69 6e 67 |ods.more|_warning|
|000063c0| 5f 6c 65 76 65 6c 20 3d | 20 33 3b 20 2f 2a 20 62 |_level =| 3; /* b|
|000063d0| 75 74 20 73 75 70 70 72 | 65 73 73 20 61 64 64 69 |ut suppr|ess addi|
|000063e0| 74 69 6f 6e 61 6c 20 6f | 6e 65 73 20 2a 2f 0a 58 |tional o|nes */.X|
|000063f0| 0a 58 20 20 2f 2a 20 70 | 72 65 70 61 72 65 20 73 |.X /* p|repare s|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.